Package org.jclouds.providers

Examples of org.jclouds.providers.ProviderMetadata


   }

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

      ExpectedBindings bindings = injectorFor(md).getInstance(ExpectedBindings.class);
      assertEquals(bindings.raw, bindings.explicit);
   }
View Full Code Here


   }

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

      TypeToken<? extends Context> wildCardExtendsType = new TypeToken<ApiContext<? extends IntegrationTestClient>>() {
         private static final long serialVersionUID = 1L;
      };

      md = md.toBuilder().apiMetadata(md.getApiMetadata().toBuilder().context(wildCardExtendsType).build()).build();

      ExpectedBindingsWithWildCardExtends bindings = injectorFor(md).getInstance(
            ExpectedBindingsWithWildCardExtends.class);
      assertEquals(bindings.raw, bindings.explicit);
      assertEquals(bindings.explicit, bindings.wildcardExtends);
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

      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

      Properties expanded = expandProperties(resolved);

      Supplier<Credentials> credentialsSupplier = buildCredentialsSupplier(expanded);

      ProviderMetadata providerMetadata = new UpdateProviderMetadataFromProperties(apiMetadata, this.providerMetadata)
            .apply(expanded);

      // We use either the specified name (optional) or a hash of provider/api, endpoint, api version & identity. Hash
      // is used to be something readable.
      return buildInjector(name.or(String.valueOf(Objects.hashCode(providerMetadata.getId(),
            providerMetadata.getEndpoint(), providerMetadata.getApiMetadata().getVersion(), credentialsSupplier))),
            providerMetadata, credentialsSupplier, modules);
   }
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

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.