Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2009-04-05 22:58:08 +0000
committerSimon Kaegi2009-04-05 22:58:08 +0000
commit7767e8887517efe3e40dec96494bc3225c079a97 (patch)
tree0fe34c7c58a3e4d4e3ef0921500bda1029f6c585 /bundles/org.eclipse.equinox.frameworkadmin.test
parentca4015600cbc26df219d159bd79b975f9edb444e (diff)
downloadrt.equinox.p2-7767e8887517efe3e40dec96494bc3225c079a97.tar.gz
rt.equinox.p2-7767e8887517efe3e40dec96494bc3225c079a97.tar.xz
rt.equinox.p2-7767e8887517efe3e40dec96494bc3225c079a97.zip
Bug 241477 [eclipse] better support for framework extensions via eclipse touchpoint
Diffstat (limited to 'bundles/org.eclipse.equinox.frameworkadmin.test')
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/dummy.frameworkextension_1.0.0.jarbin0 -> 431 bytes
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java25
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FrameworkExtensionTest.java33
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java8
5 files changed, 61 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/dummy.frameworkextension_1.0.0.jar b/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/dummy.frameworkextension_1.0.0.jar
new file mode 100644
index 000000000..e69311419
--- /dev/null
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/dummy.frameworkextension_1.0.0.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java
index 1c481ddc4..baaccb0b5 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java
@@ -185,12 +185,12 @@ public abstract class AbstractFwkAdminTest extends TestCase {
assertTrue(tmp.indexOf(value) == -1);
}
- public void assertPropertyNotContain(File file, String property, String search) {
+ private String getProperty(File file, String property) {
Properties p = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
- p.load(fis);
+ p.load(fis);
} catch (FileNotFoundException e) {
fail("Can't find file " + file);
} catch (IOException e) {
@@ -203,6 +203,27 @@ public abstract class AbstractFwkAdminTest extends TestCase {
//ignore
}
}
+ return p.getProperty(property);
+ }
+
+ public void assertPropertyContains(File file, String property, String text) {
+ String value = getProperty(file, property);
+ if (value == null)
+ fail("property: " + property + " not found in: " +file);
+
+ int index = value.indexOf(text);
+ if (index == -1)
+ fail(text + " not found in property:" + property + " for file: " +file);
+ }
+
+ public void assertNotPropertyContains(File file, String property, String text) {
+ String value = getProperty(file, property);
+ if (value == null)
+ return;
+
+ int index = value.indexOf(text);
+ if (index != -1)
+ fail(text + " found in property:" + property + " for file: " +file);
}
public void assertEquals(String[] array1, String[] array2) {
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AllTests.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AllTests.java
index a2a994675..8f5cceb71 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AllTests.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AllTests.java
@@ -46,6 +46,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(ManipulatorTests.class);
suite.addTestSuite(UtilsTest.class);
suite.addTestSuite(LauncherDataTest.class);
+ suite.addTestSuite(FrameworkExtensionTest.class);
return suite;
}
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FrameworkExtensionTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FrameworkExtensionTest.java
new file mode 100644
index 000000000..38aa1d5b0
--- /dev/null
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FrameworkExtensionTest.java
@@ -0,0 +1,33 @@
+package org.eclipse.equinox.frameworkadmin.tests;
+
+import org.osgi.framework.Constants;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
+
+public class FrameworkExtensionTest extends FwkAdminAndSimpleConfiguratorTest {
+
+ public FrameworkExtensionTest(String name) {
+ super(name);
+ }
+
+ public void testAddRemoveFrameworkExtension() throws Exception {
+ Manipulator manipulator = createMinimalConfiguration(FrameworkExtensionTest.class.getName());
+ BundleInfo bundleInfo = new BundleInfo("dummy.frameworkextension", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/dummy.frameworkextension_1.0.0.jar"))), 4, false);
+ bundleInfo.setFragmentHost(Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
+ manipulator.getConfigData().addBundle(bundleInfo);
+ manipulator.save(false);
+ assertContent(getBundleTxt(), "dummy.frameworkextension");
+ assertPropertyContains(getConfigIni(),"osgi.framework.extensions", "dummy.frameworkextension");
+ assertNotPropertyContains(getConfigIni(),"osgi.bundles", "dummy.frameworkextension");
+
+ BundleInfo basicBundleInfo = new BundleInfo("dummy.frameworkextension", "1.0.0", null, -1, false);
+ manipulator.getConfigData().removeBundle(basicBundleInfo);
+ manipulator.save(false);
+ assertNotContent(getBundleTxt(), "dummy.frameworkextension");
+ assertNotPropertyContains(getConfigIni(),"osgi.framework.extensions", "dummy.frameworkextension");
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java
index 137e05d1b..d0a1560eb 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java
@@ -42,7 +42,7 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
assertEquals(true, defaultManipulator.getConfigData().removeBundle(osgi));
defaultManipulator.save(false);
assertNotContent(getBundleTxt(), "org.eclipse.osgi");
- assertPropertyNotContain(getConfigIni(),"osgi.bundles", "org.eclipse.osgi");
+ assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi");
}
public void testRemovalUsingOtherManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException {
@@ -58,7 +58,7 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
newManipulator.getConfigData().removeBundle(osgi);
newManipulator.save(false);
assertNotContent(getBundleTxt(), "org.eclipse.osgi");
- assertPropertyNotContain(getConfigIni(),"osgi.bundles", "org.eclipse.osgi");
+ assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi");
}
public void testAdditionUsingOtherManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException {
@@ -78,7 +78,7 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
newManipulator.getConfigData().addBundle(osgi);
newManipulator.save(false);
assertContent(getBundleTxt(), "org.eclipse.osgi");
- assertPropertyNotContain(getConfigIni(),"osgi.bundles", "org.eclipse.osgi");
+ assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi");
}
public void testChangeVersion() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, URISyntaxException {
@@ -116,7 +116,7 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
defaultManipulator.getConfigData().removeBundle(osgi);
defaultManipulator.save(false);
assertNotContent(getBundleTxt(), "org.eclipse.osgi");
- assertPropertyNotContain(getConfigIni(),"osgi.bundles", "org.eclipse.osgi");
+ assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi");
Manipulator newManipulator = getNewManipulator(workArea);
assertEquals(1, newManipulator.getConfigData().getBundles().length);

Back to the top