BlobStoreContext context = builder.build(BlobStoreContext.class); BlobStore blobStore = context.getBlobStore(); if (context instanceof RegionScopedBlobStoreContext &&
builder.blobStoreProvider) .credentials(accessKey, secretKey) .overrides(properties).build(BlobStoreContext.class);
/** * Builds the base context for this api. Note that this may be of type {@link Closer}, if nothing * else was configured via {@link ApiMetadata#getContext()}. Typically, the type returned is * {@link RestContext} * * @see ApiMetadata#getContext() * @see #build(TypeToken) */ @SuppressWarnings("unchecked") public <C extends Context> C build() { return (C) build(apiMetadata.getContext()); }
/** * Builds the base context for this api. Note that this may be of type {@link Closer}, if nothing * else was configured via {@link ApiMetadata#getContext()}. Typically, the type returned is * {@link RestContext} * * @see ApiMetadata#getContext() * @see #build(TypeToken) */ @SuppressWarnings("unchecked") public <C extends Context> C build() { return (C) build(apiMetadata.getContext()); }
/** * Builds the base context for this api. Note that this may be of type {@link Closer}, if nothing * else was configured via {@link ApiMetadata#getContext()}. Typically, the type returned is * {@link RestContext} * * @see ApiMetadata#getContext() * @see #build(TypeToken) */ @SuppressWarnings("unchecked") public <C extends Context> C build() { return (C) build(apiMetadata.getContext()); }
/** * Builds the base context for this api. Note that this may be of type {@link Closer}, if nothing * else was configured via {@link ApiMetadata#getContext()}. Typically, the type returned is * {@link ApiContext} * * @see ApiMetadata#getContext() * @see #build(TypeToken) */ @SuppressWarnings("unchecked") public <C extends Context> C build() { return (C) build(apiMetadata.getContext()); }
/** * Builds the base context for this api. Note that this may be of type {@link Closer}, if nothing * else was configured via {@link ApiMetadata#getContext()}. Typically, the type returned is * {@link ApiContext} * * @see ApiMetadata#getContext() * @see #build(TypeToken) */ @SuppressWarnings("unchecked") public <C extends Context> C build() { return (C) build(apiMetadata.getContext()); }
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); }
@BeforeClass void addDefaultObjectsSoThatTestsWillPass() { context = ContextBuilder.newBuilder("transient").build(BlobStoreContext.class); map = (InputStreamMapImpl) context.createInputStreamMap("test"); }
@Test public void testCanBuildById() { ComputeServiceContext context = ContextBuilder.newBuilder("servermanager").build(ComputeServiceContext.class); context.close(); }
@Test public void testNodesParseWithFileUrl() throws Exception { assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint( "file://" + getClass().getResource("/test1.yaml").getPath()).build(ComputeServiceContext.class)); }
@Test public void testUnwrapIsCorrectType() { ComputeServiceContext context = ContextBuilder.newBuilder("servermanager").build(ComputeServiceContext.class); assertEquals(context.unwrap().getClass(), ContextImpl.class); context.close(); } }
@Test public void testCanBuildWithApiMetadata() { ComputeServiceContext context = ContextBuilder.newBuilder( new ServerManagerApiMetadata()).build(ComputeServiceContext.class); context.close(); }
@Override public Context createContext(String id, String name, String identity, String credential, String endpoint, String overrides) throws IOException { return ToContext.INSTANCE.apply( ContextBuilder.newBuilder(id).name(name).credentials(identity, credential).endpoint(endpoint) .modules(ImmutableSet.of(new ManagementLifecycle(BaseManagementContext.INSTANCE))) .overrides(stringToProperties(overrides)) .build() ); }
@Test(expectedExceptions=UnsupportedOperationException.class) public void testSocketOpenThrowsUnsupported() { Context context = ContextBuilder.newBuilder( AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, "dummyurl")) .modules(ImmutableSet.of(new GoogleAppEngineConfigurationModule())) .build(); SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class); socketOpen.apply(HostAndPort.fromParts("localhost", 22)); } }
@Test public void testContextName() { ContextBuilder withNoName = testContextBuilder().endpoint("http://${jclouds.identity}.service.com").name("mytest") .credentials("foo", "bar"); Context context = withNoName.build(); assertEquals(context.getName(), "mytest"); }
@BeforeTest void setupBlobStore() { blobstore = ContextBuilder.newBuilder("transient").build(BlobStoreContext.class).getBlobStore(); }
@Test public void testNodesParseWithClasspathUrl() throws Exception { assertNodesParse("classpath:///test1.yaml", ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint( "classpath:///test1.yaml").build(ComputeServiceContext.class)); }
@Test public void testAndExperiment() { ComputeServiceContext context = null; try { context = ContextBuilder .newBuilder(new GleSYSProviderMetadata()) .overrides(setupProperties()) .modules(setupModules()).build(ComputeServiceContext.class); assertEquals(context.getComputeService().listAssignableLocations().size(), 4); } finally { Closeables.closeQuietly(context); } }
@Test public void testNodesParseNodeMap() throws Exception { assertNodesParse("foo", ContextBuilder.newBuilder( new BYONApiMetadata().toBuilder().defaultModule(BYONComputeServiceContextModule.class).build()) .endpoint("foo").modules( ImmutableSet.<Module> of(new CacheNodeStoreModule(ImmutableMap.<String, Node> of( NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))).build( ComputeServiceContext.class)); }