mirror of https://github.com/apache/jclouds.git
fixed context builder when params in properties
This commit is contained in:
parent
fd6d0c5c49
commit
298e764f85
|
@ -260,7 +260,7 @@ public class ContextBuilder {
|
||||||
|
|
||||||
//We use either the specified name (optional) or a hash of provider/api, endpoint, api version & identity. Hash is used to be something readable.
|
//We use either the specified name (optional) or a hash of provider/api, endpoint, api version & identity. Hash is used to be something readable.
|
||||||
return buildInjector(name.or(String.valueOf(Objects.hashCode(providerMetadata.getId(),
|
return buildInjector(name.or(String.valueOf(Objects.hashCode(providerMetadata.getId(),
|
||||||
providerMetadata.getEndpoint() , apiVersion , identity.get()))), providerMetadata, creds, modules);
|
providerMetadata.getEndpoint(), providerMetadata.getApiMetadata().getVersion(), creds.identity))), providerMetadata, creds, modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getAndRemove(Properties expanded, String key) {
|
private static String getAndRemove(Properties expanded, String key) {
|
||||||
|
@ -375,7 +375,7 @@ public class ContextBuilder {
|
||||||
@SuppressWarnings( { "unchecked" })
|
@SuppressWarnings( { "unchecked" })
|
||||||
static Map<String, Object> propertiesPrefixedWithJcloudsApiOrProviderId(Properties properties, String apiId,
|
static Map<String, Object> propertiesPrefixedWithJcloudsApiOrProviderId(Properties properties, String apiId,
|
||||||
String providerId) {
|
String providerId) {
|
||||||
return Maps.filterKeys((Map) properties, containsPattern("^(jclouds|" + providerId + "|" + apiId
|
return Maps.filterKeys(Map.class.cast(properties), containsPattern("^(jclouds|" + providerId + "|" + apiId
|
||||||
+ ").*"));
|
+ ").*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||||
import org.jclouds.providers.ProviderMetadata;
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
import org.jclouds.rest.annotations.ApiVersion;
|
||||||
|
import org.jclouds.rest.annotations.Identity;
|
||||||
import org.jclouds.rest.config.CredentialStoreModule;
|
import org.jclouds.rest.config.CredentialStoreModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -107,6 +109,24 @@ public class ContextBuilderTest {
|
||||||
assertEquals(codes, ImmutableSet.<String> of());
|
assertEquals(codes, ImmutableSet.<String> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProviderMetadataWithCredentialsSetViaProperty() {
|
||||||
|
Properties overrides = new Properties();
|
||||||
|
overrides.setProperty(Constants.PROPERTY_IDENTITY, "foo");
|
||||||
|
overrides.setProperty(Constants.PROPERTY_CREDENTIAL, "BAR");
|
||||||
|
ContextBuilder withCredsInProps = testContextBuilder().overrides(overrides);
|
||||||
|
String identity = withCredsInProps.buildInjector().getInstance(Key.get(String.class, Identity.class));
|
||||||
|
assertEquals(identity, "foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProviderMetadataWithVersionSetViaProperty() {
|
||||||
|
Properties overrides = new Properties();
|
||||||
|
overrides.setProperty(Constants.PROPERTY_API_VERSION, "1.1");
|
||||||
|
ContextBuilder withVersionInProps = testContextBuilder().overrides(overrides);
|
||||||
|
String version = withVersionInProps.buildInjector().getInstance(Key.get(String.class, ApiVersion.class));
|
||||||
|
assertEquals(version, "1.1");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddHttpModuleIfNotPresent() {
|
public void testAddHttpModuleIfNotPresent() {
|
||||||
|
|
Loading…
Reference in New Issue