Search in sources :

Example 1 with ServiceLocator

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

the class DefaultCatalogService method registerDynamicFavoritesService.

private void registerDynamicFavoritesService(String catalogUrl, String favoritesApiServer, String favoritesApiKey) {
    IMarketplaceServiceLocator marketplaceServiceLocator = ServiceHelper.getMarketplaceServiceLocator();
    IUserFavoritesService favoritesService = marketplaceServiceLocator.getFavoritesService(catalogUrl);
    if (favoritesService != null) {
        return;
    }
    ((ServiceLocator) marketplaceServiceLocator).registerFavoritesService(catalogUrl, favoritesApiServer, favoritesApiKey);
}
Also used : IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator) ServiceLocator(org.eclipse.epp.internal.mpc.core.ServiceLocator) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator)

Example 2 with ServiceLocator

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

the class UserFavoritesServiceTest method setUp.

@Before
public void setUp() throws Exception {
    marketplaceStorageService = ServiceHelper.getMarketplaceServiceLocator().getDefaultStorageService();
    assertNotNull(marketplaceStorageService);
    assertEquals(USERSTORAGE_SERVICE_URI, marketplaceStorageService.getServiceUri());
    marketplaceStorageService.getStorage().setCredentialsProvider(new AbstractCredentialsProvider() {

        @Override
        public Credentials provideCredentials(IStorageService service, boolean reauthentication) {
            String marketplaceUser;
            String marketplacePass;
            try {
                marketplaceUser = TestProperties.getTestProperty("mpc.storage.user");
                marketplacePass = TestProperties.getTestProperty("mpc.storage.pass");
            } catch (IOException e) {
                throw new AssertionError("Cannot load test properties", e);
            }
            Assume.assumeNotNull(marketplaceUser, marketplacePass);
            return new Credentials(marketplaceUser, marketplacePass);
        }
    });
    favoritesService = ServiceHelper.getMarketplaceServiceLocator().getDefaultFavoritesService();
    // assertNotNull(favoritesService);
    if (favoritesService == null) {
        ((ServiceLocator) ServiceHelper.getMarketplaceServiceLocator()).registerFavoritesService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, marketplaceStorageService.getServiceUri().toString(), null);
        favoritesService = ServiceHelper.getMarketplaceServiceLocator().getDefaultFavoritesService();
    }
    assertSame(marketplaceStorageService, favoritesService.getStorageService());
}
Also used : ServiceLocator(org.eclipse.epp.internal.mpc.core.ServiceLocator) IStorageService(org.eclipse.userstorage.IStorageService) AbstractCredentialsProvider(org.eclipse.userstorage.spi.AbstractCredentialsProvider) IOException(java.io.IOException) Credentials(org.eclipse.userstorage.spi.Credentials) Before(org.junit.Before)

Example 3 with ServiceLocator

use of org.eclipse.epp.internal.mpc.core.ServiceLocator 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

ServiceLocator (org.eclipse.epp.internal.mpc.core.ServiceLocator)3 IOException (java.io.IOException)1 URL (java.net.URL)1 IStatus (org.eclipse.core.runtime.IStatus)1 DefaultCatalogService (org.eclipse.epp.internal.mpc.core.service.DefaultCatalogService)1 MarketplaceWizardCommand (org.eclipse.epp.internal.mpc.ui.commands.MarketplaceWizardCommand)1 ICatalogService (org.eclipse.epp.mpc.core.service.ICatalogService)1 IMarketplaceServiceLocator (org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator)1 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)1 IStorageService (org.eclipse.userstorage.IStorageService)1 AbstractCredentialsProvider (org.eclipse.userstorage.spi.AbstractCredentialsProvider)1 Credentials (org.eclipse.userstorage.spi.Credentials)1 Before (org.junit.Before)1 Test (org.junit.Test)1