Search in sources :

Example 11 with MarketplaceWizardCommand

use of org.eclipse.epp.internal.mpc.ui.commands.MarketplaceWizardCommand 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

MarketplaceWizardCommand (org.eclipse.epp.internal.mpc.ui.commands.MarketplaceWizardCommand)11 WizardState (org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceWizard.WizardState)8 AbstractMarketplaceWizardCommand (org.eclipse.epp.internal.mpc.ui.commands.AbstractMarketplaceWizardCommand)7 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 IStatus (org.eclipse.core.runtime.IStatus)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URL (java.net.URL)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Status (org.eclipse.core.runtime.Status)1 ServiceLocator (org.eclipse.epp.internal.mpc.core.ServiceLocator)1 DefaultCatalogService (org.eclipse.epp.internal.mpc.core.service.DefaultCatalogService)1 INode (org.eclipse.epp.mpc.core.model.INode)1 ICatalogService (org.eclipse.epp.mpc.core.service.ICatalogService)1 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)1 MarketplaceUrlHandler (org.eclipse.epp.mpc.ui.MarketplaceUrlHandler)1 SolutionInstallationInfo (org.eclipse.epp.mpc.ui.MarketplaceUrlHandler.SolutionInstallationInfo)1 VoidResult (org.eclipse.swtbot.swt.finder.results.VoidResult)1 Test (org.junit.Test)1