Implemented the provider metadata for the aws-ec2 cloud provider.

[in providers/aws-ec2/src/main]

* java/org/jclouds/providers/AWSEC2ProviderMetadata.java: Added.

* main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata: Added.

[in providers/aws-ec2/src/test]

* java/org/jclouds/providers/AWSEC2ProviderTest.java: Added.
This commit is contained in:
Jeremy Whitlock 2011-05-12 00:41:45 -06:00
parent 1b532cb22a
commit 259159708d
3 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,71 @@
/**
*
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.providers;
import java.net.URI;
/**
* Implementation of {@ link org.jclouds.types.ProviderMetadata} for Amazon's
* Elastic Compute Cloud (EC2) provider.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>
*/
public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
/**
* {@ see org.jclouds.types.ProviderMetadata#getId()}
*/
@Override
public String getId() {
return "aws-ec2";
}
/**
* {@ see org.jclouds.types.ProviderMetadata#getType()}
*/
@Override
public String getType() {
return ProviderMetadata.COMPUTE_TYPE;
}
/**
* {@ see org.jclouds.types.ProviderMetadata#getName()}
*/
@Override
public String getName() {
return "Amazon Elastic Compute Cloud (EC2)";
}
/**
* {@ see org.jclouds.types.ProviderMetadata#getHomepage()}
*/
@Override
public URI getHomepage() {
return URI.create("http://aws.amazon.com/");
}
/**
* {@ see org.jclouds.types.ProviderMetadata#getConsole()}
*/
@Override
public URI getConsole() {
return URI.create("http://aws.amazon.com/console/");
}
}

View File

@ -0,0 +1 @@
org.jclouds.providers.AWSEC2ProviderMetadata

View File

@ -0,0 +1,65 @@
/**
*
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.providers;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import org.testng.annotations.Test;
/**
* The AWSEC2ProviderTest tests the org.jclouds.providers.AWSEC2Provider class.
*
* @author Jeremy Whitlock <jwhitlock@apache.org>
*/
@Test( groups = "unit" )
public class AWSEC2ProviderTest {
private final ProviderMetadata awsEc2ProviderMetadata = new AWSEC2ProviderMetadata();
@Test
public void testWithId() {
ProviderMetadata providerMetadata = Providers.withId(awsEc2ProviderMetadata.getId());
assertEquals(awsEc2ProviderMetadata, providerMetadata);
}
@Test
public void testOfType() {
Iterable<ProviderMetadata> providersMetadata = Providers.ofType(ProviderMetadata.COMPUTE_TYPE);
for (ProviderMetadata providerMetadata : providersMetadata) {
assertEquals(awsEc2ProviderMetadata, providerMetadata);
}
providersMetadata = Providers.ofType(ProviderMetadata.BLOBSTORE_TYPE);
assertFalse(providersMetadata.iterator().hasNext());
}
@Test
public void testAll() {
Iterable<ProviderMetadata> providersMetadata = Providers.all();
for (ProviderMetadata providerMetadata : providersMetadata) {
assertEquals(awsEc2ProviderMetadata, providerMetadata);
}
}
}