Revision 6d6b201f
Added by Andreas Kohlbecker over 6 years ago
src/main/java/eu/etaxonomy/dataportal/DataPortalContext.java | ||
---|---|---|
37 | 37 |
return baseUri; |
38 | 38 |
} |
39 | 39 |
|
40 |
/** |
|
41 |
* <code>UNUSED</code> |
|
42 |
* @return |
|
43 |
*/ |
|
40 | 44 |
public URI getCdmServerUri() { |
41 | 45 |
return cdmServerUri; |
42 | 46 |
} |
43 | 47 |
|
48 |
/** |
|
49 |
* <code>UNUSED</code> |
|
50 |
* @return |
|
51 |
*/ |
|
44 | 52 |
public UUID getClassificationUUID() { |
45 | 53 |
return classificationUUID; |
46 | 54 |
} |
src/main/java/eu/etaxonomy/dataportal/DataPortalContextProvider.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.dataportal; |
|
10 |
|
|
11 |
import java.util.List; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author a.kohlbecker |
|
15 |
* @since Apr 10, 2018 |
|
16 |
* |
|
17 |
*/ |
|
18 |
public interface DataPortalContextProvider { |
|
19 |
|
|
20 |
List<DataPortalContext> contexts(); |
|
21 |
|
|
22 |
} |
src/main/java/eu/etaxonomy/dataportal/DataPortalSiteContextProvider.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.dataportal; |
|
10 |
|
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
/** |
|
15 |
* @author a.kohlbecker |
|
16 |
* @since Apr 10, 2018 |
|
17 |
* |
|
18 |
*/ |
|
19 |
public class DataPortalSiteContextProvider implements DataPortalContextProvider { |
|
20 |
|
|
21 |
DataPortalSite[] dataPortalSites; |
|
22 |
|
|
23 |
public DataPortalSiteContextProvider(DataPortalSite[] dataPortalSites){ |
|
24 |
this.dataPortalSites = dataPortalSites; |
|
25 |
} |
|
26 |
|
|
27 |
|
|
28 |
@Override |
|
29 |
public List<DataPortalContext> contexts() { |
|
30 |
List<DataPortalContext> contexts = new ArrayList<>(dataPortalSites.length); |
|
31 |
for (DataPortalSite dataPortalSite : dataPortalSites) { |
|
32 |
contexts.add(dataPortalSite.getContext()); |
|
33 |
} |
|
34 |
return contexts; |
|
35 |
} |
|
36 |
|
|
37 |
|
|
38 |
} |
src/main/java/eu/etaxonomy/dataportal/DataPortalsListContextProvider.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.dataportal; |
|
10 |
|
|
11 |
import java.net.URL; |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
/** |
|
16 |
* Retrieves a list of data portal URLs from the URL passed as paramter to the constructor |
|
17 |
* @author a.kohlbecker |
|
18 |
* @since Apr 10, 2018 |
|
19 |
* |
|
20 |
*/ |
|
21 |
public class DataPortalsListContextProvider implements DataPortalContextProvider { |
|
22 |
|
|
23 |
List<URL> dataPoralUrls = new ArrayList<>(); |
|
24 |
|
|
25 |
public DataPortalsListContextProvider(URL url){ |
|
26 |
|
|
27 |
// FIXME read the list of dataPoralUrls from url and fill dataPoralUrls |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
/** |
|
32 |
* {@inheritDoc} |
|
33 |
*/ |
|
34 |
@Override |
|
35 |
public List<DataPortalContext> contexts() { |
|
36 |
// FIXME create the DataPortalContext for each of the dataPoralUrls |
|
37 |
// read any additional from the data portal or from the cdm webservices |
|
38 |
// if this is needed for testing. |
|
39 |
return null; |
|
40 |
} |
|
41 |
|
|
42 |
} |
src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java | ||
---|---|---|
8 | 8 |
import java.lang.annotation.Retention; |
9 | 9 |
import java.lang.annotation.RetentionPolicy; |
10 | 10 |
import java.lang.annotation.Target; |
11 |
import java.net.MalformedURLException; |
|
12 |
import java.net.URL; |
|
11 | 13 |
import java.util.ArrayList; |
12 | 14 |
import java.util.Collections; |
13 | 15 |
import java.util.List; |
... | ... | |
21 | 23 |
import org.junit.runners.model.Statement; |
22 | 24 |
|
23 | 25 |
import eu.etaxonomy.dataportal.DataPortalContext; |
26 |
import eu.etaxonomy.dataportal.DataPortalContextProvider; |
|
24 | 27 |
import eu.etaxonomy.dataportal.DataPortalSite; |
28 |
import eu.etaxonomy.dataportal.DataPortalSiteContextProvider; |
|
29 |
import eu.etaxonomy.dataportal.DataPortalsListContextProvider; |
|
25 | 30 |
|
26 | 31 |
|
27 | 32 |
/** |
... | ... | |
30 | 35 |
*/ |
31 | 36 |
public class DataPortalContextSuite extends Suite{ |
32 | 37 |
|
38 |
public static final String SYSTEM_PROPERTY_SITE_LIST_URL = "SiteListUrl"; |
|
39 |
|
|
33 | 40 |
/** |
34 | 41 |
* Only to be used for test classes which extend {@link CdmDataPortalTestBase} |
35 | 42 |
* |
... | ... | |
39 | 46 |
@Target(ElementType.TYPE) |
40 | 47 |
@Inherited |
41 | 48 |
public @interface DataPortalContexts { |
49 |
|
|
42 | 50 |
/** |
43 | 51 |
* @return an array of DataPortalSite to which the annotated test |
44 | 52 |
* class is applicable |
45 | 53 |
*/ |
46 |
DataPortalSite[] value(); |
|
54 |
DataPortalSite[] value() default {}; |
|
55 |
|
|
56 |
/** |
|
57 |
* Alternative configuration option to the default {@link #value()}. |
|
58 |
* |
|
59 |
* In case this mode is active the system property <code>SiteListUrl</code> must contain a URL which |
|
60 |
* points to a resource containing a list of Data Portals base URLs to be tested. Each dataportal URL must be in a |
|
61 |
* separate line of the text returned by the URL in <code>SiteListUrl</code. |
|
62 |
*/ |
|
63 |
boolean siteListUrl() default false; |
|
47 | 64 |
} |
48 | 65 |
|
49 | 66 |
private final List<Runner> runners = new ArrayList<Runner>(); |
... | ... | |
103 | 120 |
public DataPortalContextSuite(Class<?> klass) throws InitializationError { |
104 | 121 |
super(klass, Collections.<Runner>emptyList()); |
105 | 122 |
DataPortalContexts dataPortalContextsAnotation = getTestClass().getJavaClass().getAnnotation(DataPortalContexts.class); |
106 |
for (DataPortalSite dataPortalSite : dataPortalContextsAnotation.value()) { |
|
107 |
runners.add(new TestClassRunnerWithDataPortalContext(klass, dataPortalSite.getContext())); |
|
123 |
DataPortalContextProvider contextProvider = null; |
|
124 |
|
|
125 |
if(dataPortalContextsAnotation.siteListUrl()){ |
|
126 |
String siteListUrlString = System.getProperty(SYSTEM_PROPERTY_SITE_LIST_URL); |
|
127 |
if(System.getProperty(SYSTEM_PROPERTY_SITE_LIST_URL) == null) { |
|
128 |
throw new RuntimeException("The system property " + SYSTEM_PROPERTY_SITE_LIST_URL + " must be set if 'siteListUrl' is enabled"); |
|
129 |
} |
|
130 |
try { |
|
131 |
contextProvider = new DataPortalsListContextProvider(new URL(siteListUrlString)); |
|
132 |
} catch (MalformedURLException e) { |
|
133 |
throw new RuntimeException("Error parsing the provided URL", e); |
|
134 |
} |
|
135 |
} else { |
|
136 |
contextProvider = new DataPortalSiteContextProvider(dataPortalContextsAnotation.value()); |
|
137 |
} |
|
138 |
|
|
139 |
assert contextProvider != null; |
|
140 |
for (DataPortalContext dataPortalContext : contextProvider.contexts()) { |
|
141 |
runners.add(new TestClassRunnerWithDataPortalContext(klass, dataPortalContext)); |
|
108 | 142 |
} |
109 | 143 |
} |
110 | 144 |
|
Also available in: Unified diff
ref #7347 introducing DataPortalContextProviders, DataPortalsListContextProvider reads config from system property 'SiteListUrl'