diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 7be16f5e0d..f65cbedbd9 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -61,6 +61,7 @@ import java.util.Set; import java.util.SortedSet; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -83,12 +84,14 @@ import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; +import org.jclouds.io.CopyInputStreamInputSupplierMap; import org.jclouds.logging.LoggingModules; import org.jclouds.logging.config.LoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.config.CredentialStoreModule; import org.jclouds.scriptbuilder.domain.SaveHttpResponseTo; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.scriptbuilder.statements.java.InstallJDK; @@ -107,6 +110,7 @@ import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.common.io.InputSupplier; import com.google.common.net.InetAddresses; import com.google.common.util.concurrent.ListenableFuture; import com.google.gson.annotations.SerializedName; @@ -130,7 +134,10 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv protected Template template; protected Map keyPair; - + // isolate tests from eachother, as default credentialStore is static + protected Module credentialStoreModule = new CredentialStoreModule( + new CopyInputStreamInputSupplierMap(new ConcurrentHashMap>())); + @BeforeGroups(groups = { "integration", "live" }) public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { setServiceDefaults(); @@ -189,7 +196,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv overrides.setProperty(provider + ".identity", "MOMMA"); overrides.setProperty(provider + ".credential", "MIA"); context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(getLoggingModule()), overrides); + ImmutableSet. of(getLoggingModule(), credentialStoreModule), overrides); context.getComputeService().listNodes(); } catch (AuthorizationException e) { throw e; diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java index 6b79b46654..8577e98068 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java @@ -22,11 +22,13 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; import java.io.IOException; +import java.io.InputStream; import java.util.Map; import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Properties; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -40,10 +42,12 @@ import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; +import org.jclouds.io.CopyInputStreamInputSupplierMap; import org.jclouds.json.Json; import org.jclouds.json.config.GsonModule; import org.jclouds.logging.LoggingModules; import org.jclouds.logging.config.LoggingModule; +import org.jclouds.rest.config.CredentialStoreModule; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -55,6 +59,7 @@ import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import com.google.common.io.InputSupplier; import com.google.inject.Guice; import com.google.inject.Module; @@ -269,6 +274,10 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi } protected void tryOverrideUsingPropertyKey(String propertyKey) { + // isolate tests from eachother, as default credentialStore is static + Module credentialStoreModule = new CredentialStoreModule( + new CopyInputStreamInputSupplierMap(new ConcurrentHashMap>())); + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); @@ -278,7 +287,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi overrides.setProperty(propertyKey + ".image.authenticate-sudo", auth + ""); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(getLoggingModule()), overrides); + ImmutableSet. of(getLoggingModule(), credentialStoreModule), overrides); Iterable userPass = Splitter.on(':').split(login); String user = Iterables.get(userPass, 0); @@ -287,9 +296,6 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi LoginCredentials.builder().user(user).password(pass).authenticateSudo(auth).build()); } finally { if (context != null){ - // Need to clear persisted credentials; otherwise next time a ComputeServiceContext is created - // then it will have these "foo" credentials! - context.credentialStore().clear(); context.close(); } }