Search in sources :

Example 1 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.

the class CatalogDescriptorTest method testCatalogDescriptor.

@Test
public void testCatalogDescriptor() throws Exception {
    URL dependenciesRepository = new URL("http://marketplace.eclipse.org/repo/");
    String description = "some description";
    ImageDescriptor icon = ImageDescriptor.getMissingImageDescriptor();
    boolean installFromAllRepositories = true;
    String label = "some label";
    URL url = new URL("http://marketplace.eclipse.org");
    CatalogDescriptor descriptor = new CatalogDescriptor();
    descriptor.setDependenciesRepository(dependenciesRepository);
    descriptor.setDescription(description);
    descriptor.setIcon(icon);
    descriptor.setInstallFromAllRepositories(installFromAllRepositories);
    descriptor.setLabel(label);
    descriptor.setUrl(url);
    assertEquals(dependenciesRepository.toString(), descriptor.getDependenciesRepository().toString());
    assertEquals(description, descriptor.getDescription());
    assertEquals(icon, descriptor.getIcon());
    assertEquals(installFromAllRepositories, descriptor.isInstallFromAllRepositories());
    assertEquals(label, descriptor.getLabel());
    assertEquals(url.toString(), descriptor.getUrl().toString());
    CatalogDescriptor copyDescriptor = new CatalogDescriptor(descriptor);
    assertEquals(dependenciesRepository.toString(), copyDescriptor.getDependenciesRepository().toString());
    assertEquals(description, copyDescriptor.getDescription());
    assertEquals(icon, copyDescriptor.getIcon());
    assertEquals(installFromAllRepositories, copyDescriptor.isInstallFromAllRepositories());
    assertEquals(label, copyDescriptor.getLabel());
    assertEquals(url.toString(), copyDescriptor.getUrl().toString());
    assertTrue(descriptor.equals(copyDescriptor));
    assertEquals(descriptor.hashCode(), copyDescriptor.hashCode());
}
Also used : ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Example 2 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor 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 3 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor 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 4 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor 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 5 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.

the class MarketplaceClientUiTest method testOfflineCatalogErrors.

@Test
public void testOfflineCatalogErrors() throws Exception {
    final MarketplaceCatalog catalog = new MarketplaceCatalog();
    catalog.getDiscoveryStrategies().add(new MarketplaceDiscoveryStrategy(new CatalogDescriptor(new URL(UNREACHABLE_MARKETPLACE_URL), "Unreachable Marketplace")));
    IStatus status = catalog.performDiscovery(new NullProgressMonitor());
    assertEquals(IStatus.ERROR, status.getSeverity());
    assertTrue(status.getMessage().startsWith(OFFLINE_HINT_TEXT));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) MarketplaceDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Aggregations

CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)37 URL (java.net.URL)18 Test (org.junit.Test)10 IStatus (org.eclipse.core.runtime.IStatus)7 CatalogRegistry (org.eclipse.epp.internal.mpc.ui.CatalogRegistry)7 MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)4 MarketplaceUrlHandler (org.eclipse.epp.mpc.ui.MarketplaceUrlHandler)4 Before (org.junit.Before)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 ArrayList (java.util.ArrayList)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Status (org.eclipse.core.runtime.Status)3 MarketplaceDiscoveryStrategy (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy)3 INode (org.eclipse.epp.mpc.core.model.INode)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 List (java.util.List)2 CoreException (org.eclipse.core.runtime.CoreException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2