Package org.jclouds.providers

Examples of org.jclouds.providers.ProviderMetadata


      assertEquals(newMd.getDefaultProperties(), md.getDefaultProperties());
   }
  
   @Test
   public void testProviderMetadataWithUpdatedIso3166CodesUpdatesAndRetainsAllDefaultPropertiesExceptIso3166Codes() {
      ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(
               IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost");

      Properties props = new Properties();
      props.putAll(md.getDefaultProperties());
      props.setProperty(PROPERTY_ISO3166_CODES, "US-CA");

      ProviderMetadata newMd = new UpdateProviderMetadataFromProperties(md).apply(props);

      assertEquals(newMd.getIso3166Codes(), ImmutableSet.of("US-CA"));
      assertEquals(newMd.getDefaultProperties(), md.getDefaultProperties());
   }
View Full Code Here


      this.views = expectedApi.getViews();
   }

   @Test
   public void testWithId() {
      ProviderMetadata providerMetadata = Providers.withId(toTest.getId());

      assertEquals(toTest, providerMetadata);
      assert providerMetadata.getLinkedServices().contains(toTest.getId());
   }
View Full Code Here

   protected ApiMetadata createApiMetadata() {
      return null;
   }

   protected Injector createInjector() {
      ProviderMetadata pm = createProviderMetadata();

      ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(ApiMetadata.class
            .cast(checkNotNull(createApiMetadata(),
                  "either createApiMetadata or createProviderMetadata must be overridden")));
View Full Code Here

      return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(SessionApi.class, SessionAsyncApi.class, endpoint);
   }

   @Override
   protected ContextBuilder newBuilder() {
      ProviderMetadata pm = createProviderMetadata();
      ContextBuilder builder = ContextBuilder.newBuilder(pm);
      return builder;
   }
View Full Code Here

                              "provider ["
                                       + provider
                                       + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata");
         }
      if (builder == null) {
         ProviderMetadata pm = createProviderMetadata();
         ApiMetadata am = (pm != null) ? pm.getApiMetadata() : checkNotNull(createApiMetadata(),
                  "either createApiMetadata or createProviderMetadata must be overridden");

         builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(am);
      }
      ApiMetadata am = builder.getApiMetadata();
View Full Code Here

   }

   @Test
   public void testExpectedBindingsWhenCredentialIsNotNull() {

      ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(
               IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost");
      Supplier<Credentials> creds = Suppliers.<Credentials> ofInstance(LoginCredentials.builder().user("user")
            .password("password").build());

      ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds))
View Full Code Here

   }

   @Test
   public void testExpectedBindingsWhenCredentialIsNull() {

      ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(
               IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost");
      Supplier<Credentials> creds = Suppliers.<Credentials> ofInstance(LoginCredentials.builder().user("user").build());

      ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds))
               .getInstance(ExpectedBindings.class);
View Full Code Here

   }
  
   @Test
   public void testExpectedBindingsWhenBuildVersionAbsent() {

      ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(
               IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost");
      ApiMetadata apiMd = md.getApiMetadata().toBuilder().buildVersion(null).build();
      md = md.toBuilder().apiMetadata(apiMd).build();
      Supplier<Credentials> creds = Suppliers.<Credentials> ofInstance(LoginCredentials.builder().user("user").build());

      ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds))
               .getInstance(ExpectedBindings.class);
      assertEquals(bindings.buildVersion, null);
View Full Code Here

   }

   @Test
   public void testProviderOverridesApiMetadataProperty() {

      ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(
               IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost");
      Properties defaultProps = md.getDefaultProperties();
      defaultProps.setProperty(Constants.PROPERTY_SESSION_INTERVAL, Integer.MAX_VALUE + "");
      md = md.toBuilder().defaultProperties(defaultProps).build();

      Supplier<Credentials> creds = Suppliers.<Credentials> ofInstance(LoginCredentials.builder().user("user").build());

      int session = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds)).getInstance(
               Key.get(int.class, Names.named(Constants.PROPERTY_SESSION_INTERVAL)));
View Full Code Here

@Test(groups = "unit", testName = "UpdateProviderMetadataFromPropertiesTest")
public class UpdateProviderMetadataFromPropertiesTest {

   @Test
   public void testProviderMetadataWithUpdatedEndpointUpdatesAndRetainsAllDefaultPropertiesExceptEndpoint() {
      ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(
               IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost");

      Properties props = new Properties();
      props.putAll(md.getDefaultProperties());
      props.setProperty(Constants.PROPERTY_ENDPOINT, "http://nonlocal");

      ProviderMetadata newMd = new UpdateProviderMetadataFromProperties(md).apply(props);

      assertEquals(newMd.getEndpoint(), "http://nonlocal");
      assertEquals(newMd.getDefaultProperties(), md.getDefaultProperties());
   }
View Full Code Here

TOP

Related Classes of org.jclouds.providers.ProviderMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.