/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java

https://github.com/regularfry/jclouds · Java · 69 lines · 38 code · 7 blank · 24 comment · 0 complexity · c545fccf087903d77e70c91ce13841f7 MD5 · raw file

  1. /**
  2. * Licensed to jclouds, Inc. (jclouds) under one or more
  3. * contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. jclouds licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package org.jclouds.gae.config;
  20. import java.util.Properties;
  21. import java.util.concurrent.ExecutorService;
  22. import javax.ws.rs.core.UriBuilder;
  23. import org.jclouds.Constants;
  24. import org.jclouds.PropertiesBuilder;
  25. import org.jclouds.gae.GaeHttpCommandExecutorService;
  26. import org.jclouds.http.HttpCommandExecutorService;
  27. import org.jclouds.logging.Logger;
  28. import org.jclouds.logging.Logger.LoggerFactory;
  29. import org.testng.annotations.Test;
  30. import com.google.inject.Guice;
  31. import com.google.inject.Injector;
  32. import com.google.inject.Key;
  33. import com.google.inject.name.Names;
  34. import com.sun.jersey.api.uri.UriBuilderImpl;
  35. /**
  36. * Tests the ability to configure a {@link GoogleAppEngineConfigurationModule}
  37. *
  38. * @author Adrian Cole
  39. */
  40. @Test
  41. public class GoogleAppEngineConfigurationModuleTest {
  42. public void testConfigureBindsClient() {
  43. final Properties properties = new PropertiesBuilder().build();
  44. Injector i = Guice.createInjector(new GoogleAppEngineConfigurationModule() {
  45. @Override
  46. protected void configure() {
  47. Names.bindProperties(binder(), properties);
  48. bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
  49. public Logger getLogger(String category) {
  50. return Logger.NULL;
  51. }
  52. });
  53. bind(UriBuilder.class).to(UriBuilderImpl.class);
  54. super.configure();
  55. }
  56. });
  57. HttpCommandExecutorService client = i.getInstance(HttpCommandExecutorService.class);
  58. i.getInstance(Key.get(ExecutorService.class, Names.named(Constants.PROPERTY_USER_THREADS)));
  59. // TODO check single threaded;
  60. assert client instanceof GaeHttpCommandExecutorService;
  61. }
  62. }