mirror of https://github.com/apache/jclouds.git
Issue 550: moved providers into a scoped package and made a base test class
This commit is contained in:
parent
c621d53799
commit
4d81a5aa28
|
@ -138,7 +138,7 @@
|
|||
-->
|
||||
<excludes>
|
||||
<exclude>META-INF/services/</exclude>
|
||||
<exclude>org/jclouds/providers/*Test*.class</exclude>
|
||||
<exclude>org/jclouds/providers/ProvidersTest.class</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
*
|
||||
* 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 java.util.Set;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Whitlock <jwhitlock@apache.org>
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public abstract class BaseProviderTest {
|
||||
protected Set<String> allTypes = ImmutableSet.of(ProviderMetadata.BLOBSTORE_TYPE, ProviderMetadata.COMPUTE_TYPE);
|
||||
private final ProviderMetadata toTest;
|
||||
private final String expectedType;
|
||||
|
||||
public BaseProviderTest(ProviderMetadata toTest, String expectedType) {
|
||||
this.toTest = toTest;
|
||||
this.expectedType = expectedType;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithId() {
|
||||
ProviderMetadata providerMetadata = Providers.withId(toTest.getId());
|
||||
|
||||
assertEquals(toTest, providerMetadata);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAll() {
|
||||
Iterable<ProviderMetadata> providersMetadata = Providers.all();
|
||||
|
||||
for (ProviderMetadata providerMetadata : providersMetadata) {
|
||||
assertEquals(toTest, providerMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInRestProperties() {
|
||||
Iterable<String> providers = org.jclouds.rest.Providers.getSupportedProviders();
|
||||
assert Iterables.contains(providers, toTest.getId()) : providers;
|
||||
}
|
||||
}
|
|
@ -16,10 +16,13 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.providers;
|
||||
package org.jclouds.aws.ec2;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.providers.BaseProviderMetadata;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
/**
|
||||
* Implementation of {@ link org.jclouds.types.ProviderMetadata} for Amazon's
|
||||
* Elastic Compute Cloud (EC2) provider.
|
||||
|
@ -29,7 +32,7 @@ import java.net.URI;
|
|||
public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
||||
|
||||
/**
|
||||
* {@ see org.jclouds.types.ProviderMetadata#getId()}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
|
@ -37,7 +40,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@ see org.jclouds.types.ProviderMetadata#getType()}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
|
@ -45,7 +48,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@ see org.jclouds.types.ProviderMetadata#getName()}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -53,19 +56,19 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@ see org.jclouds.types.ProviderMetadata#getHomepage()}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getHomepage() {
|
||||
return URI.create("http://aws.amazon.com/");
|
||||
return URI.create("http://aws.amazon.com/ec2/");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@ see org.jclouds.types.ProviderMetadata#getConsole()}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getConsole() {
|
||||
return URI.create("http://aws.amazon.com/console/");
|
||||
return URI.create("https://console.aws.amazon.com/ec2/home");
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +1 @@
|
|||
org.jclouds.providers.AWSEC2ProviderMetadata
|
||||
org.jclouds.aws.ec2.AWSEC2ProviderMetadata
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.providers;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
|
||||
import org.jclouds.aws.ec2.AWSEC2ProviderMetadata;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -28,38 +26,10 @@ import org.testng.annotations.Test;
|
|||
*
|
||||
* @author Jeremy Whitlock <jwhitlock@apache.org>
|
||||
*/
|
||||
@Test( groups = "unit" )
|
||||
public class AWSEC2ProviderTest {
|
||||
@Test(groups = "unit", testName = "AWSEC2ProviderTest")
|
||||
public class AWSEC2ProviderTest extends BaseProviderTest {
|
||||
|
||||
private final ProviderMetadata awsEc2ProviderMetadata = new AWSEC2ProviderMetadata();
|
||||
|
||||
@Test
|
||||
public void testWithId() {
|
||||
ProviderMetadata providerMetadata = Providers.withId(awsEc2ProviderMetadata.getId());
|
||||
|
||||
assertEquals(awsEc2ProviderMetadata, providerMetadata);
|
||||
public AWSEC2ProviderTest() {
|
||||
super(new AWSEC2ProviderMetadata(), ProviderMetadata.COMPUTE_TYPE);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
*
|
||||
* 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.vcloud.terremark;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.providers.BaseProviderMetadata;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
/**
|
||||
* Implementation of {@link org.jclouds.types.ProviderMetadata} for Terremark's vCloud Express.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "trmk-vcloudexpress";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return ProviderMetadata.COMPUTE_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Terremark vCloud Express";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getHomepage() {
|
||||
return URI.create("https://vcloudexpress.terremark.com/");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getConsole() {
|
||||
return URI.create("https://my.vcloudexpress.terremark.com");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.jclouds.vcloud.terremark.TerremarkVCloudExpressProviderMetadata
|
|
@ -16,33 +16,20 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.vcloud.terremark;
|
||||
package org.jclouds.providers;
|
||||
|
||||
import org.jclouds.compute.util.ComputeServiceUtils;
|
||||
import org.jclouds.rest.Providers;
|
||||
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressProviderMetadata;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* The TerremarkVCloudExpressProviderTest tests the org.jclouds.providers.TerremarkVCloudExpressProvider class.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ProvidersInPropertiesTest {
|
||||
|
||||
@Test
|
||||
public void testSupportedProviders() {
|
||||
Iterable<String> providers = Providers.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "trmk-vcloudexpress") : providers;
|
||||
@Test(groups = "unit", testName = "TerremarkVCloudExpressProviderTest")
|
||||
public class TerremarkVCloudExpressProviderTest extends BaseProviderTest {
|
||||
|
||||
public TerremarkVCloudExpressProviderTest() {
|
||||
super(new TerremarkVCloudExpressProviderMetadata(), ProviderMetadata.COMPUTE_TYPE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupportedComputeServiceProviders() {
|
||||
Iterable<String> providers = ComputeServiceUtils.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "trmk-vcloudexpress") : providers;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue