use of org.eclipse.userstorage.spi.AbstractCredentialsProvider 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());
}
Aggregations