diff --git a/core/src/main/java/org/jclouds/providers/Providers.java b/core/src/main/java/org/jclouds/providers/Providers.java index 7688fe99fe..b646ae1fe8 100644 --- a/core/src/main/java/org/jclouds/providers/Providers.java +++ b/core/src/main/java/org/jclouds/providers/Providers.java @@ -26,15 +26,14 @@ import java.util.ServiceLoader; /** * The Providers class provides static methods for accessing providers. - * + * * @author Jeremy Whitlock */ public class Providers { /** - * Returns the providers located on the classpath via - * {@link java.util.ServiceLoader}. - * + * Returns the providers located on the classpath via {@link java.util.ServiceLoader}. + * * @return all available providers loaded from classpath via ServiceLoader */ private static Iterable fromServiceLoader() { @@ -43,7 +42,7 @@ public class Providers { /** * Returns all available providers. - * + * * @return all available providers */ public static Iterable all() { @@ -52,24 +51,23 @@ public class Providers { /** * Returns the first provider with the provided id - * + * * @param id * the id of the provider to return - * + * * @return the provider with the given id - * + * * @throws NoSuchElementException - * whenever there are no providers with the provided id + * whenever there are no providers with the provided id */ - public static ProviderMetadata withId(String id) - throws NoSuchElementException { + public static ProviderMetadata withId(String id) throws NoSuchElementException { return find(all(), ProviderPredicates.id(id)); } /** * Returns the providers that are of type * {@link org.jclouds.providers.ProviderMetadata#BLOBSTORE_TYPE}. - * + * * @return the blobstore providers */ public static Iterable allBlobStore() { @@ -79,19 +77,49 @@ public class Providers { /** * Returns the providers that are of type * {@link org.jclouds.providers.ProviderMetadata#COMPUTE_TYPE}. - * + * * @return the compute service providers */ public static Iterable allCompute() { return filter(all(), ProviderPredicates.type(ProviderMetadata.COMPUTE_TYPE)); } + /** + * Returns the providers that are of type + * {@link org.jclouds.providers.ProviderMetadata#QUEUE_TYPE}. + * + * @return the queue service providers + */ + public static Iterable allQueue() { + return filter(all(), ProviderPredicates.type(ProviderMetadata.QUEUE_TYPE)); + } + + /** + * Returns the providers that are of type + * {@link org.jclouds.providers.ProviderMetadata#TABLE_TYPE}. + * + * @return the table service providers + */ + public static Iterable allTable() { + return filter(all(), ProviderPredicates.type(ProviderMetadata.TABLE_TYPE)); + } + + /** + * Returns the providers that are of type + * {@link org.jclouds.providers.ProviderMetadata#LOADBALANCER_TYPE}. + * + * @return the load balancer service providers + */ + public static Iterable allLoadBalancer() { + return filter(all(), ProviderPredicates.type(ProviderMetadata.LOADBALANCER_TYPE)); + } + /** * Returns the providers that are of the provided type. - * + * * @param type * the type to providers to return - * + * * @return the providers of the provided type */ public static Iterable ofType(String type) { diff --git a/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java b/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java index d77d9a82e1..96abc65913 100644 --- a/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java +++ b/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java @@ -26,7 +26,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; /** * @@ -36,6 +35,7 @@ import com.google.common.collect.Sets; public abstract class BaseProviderMetadataTest { protected Set allTypes = ImmutableSet.of(ProviderMetadata.BLOBSTORE_TYPE, ProviderMetadata.COMPUTE_TYPE, ProviderMetadata.LOADBALANCER_TYPE, ProviderMetadata.QUEUE_TYPE, ProviderMetadata.TABLE_TYPE); + private final ProviderMetadata toTest; private final String expectedType; @@ -52,21 +52,15 @@ public abstract class BaseProviderMetadataTest { assert providerMetadata.getLinkedServices().contains(toTest.getId()); } + // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) @Test - public void testOfType() { - assertEquals(Iterables.getOnlyElement(Providers.ofType(expectedType)), toTest); - - for (String type : Sets.difference(allTypes, ImmutableSet.of(expectedType))) - assertEquals(Iterables.size(Providers.ofType(type)), 0); + public void testOfTypeContains() { + assert ImmutableSet.of(Providers.ofType(expectedType)).contains(toTest); } @Test - public void testAll() { - Iterable providersMetadata = Providers.all(); - - for (ProviderMetadata providerMetadata : providersMetadata) { - assertEquals(toTest, providerMetadata); - } + public void testAllContains() { + assert ImmutableSet.of(Providers.all()).contains(toTest); } @Test diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java index 4fac3e2ab3..4932440b60 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java @@ -63,7 +63,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata { */ @Override public String getIdentityName() { - return "accessKeyID"; + return "Access Key ID"; } /** @@ -71,7 +71,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata { */ @Override public String getCredentialName() { - return "secretAccessKey"; + return "Secret Access Key"; } /** @@ -102,7 +102,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata { */ @Override public Set getLinkedServices() { - return ImmutableSet.of(getId(), "aws-s3"); + return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb"); } } \ No newline at end of file diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java index 3bb21e4859..173dff1956 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java @@ -55,7 +55,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata { */ @Override public String getName() { - return "Amazon Elastic Compute Cloud (S3)"; + return "Amazon Simple Storage Service (S3)"; } /** @@ -63,7 +63,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata { */ @Override public String getIdentityName() { - return "accessKeyID"; + return "Access Key ID"; } /** @@ -71,7 +71,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata { */ @Override public String getCredentialName() { - return "secretAccessKey"; + return "Secret Access Key"; } /** diff --git a/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java b/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java new file mode 100644 index 0000000000..3a674c8195 --- /dev/null +++ b/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java @@ -0,0 +1,108 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.aws.elb; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +import com.google.common.collect.ImmutableSet; + +/** + * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing + * provider. + * + * @author Adrian Cole + */ +public class AWSELBProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "aws-elb"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.LOADBALANCER_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Amazon Elastic Load Balancing"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Access Key ID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret Access Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://aws.amazon.com/elasticloadbalancing"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://console.aws.amazon.com/ec2/home"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb"); + } + +} \ No newline at end of file diff --git a/sandbox-providers/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/sandbox-providers/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..6b88bf79db --- /dev/null +++ b/sandbox-providers/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.aws.elb.AWSELBProviderMetadata diff --git a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/ProvidersInPropertiesTest.java b/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java similarity index 67% rename from sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/ProvidersInPropertiesTest.java rename to sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java index 41ed1fb94d..bf31bc94cd 100644 --- a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/ProvidersInPropertiesTest.java +++ b/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java @@ -18,23 +18,19 @@ */ package org.jclouds.aws.elb; -import org.jclouds.rest.Providers; +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; -import com.google.common.collect.Iterables; - /** + * The AWSELBProviderTest tests the org.jclouds.providers.AWSELBProvider class. * * @author Adrian Cole - * */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "aws-elb") : providers; - } +@Test(groups = "unit", testName = "AWSELBProviderTest") +public class AWSELBProviderTest extends BaseProviderMetadataTest { -} + public AWSELBProviderTest() { + super(new AWSELBProviderMetadata(), ProviderMetadata.LOADBALANCER_TYPE); + } +} \ No newline at end of file diff --git a/sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/AWSSimpleDBProviderMetadata.java b/sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/AWSSimpleDBProviderMetadata.java new file mode 100644 index 0000000000..105c3f8f8a --- /dev/null +++ b/sandbox-providers/aws-simpledb/src/main/java/org/jclouds/aws/simpledb/AWSSimpleDBProviderMetadata.java @@ -0,0 +1,108 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.aws.simpledb; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +import com.google.common.collect.ImmutableSet; + +/** + * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's SimpleDB provider. + * + * @author Adrian Cole + */ +public class AWSSimpleDBProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "aws-simpledb"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.TABLE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Amazon SimpleDB"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Access Key ID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret Access Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://aws.amazon.com/simpledb"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb"); + } + +} \ No newline at end of file diff --git a/sandbox-providers/aws-simpledb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/sandbox-providers/aws-simpledb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..2e3fd4f328 --- /dev/null +++ b/sandbox-providers/aws-simpledb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.aws.simpledb.AWSSimpleDBProviderMetadata diff --git a/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBProviderTest.java b/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBProviderTest.java new file mode 100644 index 0000000000..69969c47cc --- /dev/null +++ b/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/AWSSimpleDBProviderTest.java @@ -0,0 +1,36 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.aws.simpledb; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * The AWSSimpleDBProviderTest tests the org.jclouds.providers.AWSSimpleDBProvider class. + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "AWSSimpleDBProviderTest") +public class AWSSimpleDBProviderTest extends BaseProviderMetadataTest { + + public AWSSimpleDBProviderTest() { + super(new AWSSimpleDBProviderMetadata(), ProviderMetadata.TABLE_TYPE); + } +} \ No newline at end of file