Project

General

Profile

« Previous | Next » 

Revision a740abba

Added by Andreas Kohlbecker almost 13 years ago

licence comments, log4j, browser configurable via -Dbrowser=[firefox,iexplorer,chrome]

View differences:

modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/DataPortalContextAwareRunner.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 EDIT
4
 * European Distributed Institute of Taxonomy 
5
 * http://www.e-taxonomy.eu
6
 * 
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
1 10
package eu.etaxonomy.dataportal;
2 11

  
3 12
import java.lang.annotation.ElementType;
......
15 24
import org.junit.runners.model.Statement;
16 25

  
17 26
public class DataPortalContextAwareRunner extends BlockJUnit4ClassRunner {
18
	
19 27

  
20 28
	@Retention(RetentionPolicy.RUNTIME)
21 29
	@Target(ElementType.TYPE)
22 30
	@Inherited
23 31
	public @interface DataPortalContexts {
24 32
		/**
25
		 * @return an array of DataPortalContext to which the annotated test class is applicable
33
		 * @return an array of DataPortalContext to which the annotated test
34
		 *         class is applicable
26 35
		 */
27 36
		DataPortalContext[] value();
28 37
	}
29
	
30
	private DataPortalContext dataPortalContext; 
31
	
38

  
39
	private DataPortalContext dataPortalContext;
40

  
32 41
	public DataPortalContextAwareRunner(Class<?> klass)
33 42
			throws InitializationError {
34 43
		super(klass);
35 44
		dataPortalContext = DataPortalManager.currentDataPortalContext();
36 45
	}
37
	
46

  
38 47
	@Override
39 48
	public void run(final RunNotifier notifier) {
40
		EachTestNotifier testNotifier= new EachTestNotifier(notifier,
49
		EachTestNotifier testNotifier = new EachTestNotifier(notifier,
41 50
				getDescription());
42
		
51

  
43 52
		boolean isApplicableToContext = false;
44
		DataPortalContexts dataPortalContextsAnotation = getTestClass().getJavaClass().getAnnotation(DataPortalContexts.class);
45
		for(DataPortalContext cntxt : dataPortalContextsAnotation.value()){
46
			if(dataPortalContext.equals(cntxt)){
53
		DataPortalContexts dataPortalContextsAnotation = getTestClass()
54
				.getJavaClass().getAnnotation(DataPortalContexts.class);
55
		for (DataPortalContext cntxt : dataPortalContextsAnotation.value()) {
56
			if (dataPortalContext.equals(cntxt)) {
47 57
				isApplicableToContext = true;
48 58
			}
49 59
		}
50
		
51
		if(!isApplicableToContext){
60

  
61
		if (!isApplicableToContext) {
52 62
			testNotifier.fireTestIgnored();
53 63
			return;
54 64
		}
55
			
65

  
56 66
		try {
57
			Statement statement= classBlock(notifier);
67
			Statement statement = classBlock(notifier);
58 68
			statement.evaluate();
59 69
		} catch (AssumptionViolatedException e) {
60 70
			testNotifier.fireTestIgnored();

Also available in: Unified diff