summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-04-11 19:04:17 (EDT)
committerSteffen Pingel2013-04-11 19:04:17 (EDT)
commitaf78b5351894630a2679258d3323eb39243d6c2a (patch)
tree508c753792cfc0115955d56c827bf2e08d0fba33
parent3f1330f1dfc307b2960d1a18b9719cb359b99b71 (diff)
downloadorg.eclipse.mylyn.commons-af78b5351894630a2679258d3323eb39243d6c2a.zip
org.eclipse.mylyn.commons-af78b5351894630a2679258d3323eb39243d6c2a.tar.gz
org.eclipse.mylyn.commons-af78b5351894630a2679258d3323eb39243d6c2a.tar.bz2
400396: fix handling of default fixture
Change-Id: I60867cc9cf02e4ec5770c2e8100c705ca2173659 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=400396
-rw-r--r--org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/FixtureConfiguration.java4
-rw-r--r--org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/TestConfiguration.java17
2 files changed, 14 insertions, 7 deletions
diff --git a/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/FixtureConfiguration.java b/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/FixtureConfiguration.java
index 271cacb..7007eb0 100644
--- a/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/FixtureConfiguration.java
+++ b/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/FixtureConfiguration.java
@@ -74,4 +74,8 @@ public class FixtureConfiguration {
return tags;
}
+ public boolean isDefault() {
+ return properties != null && "1".equals(properties.get("default"));
+ }
+
}
diff --git a/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/TestConfiguration.java b/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/TestConfiguration.java
index 0dfed03..f524f43 100644
--- a/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/TestConfiguration.java
+++ b/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/TestConfiguration.java
@@ -120,7 +120,7 @@ public class TestConfiguration {
try {
File file = CommonTestUtil.getFile(clazz, "local.json");
- fixtures = discover("file://" + file.getAbsolutePath(), "", clazz, fixtureType);
+ fixtures = discover("file://" + file.getAbsolutePath(), "", clazz, fixtureType, isDefaultOnly());
} catch (AssertionFailedError e) {
// ignore
} catch (IOException e) {
@@ -129,17 +129,19 @@ public class TestConfiguration {
if (fixtures.isEmpty()) {
fixtures = discover(URL_SERVICES_LOCALHOST + "/cgi-bin/services", URL_SERVICES_LOCALHOST, clazz,
- fixtureType);
+ fixtureType, isDefaultOnly());
}
if (fixtures.isEmpty()) {
- fixtures = discover(URL_SERVICES_DEFAULT + "/cgi-bin/services", URL_SERVICES_DEFAULT, clazz, fixtureType);
+ fixtures = discover(URL_SERVICES_DEFAULT + "/cgi-bin/services", URL_SERVICES_DEFAULT, clazz, fixtureType,
+ isDefaultOnly());
}
return fixtures;
}
- public static <T> List<T> discover(String location, String baseUrl, Class<T> clazz, String fixtureType) {
+ private static <T> List<T> discover(String location, String baseUrl, Class<T> clazz, String fixtureType,
+ boolean defaultOnly) {
Assert.isNotNull(fixtureType);
List<FixtureConfiguration> configurations = getConfigurations(location);
if (configurations != null) {
@@ -148,16 +150,17 @@ public class TestConfiguration {
configuration.setUrl(baseUrl + configuration.getUrl());
}
}
- return loadFixtures(configurations, clazz, fixtureType);
+ return loadFixtures(configurations, clazz, fixtureType, defaultOnly);
}
return Collections.emptyList();
}
private static <T> List<T> loadFixtures(List<FixtureConfiguration> configurations, Class<T> clazz,
- String fixtureType) {
+ String fixtureType, boolean defaultOnly) {
List<T> result = new ArrayList<T>();
for (FixtureConfiguration configuration : configurations) {
- if (configuration != null && fixtureType.equals(configuration.getType())) {
+ if (configuration != null && fixtureType.equals(configuration.getType())
+ && (!defaultOnly || configuration.isDefault())) {
try {
Constructor<T> constructor = clazz.getConstructor(FixtureConfiguration.class);
result.add(constructor.newInstance(configuration));