Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/AllDiscoveryTests.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/DiscoveryTestConstants.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/BundleDiscoveryStrategyTest.java104
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/ConnectorDiscoveryRemoteTest.java83
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/ConnectorDiscoveryTest.java153
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/DirectoryParserTest.java106
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/RemoteBundleDiscoveryStrategyTest.java71
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/AbstractMockFactory.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/CatalogCategoryMockFactory.java65
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/CatalogItemMockFactory.java112
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockBundleDiscoveryStrategy.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockCatalogSource.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockDiscoveryStrategy.java88
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/CatalogCategoryComparatorTest.java79
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/CatalogConnectorComparatorTest.java81
15 files changed, 0 insertions, 1126 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/AllDiscoveryTests.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/AllDiscoveryTests.java
deleted file mode 100644
index a01039556..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/AllDiscoveryTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.discovery.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.equinox.p2.discovery.tests.core.*;
-
-/**
- * @author Steffen Pingel
- */
-public class AllDiscoveryTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Tests for org.eclipse.equinox.p2.discovery.tests"); //$NON-NLS-1$
- suite.addTestSuite(ConnectorDiscoveryTest.class);
- suite.addTestSuite(DirectoryParserTest.class);
- suite.addTestSuite(BundleDiscoveryStrategyTest.class);
- //suite.addTestSuite(RemoteBundleDiscoveryStrategyTest.class);
- //suite.addTestSuite(ConnectorDiscoveryRemoteTest.class);
- return suite;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/DiscoveryTestConstants.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/DiscoveryTestConstants.java
deleted file mode 100644
index 909b87d2e..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/DiscoveryTestConstants.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.discovery.tests;
-
-/**
- * @author David Green
- */
-public abstract class DiscoveryTestConstants {
-
- /**
- * The URL of the mylyn discovery directory, may be overridden using the system property
- * <tt>mylyn.discovery.directory</tt>.
- */
- public static final String DISCOVERY_URL = System.getProperty("mylyn.discovery.directory", "http://www.eclipse.org/mylyn/discovery/directory-3.3.xml"); //$NON-NLS-1$ //$NON-NLS-2$
-
- private DiscoveryTestConstants() {
- // don't allow clients to instantiate
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/BundleDiscoveryStrategyTest.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/BundleDiscoveryStrategyTest.java
deleted file mode 100644
index 9465da547..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/BundleDiscoveryStrategyTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.discovery.tests.core;
-
-import java.util.*;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.discovery.Policy;
-import org.eclipse.equinox.internal.p2.discovery.model.*;
-import org.eclipse.equinox.p2.discovery.tests.core.mock.MockBundleDiscoveryStrategy;
-
-/**
- * @author David Green
- * @author Steffen Pingel
- */
-public class BundleDiscoveryStrategyTest extends TestCase {
-
- private MockBundleDiscoveryStrategy discoveryStrategy;
-
- private final List<CatalogCategory> categories = new ArrayList<CatalogCategory>();
-
- private final List<CatalogItem> connectors = new ArrayList<CatalogItem>();
-
- private final List<Certification> certifications = new ArrayList<Certification>();
-
- private final List<Tag> tags = new ArrayList<Tag>();
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- discoveryStrategy = new MockBundleDiscoveryStrategy();
- discoveryStrategy.setPolicy(new Policy(true));
- discoveryStrategy.setCategories(categories);
- discoveryStrategy.setItems(connectors);
- discoveryStrategy.setCertifications(certifications);
- discoveryStrategy.setTags(tags);
- }
-
- public void testDiscovery() throws CoreException {
- discoveryStrategy.performDiscovery(new NullProgressMonitor());
-
- assertFalse(categories.isEmpty());
- assertFalse(connectors.isEmpty());
- CatalogCategory category = findCategoryById("org.eclipse.mylyn.discovery.tests.connectorCategory1"); //$NON-NLS-1$
- assertNotNull(category);
- CatalogItem connector = findConnectorById("org.eclipse.mylyn.discovery.tests.connectorDescriptor1"); //$NON-NLS-1$
- assertNotNull(connector);
- Certification certification = findCertificationById("org.eclipse.mylyn.discovery.tests.certification1"); //$NON-NLS-1$
- assertNotNull(certification);
- }
-
- public void testCustomTag() throws CoreException {
- discoveryStrategy.performDiscovery(new NullProgressMonitor());
-
- CatalogItem connector = findConnectorById("org.eclipse.mylyn.discovery.test.tagged"); //$NON-NLS-1$
- assertEquals(new HashSet<Tag>(Arrays.asList(new Tag("Custom", "Custom"))), connector.getTags()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(Arrays.asList(new Tag("task", "Tasks"), new Tag("Custom", "Custom")), discoveryStrategy.getTags()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
- }
-
- public void testDiscoveryNoCategoriesPolicy() throws CoreException {
- discoveryStrategy.setPolicy(new Policy(false));
- discoveryStrategy.performDiscovery(new NullProgressMonitor());
-
- assertTrue(categories.isEmpty());
- }
-
- private CatalogItem findConnectorById(String id) {
- for (CatalogItem descriptor : connectors) {
- if (id.equals(descriptor.getId())) {
- return descriptor;
- }
- }
- return null;
- }
-
- private CatalogCategory findCategoryById(String id) {
- for (CatalogCategory descriptor : categories) {
- if (id.equals(descriptor.getId())) {
- return descriptor;
- }
- }
- return null;
- }
-
- private Certification findCertificationById(String id) {
- for (Certification descriptor : certifications) {
- if (id.equals(descriptor.getId())) {
- return descriptor;
- }
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/ConnectorDiscoveryRemoteTest.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/ConnectorDiscoveryRemoteTest.java
deleted file mode 100644
index 4c6bbbe12..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/ConnectorDiscoveryRemoteTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.discovery.tests.core;
-
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.discovery.Catalog;
-import org.eclipse.equinox.internal.p2.discovery.compatibility.RemoteBundleDiscoveryStrategy;
-import org.eclipse.equinox.p2.discovery.tests.DiscoveryTestConstants;
-
-/**
- * A test that uses the real discovery directory and verifies that it works, and that all referenced update sites appear
- * to be available.
- *
- * @author David Green
- */
-public class ConnectorDiscoveryRemoteTest extends TestCase {
-
- private Catalog connectorDiscovery;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- connectorDiscovery = new Catalog();
- connectorDiscovery.setVerifyUpdateSiteAvailability(false);
-
- connectorDiscovery.getDiscoveryStrategies().clear();
- RemoteBundleDiscoveryStrategy remoteStrategy = new RemoteBundleDiscoveryStrategy();
- remoteStrategy.setDirectoryUrl(DiscoveryTestConstants.DISCOVERY_URL);
- connectorDiscovery.getDiscoveryStrategies().add(remoteStrategy);
- }
-
- public void testRemoteDirectory() {
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
-
- assertFalse(connectorDiscovery.getCategories().isEmpty());
- assertFalse(connectorDiscovery.getItems().isEmpty());
- }
-
- // public void testVerifyAvailability() throws CoreException {
- // connectorDiscovery.performDiscovery(new NullProgressMonitor());
- // for (CatalogItem connector : connectorDiscovery.getConnectors()) {
- // assertNull(connector.getAvailable());
- // }
- // connectorDiscovery.verifySiteAvailability(new NullProgressMonitor());
- //
- // assertFalse(connectorDiscovery.getConnectors().isEmpty());
- //
- // int unavailableCount = 0;
- // for (CatalogItem connector : connectorDiscovery.getConnectors()) {
- // assertNotNull(connector.getAvailable());
- // if (!connector.getAvailable()) {
- // ++unavailableCount;
- // }
- // }
- // if (unavailableCount > 0) {
- // fail(String.format("%s unavailable: %s", unavailableCount, computeUnavailableConnetorDescriptorNames()));
- // }
- // }
-
- // private String computeUnavailableConnetorDescriptorNames() {
- // String message = "";
- // for (CatalogItem connector : connectorDiscovery.getItems()) {
- // if (!connector.getAvailable()) {
- // if (message.length() > 0) {
- // message += ", ";
- // }
- // message += connector.getName();
- // }
- // }
- // return message;
- // }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/ConnectorDiscoveryTest.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/ConnectorDiscoveryTest.java
deleted file mode 100644
index a3d3f7abf..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/ConnectorDiscoveryTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.discovery.tests.core;
-
-import java.util.*;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.discovery.Catalog;
-import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
-import org.eclipse.equinox.p2.discovery.tests.core.mock.CatalogItemMockFactory;
-import org.eclipse.equinox.p2.discovery.tests.core.mock.MockDiscoveryStrategy;
-import org.osgi.framework.Version;
-
-/**
- * @author David Green
- */
-public class ConnectorDiscoveryTest extends TestCase {
-
- private Catalog connectorDiscovery;
-
- private MockDiscoveryStrategy mockDiscoveryStrategy;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- connectorDiscovery = new Catalog();
- mockDiscoveryStrategy = new MockDiscoveryStrategy();
- connectorDiscovery.getDiscoveryStrategies().add(mockDiscoveryStrategy);
- }
-
- public void testPlatformFilter_None() {
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
- assertEquals(mockDiscoveryStrategy.getConnectorCount(), connectorDiscovery.getItems().size());
- }
-
- public void testPlatformFilter_NegativeMatch() {
- mockDiscoveryStrategy.setConnectorMockFactory(new CatalogItemMockFactory() {
- @Override
- protected void populateMockData() {
- super.populateMockData();
- platformFilter("(& (osgi.os=macosx) (osgi.ws=carbon))"); //$NON-NLS-1$
- }
- });
- // test to ensure that all non-matching platform filters are not discovered
- Dictionary<Object, Object> environment = new Properties();
- environment.put("osgi.os", "win32"); //$NON-NLS-1$ //$NON-NLS-2$
- environment.put("osgi.ws", "windows"); //$NON-NLS-1$ //$NON-NLS-2$
- connectorDiscovery.setEnvironment(environment);
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
-
- assertTrue(connectorDiscovery.getItems().isEmpty());
- }
-
- public void testPlatformFilter_PositiveMatch() {
- mockDiscoveryStrategy.setConnectorMockFactory(new CatalogItemMockFactory() {
- @Override
- protected void populateMockData() {
- super.populateMockData();
- platformFilter("(& (osgi.os=macosx) (osgi.ws=carbon))"); //$NON-NLS-1$
- }
- });
- Dictionary<Object, Object> environment = new Properties();
-
- // test to ensure that all matching platform filters are discovered
- environment.put("osgi.os", "macosx"); //$NON-NLS-1$//$NON-NLS-2$
- environment.put("osgi.ws", "carbon"); //$NON-NLS-1$ //$NON-NLS-2$
- connectorDiscovery.setEnvironment(environment);
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
-
- assertFalse(connectorDiscovery.getItems().isEmpty());
- assertEquals(mockDiscoveryStrategy.getConnectorCount(), connectorDiscovery.getItems().size());
- }
-
- public void testFeatureFilter_PositiveMatch() {
- mockDiscoveryStrategy.setConnectorMockFactory(new CatalogItemMockFactory() {
- @Override
- protected void populateMockData() {
- super.populateMockData();
- featureFilter("com.foo.bar.feature", "[1.0,2.0)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- Map<String, Version> featureToVersion = new HashMap<String, Version>();
- featureToVersion.put("com.foo.bar.feature", new Version("1.1")); //$NON-NLS-1$ //$NON-NLS-2$
- connectorDiscovery.setFeatureToVersion(featureToVersion);
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
-
- assertFalse(connectorDiscovery.getItems().isEmpty());
- assertEquals(mockDiscoveryStrategy.getConnectorCount(), connectorDiscovery.getItems().size());
- }
-
- public void testFeatureFilter_NegativeMatch_VersionMismatch() {
- mockDiscoveryStrategy.setConnectorMockFactory(new CatalogItemMockFactory() {
- @Override
- protected void populateMockData() {
- super.populateMockData();
- featureFilter("com.foo.bar.feature", "[1.2,2.0)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- Map<String, Version> featureToVersion = new HashMap<String, Version>();
- featureToVersion.put("com.foo.bar.feature", new Version("1.1")); //$NON-NLS-1$ //$NON-NLS-2$
- connectorDiscovery.setFeatureToVersion(featureToVersion);
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
-
- assertTrue(connectorDiscovery.getItems().isEmpty());
- }
-
- public void testFeatureFilter_NegativeMatch_NotPresent() {
- mockDiscoveryStrategy.setConnectorMockFactory(new CatalogItemMockFactory() {
- @Override
- protected void populateMockData() {
- super.populateMockData();
- featureFilter("com.foo.bar.feature", "[1.2,2.0)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- Map<String, Version> featureToVersion = new HashMap<String, Version>();
- connectorDiscovery.setFeatureToVersion(featureToVersion);
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
-
- assertTrue(connectorDiscovery.getItems().isEmpty());
- }
-
- public void testCategorization() {
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
- assertTrue(!connectorDiscovery.getItems().isEmpty());
- assertTrue(!connectorDiscovery.getCategories().isEmpty());
-
- for (CatalogItem connector : connectorDiscovery.getItems()) {
- assertNotNull(connector.getCategory());
- assertEquals(connector.getCategoryId(), connector.getCategory().getId());
- assertTrue(connector.getCategory().getItems().contains(connector));
- }
- }
-
- public void testMultipleStrategies() {
- MockDiscoveryStrategy strategy = new MockDiscoveryStrategy();
- strategy.setConnectorMockFactory(mockDiscoveryStrategy.getConnectorMockFactory());
- strategy.setCategoryMockFactory(mockDiscoveryStrategy.getCategoryMockFactory());
- connectorDiscovery.getDiscoveryStrategies().add(strategy);
-
- connectorDiscovery.performDiscovery(new NullProgressMonitor());
-
- assertEquals(mockDiscoveryStrategy.getConnectorMockFactory().getCreatedCount(), connectorDiscovery.getItems().size());
- assertEquals(mockDiscoveryStrategy.getCategoryMockFactory().getCreatedCount(), connectorDiscovery.getCategories().size());
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/DirectoryParserTest.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/DirectoryParserTest.java
deleted file mode 100644
index f9dfce53f..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/DirectoryParserTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.discovery.tests.core;
-
-import java.io.IOException;
-import java.io.StringReader;
-import junit.framework.TestCase;
-import org.eclipse.equinox.internal.p2.discovery.compatibility.Directory;
-import org.eclipse.equinox.internal.p2.discovery.compatibility.DirectoryParser;
-
-/**
- * @author David Green
- */
-public class DirectoryParserTest extends TestCase {
-
- private DirectoryParser parser;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- parser = new DirectoryParser();
- }
-
- public void testParse() throws IOException {
- Directory directory = parser.parse(new StringReader("<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\"/></directory>")); //$NON-NLS-1$
- assertNotNull(directory);
- assertEquals(1, directory.getEntries().size());
- assertEquals("http://foo.bar.nodomain/baz.jar", directory.getEntries().get(0).getLocation()); //$NON-NLS-1$
- }
-
- public void testParseBadFormat() {
- try {
- parser.parse(new StringReader("<directory2 xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\"/></directory2>")); //$NON-NLS-1$
- fail("Expected exception"); //$NON-NLS-1$
- } catch (IOException e) {
- // expected
- }
- }
-
- public void testParseMalformed() {
- try {
- parser.parse(new StringReader("<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\">")); //$NON-NLS-1$
- fail("Expected exception"); //$NON-NLS-1$
- } catch (IOException e) {
- // expected
- }
- }
-
- public void testParseUnexpectedElementsAndAttributes() throws IOException {
- Directory directory = parser.parse(new StringReader("<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\" id=\"asdf\"><baz/></entry><foo/></directory>")); //$NON-NLS-1$
- assertNotNull(directory);
- assertEquals(1, directory.getEntries().size());
- assertEquals("http://foo.bar.nodomain/baz.jar", directory.getEntries().get(0).getLocation()); //$NON-NLS-1$
- }
-
- public void testParseNoNS() throws IOException {
- Directory directory = parser.parse(new StringReader("<directory><entry url=\"http://foo.bar.nodomain/baz.jar\"/></directory>")); //$NON-NLS-1$
- assertNotNull(directory);
- assertEquals(1, directory.getEntries().size());
- assertEquals("http://foo.bar.nodomain/baz.jar", directory.getEntries().get(0).getLocation()); //$NON-NLS-1$
- }
-
- public void testParsePermitCategoriesTrue() throws IOException {
- Directory directory = parser.parse(new StringReader("<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\" permitCategories=\"true\"/></directory>")); //$NON-NLS-1$
- assertNotNull(directory);
- assertEquals(1, directory.getEntries().size());
- assertEquals(true, directory.getEntries().get(0).isPermitCategories());
- }
-
- public void testParsePermitCategoriesFalse() throws IOException {
- Directory directory = parser.parse(new StringReader("<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\" permitCategories=\"false\"/></directory>")); //$NON-NLS-1$
- assertNotNull(directory);
- assertEquals(1, directory.getEntries().size());
- assertEquals(false, directory.getEntries().get(0).isPermitCategories());
- }
-
- public void testParsePermitCategoriesNotSpecified() throws IOException {
- Directory directory = parser.parse(new StringReader("<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\"/></directory>")); //$NON-NLS-1$
- assertNotNull(directory);
- assertEquals(1, directory.getEntries().size());
- assertEquals(false, directory.getEntries().get(0).isPermitCategories());
- }
-
- public void testParsePermitCategoriesSpecifiedBadly() throws IOException {
- Directory directory = parser.parse(new StringReader("<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\" permitCategories=\"\"/></directory>")); //$NON-NLS-1$
- assertNotNull(directory);
- assertEquals(1, directory.getEntries().size());
- assertEquals(false, directory.getEntries().get(0).isPermitCategories());
- }
-
- public void testParsePermitCategoriesSpecifiedBadly2() throws IOException {
- Directory directory = parser.parse(new StringReader("<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"http://foo.bar.nodomain/baz.jar\" permitCategories=\"asdf\"/></directory>")); //$NON-NLS-1$
- assertNotNull(directory);
- assertEquals(1, directory.getEntries().size());
- assertEquals(false, directory.getEntries().get(0).isPermitCategories());
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/RemoteBundleDiscoveryStrategyTest.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/RemoteBundleDiscoveryStrategyTest.java
deleted file mode 100644
index 8082177c7..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/RemoteBundleDiscoveryStrategyTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.discovery.tests.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.discovery.compatibility.RemoteBundleDiscoveryStrategy;
-import org.eclipse.equinox.internal.p2.discovery.model.*;
-import org.eclipse.equinox.p2.discovery.tests.DiscoveryTestConstants;
-
-/**
- * @author David Green
- */
-public class RemoteBundleDiscoveryStrategyTest extends TestCase {
-
- private RemoteBundleDiscoveryStrategy discoveryStrategy;
-
- @Override
- protected void setUp() throws Exception {
- discoveryStrategy = new RemoteBundleDiscoveryStrategy();
- discoveryStrategy.setDirectoryUrl(DiscoveryTestConstants.DISCOVERY_URL);
- discoveryStrategy.setCategories(new ArrayList<CatalogCategory>());
- discoveryStrategy.setItems(new ArrayList<CatalogItem>());
- discoveryStrategy.setCertifications(new ArrayList<Certification>());
- discoveryStrategy.setTags(new ArrayList<Tag>());
- }
-
- public void testPerformDiscovery() throws CoreException, IOException {
- discoveryStrategy.performDiscovery(new NullProgressMonitor());
- assertFalse(discoveryStrategy.getCategories().isEmpty());
- for (CatalogCategory category : discoveryStrategy.getCategories()) {
- // System.out.println(String.format("%s: %s: %s", category.getId(), category.getName(),
- // category.getDescription()));
- assertNotNull(category.getId());
- assertNotNull(category.getName());
- assertNotNull(category.getDescription());
- }
- assertFalse(discoveryStrategy.getItems().isEmpty());
- for (CatalogItem connector : discoveryStrategy.getItems()) {
- // System.out.println(String.format("%s: %s: %s", connector.getId(), connector.getName(),
- // connector.getDescription()));
- assertNotNull(connector.getId());
- assertNotNull(connector.getTags());
- assertNotNull(connector.getName());
- assertNotNull(connector.getDescription());
-
- // we _know_ that the bundle must have a plugin.xml... so verify that the source is working correctly
- assertNotNull(connector.getSource());
- URL pluginXmlUrl = connector.getSource().getResource("plugin.xml"); //$NON-NLS-1$
- // System.out.println("URL: " + pluginXmlUrl);
- InputStream in = pluginXmlUrl.openStream();
- assertNotNull(in);
- in.close();
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/AbstractMockFactory.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/AbstractMockFactory.java
deleted file mode 100644
index dc398199f..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/AbstractMockFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.discovery.tests.core.mock;
-
-/**
- *
- * @author David Green
- */
-public abstract class AbstractMockFactory<MockType> {
-
- protected int seed = 0;
-
- private MockType mockObject;
-
- protected MockCatalogSource source = new MockCatalogSource();
-
- public final MockType get() {
- MockType object = getMockObject();
- mockObject = null;
- return object;
- }
-
- public final MockType getMockObject() {
- if (mockObject == null) {
- ++seed;
- mockObject = createMockObject();
- populateMockData();
- }
- return mockObject;
- }
-
- protected abstract void populateMockData();
-
- protected abstract MockType createMockObject();
-
- /**
- * get the number of objects created by this factory
- */
- public int getCreatedCount() {
- return seed;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/CatalogCategoryMockFactory.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/CatalogCategoryMockFactory.java
deleted file mode 100644
index 963bb087c..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/CatalogCategoryMockFactory.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.discovery.tests.core.mock;
-
-import org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory;
-import org.eclipse.equinox.internal.p2.discovery.model.Icon;
-
-/**
- * @author David Green
- */
-public class CatalogCategoryMockFactory extends AbstractMockFactory<CatalogCategory> {
-
- CatalogCategory category;
-
- @Override
- protected CatalogCategory createMockObject() {
- return new CatalogCategory();
- }
-
- @Override
- protected void populateMockData() {
- // mock up some data
-
- getMockObject().setSource(source);
-
- name("Category " + seed).id(CatalogCategoryMockFactory.class.getPackage().getName() + ".connector" + seed).description("A category of things, " + seed); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- Icon icon = new Icon();
- icon.setImage128("images/ico128.png"); //$NON-NLS-1$
- icon.setImage16("images/ico16.png"); //$NON-NLS-1$
- icon.setImage32("images/ico32.png"); //$NON-NLS-1$
- icon.setImage64("images/ico64.png"); //$NON-NLS-1$
-
- getMockObject().setIcon(icon);
- }
-
- public CatalogCategoryMockFactory description(String description) {
- getMockObject().setDescription(description);
- return this;
- }
-
- public CatalogCategoryMockFactory icon(Icon icon) {
- getMockObject().setIcon(icon);
- return this;
- }
-
- public CatalogCategoryMockFactory id(String id) {
- getMockObject().setId(id);
- return this;
- }
-
- public CatalogCategoryMockFactory name(String name) {
- getMockObject().setName(name);
- return this;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/CatalogItemMockFactory.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/CatalogItemMockFactory.java
deleted file mode 100644
index 7d9e6b480..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/CatalogItemMockFactory.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.discovery.tests.core.mock;
-
-import org.eclipse.equinox.internal.p2.discovery.model.*;
-
-/**
- * @author David Green
- */
-public class CatalogItemMockFactory extends AbstractMockFactory<CatalogItem> {
-
- @Override
- protected void populateMockData() {
-
- // mock up some data
-
- getMockObject().setSource(source);
-
- name("Connector " + seed).id(CatalogItemMockFactory.class.getPackage().getName() + ".connector" + seed).siteUrl("http://example.nodomain/some/path/updateSite3.x/").tag(new Tag("", "")).license(seed % 2 == 0 ? "EPL 1.0" : "APL 2.0").description("a connector for the Example Task System versions 1.0 - 5.3").categoryId("example").provider("Testing 123 Inc."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
-
- Icon icon = new Icon();
- icon.setImage128("images/ico128.png"); //$NON-NLS-1$
- icon.setImage16("images/ico16.png"); //$NON-NLS-1$
- icon.setImage32("images/ico32.png"); //$NON-NLS-1$
- icon.setImage64("images/ico64.png"); //$NON-NLS-1$
-
- Overview overview = new Overview();
- overview.setScreenshot("images/screenshot-main.png"); //$NON-NLS-1$
- overview.setSummary("some long text that summarizes the connector"); //$NON-NLS-1$
- overview.setUrl("http://example.nodomain/some/path/updateSite3.x/overview.html"); //$NON-NLS-1$
-
- icon(icon).overview(overview);
- overview.setItem(getMockObject());
- }
-
- @Override
- protected CatalogItem createMockObject() {
- return new CatalogItem();
- }
-
- public CatalogItemMockFactory categoryId(String categoryId) {
- getMockObject().setCategoryId(categoryId);
- return this;
- }
-
- public CatalogItemMockFactory description(String description) {
- getMockObject().setDescription(description);
- return this;
- }
-
- public CatalogItemMockFactory icon(Icon icon) {
- getMockObject().setIcon(icon);
- return this;
- }
-
- public CatalogItemMockFactory id(String id) {
- getMockObject().setId(id);
- return this;
- }
-
- public CatalogItemMockFactory tag(Tag tag) {
- getMockObject().addTag(tag);
- return this;
- }
-
- public CatalogItemMockFactory license(String license) {
- getMockObject().setLicense(license);
- return this;
- }
-
- public CatalogItemMockFactory name(String name) {
- getMockObject().setName(name);
- return this;
- }
-
- public CatalogItemMockFactory overview(Overview overview) {
- getMockObject().setOverview(overview);
- return this;
- }
-
- public CatalogItemMockFactory platformFilter(String platformFilter) {
- getMockObject().setPlatformFilter(platformFilter);
- return this;
- }
-
- public CatalogItemMockFactory provider(String provider) {
- getMockObject().setProvider(provider);
- return this;
- }
-
- public CatalogItemMockFactory siteUrl(String siteUrl) {
- getMockObject().setSiteUrl(siteUrl);
- return this;
- }
-
- public CatalogItemMockFactory featureFilter(String featureId, String versionRange) {
- FeatureFilter featureFilter = new FeatureFilter();
- featureFilter.setItem(getMockObject());
- featureFilter.setFeatureId(featureId);
- featureFilter.setVersion(versionRange);
- getMockObject().getFeatureFilter().add(featureFilter);
- return this;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockBundleDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockBundleDiscoveryStrategy.java
deleted file mode 100644
index ac6069da1..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockBundleDiscoveryStrategy.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.discovery.tests.core.mock;
-
-import org.eclipse.core.runtime.IContributor;
-import org.eclipse.equinox.internal.p2.discovery.AbstractCatalogSource;
-import org.eclipse.equinox.internal.p2.discovery.Policy;
-import org.eclipse.equinox.internal.p2.discovery.compatibility.BundleDiscoveryStrategy;
-
-/**
- * a discovery strategy for bundles where the policy can be arbitrarily set
- *
- * @author David Green
- */
-public class MockBundleDiscoveryStrategy extends BundleDiscoveryStrategy {
- private Policy policy = Policy.defaultPolicy();
-
- @Override
- protected AbstractCatalogSource computeDiscoverySource(IContributor contributor) {
- AbstractCatalogSource discoverySource = super.computeDiscoverySource(contributor);
- discoverySource.setPolicy(policy);
- return discoverySource;
- }
-
- public Policy getPolicy() {
- return policy;
- }
-
- public void setPolicy(Policy policy) {
- this.policy = policy;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockCatalogSource.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockCatalogSource.java
deleted file mode 100644
index daa9a1f63..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockCatalogSource.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.discovery.tests.core.mock;
-
-import java.net.URL;
-import org.eclipse.equinox.internal.p2.discovery.AbstractCatalogSource;
-
-/**
- * @author David Green
- */
-public class MockCatalogSource extends AbstractCatalogSource {
-
- @Override
- public Object getId() {
- return "mock:mock"; //$NON-NLS-1$
- }
-
- @Override
- public URL getResource(String resourceName) {
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockDiscoveryStrategy.java
deleted file mode 100644
index 8f867eb07..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/mock/MockDiscoveryStrategy.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.discovery.tests.core.mock;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy;
-import org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory;
-import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
-
-/**
- * @author David Green
- */
-public class MockDiscoveryStrategy extends AbstractDiscoveryStrategy {
-
- private int connectorCount = 15;
-
- private int categoryCount = 5;
-
- protected CatalogItemMockFactory connectorMockFactory = new CatalogItemMockFactory();
-
- protected CatalogCategoryMockFactory categoryMockFactory = new CatalogCategoryMockFactory();
-
- @Override
- public void performDiscovery(IProgressMonitor monitor) {
- for (int x = 0; x < categoryCount; ++x) {
- CatalogCategory mockCategory = createDiscoveryCategory();
- getCategories().add(mockCategory);
- }
- for (int x = 0; x < connectorCount; ++x) {
- CatalogItem mockConnector = createDiscoveryConnector();
- // put the connector in a category
- if (!getCategories().isEmpty()) {
- int categoryIndex = x % getCategories().size();
- mockConnector.setCategoryId(getCategories().get(categoryIndex).getId());
- }
- getItems().add(mockConnector);
- }
- }
-
- protected CatalogCategory createDiscoveryCategory() {
- return categoryMockFactory.get();
- }
-
- protected CatalogItem createDiscoveryConnector() {
- return connectorMockFactory.get();
- }
-
- public CatalogCategoryMockFactory getCategoryMockFactory() {
- return categoryMockFactory;
- }
-
- public void setCategoryMockFactory(CatalogCategoryMockFactory categoryMockFactory) {
- this.categoryMockFactory = categoryMockFactory;
- }
-
- public CatalogItemMockFactory getConnectorMockFactory() {
- return connectorMockFactory;
- }
-
- public void setConnectorMockFactory(CatalogItemMockFactory connectorMockFactory) {
- this.connectorMockFactory = connectorMockFactory;
- }
-
- public int getConnectorCount() {
- return connectorCount;
- }
-
- public void setConnectorCount(int connectorCount) {
- this.connectorCount = connectorCount;
- }
-
- public int getCategoryCount() {
- return categoryCount;
- }
-
- public void setCategoryCount(int categoryCount) {
- this.categoryCount = categoryCount;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/CatalogCategoryComparatorTest.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/CatalogCategoryComparatorTest.java
deleted file mode 100644
index 828bdf09c..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/CatalogCategoryComparatorTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.discovery.tests.core.util;
-
-import junit.framework.TestCase;
-import org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory;
-import org.eclipse.equinox.internal.p2.discovery.util.CatalogCategoryComparator;
-
-public class CatalogCategoryComparatorTest extends TestCase {
-
- private CatalogCategoryComparator comparator;
-
- private CatalogCategory category1;
-
- private CatalogCategory category2;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- comparator = new CatalogCategoryComparator();
- category1 = new CatalogCategory();
- category2 = new CatalogCategory();
- }
-
- public void testSortByRelevanceInequal() {
- category1.setRelevance("100"); //$NON-NLS-1$
- category2.setRelevance("50"); //$NON-NLS-1$
- assertEquals(-1, comparator.compare(category1, category2));
- assertEquals(1, comparator.compare(category2, category1));
- }
-
- public void testSortByRelevanceOneNotSpecified() {
- category1.setRelevance("10"); //$NON-NLS-1$
- assertEquals(-1, comparator.compare(category1, category2));
- assertEquals(1, comparator.compare(category2, category1));
- }
-
- public void testSortByRelevanceSame() {
- category1.setRelevance("10"); //$NON-NLS-1$
- category1.setName("test"); //$NON-NLS-1$
- category1.setId("1"); //$NON-NLS-1$
- category2.setRelevance("10"); //$NON-NLS-1$
- category2.setName("test"); //$NON-NLS-1$
- category2.setId("1"); //$NON-NLS-1$
- assertEquals(0, comparator.compare(category1, category2));
- assertEquals(0, comparator.compare(category2, category1));
- }
-
- public void testSortByRelevanceSameIdsDiffer() {
- category1.setRelevance("10"); //$NON-NLS-1$
- category1.setName("test"); //$NON-NLS-1$
- category1.setId("a"); //$NON-NLS-1$
- category2.setRelevance("10"); //$NON-NLS-1$
- category2.setName("test"); //$NON-NLS-1$
- category2.setId("b"); //$NON-NLS-1$
- assertEquals(-1, comparator.compare(category1, category2));
- assertEquals(1, comparator.compare(category2, category1));
- }
-
- public void testSortByRelevanceSameNamesDiffer() {
- category1.setRelevance("10"); //$NON-NLS-1$
- category1.setName("a"); //$NON-NLS-1$
- category1.setId("a"); //$NON-NLS-1$
- category2.setRelevance("10"); //$NON-NLS-1$
- category2.setName("b"); //$NON-NLS-1$
- category2.setId("a"); //$NON-NLS-1$
- assertEquals(-1, comparator.compare(category1, category2));
- assertEquals(1, comparator.compare(category2, category1));
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/CatalogConnectorComparatorTest.java b/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/CatalogConnectorComparatorTest.java
deleted file mode 100644
index 04d9b7b2a..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.discovery/src/org/eclipse/equinox/p2/discovery/tests/core/util/CatalogConnectorComparatorTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.discovery.tests.core.util;
-
-import junit.framework.TestCase;
-import org.eclipse.equinox.internal.p2.discovery.model.*;
-import org.eclipse.equinox.internal.p2.discovery.util.CatalogItemComparator;
-
-public class CatalogConnectorComparatorTest extends TestCase {
-
- private CatalogCategory category;
-
- private CatalogItemComparator comparator;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- category = new CatalogCategory();
- comparator = new CatalogItemComparator();
- }
-
- private Group addGroup(String id) {
- Group group = new Group();
- group.setId(id);
- category.getGroup().add(group);
- return group;
- }
-
- private CatalogItem addConnectorDescriptor(String id, String name, String groupId) {
- CatalogItem connector = new CatalogItem();
- connector.setId(id);
- connector.setName(name);
- connector.setGroupId(groupId);
- connector.setCategory(category);
- category.getItems().add(connector);
- return connector;
- }
-
- public void testOrderByGroup() {
- addGroup("1"); //$NON-NLS-1$
- addGroup("2"); //$NON-NLS-1$
- CatalogItem t1 = addConnectorDescriptor("b", "btest", "2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- CatalogItem t2 = addConnectorDescriptor("a", "atest", "2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- CatalogItem t3 = addConnectorDescriptor("c", "ctest", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- CatalogItem t4 = addConnectorDescriptor("d", "dtest", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- CatalogItem t5 = addConnectorDescriptor("0", "0test", null); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertEquals(-1, comparator.compare(t2, t1));
- assertEquals(1, comparator.compare(t1, t2));
- assertEquals(-1, comparator.compare(t3, t4));
- assertEquals(1, comparator.compare(t4, t3));
-
- assertEquals(-1, comparator.compare(t1, t5));
- assertEquals(1, comparator.compare(t5, t1));
- assertEquals(-1, comparator.compare(t2, t5));
- assertEquals(1, comparator.compare(t5, t2));
- assertEquals(-1, comparator.compare(t3, t5));
- assertEquals(1, comparator.compare(t5, t3));
- assertEquals(-1, comparator.compare(t4, t5));
- assertEquals(1, comparator.compare(t5, t4));
-
- assertEquals(-1, comparator.compare(t3, t1));
- assertEquals(1, comparator.compare(t1, t3));
- assertEquals(-1, comparator.compare(t3, t2));
- assertEquals(1, comparator.compare(t2, t3));
-
- assertEquals(-1, comparator.compare(t4, t1));
- assertEquals(1, comparator.compare(t1, t4));
- assertEquals(-1, comparator.compare(t4, t2));
- assertEquals(1, comparator.compare(t2, t4));
- }
-}

Back to the top