Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-09-18 04:21:53 +0000
committerspingel2009-09-18 04:21:53 +0000
commit05588e92cce7e001834d0fa6b84213f47d3509b1 (patch)
tree3bd141a360ca3b0bcc16e3c18d255e06f8feda53
parentd3a1bd02743ae16dd0f14cf057828350d812731a (diff)
downloadorg.eclipse.mylyn.tasks-05588e92cce7e001834d0fa6b84213f47d3509b1.tar.gz
org.eclipse.mylyn.tasks-05588e92cce7e001834d0fa6b84213f47d3509b1.tar.xz
org.eclipse.mylyn.tasks-05588e92cce7e001834d0fa6b84213f47d3509b1.zip
NEW - bug 221939: [releng] manage branches
https://bugs.eclipse.org/bugs/show_bug.cgi?id=221939
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java
index e4ade6cf5..868d9069e 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/TestFixture.java
@@ -11,11 +11,17 @@
package org.eclipse.mylyn.bugzilla.tests.support;
+import java.io.File;
+import java.io.IOException;
import java.net.Proxy;
+import java.net.URL;
+import junit.framework.Assert;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
@@ -28,6 +34,7 @@ import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.osgi.framework.Bundle;
/**
* @author Steffen Pingel
@@ -134,4 +141,34 @@ public abstract class TestFixture {
return connector;
}
+ public static File getFile(String bundleId, Class<?> clazz, String filename) throws IOException {
+ Bundle bundle = Platform.getBundle(bundleId);
+ if (bundle != null) {
+ URL localURL = FileLocator.toFileURL(bundle.getEntry(filename));
+ filename = localURL.getFile();
+ } else {
+ URL localURL = clazz.getResource("");
+ String path = localURL.getFile();
+ int i = path.indexOf("!");
+ if (i != -1) {
+ int j = path.lastIndexOf(File.separatorChar, i);
+ if (j != -1) {
+ path = path.substring(0, j);
+ } else {
+ Assert.fail("Unable to determine location for '" + filename + "' at '" + path + "'");
+ }
+ } else {
+ String[] tokens = path.split("\\.");
+ for (int j = 0; j < tokens.length + 1; j++) {
+ path += ".." + File.separator;
+ }
+ if (path.contains("bin" + File.separator)) {
+ path += ".." + File.separator;
+ }
+ }
+ filename = path + filename.replaceAll("/", File.separator);
+ }
+ return new File(filename);
+ }
+
}

Back to the top