Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2008-11-25 19:51:23 +0000
committerDJ Houghton2008-11-25 19:51:23 +0000
commit9532e99fe38608885b871fcd2d361020b89f12c0 (patch)
tree03c7edfe0d37b0a9e7798456585ecfe1c59a5a53 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator
parent4722ab4bc3574c191036f1014c05334977736d35 (diff)
downloadrt.equinox.p2-9532e99fe38608885b871fcd2d361020b89f12c0.tar.gz
rt.equinox.p2-9532e99fe38608885b871fcd2d361020b89f12c0.tar.xz
rt.equinox.p2-9532e99fe38608885b871fcd2d361020b89f12c0.zip
Merged path_fun_2008 branch.v20081125_postPathFunMerge
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsTest.java110
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/AllTests.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtilsTest.java55
4 files changed, 191 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java
index 8d50c5015..a3b448fa5 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java
@@ -16,6 +16,7 @@ public class SimpleConfiguratorTests {
public static Test suite() {
TestSuite suite = new TestSuite("Tests for org.eclipse.equinox.simpleconfigurator");
//$JUnit-BEGIN$
+ suite.addTestSuite(SimpleConfiguratorUtilsTest.class);
suite.addTestSuite(BundlesTxtTest.class);
suite.addTestSuite(NonExclusiveMode.class);
//$JUnit-END$
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsTest.java
new file mode 100644
index 000000000..a0722c49a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsTest.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.*;
+import java.util.List;
+import org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo;
+import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+
+public class SimpleConfiguratorUtilsTest extends AbstractProvisioningTest {
+
+ public void testParseBundleInfo() throws MalformedURLException {
+
+ File baseFile = getTempFolder();
+ URI baseURI = baseFile.toURI();
+
+ String canonicalForm = "javax.servlet,2.4.0.v200806031604,plugins/javax.servlet_2.4.0.v200806031604.jar,4,false";
+ BundleInfo canonicalInfo = SimpleConfiguratorUtils.parseBundleInfoLine(canonicalForm, baseURI);
+ File canonicalFile = new File(baseFile, "plugins/javax.servlet_2.4.0.v200806031604.jar");
+
+ String line[] = new String[7];
+ line[0] = "javax.servlet,2.4.0.v200806031604,file:plugins/javax.servlet_2.4.0.v200806031604.jar,4,false";
+ line[1] = "javax.servlet,2.4.0.v200806031604,plugins\\javax.servlet_2.4.0.v200806031604.jar,4,false";
+ line[2] = "javax.servlet,2.4.0.v200806031604,file:plugins\\javax.servlet_2.4.0.v200806031604.jar,4,false";
+ line[3] = "javax.servlet,2.4.0.v200806031604,file:plugins\\javax.servlet_2.4.0.v200806031604.jar,4,false";
+ line[4] = "javax.servlet,2.4.0.v200806031604,file:" + canonicalFile.toString() + ",4,false";
+ line[5] = "javax.servlet,2.4.0.v200806031604," + canonicalFile.toURL().toExternalForm() + ",4,false";
+ line[6] = "javax.servlet,2.4.0.v200806031604," + canonicalFile.toURI().toString() + ",4,false";
+
+ String relativeBundleLocation = "reference:file:plugins/javax.servlet_2.4.0.v200806031604.jar";
+ String absoluteBundleLocation = "reference:" + canonicalFile.toURL().toExternalForm();
+
+ for (int i = 0; i < line.length; i++) {
+ BundleInfo info = SimpleConfiguratorUtils.parseBundleInfoLine(line[i], baseURI);
+ assertEquals("[" + i + "]", canonicalInfo, info);
+ if (info.getLocation().isAbsolute())
+ assertEquals("[" + i + "]", absoluteBundleLocation, SimpleConfiguratorUtils.getBundleLocation(info, true));
+ else
+ assertEquals("[" + i + "]", relativeBundleLocation, SimpleConfiguratorUtils.getBundleLocation(info, true));
+ }
+ }
+
+ public void testParseUNCBundleInfo() throws MalformedURLException {
+
+ File baseFile = new File("\\\\127.0.0.1\\somefolder\\");
+ URI baseURI = baseFile.toURI();
+
+ String canonicalForm = "javax.servlet,2.4.0.v200806031604,plugins/javax.servlet_2.4.0.v200806031604.jar,4,false";
+ BundleInfo canonicalInfo = SimpleConfiguratorUtils.parseBundleInfoLine(canonicalForm, baseURI);
+ File canonicalFile = new File(baseFile, "plugins/javax.servlet_2.4.0.v200806031604.jar");
+
+ String line[] = new String[4];
+ line[0] = "javax.servlet,2.4.0.v200806031604,file:plugins/javax.servlet_2.4.0.v200806031604.jar,4,false";
+ line[1] = "javax.servlet,2.4.0.v200806031604,plugins\\javax.servlet_2.4.0.v200806031604.jar,4,false";
+ line[2] = "javax.servlet,2.4.0.v200806031604,file:plugins\\javax.servlet_2.4.0.v200806031604.jar,4,false";
+ line[3] = "javax.servlet,2.4.0.v200806031604,file:plugins\\javax.servlet_2.4.0.v200806031604.jar,4,false";
+
+ //TODO: we need to fix URI.resolve for UNC paths
+ //line[4] = "javax.servlet,2.4.0.v200806031604," + canonicalFile.toURI().toString() + ",4,false";
+
+ String relativeBundleLocation = "reference:file:plugins/javax.servlet_2.4.0.v200806031604.jar";
+ String absoluteBundleLocation = "reference:" + canonicalFile.toURL().toExternalForm();
+
+ for (int i = 0; i < line.length; i++) {
+ BundleInfo info = SimpleConfiguratorUtils.parseBundleInfoLine(line[i], baseURI);
+ assertEquals("[" + i + "]", canonicalInfo, info);
+ if (info.getLocation().isAbsolute())
+ assertEquals("[" + i + "]", absoluteBundleLocation, SimpleConfiguratorUtils.getBundleLocation(info, true));
+ else
+ assertEquals("[" + i + "]", relativeBundleLocation, SimpleConfiguratorUtils.getBundleLocation(info, true));
+ }
+ }
+
+ public void testRead34BundlesInfo() {
+
+ File data = getTestData("1.0", "testData/simpleConfiguratorTest/3.4.bundles.info");
+ try {
+ URI baseLocation = new URI("file:/c:/tmp/foo");
+ List infos = SimpleConfiguratorUtils.readConfiguration(data.toURL(), baseLocation);
+ assertEquals("1.1", 2, infos.size());
+
+ BundleInfo a = new BundleInfo("a", "1.0.0", new URI("plugins/a_1.0.0.jar"), 4, false);
+ a.setBaseLocation(baseLocation);
+ BundleInfo b = new BundleInfo("b", "1.0.0", new URI("plugins/b_1.0.0.jar"), -1, true);
+ b.setBaseLocation(baseLocation);
+
+ assertEquals("1.2", a, infos.get(0));
+ assertEquals("1.3", b, infos.get(1));
+
+ } catch (URISyntaxException e) {
+ fail("1.97", e);
+ } catch (MalformedURLException e) {
+ fail("1.98", e);
+ } catch (IOException e) {
+ fail("1.99", e);
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/AllTests.java
new file mode 100644
index 000000000..e8ed347c3
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/AllTests.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator.manipulator;
+
+import junit.framework.*;
+
+/**
+ * Performs all automated director tests.
+ */
+public class AllTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ suite.addTestSuite(SimpleConfiguratorManipulatorUtilsTest.class);
+ return suite;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtilsTest.java
new file mode 100644
index 000000000..e3a2d51a1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtilsTest.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator.manipulator;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.eclipse.equinox.internal.simpleconfigurator.manipulator.SimpleConfiguratorManipulatorUtils;
+import org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo;
+import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+
+public class SimpleConfiguratorManipulatorUtilsTest extends AbstractProvisioningTest {
+
+ public void testWriteBundleInfoLine() throws URISyntaxException, IOException {
+ String expectedLine = "javax.servlet,2.4.0.v200806031604,plugins/javax.servlet_2.4.0.v200806031604.jar,4,false";
+ BundleInfo bundleInfo = new BundleInfo("javax.servlet", "2.4.0.v200806031604", new URI("plugins/javax.servlet_2.4.0.v200806031604.jar"), 4, false);
+ String line = SimpleConfiguratorManipulatorUtils.createBundleInfoLine(bundleInfo);
+ assertEquals(expectedLine, line);
+ assertEquals(bundleInfo, SimpleConfiguratorUtils.parseBundleInfoLine(line, null));
+ }
+
+ public void testWriteBundleInfoLineWithComma() throws URISyntaxException, IOException {
+ String expectedLine = "javax.servlet,2.4.0.v200806031604,plugin%2Cs/javax.servlet_2.4.0.v200806031604.jar,4,false";
+ BundleInfo bundleInfo = new BundleInfo("javax.servlet", "2.4.0.v200806031604", new URI("plugin,s/javax.servlet_2.4.0.v200806031604.jar"), 4, false);
+ String line = SimpleConfiguratorManipulatorUtils.createBundleInfoLine(bundleInfo);
+ assertEquals(expectedLine, line);
+ assertEquals(bundleInfo, SimpleConfiguratorUtils.parseBundleInfoLine(line, null));
+ }
+
+ public void testWriteBundleInfoLineWithSpace() throws URISyntaxException, IOException {
+ String expectedLine = "javax.servlet,2.4.0.v200806031604,plugin%20s/javax.servlet_2.4.0.v200806031604.jar,4,false";
+ BundleInfo bundleInfo = new BundleInfo("javax.servlet", "2.4.0.v200806031604", new URI("plugin%20s/javax.servlet_2.4.0.v200806031604.jar"), 4, false);
+ String line = SimpleConfiguratorManipulatorUtils.createBundleInfoLine(bundleInfo);
+ assertEquals(expectedLine, line);
+ assertEquals(bundleInfo, SimpleConfiguratorUtils.parseBundleInfoLine(line, null));
+ }
+
+ public void testWriteBundleInfoLineWithAtSymbol() throws URISyntaxException, IOException {
+ String expectedLine = "javax.servlet,2.4.0.v200806031604,plugin@s/javax.servlet_2.4.0.v200806031604.jar,4,false";
+ BundleInfo bundleInfo = new BundleInfo("javax.servlet", "2.4.0.v200806031604", new URI("plugin@s/javax.servlet_2.4.0.v200806031604.jar"), 4, false);
+ String line = SimpleConfiguratorManipulatorUtils.createBundleInfoLine(bundleInfo);
+ assertEquals(expectedLine, line);
+ assertEquals(bundleInfo, SimpleConfiguratorUtils.parseBundleInfoLine(line, null));
+ }
+
+}

Back to the top