Search in sources :

Example 1 with DefaultCatalogService

use of org.eclipse.epp.internal.mpc.core.service.DefaultCatalogService in project epp.mpc by eclipse.

the class ServiceLocator method getCatalogService.

public synchronized ICatalogService getCatalogService() {
    if (catalogServiceTracker != null) {
        ICatalogService registeredService = catalogServiceTracker.getService();
        if (registeredService != null) {
            // we don't cache this on our own, since it might become invalid
            return registeredService;
        }
    }
    if (catalogService != null) {
        return catalogService;
    }
    ICatalogService catalogService = new DefaultCatalogService(defaultCatalogUrl);
    registerService(null, ICatalogService.class, catalogService);
    return catalogService;
}
Also used : ICatalogService(org.eclipse.epp.mpc.core.service.ICatalogService) DefaultCatalogService(org.eclipse.epp.internal.mpc.core.service.DefaultCatalogService)

Example 2 with DefaultCatalogService

use of org.eclipse.epp.internal.mpc.core.service.DefaultCatalogService in project epp.mpc by eclipse.

the class MarketplaceClientUiTest method testOfflineCatalogServiceErrors.

@Test
public void testOfflineCatalogServiceErrors() throws Exception {
    // since NoRouteToHost and ConnectExceptions are hard to fake and happen at pretty much the same place,
    // we only simulate the UnknownHostException case here (by actually using an invalid host address)
    final DefaultCatalogService catalogService = (DefaultCatalogService) ServiceLocator.getInstance().getCatalogService();
    catalogService.setBaseUrl(new URL(UNREACHABLE_MARKETPLACE_URL));
    try {
        ServiceLocator.setInstance(new ServiceLocator() {

            @Override
            public ICatalogService getCatalogService() {
                return catalogService;
            }
        });
        IStatus status = new MarketplaceWizardCommand().installRemoteCatalogs();
        assertEquals(IStatus.ERROR, status.getSeverity());
        assertTrue(status.getMessage().contains(": " + OFFLINE_HINT_TEXT));
    } finally {
        ServiceLocator.setInstance(new ServiceLocator());
    }
}
Also used : ServiceLocator(org.eclipse.epp.internal.mpc.core.ServiceLocator) IStatus(org.eclipse.core.runtime.IStatus) ICatalogService(org.eclipse.epp.mpc.core.service.ICatalogService) DefaultCatalogService(org.eclipse.epp.internal.mpc.core.service.DefaultCatalogService) URL(java.net.URL) MarketplaceWizardCommand(org.eclipse.epp.internal.mpc.ui.commands.MarketplaceWizardCommand) Test(org.junit.Test)

Aggregations

DefaultCatalogService (org.eclipse.epp.internal.mpc.core.service.DefaultCatalogService)2 ICatalogService (org.eclipse.epp.mpc.core.service.ICatalogService)2 URL (java.net.URL)1 IStatus (org.eclipse.core.runtime.IStatus)1 ServiceLocator (org.eclipse.epp.internal.mpc.core.ServiceLocator)1 MarketplaceWizardCommand (org.eclipse.epp.internal.mpc.ui.commands.MarketplaceWizardCommand)1 Test (org.junit.Test)1