diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/paas/config/HttpClientModule.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/paas/config/HttpClientModule.java new file mode 100644 index 0000000000..5aa077b6cd --- /dev/null +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/paas/config/HttpClientModule.java @@ -0,0 +1,65 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.demo.paas.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.inject.name.Names.bindProperties; +import static org.jclouds.Constants.*; + +import java.util.Properties; + +import javax.servlet.ServletContext; +import javax.ws.rs.core.UriBuilder; + +import org.jclouds.demo.tweetstore.config.util.PropertiesLoader; + +import com.google.inject.AbstractModule; +import com.sun.jersey.api.uri.UriBuilderImpl; + +/** + * @author Andrew Phillips + */ +public class HttpClientModule extends AbstractModule { + private final ServletContext context; + + HttpClientModule(ServletContext context) { + this.context = context; + } + + @Override + protected void configure() { + // URL connection defaults + Properties toBind = defaultProperties(); + toBind.putAll(checkNotNull(new PropertiesLoader(context).get(), "properties")); + toBind.putAll(System.getProperties()); + bindProperties(binder(), toBind); + bind(UriBuilder.class).to(UriBuilderImpl.class); + } + + private static Properties defaultProperties() { + Properties props = new Properties(); + props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + ""); + props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + ""); + props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + ""); + props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); + props.setProperty(PROPERTY_USER_THREADS, 0 + ""); + props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); + return props; + } +} diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java index bb02bbbda8..ee74adaf6e 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java @@ -19,30 +19,22 @@ package org.jclouds.demo.paas.config; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.inject.name.Names.bindProperties; import static java.util.concurrent.TimeUnit.SECONDS; -import java.util.Properties; - import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; -import javax.ws.rs.core.UriBuilder; -import org.jclouds.PropertiesBuilder; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.demo.paas.PlatformServices; import org.jclouds.demo.paas.service.scheduler.Scheduler; import org.jclouds.demo.paas.service.taskqueue.TaskQueue; -import org.jclouds.demo.tweetstore.config.util.PropertiesLoader; import org.jclouds.http.HttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; -import com.google.inject.AbstractModule; import com.google.inject.Guice; -import com.sun.jersey.api.uri.UriBuilderImpl; /** * @author Andrew Phillips @@ -69,17 +61,8 @@ public class PlatformServicesInitializer implements ServletContextListener { final ServletContext context) { return Guice.createInjector(new ExecutorServiceModule(), new JavaUrlHttpCommandExecutorServiceModule(), - new AbstractModule() { - @Override - protected void configure() { - // URL connection defaults - Properties toBind = new PropertiesBuilder().build(); - toBind.putAll(checkNotNull(new PropertiesLoader(context).get(), "properties")); - toBind.putAll(System.getProperties()); - bindProperties(binder(), toBind); - bind(UriBuilder.class).to(UriBuilderImpl.class); - } - }).getInstance(HttpCommandExecutorService.class); + new HttpClientModule(context)) + .getInstance(HttpCommandExecutorService.class); } protected static String getBaseUrl(ServletContext context) { diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index a294878748..24d0c94c06 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -38,8 +38,8 @@ import java.util.Set; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.paas.PlatformServices; import org.jclouds.demo.paas.service.taskqueue.TaskQueue; import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; @@ -70,7 +70,7 @@ import com.google.inject.servlet.ServletModule; * @author Adrian Cole */ public class GuiceServletConfig extends GuiceServletContextListener { - private Map> providerTypeToBlobStoreMap; + private Map providerTypeToBlobStoreMap; private Twitter twitterClient; private String container; private TaskQueue queue; @@ -100,8 +100,8 @@ public class GuiceServletConfig extends GuiceServletContextListener { // instantiate and store references to all blobstores by provider name providerTypeToBlobStoreMap = Maps.newHashMap(); for (String hint : getBlobstoreContexts(props)) { - providerTypeToBlobStoreMap.put(hint, BlobStoreContextBuilder - .newBuilder(hint).modules(modules).overrides(props).build()); + providerTypeToBlobStoreMap.put(hint, ContextBuilder.newBuilder(hint) + .modules(modules).overrides(props).build(BlobStoreContext.class)); } // get a queue for submitting store tweet requests and the application's base URL @@ -127,7 +127,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { return Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { - bind(new TypeLiteral>>() {}) + bind(new TypeLiteral>() {}) .toInstance(providerTypeToBlobStoreMap); bind(Twitter.class).toInstance(twitterClient); bind(TaskQueue.class).toInstance(queue); @@ -144,7 +144,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { @Override public void contextDestroyed(ServletContextEvent servletContextEvent) { - for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { + for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { context.close(); } queue.destroy(); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java index 1805ee8f5c..007fbafdef 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -54,14 +54,14 @@ public class AddTweetsController extends HttpServlet implements /** The serialVersionUID */ private static final long serialVersionUID = 3888348023150822683L; - private final Map> contexts; + private final Map contexts; private final ServiceToStoredTweetStatuses blobStoreContextToContainerResult; @Resource protected Logger logger = Logger.NULL; @Inject - AddTweetsController(Map> contexts, + AddTweetsController(Map contexts, ServiceToStoredTweetStatuses blobStoreContextToContainerResult) { this.contexts = contexts; this.blobStoreContextToContainerResult = blobStoreContextToContainerResult; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java index 71b715863b..592eaaa8bd 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java @@ -65,7 +65,7 @@ public class EnqueueStoresController extends HttpServlet { protected Logger logger = Logger.NULL; @Inject - public EnqueueStoresController(Map> contexts, TaskQueue taskQueue, + public EnqueueStoresController(Map contexts, TaskQueue taskQueue, @Named(PaasConstants.PROPERTY_PLATFORM_BASE_URL) String baseUrl) { contextNames = contexts.keySet(); this.taskQueue = taskQueue; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index edd750e90d..948c9ff4ca 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -75,7 +75,7 @@ public class StoreTweetsController extends HttpServlet { /** The serialVersionUID */ private static final long serialVersionUID = 7215420527854203714L; - private final Map> contexts; + private final Map contexts; private final Twitter client; private final String container; @@ -84,7 +84,7 @@ public class StoreTweetsController extends HttpServlet { @Inject @VisibleForTesting - public StoreTweetsController(Map> contexts, + public StoreTweetsController(Map contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container, Twitter client) { this.container = container; this.contexts = contexts; @@ -93,7 +93,7 @@ public class StoreTweetsController extends HttpServlet { @VisibleForTesting public void addMyTweets(String contextName, Iterable responseList) { - BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + contexts.keySet()); BlobMap map = context.createBlobMap(container); for (Status status : responseList) { diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java index 36437544d4..b29ec14549 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java @@ -18,6 +18,7 @@ */ package org.jclouds.demo.tweetstore.functions; +import java.net.URI; import java.util.Collections; import java.util.Map; import java.util.Set; @@ -27,6 +28,7 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; @@ -39,11 +41,11 @@ import com.google.common.collect.Iterables; @Singleton public class ServiceToStoredTweetStatuses implements Function> { - private final Map> contexts; + private final Map contexts; private final String container; @Inject - public ServiceToStoredTweetStatuses(Map> contexts, + public ServiceToStoredTweetStatuses(Map contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container) { this.contexts = contexts; this.container = container; @@ -53,8 +55,8 @@ public class ServiceToStoredTweetStatuses implements Function apply(String service) { - BlobStoreContext context = contexts.get(service); - String host = context.getProviderSpecificContext().getEndpoint().getHost(); + BlobStoreContext context = contexts.get(service); + String host = URI.create(context.unwrap(Context.class).getProviderMetadata().getEndpoint()).getHost(); try { BlobMap blobMap = context.createBlobMap(container); Set blobs = blobMap.keySet(); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index d6989d8bbe..1c93403650 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -25,8 +25,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; @@ -46,12 +46,12 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class AddTweetsControllerTest { - Map> createServices(String container) throws InterruptedException, + Map createServices(String container) throws InterruptedException, ExecutionException { - Map> services = Maps.newHashMap(); + Map services = Maps.newHashMap(); TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); + BlobStoreContext context = ContextBuilder.newBuilder(transientApiMetadata).build(BlobStoreContext.class); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -64,7 +64,7 @@ public class AddTweetsControllerTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map> contexts = createServices(container); + Map contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); AddTweetsController controller = new AddTweetsController(contexts, function); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java index c324579f82..3c5e5b1d80 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java @@ -23,8 +23,8 @@ import static org.easymock.EasyMock.*; import java.net.URI; import java.util.Map; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.demo.paas.RunnableHttpRequest; import org.jclouds.demo.paas.RunnableHttpRequest.Factory; @@ -43,16 +43,16 @@ import com.google.common.collect.ImmutableMultimap; @Test(groups = "unit") public class EnqueueStoresControllerTest { - Map> createBlobStores() { + Map createBlobStores() { TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); - Map> contexts = ImmutableMap.>of( - "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), - "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); + Map contexts = ImmutableMap.of( + "test1", ContextBuilder.newBuilder(transientApiMetadata).build(BlobStoreContext.class), + "test2", ContextBuilder.newBuilder(transientApiMetadata).build(BlobStoreContext.class)); return contexts; } public void testEnqueueStores() { - Map> stores = createBlobStores(); + Map stores = createBlobStores(); TaskQueue taskQueue = createMock(TaskQueue.class); Factory httpRequestFactory = createMock(Factory.class); EnqueueStoresController function = new EnqueueStoresController(stores, diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java index 767245cdf7..9cc56351f2 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -30,9 +30,9 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -57,19 +57,19 @@ public class StoreTweetsControllerTest { return createMock(Twitter.class); } - Map> createBlobStores() throws InterruptedException, ExecutionException { + Map createBlobStores() throws InterruptedException, ExecutionException { TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); - Map> contexts = ImmutableMap.>of( - "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), - "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); - for (BlobStoreContext blobstore : contexts.values()) { + Map contexts = ImmutableMap.of( + "test1", ContextBuilder.newBuilder(transientApiMetadata).build(BlobStoreContext.class), + "test2", ContextBuilder.newBuilder(transientApiMetadata).build(BlobStoreContext.class)); + for (BlobStoreContext blobstore : contexts.values()) { blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); } return contexts; } public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { - Map> stores = createBlobStores(); + Map stores = createBlobStores(); StoreTweetsController function = new StoreTweetsController(stores, "favo", createTwitter()); User frank = createMock(User.class); @@ -101,7 +101,7 @@ public class StoreTweetsControllerTest { verify(jimmy); verify(jimmyStatus); - for (Entry> entry : stores.entrySet()) { + for (Entry entry : stores.entrySet()) { BlobMap map = entry.getValue().createBlobMap("favo"); Blob frankBlob = map.get("1"); assertEquals(frankBlob.getMetadata().getName(), "1"); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index a85df55fc8..aab06ec0b6 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.concurrent.ExecutionException; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; @@ -41,8 +41,8 @@ import org.testng.annotations.Test; public class KeyToStoredTweetStatusTest { BlobMap createMap() throws InterruptedException, ExecutionException { - BlobStoreContext context = - BlobStoreContextBuilder.newBuilder(TransientApiMetadata.builder().build()).build(); + BlobStoreContext context = + ContextBuilder.newBuilder(TransientApiMetadata.builder().build()).build(BlobStoreContext.class); context.getBlobStore().createContainerInLocation(null, "test1"); return context.createBlobMap("test1"); } diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index 54deb948db..5fec52711e 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -24,8 +24,8 @@ import java.io.IOException; import java.util.Map; import java.util.concurrent.ExecutionException; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; @@ -43,12 +43,12 @@ import com.google.common.collect.Iterables; @Test(groups = "unit") public class ServiceToStoredTweetStatusesTest { - Map> createServices(String container) throws InterruptedException, + Map createServices(String container) throws InterruptedException, ExecutionException { - Map> services = Maps.newHashMap(); + Map services = Maps.newHashMap(); TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); + BlobStoreContext context = ContextBuilder.newBuilder(transientApiMetadata).build(BlobStoreContext.class); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -61,7 +61,7 @@ public class ServiceToStoredTweetStatusesTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map> contexts = createServices(container); + Map contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 303e1ec9d9..207ec2b6e6 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -38,8 +38,9 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; +import org.jclouds.Context; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.AuthorizationException; @@ -73,7 +74,7 @@ public class TweetStoreLiveTest { RunAtCloudServer server; private URL url; - private Map> contexts; + private Map contexts; private String container; private static final Iterable blobstores = Splitter.on(',').split(getRequiredSystemProperty(PROPERTY_TWEETSTORE_BLOBSTORES)); @@ -97,8 +98,8 @@ public class TweetStoreLiveTest { this.contexts = Maps.newConcurrentMap(); for (String provider : blobstores) { - contexts.put(provider, BlobStoreContextBuilder.newBuilder(provider) - .modules(wiring).overrides(props).build()); + contexts.put(provider, ContextBuilder.newBuilder(provider) + .modules(wiring).overrides(props).build(BlobStoreContext.class)); } Configuration conf = new ConfigurationBuilder() @@ -113,11 +114,11 @@ public class TweetStoreLiveTest { ResponseList statuses = client.getMentions(); boolean deleted = false; - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { try { if (context.getBlobStore().containerExists(container)) { - System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() - .getEndpoint()); + System.err.printf("deleting container %s at %s%n", container, + context.unwrap(Context.class).getProviderMetadata().getEndpoint()); context.getBlobStore().deleteContainer(container); deleted = true; } @@ -129,9 +130,9 @@ public class TweetStoreLiveTest { System.err.println("sleeping 60 seconds to allow containers to clear"); Thread.sleep(60000); } - for (BlobStoreContext context : contexts.values()) { - System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() - .getEndpoint()); + for (BlobStoreContext context : contexts.values()) { + System.err.printf("creating container %s at %s%n", container, + context.unwrap(Context.class).getProviderMetadata().getEndpoint()); context.getBlobStore().createContainerInLocation(null, container); } @@ -140,7 +141,7 @@ public class TweetStoreLiveTest { Thread.sleep(5000); } - for (Entry> entry : contexts.entrySet()) { + for (Entry entry : contexts.entrySet()) { System.err.printf("filling container %s at %s%n", container, entry.getKey()); controller.addMyTweets(entry.getKey(), statuses); } @@ -210,8 +211,8 @@ public class TweetStoreLiveTest { System.err.println("sleeping 20 seconds to allow for eventual consistency delay"); Thread.sleep(20000); - for (BlobStoreContext context : contexts.values()) { - assert context.createInputStreamMap(container).size() > 0 : context.getProviderSpecificContext().getEndpoint(); + for (BlobStoreContext context : contexts.values()) { + assert context.createInputStreamMap(container).size() > 0 : context.unwrap(Context.class).getProviderMetadata().getEndpoint(); } }