summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-04-11 23:49:47 (EDT)
committer Steffen Pingel2013-04-11 23:49:47 (EDT)
commit88a660d6b14556b22db01e18003c71e380c8276c (patch)
tree53355394845b8277a7eadbe19d22384a81d03ab2
parentaf78b5351894630a2679258d3323eb39243d6c2a (diff)
downloadorg.eclipse.mylyn.commons-88a660d6b14556b22db01e18003c71e380c8276c.zip
org.eclipse.mylyn.commons-88a660d6b14556b22db01e18003c71e380c8276c.tar.gz
org.eclipse.mylyn.commons-88a660d6b14556b22db01e18003c71e380c8276c.tar.bz2
400396: provide method for discovering default fixturerefs/changes/41/11841/1
Change-Id: I9943a2a97c16cb2499eb16a2ead2f30c450d1dfd 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/TestConfiguration.java19
1 files changed, 16 insertions, 3 deletions
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 f524f43..e03318a 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
@@ -25,6 +25,7 @@ import java.util.List;
import junit.framework.AssertionFailedError;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.osgi.util.NLS;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@@ -116,11 +117,23 @@ public class TestConfiguration {
}
public <T> List<T> discover(Class<T> clazz, String fixtureType) {
+ return discover(clazz, fixtureType, isDefaultOnly());
+ }
+
+ public <T> T discoverDefault(Class<T> clazz, String fixtureType) {
+ List<T> fixtures = discover(clazz, fixtureType, true);
+ if (fixtures.isEmpty()) {
+ throw new RuntimeException(NLS.bind("No default fixture available for {0}", fixtureType));
+ }
+ return fixtures.get(0);
+ }
+
+ public <T> List<T> discover(Class<T> clazz, String fixtureType, boolean defaultOnly) {
List<T> fixtures = Collections.emptyList();
try {
File file = CommonTestUtil.getFile(clazz, "local.json");
- fixtures = discover("file://" + file.getAbsolutePath(), "", clazz, fixtureType, isDefaultOnly());
+ fixtures = discover("file://" + file.getAbsolutePath(), "", clazz, fixtureType, defaultOnly);
} catch (AssertionFailedError e) {
// ignore
} catch (IOException e) {
@@ -129,12 +142,12 @@ public class TestConfiguration {
if (fixtures.isEmpty()) {
fixtures = discover(URL_SERVICES_LOCALHOST + "/cgi-bin/services", URL_SERVICES_LOCALHOST, clazz,
- fixtureType, isDefaultOnly());
+ fixtureType, defaultOnly);
}
if (fixtures.isEmpty()) {
fixtures = discover(URL_SERVICES_DEFAULT + "/cgi-bin/services", URL_SERVICES_DEFAULT, clazz, fixtureType,
- isDefaultOnly());
+ defaultOnly);
}
return fixtures;