Refine search
Properties overrides = new Properties(); overrides.setProperty("s3" + ".identity", accessId); overrides.setProperty("s3" + ".credential", secretKey); final Iterable<? extends Module> MODULES = ImmutableSet.of( new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new NettyPayloadModule()); BlobStoreContext context = ContextBuilder.newBuilder("s3") .credentials(accessId, secretKey) .modules(MODULES) .overrides(overrides) .buildView(BlobStoreContext.class); BlobStore blobStore = context.getBlobStore();
private static BlobStore createBlobStore(Properties properties, ExecutorService executorService) throws IOException { String provider = properties.getProperty(Constants.PROPERTY_PROVIDER); String identity = properties.getProperty(Constants.PROPERTY_IDENTITY); String credential = properties.getProperty( Constants.PROPERTY_CREDENTIAL); String endpoint = properties.getProperty(Constants.PROPERTY_ENDPOINT); .newBuilder(provider) .credentials(identity, credential) .modules(ImmutableList.<Module>of( new SLF4JLoggingModule(), new ExecutorServiceModule(executorService))) .overrides(properties); if (!Strings.isNullOrEmpty(endpoint)) { builder = builder.endpoint(endpoint); BlobStoreContext context = builder.build(BlobStoreContext.class); BlobStore blobStore = context.getBlobStore(); if (context instanceof RegionScopedBlobStoreContext &&
@Provides @LazySingleton public CloudFilesApi getCloudFilesApi(final CloudFilesAccountConfig config) { log.info("Building Cloud Files Api..."); Iterable<com.google.inject.Module> modules; if (config.getUseServiceNet()) { log.info("Configuring Cloud Files Api to use the internal service network..."); modules = ImmutableSet.of(new SLF4JLoggingModule(), new InternalUrlModule()); } else { log.info("Configuring Cloud Files Api to use the public network..."); modules = ImmutableSet.of(new SLF4JLoggingModule()); } ProviderRegistry.registerProvider(CloudFilesUSProviderMetadata.builder().build()); ProviderRegistry.registerProvider(CloudFilesUKProviderMetadata.builder().build()); ContextBuilder cb = ContextBuilder.newBuilder(config.getProvider()) .credentials(config.getUserName(), config.getApiKey()).modules(modules); CloudFilesApi cfa = cb.buildApi(CloudFilesApi.class); log.info("Cloud Files Api built."); return cfa; }
ContextBuilder ctxBuilder = ContextBuilder.newBuilder(provider); ctxBuilder.credentials(identity, credential); Properties properties = new Properties(); properties.setProperty(Constants.PROPERTY_SO_TIMEOUT, JCLOUD_CONNECTION_TIMEOUT); properties.setProperty(Constants.PROPERTY_CONNECTION_TIMEOUT, JCLOUD_CONNECTION_TIMEOUT); properties.setProperty(LocationConstants.PROPERTY_ZONES, keysSetToStr(zones)); ctxBuilder.overrides(properties); computeService = ctxBuilder.buildView(ComputeServiceContext.class).getComputeService();
@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"); }
public void testOverridePollPeriod() { Properties overrides = new Properties(); overrides.setProperty(ComputeServiceProperties.POLL_INITIAL_PERIOD, "501"); overrides.setProperty(ComputeServiceProperties.POLL_MAX_PERIOD, "5001"); PollPeriod props = ContextBuilder.newBuilder("stub").overrides(overrides).buildInjector() .getInstance(PollPeriod.class); assertEquals(props.pollInitialPeriod, 501); assertEquals(props.pollMaxPeriod, 5001); } }
static DynECTApi mockDynectApi(String uri) { Properties overrides = new Properties(); overrides.setProperty(PROPERTY_MAX_RETRIES, "1"); return ContextBuilder.newBuilder("dynect") .credentials("jclouds:joe", "letmein") .endpoint(uri) .overrides(overrides) .modules(modules) .buildApi(DynECTApi.class); }
@Test public void testProviderMetadataWithEmptyIsoCodePropertyHasEmptySet() { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_ISO3166_CODES, ""); ContextBuilder withVariablesToReplace = testContextBuilder().overrides(overrides).credentials("foo", "bar"); Set<String> codes = withVariablesToReplace.buildInjector().getInstance(ProviderMetadata.class).getIso3166Codes(); assertEquals(codes, ImmutableSet.<String> of()); }
protected RestContext<CloudStackClient, CloudStackAsyncClient> newCloudStackContext(Provider provider) { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); return ContextBuilder.newBuilder(new CloudStackApiMetadata()) .endpoint(provider.getEndpoint().get()) .modules(ImmutableSet.of(new SLF4JLoggingModule())) .credentials(provider.getAccessKey(), provider.getSecretKey()) .overrides(overrides) .build(CloudStackApiMetadata.CONTEXT_TOKEN); }
secretKey = builder.secretKey; Properties properties = new Properties(); try { blobStoreLocation = Files.createTempDirectory("S3ProxyRule") .toFile(); properties.setProperty("jclouds.filesystem.basedir", blobStoreLocation.getCanonicalPath()); } catch (IOException e) { blobStoreContext = ContextBuilder.newBuilder( builder.blobStoreProvider) .credentials(accessKey, secretKey) .overrides(properties).build(BlobStoreContext.class);
/** * Creates a test api for the given class, URI and Module. */ protected <T extends Closeable> T api(Class<T> apiClass, String url, Module... connectionModules) { Properties properties = new Properties(); properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true"); addOverrideProperties(properties); return ContextBuilder.newBuilder(AnonymousProviderMetadata.forApiOnEndpoint(apiClass, url)) .modules(ImmutableSet.copyOf(connectionModules)).overrides(properties).buildApi(apiClass); }
public static CloudstackNew40FeaturesClient newInstance(String endpoint, String apiKey, String secretKey, Optional<AccountAndDomain> accAndDomain) { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); ContextBuilder builder = ContextBuilder .newBuilder("cloudstack") .endpoint(endpoint) .apiVersion("3.0.5") .credentials(apiKey, secretKey) .modules(ImmutableSet.<Module>builder() .add(new SLF4JLoggingModule()) .build()) .overrides(overrides); CloudStackContext context = builder.buildView(CloudStackContext.class); return new CloudstackNew40FeaturesClient(endpoint, apiKey, secretKey, accAndDomain, context); }
static SequentialMultipartUploadStrategy mockSequentialMultipartUploadStrategy(String uri, int partSize) { Properties overrides = new Properties(); // prevent expect-100 bug http://code.google.com/p/mockwebserver/issues/detail?id=6 overrides.setProperty(PROPERTY_SO_TIMEOUT, "0"); overrides.setProperty(PROPERTY_MAX_RETRIES, "1"); overrides.setProperty("jclouds.mpu.parts.size", String.valueOf(partSize)); return ContextBuilder.newBuilder("swift-keystone") .credentials("user", "password").endpoint(uri) .overrides(overrides) .modules(modules) .buildInjector().getInstance(SequentialMultipartUploadStrategy.class); }
private static <A extends Closeable> A api(Class<A> apitype, final String provider, final String credId, final Properties overrides) { // correct the classloader so that extensions can be found Thread.currentThread().setContextClassLoader(Apis.class.getClassLoader()); return CredentialsHelper.setCredentials(ContextBuilder.newBuilder(provider), credId) .overrides(overrides).modules(MODULES).buildApi(typeToken(apitype)); }
@BeforeMethod public void start() throws IOException { server = new MockWebServer(); server.play(); ctx = ContextBuilder.newBuilder(DimensionDataCloudControlProviderMetadata.builder().build()).credentials("", "") .endpoint(url("")).modules(modules).overrides(new Properties()).build(); json = ctx.utils().injector().getInstance(Json.class); api = ctx.getApi(); applyAdditionalServerConfig(); assertedRequestCount = 0; datacenters = getZones(); }
@BeforeClass public void setUp() { ctx = ContextBuilder.newBuilder(DimensionDataCloudControlProviderMetadata.builder().build()).credentials("", "") .modules(modules).overrides(new Properties()).build(); datacenters = getZones(); }
public static ContextBuilder newBuilder(int testPort, Properties properties, Module... connectionModules) { properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true"); return ContextBuilder .newBuilder( AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost:" + testPort)) .modules(ImmutableSet.<Module> copyOf(connectionModules)).overrides(properties); }
@Test public void testVariablesReplaceOnEndpoint() { ContextBuilder withVariablesToReplace = testContextBuilder().endpoint("http://${jclouds.identity}.service.com") .credentials("foo", "bar"); URI endpoint = withVariablesToReplace.buildInjector().getInstance( Key.get(new TypeLiteral<Supplier<URI>>(){}, Provider.class)).get(); assertEquals(endpoint, URI.create("http://foo.service.com")); }
@SuppressWarnings("serial") public A api(String uri, String provider, Properties overrides) { if (!overrides.containsKey(PROPERTY_MAX_RETRIES)) { overrides.setProperty(PROPERTY_MAX_RETRIES, "1"); } return ContextBuilder.newBuilder(provider) .credentials("jclouds:joe", "letmein") .endpoint(uri) .overrides(overrides) .modules(modules) .buildApi(new TypeToken<A>(getClass()) {}); }
public void testDefaultInitStatusProperties() { InitStatusProperties props = ContextBuilder.newBuilder("stub").buildInjector() .getInstance(InitStatusProperties.class); assertEquals(props.initStatusInitialPeriod, 500); assertEquals(props.initStatusMaxPeriod, 5000); }