Search in sources :

Example 6 with CatalogRegistry

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

the class CatalogDescriptorTest method testFindCatalogDescriptorWithCommonPrefix.

/**
 * @throws Exception
 * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=488436">bug 488436</a>
 */
@Test
public void testFindCatalogDescriptorWithCommonPrefix() throws Exception {
    CatalogRegistry registry = CatalogRegistry.getInstance();
    String marketplace = "http://marketplace.eclipse.org";
    String hostedMarketplace = "http://marketplace.eclipse.org/hosted_catalog/test";
    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(marketplace);
    assertThat(found, is(marketplaceDescriptor));
    found = registry.findCatalogDescriptor(hostedMarketplace);
    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 7 with CatalogRegistry

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

the class AbstractMarketplaceWizardCommand method registerOrOverrideCatalog.

private void registerOrOverrideCatalog(CatalogDescriptor descriptor) {
    CatalogRegistry catalogRegistry = CatalogRegistry.getInstance();
    List<CatalogDescriptor> descriptors = catalogRegistry.getCatalogDescriptors();
    for (CatalogDescriptor catalogDescriptor : descriptors) {
        if (catalogDescriptor.getUrl().toExternalForm().equals(descriptor.getUrl().toExternalForm())) {
            catalogRegistry.unregister(catalogDescriptor);
        }
    }
    catalogRegistry.register(descriptor);
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

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