Package org.jclouds.apis

Examples of org.jclouds.apis.ApiMetadata


public class ServiceFactoryValidationTest {

    @Test
    public void testProviderValidationWithDefaults() throws InvalidConfigurationException {
        ApiMetadata apiMetadata = createMock(ApiMetadata.class);
        ProviderMetadata providerMetadata = createMock(ProviderMetadata.class);
        expect(apiMetadata.getDefaultIdentity()).andReturn(Optional.of("defaultIdentity")).anyTimes();
        expect(apiMetadata.getDefaultCredential()).andReturn(Optional.of("defaultCredential")).anyTimes();
        expect(apiMetadata.getDefaultEndpoint()).andReturn(Optional.of("defaultEndpoint")).anyTimes();
        expect(providerMetadata.getApiMetadata()).andReturn(apiMetadata).anyTimes();
        replay(providerMetadata);
        replay(apiMetadata);
        ComputeServiceFactory.validate(providerMetadata, new Properties());
    }
View Full Code Here


        ComputeServiceFactory.validate(providerMetadata, new Properties());
    }

    @Test
    public void testApiValidationWithDefaults() throws InvalidConfigurationException {
        ApiMetadata apiMetadata = createMock(ApiMetadata.class);
        expect(apiMetadata.getDefaultIdentity()).andReturn(Optional.of("defaultIdentity")).anyTimes();
        expect(apiMetadata.getDefaultCredential()).andReturn(Optional.of("defaultCredential")).anyTimes();
        expect(apiMetadata.getDefaultEndpoint()).andReturn(Optional.of("defaultEndpoint")).anyTimes();
        replay(apiMetadata);
        ComputeServiceFactory.validate(apiMetadata, new Properties());
    }
View Full Code Here

    }


    @Test(expected = InvalidConfigurationException.class)
    public void testProviderValidationWithNoIdentity() throws InvalidConfigurationException {
        ApiMetadata apiMetadata = createMock(ApiMetadata.class);
        ProviderMetadata providerMetadata = createMock(ProviderMetadata.class);
        expect(apiMetadata.getDefaultIdentity()).andReturn(Optional.<String>absent()).anyTimes();
        expect(apiMetadata.getDefaultCredential()).andReturn(Optional.of("defaultCredential")).anyTimes();
        expect(apiMetadata.getDefaultEndpoint()).andReturn(Optional.of("defaultEndpoint")).anyTimes();
        expect(providerMetadata.getApiMetadata()).andReturn(apiMetadata).anyTimes();
        replay(providerMetadata);
        replay(apiMetadata);
        ComputeServiceFactory.validate(providerMetadata, new Properties());
    }
View Full Code Here

        ComputeServiceFactory.validate(providerMetadata, new Properties());
    }

    @Test(expected = InvalidConfigurationException.class)
    public void testApiValidationWithNoIdentity() throws InvalidConfigurationException {
        ApiMetadata apiMetadata = createMock(ApiMetadata.class);
        expect(apiMetadata.getDefaultIdentity()).andReturn(Optional.<String>absent()).anyTimes();
        expect(apiMetadata.getDefaultCredential()).andReturn(Optional.of("defaultCredential")).anyTimes();
        expect(apiMetadata.getDefaultEndpoint()).andReturn(Optional.of("defaultEndpoint")).anyTimes();
        replay(apiMetadata);
        ComputeServiceFactory.validate(apiMetadata, new Properties());
    }
View Full Code Here

        ComputeServiceFactory.validate(apiMetadata, new Properties());
    }

    @Test(expected = InvalidConfigurationException.class)
    public void testProviderValidationWithNoCredential() throws InvalidConfigurationException {
        ApiMetadata apiMetadata = createMock(ApiMetadata.class);
        ProviderMetadata providerMetadata = createMock(ProviderMetadata.class);
        expect(apiMetadata.getDefaultIdentity()).andReturn(Optional.of("defaultIdentity")).anyTimes();
        expect(apiMetadata.getDefaultCredential()).andReturn(Optional.<String>absent()).anyTimes();
        expect(apiMetadata.getDefaultEndpoint()).andReturn(Optional.of("defaultEndpoint")).anyTimes();
        expect(providerMetadata.getApiMetadata()).andReturn(apiMetadata).anyTimes();
        replay(providerMetadata);
        replay(apiMetadata);
        ComputeServiceFactory.validate(providerMetadata, new Properties());
    }
View Full Code Here

        ComputeServiceFactory.validate(providerMetadata, new Properties());
    }

    @Test(expected = InvalidConfigurationException.class)
    public void testApiValidationWithNoCredential() throws InvalidConfigurationException {
        ApiMetadata apiMetadata = createMock(ApiMetadata.class);
        expect(apiMetadata.getDefaultIdentity()).andReturn(Optional.of("defaultIdentity")).anyTimes();
        expect(apiMetadata.getDefaultCredential()).andReturn(Optional.<String>absent()).anyTimes();
        expect(apiMetadata.getDefaultEndpoint()).andReturn(Optional.of("defaultEndpoint")).anyTimes();
        replay(apiMetadata);
        ComputeServiceFactory.validate(apiMetadata, new Properties());
    }
View Full Code Here

        ComputeServiceFactory.validate(apiMetadata, new Properties());
    }

    @Test(expected = InvalidConfigurationException.class)
    public void testApiValidationWithNoEndpoint() throws InvalidConfigurationException {
        ApiMetadata apiMetadata = createMock(ApiMetadata.class);
        expect(apiMetadata.getDefaultIdentity()).andReturn(Optional.of("defaultIdentity")).anyTimes();
        expect(apiMetadata.getDefaultCredential()).andReturn(Optional.of("defaultCredential")).anyTimes();
        expect(apiMetadata.getDefaultEndpoint()).andReturn(Optional.<String>absent()).anyTimes();
        replay(apiMetadata);
        ComputeServiceFactory.validate(apiMetadata, new Properties());
    }
View Full Code Here

                }

                String api = (String) properties.get(ChefConstants.API);

                ProviderMetadata providerMetadata = null;
                ApiMetadata apiMetadata = null;
                if (!Strings.isNullOrEmpty(api) && installedApis.containsKey(api)) {
                    apiMetadata = installedApis.get(api);
                    validate(apiMetadata, properties);
                } else {
View Full Code Here

                String provider = (String) properties.get(Constants.PROVIDER);
                String api = (String) properties.get(Constants.API);

                ProviderMetadata providerMetadata = null;
                ApiMetadata apiMetadata = null;

                if (!Strings.isNullOrEmpty(provider) && installedProviders.containsKey(provider)) {
                    providerMetadata = installedProviders.get(provider);
                    validate(providerMetadata, properties);
                } else if (!Strings.isNullOrEmpty(api) && installedApis.containsKey(api)) {
                    apiMetadata = installedApis.get(api);
                    validate(apiMetadata, properties);
                } else {
                    if (!Strings.isNullOrEmpty(provider)) {
                        providerPids.put(provider, pid);
                    }
                    if (!Strings.isNullOrEmpty(api)) {
                        apiPids.put(api, pid);
                    }
                    pendingPids.put(pid, properties);
                    LOGGER.warn("Provider {} or Api {} is not currently installed. Service will resume once the the provider is installed.", provider, api);
                    return;
                }

                //We are removing credentials as we don't want them to be visible in the service registration.
                String id = (String) properties.get(Constants.NAME);
                String identity = (String) properties.remove(Constants.IDENTITY);
                String credential = (String) properties.remove(Constants.CREDENTIAL);
                String endpoint = (String) properties.get(Constants.ENDPOINT);
                String storeType = (String) properties.get(CREDENTIAL_STORE);
                String eventSupport = (String) properties.get(NODE_EVENT_SUPPORT);
                Boolean enableEventSupport = false;

                if (Strings.isNullOrEmpty(credential) && providerMetadata != null && !providerMetadata.getApiMetadata().getDefaultCredential().isPresent()) {
                    LOGGER.warn("No credential specified and provider {}.", providerMetadata.getId());
                    return;
                }
                if (Strings.isNullOrEmpty(credential) && apiMetadata != null && !apiMetadata.getDefaultCredential().isPresent()) {
                    LOGGER.warn("No credential specified and api {}.", apiMetadata.getId());
                    return;
                }

                if (storeType == null || storeType.isEmpty()) {
                    storeType = DEFAULT_CREDENTIAL_STORE_TYPE;
View Full Code Here

                }
                String provider = (String) properties.get(Constants.PROVIDER);
                String api = (String) properties.get(Constants.API);

                ProviderMetadata providerMetadata = null;
                ApiMetadata apiMetadata = null;


                if (!Strings.isNullOrEmpty(provider) && installedProviders.containsKey(provider)) {
                    providerMetadata = installedProviders.get(provider);
                    validate(providerMetadata, properties);
View Full Code Here

TOP

Related Classes of org.jclouds.apis.ApiMetadata

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.