Search in sources :

Example 1 with CatalogRegistry

use of org.eclipse.epp.internal.mpc.ui.CatalogRegistry in project epp.mpc by eclipse.

the class CatalogDescriptorTest method testFindCatalogDescriptorMatchingProtocol.

@Test
public void testFindCatalogDescriptorMatchingProtocol() throws Exception {
    CatalogRegistry registry = CatalogRegistry.getInstance();
    String marketplace = "http://marketplace.eclipse.org";
    String marketplaceHttps = URLUtil.toggleHttps(marketplace);
    CatalogDescriptor marketplaceDescriptor = new CatalogDescriptor(new URL(marketplace), null);
    CatalogDescriptor marketplaceHttpsDescriptor = new CatalogDescriptor(new URL(marketplaceHttps), null);
    registry.register(marketplaceHttpsDescriptor);
    registry.register(marketplaceDescriptor);
    CatalogDescriptor found = registry.findCatalogDescriptor(marketplace);
    assertThat(found, is(marketplaceDescriptor));
    found = registry.findCatalogDescriptor(marketplaceHttps);
    assertThat(found, is(marketplaceHttpsDescriptor));
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Example 2 with CatalogRegistry

use of org.eclipse.epp.internal.mpc.ui.CatalogRegistry in project epp.mpc by eclipse.

the class CatalogDescriptorTest method testIgnoreCatalogDescriptorWithDedicatedHostingSuffix.

@Test
public void testIgnoreCatalogDescriptorWithDedicatedHostingSuffix() throws Exception {
    CatalogRegistry registry = CatalogRegistry.getInstance();
    String marketplace = "http://marketplace.eclipse.org";
    String dedicatedHostingMarketplace = marketplace + "/" + ICatalogService.DEDICATED_CATALOG_HOSTING_SEGMENT + "test";
    CatalogDescriptor dedicatedHostingDescriptor = new CatalogDescriptor(new URL(dedicatedHostingMarketplace), null);
    registry.register(dedicatedHostingDescriptor);
    CatalogDescriptor found = registry.findCatalogDescriptor(marketplace);
    assertNull(found);
    found = registry.findCatalogDescriptor(dedicatedHostingMarketplace);
    assertThat(found, is(dedicatedHostingDescriptor));
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Example 3 with CatalogRegistry

use of org.eclipse.epp.internal.mpc.ui.CatalogRegistry in project epp.mpc by eclipse.

the class CatalogDescriptorTest method cleanRegistry.

@Before
@After
public void cleanRegistry() {
    CatalogRegistry registry = CatalogRegistry.getInstance();
    List<CatalogDescriptor> catalogs = new ArrayList<>(registry.getCatalogDescriptors());
    for (CatalogDescriptor descriptor : catalogs) {
        registry.unregister(descriptor);
    }
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) ArrayList(java.util.ArrayList) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Before(org.junit.Before) After(org.junit.After)

Example 4 with CatalogRegistry

use of org.eclipse.epp.internal.mpc.ui.CatalogRegistry in project epp.mpc by eclipse.

the class CatalogDescriptorTest method testFindCatalogDescriptorWithCommonPrefixDifferentProtocol2.

/**
 * @throws Exception
 * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=488436">bug 488436</a>
 */
@Test
public void testFindCatalogDescriptorWithCommonPrefixDifferentProtocol2() throws Exception {
    CatalogRegistry registry = CatalogRegistry.getInstance();
    String marketplace = "https://marketplace.eclipse.org";
    String marketplaceHttp = URLUtil.toggleHttps(marketplace);
    String hostedMarketplace = "http://marketplace.eclipse.org/hosted_catalog/test";
    String hostedMarketplaceHttps = URLUtil.toggleHttps(hostedMarketplace);
    CatalogDescriptor marketplaceDescriptor = new CatalogDescriptor(new URL(marketplace), null);
    CatalogDescriptor hostedMarketplaceDescriptor = new CatalogDescriptor(new URL(hostedMarketplace), null);
    registry.register(marketplaceDescriptor);
    registry.register(hostedMarketplaceDescriptor);
    CatalogDescriptor found = registry.findCatalogDescriptor(marketplaceHttp);
    assertThat(found, is(marketplaceDescriptor));
    found = registry.findCatalogDescriptor(hostedMarketplaceHttps);
    assertThat(found, is(hostedMarketplaceDescriptor));
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Example 5 with CatalogRegistry

use of org.eclipse.epp.internal.mpc.ui.CatalogRegistry in project epp.mpc by eclipse.

the class CatalogDescriptorTest method testFindCatalogDescriptorWithCommonPrefixDifferentProtocol1.

/**
 * @throws Exception
 * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=488436">bug 488436</a>
 */
@Test
public void testFindCatalogDescriptorWithCommonPrefixDifferentProtocol1() throws Exception {
    CatalogRegistry registry = CatalogRegistry.getInstance();
    String marketplace = "http://marketplace.eclipse.org";
    String marketplaceHttps = URLUtil.toggleHttps(marketplace);
    String hostedMarketplace = "https://marketplace.eclipse.org/hosted_catalog/test";
    String hostedMarketplaceHttp = URLUtil.toggleHttps(hostedMarketplace);
    CatalogDescriptor marketplaceDescriptor = new CatalogDescriptor(new URL(marketplace), null);
    CatalogDescriptor hostedMarketplaceDescriptor = new CatalogDescriptor(new URL(hostedMarketplace), null);
    registry.register(marketplaceDescriptor);
    registry.register(hostedMarketplaceDescriptor);
    CatalogDescriptor found = registry.findCatalogDescriptor(marketplaceHttps);
    assertThat(found, is(marketplaceDescriptor));
    found = registry.findCatalogDescriptor(hostedMarketplaceHttp);
    assertThat(found, is(hostedMarketplaceDescriptor));
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Aggregations

CatalogRegistry (org.eclipse.epp.internal.mpc.ui.CatalogRegistry)7 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)7 URL (java.net.URL)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)1 After (org.junit.After)1 Before (org.junit.Before)1