Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2008-04-14 14:21:32 +0000
committerSimon Kaegi2008-04-14 14:21:32 +0000
commit362b6b290eb66edf3fef09ee8f58b53032f60b23 (patch)
tree3fac96dd8943264babaf0993e25b8872e9507cbf /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation
parent1b3091b2b6a1cab170ea373ccb1b8b8886bc2cbe (diff)
downloadrt.equinox.p2-362b6b290eb66edf3fef09ee8f58b53032f60b23.tar.gz
rt.equinox.p2-362b6b290eb66edf3fef09ee8f58b53032f60b23.tar.xz
rt.equinox.p2-362b6b290eb66edf3fef09ee8f58b53032f60b23.zip
Bug 223506 Need to improve reconciler tests
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/AllTests.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java224
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java225
3 files changed, 476 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/AllTests.java
new file mode 100644
index 000000000..d51b261d4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/AllTests.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.extensionlocation;
+
+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(ExtensionLocationArtifactRepositoryFactoryTest.class);
+ suite.addTestSuite(ExtensionLocationMetadataRepositoryFactoryTest.class);
+ return suite;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java
new file mode 100644
index 000000000..2d7d1f373
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * 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.extensionlocation;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationArtifactRepositoryFactory;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.TestActivator;
+
+public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProvisioningTest {
+
+ private File tempDirectory;
+ private ExtensionLocationArtifactRepositoryFactory factory;
+
+ public ExtensionLocationArtifactRepositoryFactoryTest(String name) {
+ super(name);
+ }
+
+ protected void tearDown() throws Exception {
+ delete(tempDirectory);
+ super.tearDown();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ String tempDir = System.getProperty("java.io.tmpdir");
+ tempDirectory = new File(tempDir, "extensionlocationtest");
+ delete(tempDirectory);
+ tempDirectory.mkdirs();
+ factory = new ExtensionLocationArtifactRepositoryFactory();
+
+ }
+
+ public static File getFile(String path) throws IOException {
+ URL fileURL = TestActivator.getContext().getBundle().getEntry(path);
+ return new File(FileLocator.toFileURL(fileURL).getPath());
+ }
+
+ public void testNonFileURL() throws MalformedURLException {
+ URL nonFileURL = new URL("http://www.eclipse.org");
+ try {
+ factory.load(nonFileURL, null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testNonExistentFile() throws MalformedURLException {
+ File directory = new File(tempDirectory, "nonexistent");
+ delete(directory);
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testNotDirectory() throws IOException {
+ File file = new File(tempDirectory, "exists.file");
+ file.createNewFile();
+ try {
+ factory.load(file.toURL(), null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testNoFeatureOrPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testEmptyFeatureAndPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ new File(directory, "plugins").mkdir();
+ new File(directory, "features").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ }
+
+ public void testEmptyFeaturesDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ new File(directory, "features").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ }
+
+ public void testEmptyPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ new File(directory, "plugins").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ }
+
+ public void testEclipseBaseEmptyFeatureAndPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File eclipseDirectory = new File(directory, "eclipse");
+ eclipseDirectory.mkdir();
+ new File(eclipseDirectory, "plugins").mkdir();
+ new File(eclipseDirectory, "features").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ }
+
+ public void testNotEclipseBaseEmptyFeatureAndPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File eclipseDirectory = new File(directory, "noteclipse");
+ eclipseDirectory.mkdir();
+ new File(eclipseDirectory, "plugins").mkdir();
+ new File(eclipseDirectory, "features").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testNormalFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ copy("1.0", getFile("/testdata/extensionlocation"), directory);
+ IArtifactRepository repo = null;
+ try {
+ repo = factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ if (repo.getArtifactKeys().length != 2)
+ fail();
+ }
+
+ public void testNormalFeaturesDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists/features");
+ directory.mkdirs();
+ File features = new File(directory, "features");
+ features.mkdir();
+ copy("1.0", getFile("/testdata/extensionlocation/features"), features);
+ IArtifactRepository repo = null;
+ try {
+ repo = factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ if (repo.getArtifactKeys().length != 1)
+ fail();
+ }
+
+ public void testNormalPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists/plugins");
+ directory.mkdirs();
+ File plugins = new File(directory, "plugins");
+ plugins.mkdir();
+ copy("1.0", getFile("/testdata/extensionlocation/plugins"), plugins);
+ IArtifactRepository repo = null;
+ try {
+ repo = factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ if (repo.getArtifactKeys().length != 1)
+ fail();
+ }
+
+ public void testEclipseBaseNormalFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File eclipseDirectory = new File(directory, "eclipse");
+ copy("1.0", getFile("/testdata/extensionlocation"), eclipseDirectory);
+ IArtifactRepository repo = null;
+ try {
+ repo = factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ if (repo.getArtifactKeys().length != 2)
+ fail();
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
new file mode 100644
index 000000000..de32f33de
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * 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.extensionlocation;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationMetadataRepositoryFactory;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.internal.provisional.p2.query.Collector;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.TestActivator;
+
+public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProvisioningTest {
+
+ private File tempDirectory;
+ private ExtensionLocationMetadataRepositoryFactory factory;
+
+ public ExtensionLocationMetadataRepositoryFactoryTest(String name) {
+ super(name);
+ }
+
+ protected void tearDown() throws Exception {
+ delete(tempDirectory);
+ super.tearDown();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ String tempDir = System.getProperty("java.io.tmpdir");
+ tempDirectory = new File(tempDir, "extensionlocationtest");
+ delete(tempDirectory);
+ tempDirectory.mkdirs();
+ factory = new ExtensionLocationMetadataRepositoryFactory();
+ }
+
+ public static File getFile(String path) throws IOException {
+ URL fileURL = TestActivator.getContext().getBundle().getEntry(path);
+ return new File(FileLocator.toFileURL(fileURL).getPath());
+ }
+
+ public void testNonFileURL() throws MalformedURLException {
+ URL nonFileURL = new URL("http://www.eclipse.org");
+ try {
+ factory.load(nonFileURL, null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testNonExistentFile() throws MalformedURLException {
+ File directory = new File(tempDirectory, "nonexistent");
+ delete(directory);
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testNotDirectory() throws IOException {
+ File file = new File(tempDirectory, "exists.file");
+ file.createNewFile();
+ try {
+ factory.load(file.toURL(), null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testNoFeatureOrPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testEmptyFeatureAndPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ new File(directory, "plugins").mkdir();
+ new File(directory, "features").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ }
+
+ public void testEmptyFeaturesDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ new File(directory, "features").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ }
+
+ public void testEmptyPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ new File(directory, "plugins").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ }
+
+ public void testEclipseBaseEmptyFeatureAndPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File eclipseDirectory = new File(directory, "eclipse");
+ eclipseDirectory.mkdir();
+ new File(eclipseDirectory, "plugins").mkdir();
+ new File(eclipseDirectory, "features").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ }
+
+ public void testNotEclipseBaseEmptyFeatureAndPluginsDirectory() throws MalformedURLException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File eclipseDirectory = new File(directory, "noteclipse");
+ eclipseDirectory.mkdir();
+ new File(eclipseDirectory, "plugins").mkdir();
+ new File(eclipseDirectory, "features").mkdir();
+ try {
+ factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail();
+ }
+
+ public void testNormalFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ copy("1.0", getFile("/testdata/extensionlocation"), directory);
+ IMetadataRepository repo = null;
+ try {
+ repo = factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 3)
+ fail();
+ }
+
+ public void testNormalFeaturesDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists/features");
+ directory.mkdirs();
+ File features = new File(directory, "features");
+ features.mkdir();
+ copy("1.0", getFile("/testdata/extensionlocation/features"), features);
+ IMetadataRepository repo = null;
+ try {
+ repo = factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 2)
+ fail();
+ }
+
+ public void testNormalPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists/plugins");
+ directory.mkdirs();
+ File plugins = new File(directory, "plugins");
+ plugins.mkdir();
+ copy("1.0", getFile("/testdata/extensionlocation/plugins"), plugins);
+ IMetadataRepository repo = null;
+ try {
+ repo = factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 1)
+ fail();
+ }
+
+ public void testEclipseBaseNormalFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File eclipseDirectory = new File(directory, "eclipse");
+ copy("1.0", getFile("/testdata/extensionlocation"), eclipseDirectory);
+ IMetadataRepository repo = null;
+ try {
+ repo = factory.load(directory.toURL(), null);
+ } catch (ProvisionException e) {
+ fail();
+ }
+ if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 3)
+ fail();
+ }
+}

Back to the top