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);
}
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());
}
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());
}
}
Aggregations