Search in sources :

Example 1 with Credentials

use of org.eclipse.userstorage.spi.Credentials 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)

Aggregations

IOException (java.io.IOException)1 ServiceLocator (org.eclipse.epp.internal.mpc.core.ServiceLocator)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