use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.
the class ServiceLocator method registerFavoritesService.
public IUserFavoritesService registerFavoritesService(String marketplaceBaseUrl, String apiServerUrl, String apiKey) {
IMarketplaceStorageService storageService = getStorageService(marketplaceBaseUrl);
if (storageService == null) {
storageService = registerStorageService(marketplaceBaseUrl, apiServerUrl, apiKey);
}
UserFavoritesService favoritesService = new UserFavoritesService();
favoritesService.bindStorageService(storageService);
registerService(marketplaceBaseUrl, IUserFavoritesService.class, favoritesService);
return favoritesService;
}
use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.
the class MarketplaceStorageServiceRegistrationTest method testCleanupDuplicateStorageService.
@Test
public void testCleanupDuplicateStorageService() throws Exception {
IStorageService withSlash = storageServices.provide("WithSlash", "https://api-test.example.org/");
IStorageService withoutSlash = storageServices.provide("WithoutSlash", "https://api-test.example.org");
((StorageService) withSlash).getSecurePreferences().remove("username");
((StorageService) withoutSlash).getSecurePreferences().put("username", "testuser", false);
IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api-test.example.org", null);
assertNotNull(registered);
assertEquals("https://api-test.example.org/", registered.getServiceUri().toString());
assertSame(withSlash, registered.getStorage().getService());
withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api-test.example.org"));
assertNull(withoutSlash);
String username = ((StorageService) withSlash).getSecurePreferences().get("username", null);
assertEquals("testuser", username);
}
use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.
the class MarketplaceStorageServiceRegistrationTest method testCleanupDuplicateEclipseOrgStorageService.
@Test
public void testCleanupDuplicateEclipseOrgStorageService() throws Exception {
IStorageService withSlash = storageServices.provide("WithSlash", "https://api.eclipse.org/");
assertFalse(withSlash instanceof IStorageService.Dynamic);
IStorageService withoutSlash = storageServices.provide("WithoutSlash", "https://api.eclipse.org");
assertTrue(withoutSlash instanceof IStorageService.Dynamic);
IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api.eclipse.org/", null);
assertNotNull(registered);
assertSame(withSlash, registered.getStorage().getService());
withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api.eclipse.org"));
assertNull(withoutSlash);
}
use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.
the class MarketplaceStorageServiceRegistrationTest method testRegisterNewStorageServiceWithSlash.
@Test
public void testRegisterNewStorageServiceWithSlash() {
IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api-test.example.org/", null);
assertNotNull(registered);
assertEquals("https://api-test.example.org/", registered.getServiceUri().toString());
}
use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.
the class MarketplaceStorageServiceRegistrationTest method testRegisterNewStorageServiceWithoutSlash.
@Test
public void testRegisterNewStorageServiceWithoutSlash() {
IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api-test.example.org", null);
assertNotNull(registered);
assertEquals("https://api-test.example.org/", registered.getServiceUri().toString());
IStorageService withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api-test.example.org"));
assertNull(withoutSlash);
}
Aggregations