summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-04-10 18:24:17 (EDT)
committer Steffen Pingel2013-04-10 19:30:20 (EDT)
commit6388274da481806406282af0f0883be2cbef1445 (patch)
treeccdd012e768c7f56822c114e8779990f4649c215
parent07b22248f615d3d459ae84bc6c249b2d804fcc0f (diff)
downloadorg.eclipse.mylyn.commons-6388274da481806406282af0f0883be2cbef1445.zip
org.eclipse.mylyn.commons-6388274da481806406282af0f0883be2cbef1445.tar.gz
org.eclipse.mylyn.commons-6388274da481806406282af0f0883be2cbef1445.tar.bz2
400396: add support for tags and local configuration filesrefs/changes/90/11790/2
Change-Id: I46b457475f3f6c9d3da4c54ab6c14603f29593cd 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.java7
-rw-r--r--org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/TestConfiguration.java36
2 files changed, 30 insertions, 13 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 47a7cc8..271cacb 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
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.commons.sdk.util;
+import java.util.List;
import java.util.Map;
/**
@@ -28,6 +29,8 @@ public class FixtureConfiguration {
Map<String, String> properties;
+ List<String> tags;
+
public FixtureConfiguration() {
}
@@ -67,4 +70,8 @@ public class FixtureConfiguration {
return properties;
}
+ public List<String> getTags() {
+ return tags;
+ }
+
}
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 fdc4f0c..9debd89 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
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.commons.sdk.util;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
@@ -21,6 +22,8 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
+import junit.framework.AssertionFailedError;
+
import org.eclipse.core.runtime.Assert;
import com.google.gson.Gson;
@@ -113,29 +116,36 @@ public class TestConfiguration {
}
public <T> List<T> discover(Class<T> clazz, String fixtureType) {
- List<T> fixtures = discover(URL_SERVICES_LOCALHOST, clazz, fixtureType);
- if (fixtures != null) {
- return fixtures;
+ List<T> fixtures = Collections.emptyList();
+
+ try {
+ File file = CommonTestUtil.getFile(clazz, "local.json");
+ fixtures = discover("file://" + file.getAbsolutePath(), "", clazz, fixtureType);
+ } catch (AssertionFailedError e) {
+ // ignore
+ } catch (IOException e) {
+ // ignore
}
- fixtures = discover(URL_SERVICES_LOCALHOST, clazz, fixtureType);
- if (fixtures != null) {
- if (isDefaultOnly()) {
- return Collections.singletonList(fixtures.get(0));
- } else {
- return fixtures;
- }
+ if (fixtures.isEmpty()) {
+ fixtures = discover(URL_SERVICES_LOCALHOST + "/cgi-bin/services", URL_SERVICES_LOCALHOST, clazz,
+ fixtureType);
+ }
+
+ if (fixtures.isEmpty()) {
+ fixtures = discover(URL_SERVICES_DEFAULT + "/cgi-bin/services", URL_SERVICES_LOCALHOST, clazz, fixtureType);
}
+
return fixtures;
}
- public static <T> List<T> discover(String url, Class<T> clazz, String fixtureType) {
+ public static <T> List<T> discover(String location, String baseUrl, Class<T> clazz, String fixtureType) {
Assert.isNotNull(fixtureType);
- List<FixtureConfiguration> configurations = getConfigurations(url + "/cgi-bin/services");
+ List<FixtureConfiguration> configurations = getConfigurations(location);
if (configurations != null) {
for (FixtureConfiguration configuration : configurations) {
if (configuration != null) {
- configuration.setUrl(url + configuration.getUrl());
+ configuration.setUrl(baseUrl + configuration.getUrl());
}
}
return loadFixtures(configurations, clazz, fixtureType);