From b47860afc13af6236cbef24323f76f356e5faf2e Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Sun, 8 Apr 2012 22:32:04 -0700 Subject: [PATCH 01/69] Use inference to elide duplicated type parameters Found with: grep 'Builder.*<.*>.*Immutable.*<.*>.*builder();' --- .../atmos/binders/BindUserMetadataToHeaders.java | 2 +- .../functions/ParseUserMetadataFromHeaders.java | 2 +- ...seDirectoryListFromContentAndHeadersTest.java | 2 +- .../java/org/jclouds/byon/domain/YamlNode.java | 2 +- .../compute/CloudSigmaComputeServiceAdapter.java | 2 +- .../cloudsigma/functions/MapToDriveMetrics.java | 2 +- .../CloudStackComputeServiceAdapter.java | 4 ++-- .../cloudstack/domain/NetworkService.java | 4 ++-- .../jclouds/cloudstack/filters/QuerySigner.java | 2 +- .../CreatePortForwardingRulesForIP.java | 4 ++-- .../ParseEventTypesFromHttpResponse.java | 2 +- .../functions/ParseIdToNameFromHttpResponse.java | 2 +- .../functions/ParseNamesFromHttpResponse.java | 2 +- .../predicates/CorrectHypervisorForZone.java | 2 +- ...indBlockDeviceMappingToIndexedFormParams.java | 2 +- .../BindIpPermissionsToIndexedFormParams.java | 2 +- .../binders/BindS3UploadPolicyAndSignature.java | 2 +- ...GroupPairToSourceSecurityGroupFormParams.java | 2 +- .../jclouds/ec2/compute/EC2ComputeService.java | 2 +- .../functions/RunningInstanceToNodeMetadata.java | 2 +- .../ec2/compute/options/EC2TemplateOptions.java | 2 +- ...ecurityGroupsAsNeededAndReturnRunOptions.java | 2 +- .../EC2CreateNodesInGroupThenAddToSet.java | 2 +- .../ec2/compute/suppliers/EC2ImageSupplier.java | 2 +- .../options/internal/BaseEC2RequestOptions.java | 2 +- .../ElasticStackComputeServiceAdapter.java | 2 +- .../functions/MapToDriveMetrics.java | 2 +- .../BindSecurityGroupRuleToJsonPayload.java | 2 +- .../v1_1/compute/NovaComputeServiceAdapter.java | 6 +++--- .../CreateSecurityGroupIfNeededTest.java | 4 ++-- .../jclouds/s3/options/CopyObjectOptions.java | 2 +- .../org/jclouds/s3/options/PutObjectOptions.java | 2 +- .../org/jclouds/s3/xml/ListBucketHandler.java | 4 ++-- .../strategy/VCloudComputeServiceAdapter.java | 2 +- .../vcloud/compute/util/VCloudComputeUtils.java | 2 +- .../config/DefaultVCloudReferencesModule.java | 2 +- .../vcloud/config/VCloudRestClientModule.java | 2 +- .../BindCloneVAppParamsToXmlPayloadTest.java | 6 +++--- ...dCloneVAppTemplateParamsToXmlPayloadTest.java | 6 +++--- .../internal/BaseBlobMapIntegrationTest.java | 4 ++-- .../main/java/org/jclouds/aws/util/AWSUtils.java | 12 ++++++------ .../ParseAuthenticationResponseFromHeaders.java | 2 +- .../v2_0/binders/BindAuthToJsonPayload.java | 2 +- .../config/DefaultVCloudReferencesModule.java | 2 +- .../config/TerremarkVCloudRestClientModule.java | 2 +- .../options/AddInternetServiceOptions.java | 2 +- .../trmk/vcloud_0_8/xml/DataCentersHandler.java | 2 +- .../vcloud_0_8/xml/InternetServicesHandler.java | 2 +- .../java/org/jclouds/compute/RunScriptData.java | 2 +- ...IsParentOrIsGrandparentOfCurrentLocation.java | 2 +- .../stub/config/StubComputeServiceAdapter.java | 2 +- .../main/java/org/jclouds/crypto/SshKeys.java | 2 +- .../java/org/jclouds/functions/JoinOnK2.java | 2 +- .../java/org/jclouds/json/config/GsonModule.java | 2 +- ...ocationIdToIso3166CodesFromConfiguration.java | 2 +- ...oURIFromConfigurationOrDefaultToProvider.java | 2 +- .../RegionIdToZoneIdsFromConfiguration.java | 2 +- .../rest/internal/RestAnnotationProcessor.java | 4 ++-- .../main/java/org/jclouds/util/Multimaps2.java | 4 ++-- .../src/main/java/org/jclouds/util/SaxUtils.java | 2 +- .../compute/GleSYSComputeServiceAdapter.java | 4 ++-- .../glesys/options/CreateServerOptions.java | 2 +- .../glesys/features/ServerClientExpectTest.java | 2 +- .../strategy/VPDCComputeServiceAdapter.java | 4 ++-- .../java/org/jclouds/savvis/vpdc/util/Utils.java | 2 +- .../jclouds/savvis/vpdc/xml/OrgListHandler.java | 2 +- .../savvis/vpdc/xml/TasksListHandler.java | 2 +- .../savvis/vpdc/features/VMClientLiveTest.java | 2 +- .../BindLaunchSpecificationToFormParams.java | 2 +- .../compute/suppliers/AWSEC2ImageSupplier.java | 2 +- .../aws/ec2/compute/suppliers/CallForImages.java | 2 +- .../aws/ec2/domain/LaunchSpecification.java | 16 ++++++++-------- .../DescribeSpotPriceHistoryResponseHandler.java | 2 +- .../aws/ec2/xml/SpotInstancesHandler.java | 2 +- .../org/jclouds/aws/ec2/xml/TagSetHandler.java | 2 +- .../s3/binders/BindObjectMetadataToRequest.java | 2 +- .../binders/BindAzureBlobMetadataToRequest.java | 2 +- .../softlayer/SoftLayerPropertiesBuilder.java | 2 +- .../strategy/SoftLayerComputeServiceAdapter.java | 4 ++-- .../features/DatacenterClientLiveTest.java | 2 +- .../features/VirtualGuestClientLiveTest.java | 2 +- .../ecloud/xml/TagNameToUsageCountHandler.java | 2 +- .../BindAttributesToIndexedFormParams.java | 2 +- .../org/jclouds/scriptbuilder/ScriptBuilder.java | 2 +- .../scriptbuilder/domain/CreateRunScript.java | 4 ++-- .../scriptbuilder/domain/StatementList.java | 2 +- .../statements/login/AdminAccess.java | 2 +- .../scriptbuilder/statements/login/Sudoers.java | 2 +- .../scriptbuilder/statements/login/UserAdd.java | 4 ++-- .../statements/ssh/AuthorizeRSAPublicKeys.java | 4 ++-- .../statements/ssh/InstallRSAPrivateKey.java | 2 +- 91 files changed, 123 insertions(+), 123 deletions(-) diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java b/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java index ea0a08b1d9..670466d589 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java @@ -52,7 +52,7 @@ public class BindUserMetadataToHeaders implements Binder, Function apply(UserMetadata md) { - Builder headers = ImmutableMap. builder(); + Builder headers = ImmutableMap.builder(); if (md.getMetadata().size() > 0) { String header = Joiner.on(',').withKeyValueSeparator("=").join(md.getMetadata()); headers.put("x-emc-meta", header); diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java index 7fb167c16b..de352521d2 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java @@ -74,7 +74,7 @@ public class ParseUserMetadataFromHeaders implements Function getMetaMap(String meta) { - Builder metaMap = ImmutableMap. builder(); + Builder metaMap = ImmutableMap.builder(); for (String entry : Splitter.on(", ").split(meta)) { String[] entrySplit = entry.split("="); metaMap.put(entrySplit[0], entrySplit[1]); diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/functions/ParseDirectoryListFromContentAndHeadersTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/functions/ParseDirectoryListFromContentAndHeadersTest.java index 4bd7874a72..01d03cea75 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/functions/ParseDirectoryListFromContentAndHeadersTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/functions/ParseDirectoryListFromContentAndHeadersTest.java @@ -69,7 +69,7 @@ public class ParseDirectoryListFromContentAndHeadersTest extends BaseHandlerTest } protected Set values() { - Builder expected = ImmutableSet.builder(); + Builder expected = ImmutableSet.builder(); expected.add(new DirectoryEntry("4980cdb2a411106a04a4538c92a1b204ad92077de6e3", FileType.DIRECTORY, "adriancole-blobstore-2096685753")); expected.add(new DirectoryEntry("4980cdb2a410105404980d99e53a0504ad93939e7dc3", FileType.DIRECTORY, diff --git a/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java b/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java index e9b9173d77..b8b8615f56 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java +++ b/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java @@ -130,7 +130,7 @@ public class YamlNode { public InputStream apply(YamlNode in) { if (in == null) return null; - Builder prettier = ImmutableMap. builder(); + Builder prettier = ImmutableMap.builder(); if (in.id != null) prettier.put("id", in.id); if (in.name != null) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java index 1652168653..52ade29acf 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java @@ -140,7 +140,7 @@ public class CloudSigmaComputeServiceAdapter implements @Override public Iterable listHardwareProfiles() { - Builder hardware = ImmutableSet. builder(); + Builder hardware = ImmutableSet.builder(); for (double cpu : new double[] { 1000, 5000, 10000, 20000 }) for (int ram : new int[] { 512, 1024, 4 * 1024, 16 * 1024, 32 * 1024 }) { final float size = (float) cpu / 100; diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java index 345321567f..8aff9137e4 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java @@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableMap.Builder; public class MapToDriveMetrics implements Function, Map> { public Map apply(Map from) { - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); addIDEDevices(from, builder); addSCSIDevices(from, builder); addBlockDevices(from, builder); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java index 4ace1b5a87..2179d4fb36 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java @@ -264,7 +264,7 @@ public class CloudStackComputeServiceAdapter implements } public void disableStaticNATOnIPAddresses(Set ipAddresses) { - Builder jobsToTrack = ImmutableSet. builder(); + Builder jobsToTrack = ImmutableSet.builder(); for (Long ipAddress : ipAddresses) { Long disableStaticNAT = client.getNATClient().disableStaticNATOnPublicIP(ipAddress); if (disableStaticNAT != null) { @@ -276,7 +276,7 @@ public class CloudStackComputeServiceAdapter implements } public Set deleteIPForwardingRulesForVMAndReturnDistinctIPs(long virtualMachineId) { - Builder jobsToTrack = ImmutableSet. builder(); + Builder jobsToTrack = ImmutableSet.builder(); // immutable doesn't permit duplicates Set ipAddresses = Sets.newLinkedHashSet(); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java index 4853d3ea7e..a3d8306359 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java @@ -108,7 +108,7 @@ public class NetworkService implements Comparable { public NetworkService(String name, Map capabilities) { this.name = checkNotNull(name, "name"); - ImmutableSortedSet.Builder internal = ImmutableSortedSet. naturalOrder(); + ImmutableSortedSet.Builder internal = ImmutableSortedSet.naturalOrder(); for (Entry capabililty : checkNotNull(capabilities, "capabilities").entrySet()) internal.add(new Capability(capabililty.getKey(), capabililty.getValue())); this.capabilities = internal.build(); @@ -120,7 +120,7 @@ public class NetworkService implements Comparable { public Map getCapabilities() { // so tests and serialization comes out expected - Builder returnVal = ImmutableSortedMap. naturalOrder(); + Builder returnVal = ImmutableSortedMap.naturalOrder(); for (Capability capability : capabilities) { returnVal.put(capability.name, capability.value); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java index 4f8f0bd3b8..bf5a18fc0b 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java @@ -122,7 +122,7 @@ public class QuerySigner implements AuthenticationFilter, RequestSigner { utils.logRequest(signatureLog, request, ">>"); // encode each parameter value first, - ImmutableSortedSet.Builder builder = ImmutableSortedSet. naturalOrder(); + ImmutableSortedSet.Builder builder = ImmutableSortedSet.naturalOrder(); for (Entry entry : decodedParams.entries()) builder.add(entry.getKey() + "=" + Strings2.urlEncode(entry.getValue())); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java index 9bfccf51ea..572ef7ede2 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java @@ -76,14 +76,14 @@ public class CreatePortForwardingRulesForIP { "ip %s should be static NATed to a virtual machine before applying rules", ip); if (Iterables.size(ports) == 0) return ImmutableSet. of(); - Builder responses = ImmutableSet. builder(); + Builder responses = ImmutableSet.builder(); for (int port : ports) { AsyncCreateResponse response = client.getNATClient().createIPForwardingRule(ip.getId(), protocol, port); logger.debug(">> creating IP forwarding rule IPAddress(%s) for protocol(%s), port(%s); response(%s)", ip.getId(), protocol, port, response); responses.add(response); } - Builder rules = ImmutableSet. builder(); + Builder rules = ImmutableSet.builder(); for (AsyncCreateResponse response : responses.build()) { IPForwardingRule rule = blockUntilJobCompletesAndReturnResult. apply(response); rules.add(rule); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseEventTypesFromHttpResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseEventTypesFromHttpResponse.java index 1b20f5221f..341b578ef0 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseEventTypesFromHttpResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseEventTypesFromHttpResponse.java @@ -64,7 +64,7 @@ public class ParseEventTypesFromHttpResponse implements Function toParse = parser.apply(response); checkNotNull(toParse, "parsed result from %s", response); - Builder builder = ImmutableSet.builder(); + Builder builder = ImmutableSet.builder(); for (EventType entry : toParse) builder.add(entry.name); return builder.build(); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java index 8697aa9ace..ec9a209a3a 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java @@ -88,7 +88,7 @@ public class ParseIdToNameFromHttpResponse implements Function toParse = parser.apply(response); checkNotNull(toParse, "parsed result from %s", response); - Builder builder = ImmutableSortedMap. naturalOrder(); + Builder builder = ImmutableSortedMap.naturalOrder(); for (IdName entry : toParse) builder.put(entry.id, entry.name); return builder.build(); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseNamesFromHttpResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseNamesFromHttpResponse.java index e93898742c..16b8af5984 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseNamesFromHttpResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseNamesFromHttpResponse.java @@ -83,7 +83,7 @@ public class ParseNamesFromHttpResponse implements Function toParse = parser.apply(response); checkNotNull(toParse, "parsed result from %s", response); - Builder builder = ImmutableSet. builder(); + Builder builder = ImmutableSet.builder(); for (Name entry : toParse) builder.add(entry.name); return builder.build(); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/CorrectHypervisorForZone.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/CorrectHypervisorForZone.java index 7af0b51a03..2ef792964f 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/CorrectHypervisorForZone.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/CorrectHypervisorForZone.java @@ -63,7 +63,7 @@ public class CorrectHypervisorForZone implements Function> apply(CloudStackClient client) { checkNotNull(client, "client"); - Builder> builder = ImmutableMap.> builder(); + Builder> builder = ImmutableMap.builder(); for (Zone zone : client.getZoneClient().listZones()) { builder.put(zone.getId(), client.getHypervisorClient().listHypervisorsInZone(zone.getId())); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java b/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java index 3b2d88ca3d..5b8945c5b6 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java @@ -50,7 +50,7 @@ public class BindBlockDeviceMappingToIndexedFormParams implements Binder { checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Map"); Map blockDeviceMapping = (Map) input; - com.google.common.collect.ImmutableMap.Builder builder = ImmutableMap. builder(); + ImmutableMap.Builder builder = ImmutableMap.builder(); int amazonOneBasedIndex = 1; // according to docs, counters must start with 1 for (Entry ebsBlockDeviceName : blockDeviceMapping.entrySet()) { // not null by contract diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java b/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java index 8a83d1c3a8..590e1694b3 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java @@ -40,7 +40,7 @@ public class BindIpPermissionsToIndexedFormParams implements Binder { public R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof Iterable, "this binder is only valid for Iterable"); - Builder headers = ImmutableMultimap. builder(); + Builder headers = ImmutableMultimap.builder(); int index = 0; for (IpPermission perm : (Iterable) input) headers.putAll(IpPermissions.buildFormParametersForIndex(index++, perm)); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java b/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java index 4d9def5bbf..e0ca36827d 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java @@ -49,7 +49,7 @@ public class BindS3UploadPolicyAndSignature implements Binder { @Override public R bindToRequest(R request, Object input) { String encodedJson = CryptoStreams.base64(checkNotNull(input, "json").toString().getBytes(Charsets.UTF_8)); - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); builder.put("Storage.S3.UploadPolicy", encodedJson); String signature = signer.sign(encodedJson); builder.put("Storage.S3.UploadPolicySignature", signature); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java b/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java index ee4628d8d7..004e7292b0 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java @@ -43,7 +43,7 @@ public class BindUserIdGroupPairToSourceSecurityGroupFormParams implements Binde checkArgument(checkNotNull(input, "input") instanceof UserIdGroupPair, "this binder is only valid for UserIdGroupPair!"); UserIdGroupPair pair = (UserIdGroupPair) input; - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); builder.put("SourceSecurityGroupOwnerId", pair.getUserId()); builder.put("SourceSecurityGroupName", pair.getGroupName()); return ModifyRequest.putFormParams(request, builder.build()); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java index 36fe633f40..3ea04e1638 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java @@ -191,7 +191,7 @@ public class EC2ComputeService extends BaseComputeService { */ @Override protected void cleanUpIncidentalResourcesOfDeadNodes(Set deadNodes) { - Builder regionGroups = ImmutableMultimap. builder(); + Builder regionGroups = ImmutableMultimap.builder(); for (NodeMetadata nodeMetadata : deadNodes) { if (nodeMetadata.getGroup() != null) regionGroups.put(AWSUtils.parseHandle(nodeMetadata.getId())[0], nodeMetadata.getGroup()); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java index be6de1c5b0..ae286b251c 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -116,7 +116,7 @@ public class RunningInstanceToNodeMetadata implements Function addressesBuilder = ImmutableSet. builder(); + Builder addressesBuilder = ImmutableSet.builder(); if (Strings.emptyToNull(instance.getIpAddress()) != null) addressesBuilder.add(instance.getIpAddress()); if (Strings.emptyToNull(instance.getPrivateIpAddress()) != null) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java index a37a75d28f..8beac49fe9 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java @@ -87,7 +87,7 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable { private String keyPair = null; private boolean noKeyPair; private byte[] userData; - private ImmutableSet.Builder blockDeviceMappings = ImmutableSet. builder(); + private ImmutableSet.Builder blockDeviceMappings = ImmutableSet.builder(); public static final EC2TemplateOptions NONE = new EC2TemplateOptions(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java index 80920cd79c..31b2a03f5a 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java @@ -166,7 +166,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions { @VisibleForTesting public Set getSecurityGroupsForTagAndOptions(String region, @Nullable String group, TemplateOptions options) { - Builder groups = ImmutableSet. builder(); + Builder groups = ImmutableSet.builder(); if (group != null) { String markerGroup = String.format("jclouds#%s#%s", group, region).replace('#', delimiter); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java index dbcaa08e14..6ac3cd9b80 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java @@ -170,7 +170,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen protected Iterable allocateElasticIpsInRegion(int count, Template template) { - Builder ips = ImmutableSet. builder(); + Builder ips = ImmutableSet.builder(); if (!autoAllocateElasticIps) return ips.build(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java index 231bcb0f4d..f1c3dce547 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java @@ -106,7 +106,7 @@ public class EC2ImageSupplier implements Supplier> { public Iterable> getDescribeQueriesForOwnersInRegions(Set regions, String[] amiOwners) { DescribeImagesOptions options = getOptionsForOwners(amiOwners); - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); for (String region : regions) builder.put(region, options); return builder.build().entrySet(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java index 88d9735ec7..cbb336a444 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java @@ -51,7 +51,7 @@ public class BaseEC2RequestOptions extends BaseHttpRequestOptions { } protected Set getFormValuesWithKeysPrefixedBy(final String prefix) { - Builder values = ImmutableSet. builder(); + Builder values = ImmutableSet.builder(); for (String key : Iterables.filter(formParameters.keySet(), new Predicate() { public boolean apply(String input) { diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java index 2142e7a053..6211969d9d 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java @@ -132,7 +132,7 @@ public class ElasticStackComputeServiceAdapter implements @Override public Iterable listHardwareProfiles() { - Builder hardware = ImmutableSet. builder(); + Builder hardware = ImmutableSet.builder(); for (double cpu : new double[] { 1000, 5000, 10000, 20000 }) for (int ram : new int[] { 512, 1024, 2048, 4096, 8192 }) { final float size = (float) cpu / 1000; diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDriveMetrics.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDriveMetrics.java index 58845b76a4..ba3071442d 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDriveMetrics.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDriveMetrics.java @@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableMap.Builder; public class MapToDriveMetrics implements Function, Map> { public Map apply(Map from) { - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); addIDEDevices(from, builder); addSCSIDevices(from, builder); addBlockDevices(from, builder); diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java index 023b7a2777..90e229479a 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java @@ -57,7 +57,7 @@ public class BindSecurityGroupRuleToJsonPayload extends BindToJsonPayload implem @Override public R bindToRequest(R request, Map postParams) { - Builder payload = ImmutableMap. builder(); + Builder payload = ImmutableMap.builder(); payload.putAll(postParams); checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests!"); diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapter.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapter.java index 5a44c11518..409cebf306 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapter.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapter.java @@ -131,7 +131,7 @@ public class NovaComputeServiceAdapter implements @Override public Iterable listHardwareProfiles() { - Builder builder = ImmutableSet. builder(); + Builder builder = ImmutableSet.builder(); for (final String zoneId : zoneIds.get()) { builder.addAll(transform(novaClient.getFlavorClientForZone(zoneId).listFlavorsInDetail(), new Function() { @@ -148,7 +148,7 @@ public class NovaComputeServiceAdapter implements @Override public Iterable listImages() { - Builder builder = ImmutableSet. builder(); + Builder builder = ImmutableSet.builder(); for (final String zoneId : zoneIds.get()) { builder.addAll(transform(filter(novaClient.getImageClientForZone(zoneId).listImagesInDetail(), ImagePredicates .statusEquals(Image.Status.ACTIVE)), new Function() { @@ -165,7 +165,7 @@ public class NovaComputeServiceAdapter implements @Override public Iterable listNodes() { - Builder builder = ImmutableSet. builder(); + Builder builder = ImmutableSet.builder(); for (final String zoneId : zoneIds.get()) { builder.addAll(transform(novaClient.getServerClientForZone(zoneId).listServersInDetail(), new Function() { diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java index 0dc08b589f..fcdd6cfd3c 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java @@ -55,7 +55,7 @@ public class CreateSecurityGroupIfNeededTest extends BaseNovaClientExpectTest { public void testCreateNewGroup() throws Exception { - Builder builder = ImmutableMap.builder(); + Builder builder = ImmutableMap.builder(); builder.put(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess); builder.put(extensionsOfNovaRequest, extensionsOfNovaResponse); @@ -133,7 +133,7 @@ public class CreateSecurityGroupIfNeededTest extends BaseNovaClientExpectTest { public void testReturnExistingGroupOnAlreadyExists() throws Exception { - Builder builder = ImmutableMap.builder(); + Builder builder = ImmutableMap.builder(); builder.put(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess); builder.put(extensionsOfNovaRequest, extensionsOfNovaResponse); diff --git a/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java b/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java index cc9989a948..8f3ba01b2f 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java +++ b/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java @@ -254,7 +254,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { public Multimap buildRequestHeaders() { checkState(headerTag != null, "headerTag should have been injected!"); checkState(metadataPrefix != null, "metadataPrefix should have been injected!"); - ImmutableMultimap.Builder returnVal = ImmutableMultimap. builder(); + ImmutableMultimap.Builder returnVal = ImmutableMultimap.builder(); for (Entry entry : headers.entries()) { returnVal.put(entry.getKey().replace(DEFAULT_AMAZON_HEADERTAG, headerTag), entry.getValue()); } diff --git a/apis/s3/src/main/java/org/jclouds/s3/options/PutObjectOptions.java b/apis/s3/src/main/java/org/jclouds/s3/options/PutObjectOptions.java index ffdb53e7fa..472b4087eb 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/options/PutObjectOptions.java +++ b/apis/s3/src/main/java/org/jclouds/s3/options/PutObjectOptions.java @@ -73,7 +73,7 @@ public class PutObjectOptions extends BaseHttpRequestOptions { @Override public Multimap buildRequestHeaders() { checkState(headerTag != null, "headerTag should have been injected!"); - ImmutableMultimap.Builder returnVal = ImmutableMultimap. builder(); + ImmutableMultimap.Builder returnVal = ImmutableMultimap.builder(); for (Entry entry : headers.entries()) { returnVal.put(entry.getKey().replace(DEFAULT_AMAZON_HEADERTAG, headerTag), entry.getValue()); } diff --git a/apis/s3/src/main/java/org/jclouds/s3/xml/ListBucketHandler.java b/apis/s3/src/main/java/org/jclouds/s3/xml/ListBucketHandler.java index 214d588fa3..95e8eef42b 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/xml/ListBucketHandler.java +++ b/apis/s3/src/main/java/org/jclouds/s3/xml/ListBucketHandler.java @@ -49,8 +49,8 @@ import com.google.common.collect.ImmutableSet.Builder; * /> */ public class ListBucketHandler extends ParseSax.HandlerWithResult { - private Builder contents = ImmutableSet. builder(); - private Builder commonPrefixes = ImmutableSet. builder(); + private Builder contents = ImmutableSet.builder(); + private Builder commonPrefixes = ImmutableSet.builder(); private CanonicalUser currentOwner; private StringBuilder currentText = new StringBuilder(); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java index 707852c6de..d2c919868f 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java @@ -124,7 +124,7 @@ public class VCloudComputeServiceAdapter implements ComputeServiceAdapter listNodes() { // TODO: parallel or cache - Builder nodes = ImmutableSet. builder(); + Builder nodes = ImmutableSet.builder(); for (Org org : nameToOrg.get().values()) { for (ReferenceType vdc : org.getVDCs().values()) { for (ReferenceType resource : client.getVDCClient().getVDC(vdc.getHref()).getResourceEntities().values()) { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java index 93f197db70..22b929db58 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java @@ -86,7 +86,7 @@ public class VCloudComputeUtils { // TODO make this work with composite vApps if (vApp.getChildren().size() == 0) return ImmutableSet.of(); - Builder ips = ImmutableSet. builder(); + Builder ips = ImmutableSet.builder(); Vm vm = Iterables.get(vApp.getChildren(), 0); // TODO: figure out how to differentiate public from private ip addresses // assumption is that we'll do this from the network object, which may diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java index 708f119007..314825fc36 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java @@ -102,7 +102,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Override public Map apply(Map> arg0) { - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); for (Map v1 : arg0.values()) { for (Catalog v2 : v1.values()) { builder.put(v2.getHref(), v2); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java index f23b05ad11..910e5d37d9 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java @@ -224,7 +224,7 @@ public class VCloudRestClientModule extends RestClientModule apply(Map arg0) { - Builder returnVal = ImmutableMap. builder(); + Builder returnVal = ImmutableMap.builder(); for (Entry orgr : arg0.entrySet()) { for (String vdc : orgr.getValue().getVDCs().keySet()) { returnVal.put(vdc, orgr.getKey()); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java index 368e9917a4..fb2c2c2483 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java @@ -72,7 +72,7 @@ public class BindCloneVAppParamsToXmlPayloadTest { BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); - Builder map = ImmutableMap. builder(); + Builder map = ImmutableMap.builder(); map.put("name", "new-linux-server"); map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201"); binder.bindToRequest(request, map.build()); @@ -92,7 +92,7 @@ public class BindCloneVAppParamsToXmlPayloadTest { BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); - Builder map = ImmutableMap. builder(); + Builder map = ImmutableMap.builder(); map.put("name", "new-linux-server"); map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201"); map.put("IsSourceDelete", "true"); @@ -111,7 +111,7 @@ public class BindCloneVAppParamsToXmlPayloadTest { BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); - Builder map = ImmutableMap. builder(); + Builder map = ImmutableMap.builder(); map.put("name", "my-vapp"); map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"); binder.bindToRequest(request, map.build()); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java index c7ccee619a..e0caf5fbdc 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java @@ -73,7 +73,7 @@ public class BindCloneVAppTemplateParamsToXmlPayloadTest { BindCloneVAppTemplateParamsToXmlPayload binder = injector .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); - Builder map = ImmutableMap. builder(); + Builder map = ImmutableMap.builder(); map.put("name", "new-linux-server"); map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"); binder.bindToRequest(request, map.build()); @@ -94,7 +94,7 @@ public class BindCloneVAppTemplateParamsToXmlPayloadTest { BindCloneVAppTemplateParamsToXmlPayload binder = injector .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); - Builder map = ImmutableMap. builder(); + Builder map = ImmutableMap.builder(); map.put("name", "new-linux-server"); map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"); map.put("IsSourceDelete", "true"); @@ -114,7 +114,7 @@ public class BindCloneVAppTemplateParamsToXmlPayloadTest { BindCloneVAppTemplateParamsToXmlPayload binder = injector .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); - Builder map = ImmutableMap. builder(); + Builder map = ImmutableMap.builder(); map.put("name", "my-vapptemplate"); map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"); binder.bindToRequest(request, map.build()); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java index 1580f6f23c..a4780a7e87 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java @@ -204,7 +204,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< String bucketName = getContainerName(); try { Map map = createMap(context, bucketName); - ImmutableMap.Builder newMap = ImmutableMap. builder(); + ImmutableMap.Builder newMap = ImmutableMap.builder(); for (String key : fiveInputs.keySet()) { newMap.put( key, @@ -227,7 +227,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< String bucketName = getContainerName(); try { BlobMap map = createMap(context, bucketName); - Builder keySet = ImmutableSet. builder(); + Builder keySet = ImmutableSet.builder(); for (int i = 0; i < maxResultsForTestListings() + 1; i++) { keySet.add(i + ""); } diff --git a/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java b/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java index bb72785ad3..7e25dfc498 100644 --- a/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java +++ b/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java @@ -113,7 +113,7 @@ public class AWSUtils { checkArgument(checkNotNull(input, "input") instanceof String[], "this binder is only valid for String[] : " + input.getClass()); String[] values = (String[]) input; - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); for (int i = 0; i < values.length; i++) { builder.put(String.format(format, (i + 1)), checkNotNull(values[i], format.toLowerCase() + "s[" + i + "]")); } @@ -130,7 +130,7 @@ public class AWSUtils { checkArgument(checkNotNull(input, "input") instanceof Iterable, "this binder is only valid for Iterable: " + input.getClass()); Iterable values = (Iterable) input; - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); int i = 0; for (Object o : values) { builder.put(prefix + "." + (i++ + 1), checkNotNull(o.toString(), prefix.toLowerCase() + "s[" + i + "]")); @@ -143,7 +143,7 @@ public class AWSUtils { checkArgument(checkNotNull(input, "input") instanceof String[], "this binder is only valid for String[] : " + input.getClass()); String[] values = (String[]) input; - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); for (int i = 0; i < values.length; i++) { builder.put(prefix + "." + (i + 1), checkNotNull(values[i], prefix.toLowerCase() + "s[" + i + "]")); } @@ -154,7 +154,7 @@ public class AWSUtils { public static R indexMapToFormValuesWithPrefix(R request, String prefix, String keySuffix, String valueSuffix, Object input) { checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Map: " + input.getClass()); Map map = (Map) input; - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); int i = 1; for (Map.Entry e : map.entrySet()) { builder.put(prefix + "." + i + "." + keySuffix, checkNotNull(e.getKey().toString(), keySuffix.toLowerCase() + "s[" + i + "]")); @@ -171,7 +171,7 @@ public class AWSUtils { public static R indexMultimapToFormValuesWithPrefix(R request, String prefix, String keySuffix, String valueSuffix, Object input) { checkArgument(checkNotNull(input, "input") instanceof Multimap, "this binder is only valid for Multimap: " + input.getClass()); Multimap map = (Multimap) input; - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); int i = 1; for (Object k : map.keySet()) { builder.put(prefix + "." + i + "." + keySuffix, checkNotNull(k.toString(), keySuffix.toLowerCase() + "s[" + i + "]")); @@ -190,7 +190,7 @@ public class AWSUtils { public static R indexMapOfIterableToFormValuesWithPrefix(R request, String prefix, String keySuffix, String valueSuffix, Object input) { checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Map>: " + input.getClass()); Map> map = (Map>) input; - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); int i = 1; for (Object k : map.keySet()) { builder.put(prefix + "." + i + "." + keySuffix, checkNotNull(k.toString(), keySuffix.toLowerCase() + "s[" + i + "]")); diff --git a/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java b/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java index ca2a301c91..249a6165e4 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java @@ -66,7 +66,7 @@ public class ParseAuthenticationResponseFromHeaders implements Function builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); for (Entry entry : from.getHeaders().entries()) { if (entry.getKey().endsWith(URL_SUFFIX)) builder.put(entry.getKey(), getURI(entry.getValue())); diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java index 4dfbb92691..aa7e591238 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java @@ -73,7 +73,7 @@ public class BindAuthToJsonPayload extends BindToJsonPayload implements MapBinde GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; checkState(gRequest.getArgs() != null, "args should be initialized at this point"); - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); addCredentialsInArgsOrNull(gRequest, builder); // TODO: is tenantName permanent? or should we switch to tenantId at some point. seems most tools // still use tenantName diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java index 59e765640b..ec96dfd891 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java @@ -106,7 +106,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Override public Map apply(Map> arg0) { - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); for (Map v1 : arg0.values()) { for (Catalog v2 : v1.values()) { builder.put(v2.getHref(), v2); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java index ef66700ad1..0d48d18910 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java @@ -150,7 +150,7 @@ public class TerremarkVCloudRestClientModule apply(Map arg0) { - Builder returnVal = ImmutableMap. builder(); + Builder returnVal = ImmutableMap.builder(); for (Entry orgr : arg0.entrySet()) { for (String vdc : orgr.getValue().getVDCs().keySet()) { returnVal.put(vdc, orgr.getKey()); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddInternetServiceOptions.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddInternetServiceOptions.java index 1c7cf9a38d..232582615f 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddInternetServiceOptions.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/options/AddInternetServiceOptions.java @@ -42,7 +42,7 @@ public class AddInternetServiceOptions extends BindAddInternetServiceToXmlPayloa @Override public R bindToRequest(R request, Map postParams) { - ImmutableMap.Builder copy = ImmutableMap. builder(); + ImmutableMap.Builder copy = ImmutableMap.builder(); copy.putAll(postParams); if (description != null) copy.put("description", description); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/DataCentersHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/DataCentersHandler.java index d6b6154828..0218308046 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/DataCentersHandler.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/DataCentersHandler.java @@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSet.Builder; public class DataCentersHandler extends ParseSax.HandlerWithResult> { protected StringBuilder currentText = new StringBuilder(); - protected Builder dataCenters = ImmutableSet. builder(); + protected Builder dataCenters = ImmutableSet.builder(); protected DataCenter.Builder builder = DataCenter.builder(); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/InternetServicesHandler.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/InternetServicesHandler.java index b1e0f1ddb2..e71bda9644 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/InternetServicesHandler.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/xml/InternetServicesHandler.java @@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSet.Builder; public class InternetServicesHandler extends HandlerWithResult> { private final InternetServiceHandler handler; - private Builder builder = ImmutableSet. builder(); + private Builder builder = ImmutableSet.builder(); @Inject public InternetServicesHandler(InternetServiceHandler handler) { diff --git a/compute/src/main/java/org/jclouds/compute/RunScriptData.java b/compute/src/main/java/org/jclouds/compute/RunScriptData.java index e62fd67348..c678d6b851 100644 --- a/compute/src/main/java/org/jclouds/compute/RunScriptData.java +++ b/compute/src/main/java/org/jclouds/compute/RunScriptData.java @@ -51,7 +51,7 @@ public class RunScriptData { public static String JBOSS_HOME = "/usr/local/jboss"; public static Statement authorizePortsInIpTables(int... ports) { - Builder builder = ImmutableList. builder(); + Builder builder = ImmutableList.builder(); for (int port : ports) builder.add(exec("iptables -I INPUT 1 -p tcp --dport " + port + " -j ACCEPT")); builder.add(exec("iptables-save")); diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocation.java b/compute/src/main/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocation.java index 89cf0cbe84..54f6593c33 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocation.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/NullEqualToIsParentOrIsGrandparentOfCurrentLocation.java @@ -65,7 +65,7 @@ public class NullEqualToIsParentOrIsGrandparentOfCurrentLocation implements Pred "only locations of scope PROVIDER can have a null parent; input: %s", input.getLocation()); - Builder> predicates = ImmutableSet.>builder(); + Builder> predicates = ImmutableSet.builder(); predicates.add(equalTo(current)); diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java index 178f870e09..0bb2a81782 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java @@ -141,7 +141,7 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda public Iterable listImages() { // initializing as a List, as ImmutableSet does not allow you to put // duplicates - Builder images = ImmutableList. builder(); + Builder images = ImmutableList.builder(); int id = 1; for (boolean is64Bit : new boolean[] { true, false }) for (Entry> osVersions : this.osToVersionMap.entrySet()) { diff --git a/core/src/main/java/org/jclouds/crypto/SshKeys.java b/core/src/main/java/org/jclouds/crypto/SshKeys.java index 09b609acd2..e085d7a1ad 100644 --- a/core/src/main/java/org/jclouds/crypto/SshKeys.java +++ b/core/src/main/java/org/jclouds/crypto/SshKeys.java @@ -149,7 +149,7 @@ public class SshKeys { public static Map generate(KeyPairGenerator generator) { KeyPair pair = generateRsaKeyPair(generator); - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); builder.put("public", encodeAsOpenSSH(RSAPublicKey.class.cast(pair.getPublic()))); builder.put("private", encodeAsPem(RSAPrivateKey.class.cast(pair.getPrivate()))); return builder.build(); diff --git a/core/src/main/java/org/jclouds/functions/JoinOnK2.java b/core/src/main/java/org/jclouds/functions/JoinOnK2.java index 23866bc0fd..206ed43891 100644 --- a/core/src/main/java/org/jclouds/functions/JoinOnK2.java +++ b/core/src/main/java/org/jclouds/functions/JoinOnK2.java @@ -37,7 +37,7 @@ public class JoinOnK2 implements Function>>, M @Override public Map> apply(Map>> regionToZones) { Map> regionToEndpoint = regionToEndpointSupplier.get(); - Builder> builder = ImmutableMap.> builder(); + Builder> builder = ImmutableMap.builder(); for (Entry>> entry : regionToZones.entrySet()) { for (K2 zone : entry.getValue().get()) { builder.put(zone, regionToEndpoint.get(entry.getKey())); diff --git a/core/src/main/java/org/jclouds/json/config/GsonModule.java b/core/src/main/java/org/jclouds/json/config/GsonModule.java index 2af1baf370..7e0712cacb 100644 --- a/core/src/main/java/org/jclouds/json/config/GsonModule.java +++ b/core/src/main/java/org/jclouds/json/config/GsonModule.java @@ -185,7 +185,7 @@ public class GsonModule extends AbstractModule { @Override public void write(JsonWriter out, Properties value) throws IOException { - Builder srcMap = ImmutableMap. builder(); + Builder srcMap = ImmutableMap.builder(); for (Enumeration propNames = value.propertyNames(); propNames.hasMoreElements();) { String propName = (String) propNames.nextElement(); srcMap.put(propName, value.getProperty(propName)); diff --git a/core/src/main/java/org/jclouds/location/suppliers/fromconfig/LocationIdToIso3166CodesFromConfiguration.java b/core/src/main/java/org/jclouds/location/suppliers/fromconfig/LocationIdToIso3166CodesFromConfiguration.java index 13360e87c8..5eb0a2c1f9 100644 --- a/core/src/main/java/org/jclouds/location/suppliers/fromconfig/LocationIdToIso3166CodesFromConfiguration.java +++ b/core/src/main/java/org/jclouds/location/suppliers/fromconfig/LocationIdToIso3166CodesFromConfiguration.java @@ -71,7 +71,7 @@ public class LocationIdToIso3166CodesFromConfiguration implements LocationIdToIs } }); - Builder>> codes = ImmutableMap.>> builder(); + Builder>> codes = ImmutableMap.builder(); for (String key : ImmutableSet.of(PROPERTY_REGION, PROPERTY_ZONE)) { String regionOrZoneString = stringsBoundWithRegionOrZonePrefix.get(key + "s"); if (regionOrZoneString == null) diff --git a/core/src/main/java/org/jclouds/location/suppliers/fromconfig/LocationIdToURIFromConfigurationOrDefaultToProvider.java b/core/src/main/java/org/jclouds/location/suppliers/fromconfig/LocationIdToURIFromConfigurationOrDefaultToProvider.java index 5cc3b45a8e..04a2656f0d 100644 --- a/core/src/main/java/org/jclouds/location/suppliers/fromconfig/LocationIdToURIFromConfigurationOrDefaultToProvider.java +++ b/core/src/main/java/org/jclouds/location/suppliers/fromconfig/LocationIdToURIFromConfigurationOrDefaultToProvider.java @@ -60,7 +60,7 @@ public class LocationIdToURIFromConfigurationOrDefaultToProvider implements Supp @Override public Map> get() { - Builder> locations = ImmutableMap.> builder(); + Builder> locations = ImmutableMap.builder(); for (String location : locationIds.get()) { String configKey = configPrefix + "." + location + "." + ENDPOINT; String locationUri = config.apply(configKey); diff --git a/core/src/main/java/org/jclouds/location/suppliers/fromconfig/RegionIdToZoneIdsFromConfiguration.java b/core/src/main/java/org/jclouds/location/suppliers/fromconfig/RegionIdToZoneIdsFromConfiguration.java index 33636bcae4..03cc753371 100644 --- a/core/src/main/java/org/jclouds/location/suppliers/fromconfig/RegionIdToZoneIdsFromConfiguration.java +++ b/core/src/main/java/org/jclouds/location/suppliers/fromconfig/RegionIdToZoneIdsFromConfiguration.java @@ -75,7 +75,7 @@ public class RegionIdToZoneIdsFromConfiguration implements RegionIdToZoneIdsSupp logger.debug("no regions configured for provider %s", provider); return ImmutableMap.of(); } - Builder>> regionToZones = ImmutableMap.>> builder(); + Builder>> regionToZones = ImmutableMap.builder(); for (String region : regions) { String configKey = PROPERTY_REGION + "." + region + ".zones"; String zones = config.apply(configKey); diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index a8dd2a78ff..1564b57ce8 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -243,7 +243,7 @@ public class RestAnnotationProcessor { new CacheLoader>() { @Override public Set load(Method method) { - Builder toReturn = ImmutableSet. builder(); + Builder toReturn = ImmutableSet.builder(); for (int index = 0; index < method.getParameterTypes().length; index++) { Class type = method.getParameterTypes()[index]; if (HttpRequestOptions.class.isAssignableFrom(type) || optionsVarArgsClass.isAssignableFrom(type)) @@ -922,7 +922,7 @@ public class RestAnnotationProcessor { } public static Set getHttpMethods(Method method) { - Builder methodsBuilder = ImmutableSet. builder(); + Builder methodsBuilder = ImmutableSet.builder(); for (Annotation annotation : method.getAnnotations()) { HttpMethod http = annotation.annotationType().getAnnotation(HttpMethod.class); if (http != null) diff --git a/core/src/main/java/org/jclouds/util/Multimaps2.java b/core/src/main/java/org/jclouds/util/Multimaps2.java index 905e0e5ced..d55d29f553 100644 --- a/core/src/main/java/org/jclouds/util/Multimaps2.java +++ b/core/src/main/java/org/jclouds/util/Multimaps2.java @@ -44,7 +44,7 @@ public class Multimaps2 { */ @Deprecated public static Map> toOldSchool(Multimap in) { - ImmutableMap.Builder> out = ImmutableMap.> builder(); + ImmutableMap.Builder> out = ImmutableMap.builder(); for (K type : in.keySet()) out.put(type, ImmutableSet.copyOf(in.get(type))); return out.build(); @@ -55,7 +55,7 @@ public class Multimaps2 { */ @Deprecated public static ImmutableMultimap fromOldSchool(Map> in) { - Builder out = ImmutableMultimap. builder(); + Builder out = ImmutableMultimap.builder(); for (K type : in.keySet()) out.putAll(type, ImmutableSet.copyOf(in.get(type))); return out.build(); diff --git a/core/src/main/java/org/jclouds/util/SaxUtils.java b/core/src/main/java/org/jclouds/util/SaxUtils.java index a7fad6b54d..145719a2b0 100644 --- a/core/src/main/java/org/jclouds/util/SaxUtils.java +++ b/core/src/main/java/org/jclouds/util/SaxUtils.java @@ -36,7 +36,7 @@ public class SaxUtils { } public static Map cleanseAttributes(Attributes in) { - Builder attrs = ImmutableMap. builder(); + Builder attrs = ImmutableMap.builder(); for (int i = 0; i < in.getLength(); i++) { String name = in.getQName(i); if (name.indexOf(':') != -1) diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java b/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java index d2e2feb677..8027a90676 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java @@ -156,7 +156,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter listHardwareProfiles() { Set locationsSet = locations.get(); - ImmutableSet.Builder hardwareToReturn = ImmutableSet. builder(); + ImmutableSet.Builder hardwareToReturn = ImmutableSet.builder(); // do this loop after dupes are filtered, else OOM Set images = listImages(); @@ -167,7 +167,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter templatesSupportedBuilder = ImmutableSet. builder(); + ImmutableSet.Builder templatesSupportedBuilder = ImmutableSet.builder(); for (OSTemplate template : images) { if (template.getPlatform().equals(platformToArgs.getKey()) && diskSizeGB >= template.getMinDiskSize() && memorySizeMB >= template.getMinMemSize()) diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/options/CreateServerOptions.java b/labs/glesys/src/main/java/org/jclouds/glesys/options/CreateServerOptions.java index 5764e62526..8b69892918 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/options/CreateServerOptions.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/options/CreateServerOptions.java @@ -53,7 +53,7 @@ public class CreateServerOptions implements MapBinder { GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; checkState(gRequest.getArgs() != null, "args should be initialized at this point"); - ImmutableMultimap.Builder formParams = ImmutableMultimap. builder(); + ImmutableMultimap.Builder formParams = ImmutableMultimap.builder(); formParams.putAll(forMap(postParams)); ServerSpec serverSpec = ServerSpec.class.cast(find(gRequest.getArgs(), instanceOf(ServerSpec.class))); formParams.put("datacenter", serverSpec.getDatacenter()); diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java index 0fdfd17159..32001b2894 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java @@ -134,7 +134,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest expectedBuilder = ImmutableSet. builder(); + ImmutableSet.Builder expectedBuilder = ImmutableSet.builder(); for (String name : new String[] { "Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit", "Debian 5.0 32-bit", "Debian 5.0 64-bit", "Debian 6.0 32-bit", "Debian 6.0 64-bit", "Fedora Core 11", diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/strategy/VPDCComputeServiceAdapter.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/strategy/VPDCComputeServiceAdapter.java index d75c622ad6..9c6b6ea457 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/strategy/VPDCComputeServiceAdapter.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/strategy/VPDCComputeServiceAdapter.java @@ -126,7 +126,7 @@ public class VPDCComputeServiceAdapter implements ComputeServiceAdapter listNodes() { - Builder builder = ImmutableSet. builder(); + Builder builder = ImmutableSet.builder(); for (Resource org1 : client.listOrgs()) { Org org = client.getBrowsingClient().getOrg(org1.getId()); for (Resource vdc : org.getVDCs()) { @@ -149,7 +149,7 @@ public class VPDCComputeServiceAdapter implements ComputeServiceAdapter listLocations() { - Builder builder = ImmutableSet. builder(); + Builder builder = ImmutableSet.builder(); for (Resource org1 : client.listOrgs()) { Org org = client.getBrowsingClient().getOrg(org1.getId()); for (Resource vdc : org.getVDCs()) { diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java index 9faba4bd31..dd191b98c6 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java @@ -81,7 +81,7 @@ public class Utils { } public static Map cleanseAttributes(Attributes in) { - Builder attrs = ImmutableMap. builder(); + Builder attrs = ImmutableMap.builder(); for (int i = 0; i < in.getLength(); i++) { String name = in.getQName(i); if (name.indexOf(':') != -1) diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java index 3ae57c260c..14777d7201 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java @@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableSet.Builder; */ public class OrgListHandler extends ParseSax.HandlerWithResult> { - private Builder org = ImmutableSet. builder(); + private Builder org = ImmutableSet.builder(); public Set getResult() { try { diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java index 6e8f27d454..f5807f680b 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java @@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSet.Builder; */ public class TasksListHandler extends ParseSax.HandlerWithResult> { - private Builder tasks = ImmutableSet. builder(); + private Builder tasks = ImmutableSet.builder(); private final TaskHandler taskHandler; @Inject diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java index 9798bdbba8..6ad7591f97 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java @@ -170,7 +170,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { System.out.printf("Creating vm's - vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTier .getName().replace("-", " "), name, os); - Builder vmSpecs = ImmutableSet. builder(); + Builder vmSpecs = ImmutableSet.builder(); int noOfVms = 2; for (int i = 0; i < noOfVms; i++) { // TODO: determine the sizes available in the VDC, for example there's diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java index 8e7b9f76d6..753ab0302b 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java @@ -53,7 +53,7 @@ public class BindLaunchSpecificationToFormParams implements Binder, Function apply(LaunchSpecification launchSpec) { - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); builder.put("LaunchSpecification.ImageId", checkNotNull(launchSpec.getImageId(), "imageId")); if (launchSpec.getAvailabilityZone() != null) builder.put("LaunchSpecification.Placement.AvailabilityZone", launchSpec.getAvailabilityZone()); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java index b2c85c4719..277bc0a18c 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java @@ -149,7 +149,7 @@ public class AWSEC2ImageSupplier implements Supplier> { INSTANCE; @Override public Multimap apply(String arg0) { - ImmutableMultimap.Builder builder = ImmutableMultimap. builder(); + ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); for (String pair : Splitter.on(';').split(arg0)) { String[] keyValue = pair.split("="); if (keyValue.length == 1) diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java index 04adf718a3..fa4559c7d1 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java @@ -76,7 +76,7 @@ public class CallForImages implements Callable> { logger.debug(">> providing images"); - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); for (String region : regions) builder.put(region, filters(filter)); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java index e4c7513dec..7b390b2150 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java @@ -48,7 +48,7 @@ public class LaunchSpecification { } public static class Builder { - protected ImmutableMap.Builder securityGroupIdToNames = ImmutableMap. builder(); + protected ImmutableMap.Builder securityGroupIdToNames = ImmutableMap.builder(); protected String imageId; protected String instanceType; protected String kernelId; @@ -57,13 +57,13 @@ public class LaunchSpecification { protected String ramdiskId; protected Boolean monitoringEnabled; protected ImmutableSet.Builder blockDeviceMappings = ImmutableSet - . builder(); - protected ImmutableSet.Builder securityGroupIds = ImmutableSet. builder(); - protected ImmutableSet.Builder securityGroupNames = ImmutableSet. builder(); + .builder(); + protected ImmutableSet.Builder securityGroupIds = ImmutableSet.builder(); + protected ImmutableSet.Builder securityGroupNames = ImmutableSet.builder(); protected byte[] userData; public void clear() { - securityGroupIdToNames = ImmutableMap. builder(); + securityGroupIdToNames = ImmutableMap.builder(); imageId = null; instanceType = null; kernelId = null; @@ -71,9 +71,9 @@ public class LaunchSpecification { availabilityZone = null; ramdiskId = null; monitoringEnabled = false; - blockDeviceMappings = ImmutableSet. builder(); - securityGroupIds = ImmutableSet. builder(); - securityGroupNames = ImmutableSet. builder(); + blockDeviceMappings = ImmutableSet.builder(); + securityGroupIds = ImmutableSet.builder(); + securityGroupNames = ImmutableSet.builder(); userData = null; } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java index 020e579496..fd058b7c75 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java @@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableSet.Builder; public class DescribeSpotPriceHistoryResponseHandler extends ParseSax.HandlerWithResult> { - private Builder spots = ImmutableSet.builder(); + private Builder spots = ImmutableSet.builder(); private final SpotHandler spotHandler; @Inject diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java index 9960502864..87babbc623 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java @@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSet.Builder; */ public class SpotInstancesHandler extends ParseSax.HandlerWithResult> { - private final Builder spotRequests = ImmutableSet. builder(); + private final Builder spotRequests = ImmutableSet.builder(); private final SpotInstanceHandler spotRequestHandler; private int itemDepth; diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/TagSetHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/TagSetHandler.java index a718e2fad3..af611683b3 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/TagSetHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/TagSetHandler.java @@ -52,7 +52,7 @@ public class TagSetHandler extends ParseSax.HandlerForGeneratedRequestWithResult @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (equalsOrSuffix(qName, "tagSet")) { - result = ImmutableMap.builder(); + result = ImmutableMap.builder(); } else if (qName.equals("item")) { inItem = true; key = null; diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/binders/BindObjectMetadataToRequest.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/binders/BindObjectMetadataToRequest.java index 7f9cee3013..f498de18f7 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/binders/BindObjectMetadataToRequest.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/binders/BindObjectMetadataToRequest.java @@ -59,7 +59,7 @@ public class BindObjectMetadataToRequest implements Binder { request = metadataPrefixer.bindToRequest(request, md.getUserMetadata()); - Builder headers = ImmutableMultimap. builder(); + Builder headers = ImmutableMultimap.builder(); if (md.getCacheControl() != null) { headers.put(HttpHeaders.CACHE_CONTROL, md.getCacheControl()); } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java index 396ca42676..43b85e60b2 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java @@ -57,7 +57,7 @@ public class BindAzureBlobMetadataToRequest implements Binder { checkArgument(blob.getPayload().getContentMetadata().getContentLength() != null && blob.getPayload().getContentMetadata().getContentLength() >= 0, "size must be set"); - Builder headers = ImmutableMap. builder(); + Builder headers = ImmutableMap.builder(); headers.put("x-ms-blob-type", blob.getProperties().getType().toString()); diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerPropertiesBuilder.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerPropertiesBuilder.java index cc6b7ed6f7..142ddb9df6 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerPropertiesBuilder.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerPropertiesBuilder.java @@ -57,7 +57,7 @@ public class SoftLayerPropertiesBuilder extends PropertiesBuilder { // 10, 100, 1000 properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "10"); properties.setProperty(PROPERTY_ISO3166_CODES, "SG,NL,US-CA,US-TX,US-VA,US-WA,US-TX"); - Builder prices = ImmutableSet. builder(); + Builder prices = ImmutableSet.builder(); prices.add("21"); // 1 IP Address prices.add("55"); // Host Ping: categoryCode: monitoring, notification prices.add("57"); // Email and Ticket: categoryCode: notification diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java index 528f334b5e..74a334199d 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java @@ -146,7 +146,7 @@ public class SoftLayerComputeServiceAdapter implements } private Iterable getPrices(Template template) { - Builder result = ImmutableSet. builder(); + Builder result = ImmutableSet.builder(); int imageId = Integer.parseInt(template.getImage().getId()); result.add(ProductItemPrice.builder().id(imageId).build()); @@ -167,7 +167,7 @@ public class SoftLayerComputeServiceAdapter implements public Iterable> listHardwareProfiles() { ProductPackage productPackage = productPackageSupplier.get(); Set items = productPackage.getItems(); - Builder> result = ImmutableSet.> builder(); + Builder> result = ImmutableSet.builder(); for (ProductItem cpuItem : filter(items, matches(cpuPattern))) { for (ProductItem ramItem : filter(items, categoryCode("ram"))) { for (ProductItem sanItem : filter(items, and(matches(disk0Type), categoryCode("guest_disk0")))) { diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterClientLiveTest.java index 786b9b9100..77ca945ab6 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterClientLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterClientLiveTest.java @@ -61,7 +61,7 @@ public class DatacenterClientLiveTest extends BaseSoftLayerClientLiveTest { @Test public void testListDatacentersContent() { - Builder builder = ImmutableSet. builder(); + Builder builder = ImmutableSet.builder(); builder.add(Datacenter.builder().id(265592).name("ams01").longName("Amsterdam 1").build()); builder.add(Datacenter.builder().id(3).name("dal01").longName("Dallas").build()); builder.add(Datacenter.builder().id(18171).name("sea01").longName("Seattle").build()); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java index 41db69da16..791a9cd1ea 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java @@ -116,7 +116,7 @@ public class VirtualGuestClientLiveTest extends BaseSoftLayerClientLiveTest { ProductItemPrice osPrice = ProductItems.price().apply( osToProductItem.get("Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (64 bit)")); - Builder prices = ImmutableSet. builder(); + Builder prices = ImmutableSet.builder(); prices.addAll(Guice.createInjector(module).getInstance(Key.get(new TypeLiteral>() { }))); prices.add(ramPrice); diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandler.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandler.java index 68340ba8df..139a64f998 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandler.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandler.java @@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableMap.Builder; public class TagNameToUsageCountHandler extends ParseSax.HandlerWithResult> { protected StringBuilder currentText = new StringBuilder(); - private Builder builder = ImmutableMap. builder(); + private Builder builder = ImmutableMap.builder(); private String name; public Map getResult() { diff --git a/sandbox-apis/simpledb/src/main/java/org/jclouds/simpledb/binders/BindAttributesToIndexedFormParams.java b/sandbox-apis/simpledb/src/main/java/org/jclouds/simpledb/binders/BindAttributesToIndexedFormParams.java index 660c380e76..cfba32053f 100644 --- a/sandbox-apis/simpledb/src/main/java/org/jclouds/simpledb/binders/BindAttributesToIndexedFormParams.java +++ b/sandbox-apis/simpledb/src/main/java/org/jclouds/simpledb/binders/BindAttributesToIndexedFormParams.java @@ -49,7 +49,7 @@ public class BindAttributesToIndexedFormParams implements Binder { checkArgument(checkNotNull(input, "input") instanceof Item, "this binder is only valid for AttributeMap"); Item attributeMap = (Item) input; - Builder builder = ImmutableMultimap. builder(); + Builder builder = ImmutableMultimap.builder(); int amazonOneBasedIndex = 1; // according to docs, counters must start with 1 for (String itemName : attributeMap.getAttributes().keySet()) { diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/ScriptBuilder.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/ScriptBuilder.java index 6b29ac5966..7c71ce85fc 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/ScriptBuilder.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/ScriptBuilder.java @@ -153,7 +153,7 @@ public class ScriptBuilder implements Statement, AcceptsStatementVisitor { @VisibleForTesting public static Map resolveFunctionDependenciesForStatements(Map knownFunctions, Iterable statements, final OsFamily osFamily) { - Builder builder = ImmutableMap. builder(); + Builder builder = ImmutableMap.builder(); builder.putAll(knownFunctions); Set dependentFunctions = ImmutableSet.copyOf(Iterables.concat(Iterables.transform(statements, new Function>() { diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/CreateRunScript.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/CreateRunScript.java index ad680797e4..0678107bd5 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/CreateRunScript.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/CreateRunScript.java @@ -121,7 +121,7 @@ public class CreateRunScript extends StatementList { private void addUnixRunScript(String runScript, StringBuilder builder) { builder.append("# add desired commands from the user\n"); - Builder userCommands = ImmutableList.builder(); + Builder userCommands = ImmutableList.builder(); userCommands.add("cd " + pwd); for (Statement statement : statements) { if (statement instanceof Call @@ -137,7 +137,7 @@ public class CreateRunScript extends StatementList { private void addUnixRunScriptHeader(String runScript, StringBuilder builder) { builder.append("# create runscript header\n"); - Builder beginningOfFile = ImmutableList. builder(); + Builder beginningOfFile = ImmutableList.builder(); beginningOfFile.addAll(Splitter.on(ShellToken.LF.to(OsFamily.UNIX)).split( ShellToken.BEGIN_SCRIPT.to(OsFamily.UNIX))); beginningOfFile.add(format("PROMPT_COMMAND='echo -ne \\\"\\033]0;%s\\007\\\"'", instanceName)); diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementList.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementList.java index db5f4a3aaa..60b1c924f9 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementList.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementList.java @@ -53,7 +53,7 @@ public class StatementList extends ForwardingList implements Statemen @Override public Iterable functionDependencies(OsFamily family) { - Builder functions = ImmutableList. builder(); + Builder functions = ImmutableList.builder(); for (Statement statement : delegate()) { functions.addAll(statement.functionDependencies(family)); } diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java index f222bc8b0b..4c7237e830 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java @@ -361,7 +361,7 @@ public class AdminAccess implements Statement { checkNotNull(config.getAdminPrivateKey(), "adminPrivateKey"); checkNotNull(config.getLoginPassword(), "loginPassword"); - ImmutableList.Builder statements = ImmutableList. builder(); + ImmutableList.Builder statements = ImmutableList.builder(); UserAdd.Builder userBuilder = UserAdd.builder(); userBuilder.login(config.getAdminUsername()); if (config.shouldAuthorizeAdminPublicKey()) diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/Sudoers.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/Sudoers.java index 12c9840235..a519a26041 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/Sudoers.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/Sudoers.java @@ -44,7 +44,7 @@ public class Sudoers implements Statement { checkNotNull(family, "family"); if (family == OsFamily.WINDOWS) throw new UnsupportedOperationException("windows not yet implemented"); - Builder statements = ImmutableList. builder(); + Builder statements = ImmutableList.builder(); statements.add(createOrOverwriteFile(sudoers, ImmutableSet.of("root ALL = (ALL) ALL", "%wheel ALL = (ALL) NOPASSWD:ALL"))); statements.add(exec("chmod 0440 " + sudoers)); return new StatementList(statements.build()).render(family); diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/UserAdd.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/UserAdd.java index 20acff8053..22dccd9492 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/UserAdd.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/UserAdd.java @@ -160,11 +160,11 @@ public class UserAdd implements Statement { if (family == OsFamily.WINDOWS) throw new UnsupportedOperationException("windows not yet implemented"); String homeDir = defaultHome + "{fs}" + login; - ImmutableList.Builder statements = ImmutableList. builder(); + ImmutableList.Builder statements = ImmutableList.builder(); // useradd cannot create the default homedir statements.add(Statements.exec("{md} " + defaultHome)); - ImmutableMap.Builder userAddOptions = ImmutableMap. builder(); + ImmutableMap.Builder userAddOptions = ImmutableMap.builder(); userAddOptions.put("-s", shell); if (groups.size() > 0) { for (String group : groups) diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/AuthorizeRSAPublicKeys.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/AuthorizeRSAPublicKeys.java index 7d3b43bb24..fabf96a37a 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/AuthorizeRSAPublicKeys.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/AuthorizeRSAPublicKeys.java @@ -61,11 +61,11 @@ public class AuthorizeRSAPublicKeys implements Statement { checkNotNull(family, "family"); if (family == OsFamily.WINDOWS) throw new UnsupportedOperationException("windows not yet implemented"); - Builder statements = ImmutableList. builder(); + Builder statements = ImmutableList.builder(); statements.add(exec("mkdir -p " + sshDir)); String authorizedKeys = sshDir + "{fs}authorized_keys"; statements.add(appendFile(authorizedKeys, Splitter.on('\n').split(Joiner.on("\n\n").join(publicKeys)))); statements.add(exec("chmod 600 " + authorizedKeys)); return new StatementList(statements.build()).render(family); } -} \ No newline at end of file +} diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/InstallRSAPrivateKey.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/InstallRSAPrivateKey.java index c603842750..4a999e9131 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/InstallRSAPrivateKey.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/InstallRSAPrivateKey.java @@ -59,7 +59,7 @@ public class InstallRSAPrivateKey implements Statement { checkNotNull(family, "family"); if (family == OsFamily.WINDOWS) throw new UnsupportedOperationException("windows not yet implemented"); - Builder statements = ImmutableList. builder(); + Builder statements = ImmutableList.builder(); statements.add(exec("{md} " + sshDir)); String idRsa = sshDir + "{fs}id_rsa"; statements.add(exec("{rm} " + idRsa)); From 6128947c7e96134668a2b761c04eef6366d74e4f Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 3 Apr 2012 16:18:36 +0100 Subject: [PATCH 02/69] Issue 830: Minor updates --- .../vcloud/director/v1_5/domain/EntityType.java | 3 ++- .../director/v1_5/AbstractVAppClientLiveTest.java | 3 --- .../features/admin/AdminNetworkClientLiveTest.java | 13 ++++++++----- .../v1_5/features/admin/GroupClientExpectTest.java | 1 - .../v1_5/features/admin/UserClientExpectTest.java | 1 - 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index ad0f55efb0..59f7985d8a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -114,7 +114,8 @@ public class EntityType extends ResourceType { public B fromEntityType(EntityType in) { return fromResourceType(in) - .description(in.getDescription()).tasks(in.getTasks()) + .description(in.getDescription()) + .tasks(in.getTasks()) .id(in.getId()).name(in.getName()); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java index 0cdebc057e..cc54b2e817 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java @@ -33,7 +33,6 @@ import java.math.BigInteger; import java.net.URI; import java.util.List; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; @@ -55,7 +54,6 @@ import org.jclouds.vcloud.director.v1_5.features.QueryClient; import org.jclouds.vcloud.director.v1_5.features.VAppClient; import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; import org.jclouds.vcloud.director.v1_5.features.VdcClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataClient.Writeable; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates; import org.jclouds.xml.internal.JAXBParser; @@ -335,7 +333,6 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien JAXBParser parser = new JAXBParser(); try { String xml = parser.toXML(object); - logger.debug(Strings.padStart(Strings.padEnd(" " + object.getClass().toString() + " ", 70, '-'), 80, '-')); logger.debug(xml); logger.debug(Strings.repeat("-", 80)); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java index 59f8eaf2b0..8534ade8e1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java @@ -28,6 +28,8 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; +import java.util.Collections; + import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.ExternalNetwork; import org.jclouds.vcloud.director.v1_5.domain.IpScope; @@ -94,9 +96,10 @@ public class AdminNetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest //TODO: ensure network instanceof OrgNetwork, may require queries assertTrue(network instanceof OrgNetwork, String.format(REF_REQ_LIVE, "OrgNetwork")); - OrgNetwork oldNetwork = Network.toSubType(network).toBuilder() - .tasks(null) - .build(); + OrgNetwork oldNetwork = Network.toSubType(network) + .toBuilder() + .tasks(Collections.emptySet()) + .build(); OrgNetwork updateNetwork = getMutatedOrgNetwork(oldNetwork); @@ -159,8 +162,8 @@ public class AdminNetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest private static OrgNetwork getMutatedOrgNetwork(OrgNetwork network) { OrgNetwork.Builder networkBuilder = OrgNetwork.builder().fromNetwork(network) - .tasks(null) -// .name("new "+network.getName()) + .tasks(Collections.emptySet()) +// .name("new "+network.getName()) .description("new "+network.getDescription()) .configuration(getMutatedNetworkConfiguration(network.getConfiguration())); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java index 0c7e470861..96e49a777b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java @@ -26,7 +26,6 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.domain.Group; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.features.admin.GroupClient; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java index 77aa954f92..6fae492e4c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java @@ -29,7 +29,6 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.User; -import org.jclouds.vcloud.director.v1_5.features.admin.UserClient; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; From 411b14eddc703e37787fb955d9869f2776a8a05d Mon Sep 17 00:00:00 2001 From: Dirk Hogan Date: Mon, 9 Apr 2012 08:44:22 -0700 Subject: [PATCH 03/69] add aliases for extension namespaces --- ...paceEqualsAnyNamespaceInExtensionsSet.java | 17 +++++++++- .../v1_1/predicates/ExtensionPredicates.java | 27 +++++++++++++++ ...EqualsAnyNamespaceInExtensionsSetTest.java | 34 ++++++++++++------- 3 files changed, 65 insertions(+), 13 deletions(-) diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.java index 16aab0b7b7..30d365d278 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.java @@ -25,16 +25,20 @@ import java.net.URI; import java.util.Set; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.internal.ClassMethodArgsAndReturnVal; import org.jclouds.openstack.nova.v1_1.domain.Extension; +import org.jclouds.openstack.nova.v1_1.extensions.ExtensionNamespaces; import org.jclouds.openstack.nova.v1_1.predicates.ExtensionPredicates; import org.jclouds.rest.functions.ImplicitOptionalConverter; import com.google.common.base.Optional; import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; /** * We use the annotation {@link org.jclouds.openstack.services.Extension} to @@ -49,6 +53,17 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio ImplicitOptionalConverter { private final LoadingCache> extensions; + @com.google.inject.Inject(optional=true) + @Named("openstack.nova.extensions") + Multimap aliases = ImmutableMultimap.builder() + .put(URI.create(ExtensionNamespaces.SECURITY_GROUPS), + URI.create("http://docs.openstack.org/compute/ext/securitygroups/api/v1.1")) + .put(URI.create(ExtensionNamespaces.FLOATING_IPS), + URI.create("http://docs.openstack.org/compute/ext/floating_ips/api/v1.1")) + .put(URI.create(ExtensionNamespaces.KEYPAIRS), + URI.create("http://docs.openstack.org/compute/ext/keypairs/api/v1.1")) + .build(); + @Inject public PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet( LoadingCache> extensions) { @@ -63,7 +78,7 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio checkState(input.getArgs() != null && input.getArgs().length == 1, "expecting an arg %s", input); URI namespace = URI.create(ext.get().namespace()); if (Iterables.any(extensions.getUnchecked(checkNotNull(input.getArgs()[0], "arg[0] in %s", input).toString()), - ExtensionPredicates.namespaceEquals(namespace))) + ExtensionPredicates.namespaceOrAliasEquals(namespace, aliases.get(namespace)))) return Optional.of(input.getReturnVal()); } return Optional.absent(); diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/predicates/ExtensionPredicates.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/predicates/ExtensionPredicates.java index aac9bbfe90..74f14fae2b 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/predicates/ExtensionPredicates.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/predicates/ExtensionPredicates.java @@ -21,6 +21,7 @@ package org.jclouds.openstack.nova.v1_1.predicates; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Collection; import org.jclouds.openstack.nova.v1_1.domain.Extension; @@ -78,5 +79,31 @@ public class ExtensionPredicates { return "aliasEquals(" + alias + ")"; } }; + } + /** + * matches namespace of the given extension + * + * @param namespace + * ex {@code http://docs.openstack.org/ext/keypairs/api/v1.1} + * @param namespacesAliases + * Collection of ex {@code http://docs.openstack.org/compute/ext/keypairs/api/v1.1} + * @return predicate that will match namespace of the given extension + */ + public static Predicate namespaceOrAliasEquals(final URI namespace, final Collection namespaceAliases) { + checkNotNull(namespace, "namespace must be defined"); + checkNotNull(namespaceAliases, "namespace aliases must be defined"); + + return new Predicate() { + @Override + public boolean apply(Extension ext) { + return namespace.toASCIIString().equals(ext.getNamespace().toASCIIString().replace("https", "http")) || + namespaceAliases.contains(ext.getNamespace()); + } + + @Override + public String toString() { + return "namespaceOrAliasEquals(" + namespace + ")"; + } + }; } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java index d4b973ba4f..73f1db16d0 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java @@ -5,6 +5,8 @@ import static org.testng.Assert.assertEquals; import java.net.URI; import java.util.Set; +import javax.inject.Named; + import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.internal.ClassMethodArgsAndReturnVal; import org.jclouds.openstack.nova.v1_1.domain.Extension; @@ -23,6 +25,9 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Provides; /** * @author Adrian Cole @@ -93,7 +98,6 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio * of the authoritative namespace to alternate onces, which could be wired up with guice * */ - @Test(enabled = false) public void testPresentWhenAliasForExtensionMapsToNamespace() throws SecurityException, NoSuchMethodException { Extension keypairsWithDifferentNamespace = keypairs.toBuilder().namespace( URI.create("http://docs.openstack.org/ext/arbitrarilydifferent/keypairs/api/v1.1")).build(); @@ -102,29 +106,35 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio .getNamespace()); assertEquals(whenExtensionsAndAliasesInclude(ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply( - getFloatingIPExtension()), Optional.of("foo")); + getKeyPairExtension()), Optional.of("foo")); + assertEquals(whenExtensionsAndAliasesInclude(ImmutableSet.of(keypairsWithDifferentNamespace), aliases).apply( + getFloatingIPExtension()), Optional.absent()); } - // - private PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet whenExtensionsInclude( Extension... extensions) { return whenExtensionsAndAliasesInclude(ImmutableSet.copyOf(extensions), ImmutableMultimap. of()); } private PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet whenExtensionsAndAliasesInclude( - Set extensions, Multimap aliases) { - LoadingCache> extensionsForZone = CacheBuilder.newBuilder().build( + final Set extensions, final Multimap aliases) { + final LoadingCache> extensionsForZone = CacheBuilder.newBuilder().build( CacheLoader.from(Functions.forMap(ImmutableMap.of("expectedzone", extensions, "differentzone", ImmutableSet. of())))); - PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet fn = new PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet( - extensionsForZone); - // TODO: change the constructor to accept aliases, or add an @Inject(optional=true) field inside the class - // PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet fn = new - // PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet( - // extensionsForZone, aliases); + PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet fn = Guice.createInjector(new AbstractModule() { + @Override + protected void configure() {} + + @Provides + LoadingCache> getExtensions() { return extensionsForZone;} + + @Provides + @Named("openstack.nova.extensions") + Multimap getAliases() { return aliases;} + }).getInstance(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class); + return fn; } } From facc48f2a61021de56b8c53ccdf249ea9ed805f5 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 9 Apr 2012 15:37:17 +0100 Subject: [PATCH 04/69] eliminate/reduce need for vcloud properties --- .../v1_5/domain/ControlAccessParams.java | 25 ++++--- .../director/v1_5/features/QueryClient.java | 2 +- .../v1_5/AbstractVAppClientLiveTest.java | 5 +- .../v1_5/VCloudDirectorLiveTestConstants.java | 2 + .../vcloud/director/v1_5/domain/Checks.java | 3 + .../v1_5/features/OrgClientLiveTest.java | 45 ++++++++---- .../v1_5/features/VAppClientLiveTest.java | 72 ++++++++++++++++++- .../admin/AdminCatalogClientLiveTest.java | 4 +- 8 files changed, 131 insertions(+), 27 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java index 6272246149..de030657e9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java @@ -21,6 +21,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Collections; +import java.util.List; import java.util.Set; import javax.xml.bind.annotation.XmlElement; @@ -29,7 +31,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import com.google.common.collect.Sets; /** @@ -57,7 +60,7 @@ public class ControlAccessParams { private Boolean sharedToEveryone = Boolean.FALSE; private String everyoneAccessLevel; - private Set accessSettings = Sets.newLinkedHashSet(); + private Set accessSettings; /** * @see ControlAccessParams#getIsSharedToEveryone() @@ -95,7 +98,7 @@ public class ControlAccessParams { * @see ControlAccessParams#getAccessSettings() */ public Builder accessSettings(Iterable accessSettings) { - this.accessSettings = Sets.newLinkedHashSet(checkNotNull(accessSettings, "accessSettings")); + this.accessSettings = Sets.newLinkedHashSet(checkNotNull(accessSettings)); return this; } @@ -103,7 +106,10 @@ public class ControlAccessParams { * @see ControlAccessParams#getAccessSettings() */ public Builder accessSetting(AccessSetting accessSetting) { - this.accessSettings.add(checkNotNull(accessSetting, "accessSetting")); + if (accessSettings == null) { + accessSettings = Sets.newLinkedHashSet(); + } + accessSettings.add(checkNotNull(accessSetting, "accessSetting")); return this; } @@ -124,7 +130,10 @@ public class ControlAccessParams { public ControlAccessParams(Boolean sharedToEveryone, String everyoneAccessLevel, Iterable accessSettings) { this.sharedToEveryone = sharedToEveryone; this.everyoneAccessLevel = everyoneAccessLevel; - this.accessSettings = accessSettings == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(accessSettings); + if (sharedToEveryone) { + checkNotNull(accessSettings, "accessSettings"); + } + this.accessSettings = Iterables.isEmpty(accessSettings) ? null : ImmutableList.copyOf(accessSettings); } @XmlElement(name = "IsSharedToEveryone", required = true) @@ -133,7 +142,7 @@ public class ControlAccessParams { protected String everyoneAccessLevel; @XmlElementWrapper(name = "AccessSettings") @XmlElement(name = "AccessSetting") - protected Set accessSettings = Sets.newLinkedHashSet(); + protected List accessSettings; /** * If true, this means that the resource is shared with everyone in the organization. @@ -156,8 +165,8 @@ public class ControlAccessParams { * * Required on create and modify if {@link #isSharedToEveryone()} is false. */ - public Set getAccessSettings() { - return accessSettings; + public List getAccessSettings() { + return accessSettings == null ? Collections.emptyList() : accessSettings; } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryClient.java index 106ebf6100..8944251a2f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryClient.java @@ -178,7 +178,7 @@ public interface QueryClient { QueryResultRecords vmsQuery(String filter); /** - * Retrieves a list of {@link Medias by using REST API general QueryHandler. + * Retrieves a list of {@link Media}s by using REST API general QueryHandler. * *
     * GET /mediaList/query
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java
index cc54b2e817..4ed4d2cb73 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java
@@ -106,8 +106,8 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
     *
     * @see BaseVCloudDirectorClientLiveTest#setupRequiredClients()
     */
-   @BeforeClass(alwaysRun = true, description = "Retrieves the required clients from the REST API context")
    @Override
+   @BeforeClass(alwaysRun = true, description = "Retrieves the required clients from the REST API context")
    protected void setupRequiredClients() {
       assertNotNull(context.getApi());
 
@@ -116,6 +116,8 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
       vAppClient = context.getApi().getVAppClient();
       vAppTemplateClient = context.getApi().getVAppTemplateClient();
       vdcClient = context.getApi().getVdcClient();
+      
+      setupEnvironment();
    }
 
    /**
@@ -124,7 +126,6 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
     * Retrieves the test {@link Vdc} and {@link VAppTemplate} from their configured {@link URI}s.
     * Instantiates a new test VApp.
     */
-   @BeforeClass(alwaysRun = true, description = "Sets up the environment", dependsOnMethods = { "setupRequiredClients" })
    protected void setupEnvironment() {
       // Get the configured Vdc for the tests
       vdc = vdcClient.getVdc(vdcURI);
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java
index d92ce1c695..a7e7236134 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java
@@ -48,6 +48,8 @@ public class VCloudDirectorLiveTestConstants {
    public static final String OBJ_FIELD_CONTAINS = "ERR-107: %s %s must contain the values \"%s\" (%s)";
 
    public static final String OBJ_FIELD_GTE_0 = "ERR-108: %s field %s must be greater than to equal to 0 (%d)";
+   
+   public static final String OBJ_FIELD_GTE_1 = "ERR-108: %s field %s must be greater than to equal to 0 (%d)";
 
    public static final String GETTER_RETURNS_SAME_OBJ = "ERR-109: %s should return the same %s as %s (%s, %s)";
 
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java
index 41a30749a4..1fa7d6d113 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java
@@ -30,6 +30,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_ATTRB_REQ;
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0;
+import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_1;
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_FMT;
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT;
@@ -684,6 +685,8 @@ public class Checks {
       // Check optional fields, dependant on IsSharedToEveryone state
       if (params.isSharedToEveryone()) {
          assertNotNull(params.getEveryoneAccessLevel(), String.format(OBJ_FIELD_REQ, "ControlAccessParams", "EveryoneAccessLevel"));
+         assertNotNull(params.getAccessSettings(), String.format(OBJ_FIELD_REQ, "ControlAccessParams", "AccessSettings when isSharedToEveryone"));
+         assertTrue(params.getAccessSettings().size() >= 1, String.format(OBJ_FIELD_GTE_1, "ControlAccessParams", "AccessSettings.size", params.getAccessSettings().size()));
       } else {
          for (AccessSetting setting : params.getAccessSettings()) {
             checkAccessSetting(setting);
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java
index a709f4cfbc..b40961672f 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java
@@ -33,6 +33,7 @@ import static org.testng.Assert.assertNotNull;
 import java.net.URI;
 
 import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
+import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
 import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
 import org.jclouds.vcloud.director.v1_5.domain.Metadata;
 import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
@@ -59,29 +60,35 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
     */
 
    private OrgClient orgClient;
+   private URI catalogRef;
+   private String testCatalogId;
 
    @Override
    @BeforeClass(alwaysRun = true)
    public void setupRequiredClients() {
       orgClient = context.getApi().getOrgClient();
+      testCatalogId = catalogId;
    }
    
    @AfterClass(alwaysRun = true)
    public void cleanUp() throws Exception {
-      if (metadataSet) {
+      if (adminMembersSet) {
          adminContext.getApi().getOrgClient().getMetadataClient()
             .deleteMetadataEntry(toAdminUri(orgURI), "KEY");
+         
+         adminContext.getApi().getCatalogClient()
+            .deleteCatalog(catalogRef);
       }
    }
 
    /*
-    * Shared state between dependant tests.
+    * Shared state between dependent tests.
     */
 
    private OrgList orgList;
    private URI orgURI;
    private Org org;
-   private boolean metadataSet = false;
+   private boolean adminMembersSet = false; // track if test entities have been created
 
    @Test(description = "GET /org")
    public void testGetOrgList() {
@@ -110,19 +117,33 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
       org = orgClient.getOrg(orgURI);
 
       checkOrg(org);
+      
+      if (adminContext != null) {
+         setupAdminMembers();
+      }
    }
    
-   private void setupMetadata() {
+   /**
+    * If we're running in an admin context, it's cleaner to make temporary entities, plus eliminates the need for configuration
+    */
+   private void setupAdminMembers() {
       adminContext.getApi().getOrgClient().getMetadataClient().setMetadata(toAdminUri(orgURI), 
-            "KEY", MetadataValue.builder().value("VALUE").build()); 
-      metadataSet = true;
+            "KEY", MetadataValue.builder().value("VALUE").build());
+      
+      AdminCatalog newCatalog = AdminCatalog.builder()
+            .name("Test Catalog "+getTestDateTimeStamp())
+            .description("created by testOrg()")
+            .build();
+      newCatalog = adminContext.getApi().getCatalogClient().createCatalog(toAdminUri(orgURI), newCatalog);
+      
+      catalogRef = newCatalog.getHref();
+      testCatalogId = newCatalog.getId().substring("urn:vcloud:catalog:".length()); 
+      
+      adminMembersSet = true;
    }
    
    @Test(description = "GET /org/{id}/metadata", dependsOnMethods = { "testGetOrg" })
    public void testGetOrgMetadata() {
-      if (adminContext != null) {
-         setupMetadata();
-      }
       
       // Call the method being tested
       Metadata metadata = orgClient.getMetadataClient().getMetadata(orgURI);
@@ -151,7 +172,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
    @Test(description = "GET /org/{id}/catalog/{catalogId}/controlAccess", dependsOnMethods = { "testGetOrg" })
    public void testGetControlAccess() {
       // Call the method being tested
-      ControlAccessParams params = orgClient.getControlAccess(orgURI, catalogId);
+      ControlAccessParams params = orgClient.getControlAccess(orgURI, testCatalogId);
 
       // Check params are well formed
       checkControlAccessParams(params);
@@ -160,10 +181,10 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
    @Test(description = "GET /org/{id}/catalog/{catalogId}/action/controlAccess", dependsOnMethods = { "testGetControlAccess" })
    public void testModifyControlAccess() {
       // Setup params
-      ControlAccessParams params = orgClient.getControlAccess(orgURI, catalogId);
+      ControlAccessParams params = orgClient.getControlAccess(orgURI, testCatalogId);
 
       // Call the method being tested
-      ControlAccessParams modified = orgClient.modifyControlAccess(orgURI, catalogId, params);
+      ControlAccessParams modified = orgClient.modifyControlAccess(orgURI, testCatalogId, params);
 
       // Check params are well formed
       checkControlAccessParams(modified);
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java
index bfbe0a753f..ade21eef5c 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java
@@ -18,6 +18,10 @@
  */
 package org.jclouds.vcloud.director.v1_5.features;
 
+import static com.google.common.base.Predicates.and;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.contains;
+import static com.google.common.collect.Iterables.getFirst;
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CONDITION_FMT;
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CORRECT_VALUE_OBJECT_FMT;
 import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_EQUAL;
@@ -49,6 +53,8 @@ import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkStartupSection
 import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVApp;
 import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVirtualHardwareSection;
 import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVmPendingQuestion;
+import static org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates.relEquals;
+import static org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates.typeEquals;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
@@ -62,14 +68,18 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
+import org.jclouds.io.Payloads;
 import org.jclouds.vcloud.director.v1_5.AbstractVAppClientLiveTest;
 import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
+import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
 import org.jclouds.vcloud.director.v1_5.domain.AccessSetting;
 import org.jclouds.vcloud.director.v1_5.domain.Checks;
 import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
 import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams;
 import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
 import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection;
+import org.jclouds.vcloud.director.v1_5.domain.Link;
+import org.jclouds.vcloud.director.v1_5.domain.Media;
 import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams;
 import org.jclouds.vcloud.director.v1_5.domain.Metadata;
 import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
@@ -103,6 +113,8 @@ import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
 import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
 import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
 import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Function;
@@ -121,6 +133,62 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
 
    private MetadataValue metadataValue;
    private String key;
+   private URI mediaURI;
+   private URI testUserURI;
+   
+   @Override
+   @BeforeClass(alwaysRun = true)
+   protected void setupRequiredClients() {
+      super.setupRequiredClients();
+      
+      Set links = vdcClient.getVdc(vdcURI).getLinks();
+      Predicate addMediaLink = and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA));
+      
+      if (contains(links, addMediaLink)) {
+         Link addMedia = find(links, addMediaLink);
+         byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+         
+         Media sourceMedia = Media.builder()
+               .type(VCloudDirectorMediaType.MEDIA)
+               .name("Test media "+random.nextInt())
+               .size(iso.length)
+               .imageType(Media.ImageType.ISO)
+               .description("Test media generated by vAppClientLiveTest")
+               .build();
+         Media media = context.getApi().getMediaClient().createMedia(addMedia.getHref(), sourceMedia);
+         
+         Link uploadLink = getFirst(getFirst(media.getFiles(), null).getLinks(), null);
+         context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso));
+         
+         media = context.getApi().getMediaClient().getMedia(media.getHref());
+         
+         if (media.getTasks().size() == 1) {
+            Task uploadTask = Iterables.getOnlyElement(media.getTasks());
+            Checks.checkTask(uploadTask);
+            assertEquals(uploadTask.getStatus(), "running");
+            assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask"));
+            media = context.getApi().getMediaClient().getMedia(media.getHref());
+         }
+         
+         mediaURI = media.getHref();
+      } else {
+         mediaURI = super.mediaURI;
+      }
+      
+      if (adminContext != null) {
+         Link orgLink = find(links, and(relEquals("up"), typeEquals(VCloudDirectorMediaType.ORG)));
+         testUserURI = adminContext.getApi().getUserClient().createUser(toAdminUri(orgLink), randomTestUser("VAppAccessTest")).getHref();
+      } else {
+         testUserURI = userURI;
+      }
+   }
+   
+   @AfterClass(alwaysRun = true)
+   public void cleanUp() {
+      if (adminContext != null && mediaURI != null) {
+         assertTaskDoneEventually(context.getApi().getMediaClient().deleteMedia(mediaURI));
+      }
+   }
 
    /**
     * @see VAppClient#getVApp(URI)
@@ -326,7 +394,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
       ControlAccessParams params = ControlAccessParams.builder()
             .notSharedToEveryone()
             .accessSetting(AccessSetting.builder()
-                  .subject(Reference.builder().href(userURI).type(ADMIN_USER).build())
+                  .subject(Reference.builder().href(testUserURI).type(ADMIN_USER).build())
                   .accessLevel("ReadOnly")
                   .build())
             .build();
@@ -725,7 +793,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
 
    @Test(description = "PUT /vApp/{id}/owner", dependsOnMethods = { "testGetOwner" })
    public void testModifyOwner() {
-      Owner newOwner = Owner.builder().user(Reference.builder().href(userURI).type(ADMIN_USER).build()).build();
+      Owner newOwner = Owner.builder().user(Reference.builder().href(testUserURI).type(ADMIN_USER).build()).build();
 
       // The method under test
       vAppClient.modifyOwner(vApp.getHref(), newOwner);
diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java
index 70d8b54233..6a6b19ef2c 100644
--- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java
+++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java
@@ -84,8 +84,8 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
    protected void tidyUp() {
       if (catalog != null) {
          catalogClient.deleteCatalog(catalog.getHref());
-         try {
-            catalogClient.getCatalog(catalog.getHref());
+         try { //TODO: predicate to retry for a short while?
+            catalogClient.getCatalog(catalog.getHref()); 
             fail("The Catalog should have been deleted");
          } catch (VCloudDirectorException vcde) {
             checkError(vcde.getError());

From 344099b0f40a0d1d8eaded38317d58ab1d5a7148 Mon Sep 17 00:00:00 2001
From: Matt Stephenson 
Date: Mon, 9 Apr 2012 13:59:25 -0700
Subject: [PATCH 05/69] Construct a fully populated Server object before
 returning it back from the NovaComputeServiceAdapter in Openstack-nova

---
 .../compute/NovaComputeServiceAdapter.java    |  7 ++++-
 .../NovaComputeServiceAdapterExpectTest.java  | 31 ++++++++++++++++---
 .../compute/NovaComputeServiceExpectTest.java | 15 +++++++++
 3 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapter.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapter.java
index 409cebf306..5dc476a9d0 100644
--- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapter.java
+++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapter.java
@@ -119,7 +119,12 @@ public class NovaComputeServiceAdapter implements
       String flavorId = template.getHardware().getProviderId();
 
       logger.debug(">> creating new server zone(%s) name(%s) image(%s) flavor(%s) options(%s)", zoneId, name, imageId, flavorId, options);
-      Server server = novaClient.getServerClientForZone(zoneId).createServer(name, imageId, flavorId, options);
+      Server lightweightServer = novaClient.getServerClientForZone(zoneId).createServer(name, imageId, flavorId, options);
+      Server heavyweightServer = novaClient.getServerClientForZone(zoneId).getServer(lightweightServer.getId());
+      Server server = Server.builder().fromServer(heavyweightServer)
+                                      .adminPass(lightweightServer.getAdminPass())
+                                      .build();
+
       logger.trace("<< server(%s)", server.getId());
 
       ServerInZone serverInZone = new ServerInZone(server, zoneId);
diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java
index b8e1e6ec5a..5ffe5deb98 100644
--- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java
+++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java
@@ -66,17 +66,27 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
                   "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group2\"},{\"name\":\"group1\"}]}}","application/json"))
          .build();
 
-  
       HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
          .payload(payloadFromResourceWithContentType("/new_server.json","application/json; charset=UTF-8")).build();
 
-         
+      HttpRequest serverDetail = HttpRequest
+            .builder()
+            .method("GET")
+            .endpoint(URI.create("https://compute.north.host/v1.1/3456/servers/71752"))
+            .headers(
+                  ImmutableMultimap. builder().put("Accept", "application/json")
+                        .put("X-Auth-Token", authToken).build()).build();
+
+      HttpResponse serverDetailResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/server_details.json")).build();
+
       Map requestResponseMap = ImmutableMap. builder()
                .put(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess)
                .put(extensionsOfNovaRequest, extensionsOfNovaResponse)
                .put(listImagesDetail, listImagesDetailResponse)
                .put(listFlavorsDetail, listFlavorsDetailResponse)
-               .put(createServer, createServerResponse).build();
+               .put(createServer, createServerResponse)
+               .put(serverDetail, serverDetailResponse).build();
 
       Injector forSecurityGroups = requestsSendResponses(requestResponseMap);
 
@@ -113,13 +123,24 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
       HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
          .payload(payloadFromResourceWithContentType("/new_server.json","application/json; charset=UTF-8")).build();
 
-         
+      HttpRequest serverDetail = HttpRequest
+            .builder()
+            .method("GET")
+            .endpoint(URI.create("https://compute.north.host/v1.1/3456/servers/71752"))
+            .headers(
+                  ImmutableMultimap. builder().put("Accept", "application/json")
+                        .put("X-Auth-Token", authToken).build()).build();
+
+      HttpResponse serverDetailResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/server_details.json")).build();
+
       Map requestResponseMap = ImmutableMap. builder()
                .put(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess)
                .put(extensionsOfNovaRequest, extensionsOfNovaResponse)
                .put(listImagesDetail, listImagesDetailResponse)
                .put(listFlavorsDetail, listFlavorsDetailResponse)
-               .put(createServer, createServerResponse).build();
+               .put(createServer, createServerResponse)
+               .put(serverDetail, serverDetailResponse).build();
 
       Injector forSecurityGroups = requestsSendResponses(requestResponseMap);
 
diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java
index fb46986b8f..23e4de0e8b 100644
--- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java
+++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java
@@ -204,6 +204,17 @@ public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTe
    HttpResponse keyPairWithPrivateKey = HttpResponse.builder().statusCode(200)
          .payload(payloadFromResource("/keypair_created_computeservice.json")).build();
 
+   HttpRequest serverDetail = HttpRequest
+         .builder()
+         .method("GET")
+         .endpoint(URI.create("https://nova-api.trystack.org:9774/v1.1/3456/servers/71752"))
+         .headers(
+               ImmutableMultimap. builder().put("Accept", "application/json")
+                     .put("X-Auth-Token", authToken).build()).build();
+
+   HttpResponse serverDetailResponse = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/server_details.json")).build();
+
    @Test
    public void testCreateNodeWithGeneratedKeyPair() throws Exception {
       Builder requestResponseMap = ImmutableMap. builder()
@@ -218,6 +229,8 @@ public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTe
 
       requestResponseMap.put(createKeyPair, keyPairWithPrivateKey);
 
+      requestResponseMap.put(serverDetail, serverDetailResponse);
+
       HttpRequest createServerWithGeneratedKeyPair = HttpRequest
             .builder()
             .method("POST")
@@ -271,6 +284,8 @@ public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTe
 
       requestResponseMap.put(getSecurityGroup, securityGroupWithPort22);
 
+      requestResponseMap.put(serverDetail, serverDetailResponse);
+
       HttpRequest createServerWithSuppliedKeyPair = HttpRequest
             .builder()
             .method("POST")

From ffeaa2feb811081551b7187f414062efc0da0f49 Mon Sep 17 00:00:00 2001
From: Adam Lowe 
Date: Wed, 28 Mar 2012 14:34:15 +0100
Subject: [PATCH 06/69] Ensuring annotation processor finds the correct async
 client method

---
 .../rest/internal/RestAnnotationProcessor.java       | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java
index 1564b57ce8..5e0566e76d 100644
--- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java
+++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java
@@ -348,7 +348,7 @@ public class RestAnnotationProcessor {
       public int hashCode() {
          final int prime = 31;
          int result = 1;
-         result = prime * result + ((declaringPackage == null) ? 0 : declaringPackage.hashCode());
+         result = prime * result + ((declaringClass == null) ? 0 : declaringClass.hashCode());
          result = prime * result + ((name == null) ? 0 : name.hashCode());
          result = prime * result + parametersTypeHashCode;
          return result;
@@ -363,10 +363,10 @@ public class RestAnnotationProcessor {
          if (getClass() != obj.getClass())
             return false;
          MethodKey other = (MethodKey) obj;
-         if (declaringPackage == null) {
-            if (other.declaringPackage != null)
+         if (declaringClass == null) {
+            if (other.declaringClass != null)
                return false;
-         } else if (!declaringPackage.equals(other.declaringPackage))
+         } else if (!declaringClass.equals(other.declaringClass))
             return false;
          if (name == null) {
             if (other.name != null)
@@ -380,11 +380,11 @@ public class RestAnnotationProcessor {
 
       private final String name;
       private final int parametersTypeHashCode;
-      private final Package declaringPackage;
+      private final Class declaringClass;
 
       public MethodKey(Method method) {
          this.name = method.getName();
-         this.declaringPackage = method.getDeclaringClass().getPackage();
+         this.declaringClass = method.getDeclaringClass();
          int parametersTypeHashCode = 0;
          for (Class param : method.getParameterTypes())
             parametersTypeHashCode += param.hashCode();

From 047662a4b1fc8edf6b3f5e72da36fd8ce74cae32 Mon Sep 17 00:00:00 2001
From: Adam Lowe 
Date: Tue, 10 Apr 2012 08:06:30 +0100
Subject: [PATCH 07/69] Test to check annotation processor finds the correct
 async client method

---
 .../internal/RestAnnotationProcessorTest.java | 42 ++++++++++++++-----
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
index d30a5a1894..a7637aa065 100644
--- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
+++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
@@ -180,7 +180,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
    @ConfiguresRestClient
    protected static class CallerModule extends RestClientModule {
       CallerModule() {
-         super(Caller.class, AsyncCaller.class, ImmutableMap., Class> of(Callee.class, AsyncCallee.class));
+         super(Caller.class, AsyncCaller.class, ImmutableMap., Class> of(Callee.class, AsyncCallee.class, Callee2.class, AsyncCallee2.class));
       }
 
       @Override
@@ -199,7 +199,14 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
       @Path("/{path}")
       ListenableFuture onePath(@PathParam("path") String path);
    }
-
+ 
+   @Path("/client/{jclouds.api-version}")
+   public static interface AsyncCallee2 {
+      @GET
+      @Path("/{path}/2")
+      ListenableFuture onePath(@PathParam("path") String path);
+   }
+   
    @Endpoint(Localhost2.class)
    @Timeout(duration = 10, timeUnit = TimeUnit.NANOSECONDS)
    public static interface Caller {
@@ -212,6 +219,9 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
       @Delegate
       public Callee getCallee();
 
+      @Delegate
+      public Callee2 getCallee2();
+      
       @Delegate
       public Callee getCallee(@EndpointParam URI endpoint);
 
@@ -224,6 +234,12 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
 
       void onePath(String path);
    }
+   
+   @Timeout(duration = 10, timeUnit = TimeUnit.NANOSECONDS)
+   public static interface Callee2 {
+      
+      void onePath(String path);
+   }
 
    public static interface AsyncCaller {
       @Provides
@@ -233,6 +249,9 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
       @Delegate
       public AsyncCallee getCallee();
 
+      @Delegate
+      public AsyncCallee2 getCallee2();
+      
       @Delegate
       public AsyncCallee getCallee(@EndpointParam URI endpoint);
 
@@ -267,14 +286,14 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
    public void testDelegateIsLazyLoadedAndRequestIncludesVersionAndPath() throws InterruptedException,
          ExecutionException {
       Injector child = injectorForCaller(new HttpCommandExecutorService() {
-
+         int callCounter=0;
          @Override
          public Future submit(HttpCommand command) {
-            assertEquals(command.getCurrentRequest().getRequestLine(),
-                  "GET http://localhost:1111/client/1/foo HTTP/1.1");
+            if (callCounter == 1) assertEquals(command.getCurrentRequest().getRequestLine(), "GET http://localhost:1111/client/1/bar/2 HTTP/1.1");
+            else assertEquals(command.getCurrentRequest().getRequestLine(), "GET http://localhost:1111/client/1/foo HTTP/1.1");
+            callCounter++;
             return Futures.immediateFuture(HttpResponse.builder().build());
          }
-
       });
 
       try {
@@ -283,10 +302,13 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
       } catch (ConfigurationException e) {
 
       }
-
-      child.getInstance(Caller.class).getCallee().onePath("foo");
-      child.getInstance(Caller.class).getCallee().onePath("foo");
-
+      
+      Caller caller =  child.getInstance(Caller.class);
+      
+      caller.getCallee().onePath("foo");
+      caller.getCallee2().onePath("bar");
+      // Note this used to result in "http://localhost:1111/client/1/foo/2"!
+      caller.getCallee().onePath("foo");
    }
 
    public void testAsyncDelegateIsLazyLoadedAndRequestIncludesEndpointVersionAndPath() throws InterruptedException,

From bae9633d23b3fdf6bf3357d5098bd89678dd866f Mon Sep 17 00:00:00 2001
From: Adam Lowe 
Date: Tue, 10 Apr 2012 08:12:40 +0100
Subject: [PATCH 08/69] Test to check annotation processor finds the correct
 async client method

---
 .../rest/internal/RestAnnotationProcessorTest.java   | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
index a7637aa065..52745c9e10 100644
--- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
+++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java
@@ -302,13 +302,11 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
       } catch (ConfigurationException e) {
 
       }
-      
-      Caller caller =  child.getInstance(Caller.class);
-      
-      caller.getCallee().onePath("foo");
-      caller.getCallee2().onePath("bar");
-      // Note this used to result in "http://localhost:1111/client/1/foo/2"!
-      caller.getCallee().onePath("foo");
+
+      child.getInstance(Caller.class).getCallee().onePath("foo");
+      child.getInstance(Caller.class).getCallee2().onePath("bar");
+      // Note if wrong method is picked up, we'll see "http://localhost:1111/client/1/foo/2"!
+      child.getInstance(Caller.class).getCallee().onePath("foo");
    }
 
    public void testAsyncDelegateIsLazyLoadedAndRequestIncludesEndpointVersionAndPath() throws InterruptedException,

From ba493257be88ba33345d153ffd5247709d4c71dc Mon Sep 17 00:00:00 2001
From: Adam Lowe 
Date: Tue, 10 Apr 2012 09:39:39 +0100
Subject: [PATCH 09/69] Adjusting default cloudwatch version for live tests

---
 apis/cloudwatch/pom.xml          | 2 +-
 providers/aws-cloudwatch/pom.xml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/apis/cloudwatch/pom.xml b/apis/cloudwatch/pom.xml
index 0a8d58437b..db881fddc7 100644
--- a/apis/cloudwatch/pom.xml
+++ b/apis/cloudwatch/pom.xml
@@ -35,7 +35,7 @@
 
   
     https://monitoring.us-east-1.amazonaws.com
-    2009-05-15
+    2010-08-01
     
     ${test.aws.identity}
     ${test.aws.credential}
diff --git a/providers/aws-cloudwatch/pom.xml b/providers/aws-cloudwatch/pom.xml
index d341f23f99..91e056c68b 100644
--- a/providers/aws-cloudwatch/pom.xml
+++ b/providers/aws-cloudwatch/pom.xml
@@ -35,7 +35,7 @@
 
     
         https://monitoring.us-east-1.amazonaws.com
-        2009-05-15
+        2010-08-01
         
         ${test.aws.identity}
         ${test.aws.credential}

From 5e44ad39c293bdfaf279c02ab9310d6f16995261 Mon Sep 17 00:00:00 2001
From: danikov 
Date: Tue, 10 Apr 2012 14:03:22 +0100
Subject: [PATCH 10/69] xml enum annotation

---
 .../v1_5/domain/CustomOrgLdapSettings.java    |  97 ++++++++---
 .../vcloud/director/v1_5/domain/Error.java    |  32 ++--
 .../vcloud/director/v1_5/domain/Link.java     | 161 ++++++++++--------
 .../vcloud/director/v1_5/domain/Media.java    |  52 +++++-
 .../vcloud/director/v1_5/domain/Network.java  |  54 ++++--
 .../v1_5/domain/NetworkConfiguration.java     |  12 +-
 .../v1_5/domain/NetworkConnection.java        |  46 +++--
 .../director/v1_5/domain/OrgLdapSettings.java |  52 ++++--
 .../vcloud/director/v1_5/domain/Role.java     |  62 +++++--
 .../vcloud/director/v1_5/domain/Task.java     |  58 +++++--
 .../v1_5/domain/UndeployVAppParams.java       |  53 ++++--
 .../v1_5/predicates/TaskStatusEquals.java     |  15 +-
 .../vcloud/director/v1_5/domain/Checks.java   |   8 +-
 .../v1_5/features/MediaClientExpectTest.java  |  11 +-
 .../features/NetworkClientExpectTest.java     |   3 +-
 .../VAppTemplateClientExpectTest.java         |   3 +-
 .../v1_5/features/VdcClientExpectTest.java    |   3 +-
 .../v1_5/features/VdcClientLiveTest.java      |   3 +-
 .../features/admin/UserClientLiveTest.java    |   2 +-
 .../BaseVCloudDirectorClientLiveTest.java     |  10 +-
 .../internal/VCloudDirectorTestSession.java   |   2 +-
 21 files changed, 505 insertions(+), 234 deletions(-)

diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomOrgLdapSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomOrgLdapSettings.java
index 680948a69e..fea50b3925 100644
--- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomOrgLdapSettings.java
+++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomOrgLdapSettings.java
@@ -19,15 +19,22 @@
 package org.jclouds.vcloud.director.v1_5.domain;
 
 import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
 
-import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
 import javax.xml.bind.annotation.XmlType;
 
+import com.google.common.base.Function;
 import com.google.common.base.Objects;
 import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
 
 /**
  * Used when OrgLdapMode=CUSTOM to define connection details for
@@ -76,34 +83,74 @@ import com.google.common.base.Objects.ToStringHelper;
     "groupAttributes"
 })
 public class CustomOrgLdapSettings {
-   public static final class AuthenticationMechanism {
-      public static final String SIMPLE = "simple";
-      public static final String KERBEROS = "kerberos";
-      public static final String MD5DIGEST = "md5digest";
-      public static final String NTLM = "ntlm";
+   @XmlType
+   @XmlEnum(String.class)
+   public static enum AuthenticationMechanism {
+      @XmlEnumValue("simple") SIMPLE("simple"),
+      @XmlEnumValue("kerberos") KERBEROS("kerberos"),
+      @XmlEnumValue("md5digest") MD5DIGEST("md5digest"),
+      @XmlEnumValue("ntlm") NTLM("ntlm"),
+      UNRECOGNIZED("unrecognized");
+      
+      public static final List ALL = ImmutableList.of(
+            SIMPLE, KERBEROS, MD5DIGEST, NTLM);
 
-      /**
-       * All acceptable {@link CustomOrgLdapSettings#getAuthenticationMechanism()} values.
-       * 

- * This list must be updated whenever a new authentication mechanism is added. - */ - public static final List ALL = Arrays.asList( - SIMPLE, KERBEROS, MD5DIGEST, NTLM - ); + protected final String stringValue; + + AuthenticationMechanism(String stringValue) { + this.stringValue = stringValue; + } + + public String value() { + return stringValue; + } + + protected final static Map AUTHENTICATION_MECHANISM_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(AuthenticationMechanism.values()), new Function() { + @Override + public String apply(AuthenticationMechanism input) { + return input.stringValue; + } + }); + + public static AuthenticationMechanism fromValue(String value) { + AuthenticationMechanism authMechanism = AUTHENTICATION_MECHANISM_BY_ID.get(checkNotNull(value, "stringValue")); + return authMechanism == null ? UNRECOGNIZED : authMechanism; + } } - public static final class ConnectorType { - public static final String ACTIVE_DIRECTORY = "ACTIVE_DIRECTORY"; - public static final String OPEN_LDAP = "OPEN_LDAP"; + @XmlType + @XmlEnum(String.class) + public static enum ConnectorType { + @XmlEnumValue("ACTIVE_DIRECTORY") ACTIVE_DIRECTORY("ACTIVE_DIRECTORY"), + @XmlEnumValue("OPEN_LDAP") OPEN_LDAP("OPEN_LDAP"), + UNRECOGNIZED("unrecognized"); + + public static final List ALL = ImmutableList.of( + ACTIVE_DIRECTORY, OPEN_LDAP); - /** - * All acceptable {@link OrgLdapSettings#getLdapMode()} values. - *

- * This list must be updated whenever a new mode is added. - */ - public static final List ALL = Arrays.asList( - ACTIVE_DIRECTORY, OPEN_LDAP - ); + protected final String stringValue; + + ConnectorType(String stringValue) { + this.stringValue = stringValue; + } + + public String value() { + return stringValue; + } + + protected final static Map CONNECTOR_TYPE_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(ConnectorType.values()), new Function() { + @Override + public String apply(ConnectorType input) { + return input.stringValue; + } + }); + + public static ConnectorType fromValue(String value) { + ConnectorType type = CONNECTOR_TYPE_BY_ID.get(checkNotNull(value, "stringValue")); + return type == null ? UNRECOGNIZED : type; + } } public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java index d76973c9e9..0082b3c4cd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java @@ -25,7 +25,10 @@ import java.util.Arrays; import javax.annotation.Resource; import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; import org.jclouds.logging.Logger; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; @@ -50,21 +53,22 @@ public class Error { @Resource protected static Logger logger = Logger.NULL; + @XmlType + @XmlEnum(Integer.class) public static enum Code { - - OK(200), - CREATED(201), - ACCEPTED(202), - NO_CONTENT(204), - SEE_OTHER(303), - BAD_REQUEST(400), - UNAUTHORIZED(401), - FORBIDDEN(403), // NOTE also means 'not found' for entities - NOT_FOUND(404), - NOT_ALLOWED(405), - INTERNAL_ERROR(500), - NOT_IMPLEMENTED(501), - UNAVAILABLE(503), + @XmlEnumValue("200") OK(200), + @XmlEnumValue("201") CREATED(201), + @XmlEnumValue("202") ACCEPTED(202), + @XmlEnumValue("204") NO_CONTENT(204), + @XmlEnumValue("303") SEE_OTHER(303), + @XmlEnumValue("400") BAD_REQUEST(400), + @XmlEnumValue("401") UNAUTHORIZED(401), + @XmlEnumValue("403") FORBIDDEN(403), // NOTE also means 'not found' for entities + @XmlEnumValue("404") NOT_FOUND(404), + @XmlEnumValue("405") NOT_ALLOWED(405), + @XmlEnumValue("500") INTERNAL_ERROR(500), + @XmlEnumValue("501") NOT_IMPLEMENTED(501), + @XmlEnumValue("503") UNAVAILABLE(503), UNRECOGNIZED(-1); private Integer majorErrorCode; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index d26c6c0aa9..f5bce3a2db 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -21,15 +21,21 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Arrays; import java.util.List; import java.util.Map; import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; /** * A link. @@ -42,71 +48,70 @@ import com.google.common.base.Objects.ToStringHelper; */ @XmlRootElement(name = "Link") public class Link extends Reference { + + @XmlType + @XmlEnum(String.class) + public static enum Rel { + @XmlEnumValue("add") ADD("add"), + @XmlEnumValue("alternate") ALTERNATE("alternate"), + @XmlEnumValue("catalogItem") CATALOG_ITEM("catalogItem"), + @XmlEnumValue("collaboration:abort") COLLABORATION_ABORT("collaboration:abort"), + @XmlEnumValue("collaboration:fail") COLLABORATION_FAIL("collaboration:fail"), + @XmlEnumValue("collaboration:resume") COLLABORATION_RESUME("collaboration:resume"), + @XmlEnumValue("consolidate") CONSOLIDATE("consolidate"), + @XmlEnumValue("controlAccess") CONTROL_ACCESS("controlAccess"), + @XmlEnumValue("copy") COPY("copy"), + @XmlEnumValue("deploy") DEPLOY("deploy"), + @XmlEnumValue("disable") DISABLE("disable"), + @XmlEnumValue("discardState") DISCARD_STATE("discardState"), + @XmlEnumValue("down") DOWN("down"), + @XmlEnumValue("download:alternate") DOWNLOAD_ALTERNATE("download:alternate"), + @XmlEnumValue("download:default") DOWNLOAD_DEFAULT("download:default"), + @XmlEnumValue("edit") EDIT("edit"), + @XmlEnumValue("enable") ENABLE("enable"), + @XmlEnumValue("firstPage") FIRST_PAGE("firstPage"), + @XmlEnumValue("installVmwareTools") INSTALL_VMWARE_TOOLS("installVmwareTools"), + @XmlEnumValue("lastPage") LAST_PAGE("lastPage"), + @XmlEnumValue("media:ejectMedia") EJECT_MEDIA("media:ejectMedia"), + @XmlEnumValue("media:insertMedia") INSERT_MEDIA("media:insertMedia"), + @XmlEnumValue("move") MOVE("move"), + @XmlEnumValue("nextPage") NEXT_PAGE("nextPage"), + @XmlEnumValue("ova") OVA("ova"), + @XmlEnumValue("ovf") OVF("ovf"), + @XmlEnumValue("power:powerOff") POWER_OFF("power:powerOff"), + @XmlEnumValue("power:powerOn") POWER_ON("power:powerOn"), + @XmlEnumValue("power:reboot") REBOOT("power:reboot"), + @XmlEnumValue("power:reset") RESET("power:reset"), + @XmlEnumValue("power:shutdown") SHUTDOWN("power:shutdown"), + @XmlEnumValue("power:suspend") SUSPEND("power:suspend"), + @XmlEnumValue("previousPage") PREVIOUS_PAGE("previousPage"), + @XmlEnumValue("publish") PUBLISH("publish"), + @XmlEnumValue("recompose") RECOMPOSE("recompose"), + @XmlEnumValue("reconnect") RECONNECT("reconnect"), + @XmlEnumValue("register") REGISTER("register"), + @XmlEnumValue("reject") REJECT("reject"), + @XmlEnumValue("relocate") RELOCATE("relocate"), + @XmlEnumValue("remove") REMOVE("remove"), + @XmlEnumValue("screen:acquireTicket") SCREEN_ACQUIRE_TICKET("screen:acquireTicket"), + @XmlEnumValue("screen:thumbnail") SCREEN_THUMBNAIL("screen:thumbnail"), + @XmlEnumValue("task:cancel") TASK_CANCEL("task:cancel"), + @XmlEnumValue("blockingTask") BLOCKING_TASK("blockingTask"), + @XmlEnumValue("taskOwner") TASK_OWNER("taskOwner"), + @XmlEnumValue("taskParams") TASK_PARAMS("taskParams"), + @XmlEnumValue("taskRequest") TASK_REQUEST("taskRequest"), + @XmlEnumValue("undeploy") UNDEPLOY("undeploy"), + @XmlEnumValue("unlock") UNLOCK("unlock"), + @XmlEnumValue("unregister") UNREGISTER("unregister"), + @XmlEnumValue("up") UP("up"), + @XmlEnumValue("updateProgress") UPDATE_PROGRESS("updateProgress"), + @XmlEnumValue("upgrade") UPGRADE("upgrade"), + @XmlEnumValue("upload:alternate") UPLOAD_ALTERNATE("upload:alternate"), + @XmlEnumValue("upload:default") UPLOAD_DEFAULT("upload:default"), + @XmlEnumValue("repair") REPAIR("repair"), - public static final class Rel { - public static final String ADD = "add"; - public static final String ALTERNATE = "alternate"; - public static final String CATALOG_ITEM = "catalogItem"; - public static final String COLLABORATION_ABORT = "collaboration:abort"; - public static final String COLLABORATION_FAIL = "collaboration:fail"; - public static final String COLLABORATION_RESUME = "collaboration:resume"; - public static final String CONSOLIDATE = "consolidate"; - public static final String CONTROL_ACCESS = "controlAccess"; - public static final String COPY = "copy"; - public static final String DEPLOY = "deploy"; - public static final String DISABLE = "disable"; - public static final String DISCARD_STATE = "discardState"; - public static final String DOWN = "down"; - public static final String DOWNLOAD_ALTERNATE = "download:alternate"; - public static final String DOWNLOAD_DEFAULT = "download:default"; - public static final String EDIT = "edit"; - public static final String ENABLE = "enable"; - public static final String FIRST_PAGE = "firstPage"; - public static final String INSTALL_VMWARE_TOOLS = "installVmwareTools"; - public static final String LAST_PAGE = "lastPage"; - public static final String EJECT_MEDIA = "media:ejectMedia"; - public static final String INSERT_MEDIA = "media:insertMedia"; - public static final String MOVE = "move"; - public static final String NEXT_PAGE = "nextPage"; - public static final String OVA = "ova"; - public static final String OVF = "ovf"; - public static final String POWER_OFF = "power:powerOff"; - public static final String POWER_ON = "power:powerOn"; - public static final String REBOOT = "power:reboot"; - public static final String RESET = "power:reset"; - public static final String SHUTDOWN = "power:shutdown"; - public static final String SUSPEND = "power:suspend"; - public static final String PREVIOUS_PAGE = "previousPage"; - public static final String PUBLISH = "publish"; - public static final String RECOMPOSE = "recompose"; - public static final String RECONNECT = "reconnect"; - public static final String REGISTER = "register"; - public static final String REJECT = "reject"; - public static final String RELOCATE = "relocate"; - public static final String REMOVE = "remove"; - public static final String SCREEN_ACQUIRE_TICKET = "screen:acquireTicket"; - public static final String SCREEN_THUMBNAIL = "screen:thumbnail"; - public static final String TASK_CANCEL = "task:cancel"; - public static final String BLOCKING_TASK = "blockingTask"; - public static final String TASK_OWNER = "taskOwner"; - public static final String TASK_PARAMS = "taskParams"; - public static final String TASK_REQUEST = "taskRequest"; - public static final String UNDEPLOY = "undeploy"; - public static final String UNLOCK = "unlock"; - public static final String UNREGISTER = "unregister"; - public static final String UP = "up"; - public static final String UPDATE_PROGRESS = "updateProgress"; - public static final String UPGRADE = "upgrade"; - public static final String UPLOAD_ALTERNATE = "upload:alternate"; - public static final String UPLOAD_DEFAULT = "upload:default"; - public static final String REPAIR = "repair"; - - /** - * All acceptable {@link Link#getRel()} values. - * - * This list must be updated whenever a new relationship is added. - */ - public static final List ALL = Arrays.asList( + UNRECOGNIZED("unrecognized"); + + public static final List ALL = ImmutableList.of( ADD, ALTERNATE, CATALOG_ITEM, COLLABORATION_ABORT, COLLABORATION_FAIL, COLLABORATION_RESUME, CONSOLIDATE, CONTROL_ACCESS, COPY, DEPLOY, DISABLE, DISCARD_STATE, DOWN, @@ -118,8 +123,30 @@ public class Link extends Reference { SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER, TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP, UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT, - UPLOAD_DEFAULT - ); + UPLOAD_DEFAULT); + + protected final String stringValue; + + Rel(String stringValue) { + this.stringValue = stringValue; + } + + public String value() { + return stringValue; + } + + protected final static Map REL_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(Rel.values()), new Function() { + @Override + public String apply(Rel input) { + return input.stringValue; + } + }); + + public static Rel fromValue(String value) { + Rel rel = REL_BY_ID.get(checkNotNull(value, "stringValue")); + return rel == null ? UNRECOGNIZED : rel; + } } public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java index 651c2c924d..ab00a90710 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java @@ -19,16 +19,24 @@ f * Licensed to jclouds, Inc. (jclouds) under one or more package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Arrays; import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; /** * Represents a media. @@ -39,12 +47,38 @@ import com.google.common.base.Objects.ToStringHelper; */ @XmlRootElement(name = "Media") public class Media extends ResourceEntityType { + + @XmlType + @XmlEnum(String.class) + public static enum ImageType { + @XmlEnumValue("iso") ISO("iso"), + @XmlEnumValue("floppy") FLOPPY("floppy"), + UNRECOGNIZED("unrecognized"); + + public static final List ALL = ImmutableList.of(ISO, FLOPPY); - public static final class ImageType { - public static final String ISO = "iso"; - public static final String FLOPPY = "floppy"; + protected final String stringValue; - public static final List ALL = Arrays.asList(ISO, FLOPPY); + ImageType(String stringValue) { + this.stringValue = stringValue; + } + + public String value() { + return stringValue; + } + + protected final static Map STATUS_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(ImageType.values()), new Function() { + @Override + public String apply(ImageType input) { + return input.stringValue; + } + }); + + public static ImageType fromValue(String value) { + ImageType type = STATUS_BY_ID.get(checkNotNull(value, "stringValue")); + return type == null ? UNRECOGNIZED : type; + } } public static Builder builder() { @@ -61,7 +95,7 @@ public class Media extends ResourceEntityType { public static abstract class Builder> extends ResourceEntityType.Builder { private Owner owner; - private String imageType; + private ImageType imageType; private long size; /** @@ -75,7 +109,7 @@ public class Media extends ResourceEntityType { /** * @see Media#getImageType() */ - public B imageType(String imageType) { + public B imageType(Media.ImageType imageType) { this.imageType = imageType; return self(); } @@ -113,7 +147,7 @@ public class Media extends ResourceEntityType { @XmlElement(name = "Owner") protected Owner owner; @XmlAttribute(required = true) - protected String imageType; + protected ImageType imageType; @XmlAttribute(required = true) protected long size; @@ -127,7 +161,7 @@ public class Media extends ResourceEntityType { /** * Gets the value of the imageType property. */ - public String getImageType() { + public ImageType getImageType() { return imageType; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Network.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Network.java index 24dcfe1edc..d556416003 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Network.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Network.java @@ -19,32 +19,60 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Arrays; import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; +import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; @XmlSeeAlso({ OrgNetwork.class, ExternalNetwork.class }) public abstract class Network extends EntityType { - public static final class FenceMode { + + @XmlType + @XmlEnum(String.class) + public static enum FenceMode { + @XmlEnumValue("bridged") BRIDGED("bridged"), + @XmlEnumValue("isolated") ISOLATED("isolated"), + @XmlEnumValue("natRouted") NAT_ROUTED("natRouted"), + UNRECOGNIZED("unrecognized"); + + public static final List ALL = ImmutableList.of( + BRIDGED, ISOLATED, NAT_ROUTED); - public static final String BRIDGED = "bridged"; - public static final String ISOLATED = "isolated"; - public static final String NAT_ROUTED = "natRouted"; + protected final String stringValue; - /** - * All acceptable {@link Network#getFenceMode()} values. - *

- * This list must be updated whenever a new mode is added. - */ - public static final List ALL = Arrays.asList( - BRIDGED, ISOLATED, NAT_ROUTED - ); + FenceMode(String stringValue) { + this.stringValue = stringValue; + } + + public String value() { + return stringValue; + } + + protected final static Map FENCE_MODE_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(FenceMode.values()), new Function() { + @Override + public String apply(FenceMode input) { + return input.stringValue; + } + }); + + public static FenceMode fromValue(String value) { + FenceMode mode = FENCE_MODE_BY_ID.get(checkNotNull(value, "stringValue")); + return mode == null ? UNRECOGNIZED : mode; + } } public abstract static class Builder> extends EntityType.Builder { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java index a93d4e8cd1..eda312e713 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java @@ -25,6 +25,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode; + import com.google.common.base.Objects; /** @@ -47,7 +49,7 @@ public class NetworkConfiguration { public static class Builder { private IpScope ipScope; private Reference parentNetwork; - private String fenceMode; + private FenceMode fenceMode; private Boolean retainNetInfoAcrossDeployments; private NetworkFeatures features; private SyslogServerSettings syslogServerSettings; @@ -72,7 +74,7 @@ public class NetworkConfiguration { /** * @see NetworkConfiguration#getFenceMode() */ - public Builder fenceMode(String fenceMode) { + public Builder fenceMode(FenceMode fenceMode) { this.fenceMode = fenceMode; return this; } @@ -122,7 +124,7 @@ public class NetworkConfiguration { } } - public NetworkConfiguration(IpScope ipScope, Reference parentNetwork, String fenceMode, Boolean retainNetInfoAcrossDeployments, + public NetworkConfiguration(IpScope ipScope, Reference parentNetwork, FenceMode fenceMode, Boolean retainNetInfoAcrossDeployments, NetworkFeatures features, SyslogServerSettings syslogServerSettings, RouterInfo routerInfo) { this.ipScope = ipScope; this.parentNetwork = parentNetwork; @@ -142,7 +144,7 @@ public class NetworkConfiguration { @XmlElement(name = "ParentNetwork") private Reference parentNetwork; @XmlElement(name = "FenceMode") - private String fenceMode; + private FenceMode fenceMode; @XmlElement(name = "RetainNetInfoAcrossDeployments") private Boolean retainNetInfoAcrossDeployments; @XmlElement(name = "Features") @@ -174,7 +176,7 @@ public class NetworkConfiguration { * isolated (not connected to any other network), natRouted (connected to the ParentNetwork via a * NAT service) */ - public String getFenceMode() { + public FenceMode getFenceMode() { return fenceMode; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java index f0982f92e7..7d1d3f981b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java @@ -23,13 +23,19 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; +import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; /** @@ -70,30 +76,38 @@ import com.google.common.collect.ImmutableList; }) public class NetworkConnection { + @XmlType + @XmlEnum(String.class) public static enum IpAddressAllocationMode { - POOL("pool"), - DHCP("dhcp"), - MANUAL("manual"), - NONE("none"), + @XmlEnumValue("pool") POOL("pool"), + @XmlEnumValue("dhcp") DHCP("dhcp"), + @XmlEnumValue("manual") MANUAL("manual"), + @XmlEnumValue("none") NONE("none"), UNRECOGNIZED("unrecognized"); public static final List ALL = ImmutableList.of(POOL, DHCP, MANUAL, NONE); - - private final String label; - private IpAddressAllocationMode(String label) { - this.label = label; + + protected final String label; + + IpAddressAllocationMode(String stringValue) { + this.label = stringValue; } - - public String getLabel() { + + public String label() { return label; } - + + protected final static Map IP_ADDRESS_ALLOCATION_MODE_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(IpAddressAllocationMode.values()), new Function() { + @Override + public String apply(IpAddressAllocationMode input) { + return input.label; + } + }); + public static IpAddressAllocationMode fromValue(String value) { - try { - return valueOf(checkNotNull(value, "value").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } + IpAddressAllocationMode mode = IP_ADDRESS_ALLOCATION_MODE_BY_ID.get(checkNotNull(value, "stringValue")); + return mode == null ? UNRECOGNIZED : mode; } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java index f5e01a827a..913019a20e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java @@ -19,16 +19,23 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Arrays; import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; /** * Base settings for LDAP connection * @@ -54,20 +61,39 @@ import com.google.common.base.Objects.ToStringHelper; "customOrgLdapSettings" }) public class OrgLdapSettings extends ResourceType { + + @XmlType + @XmlEnum(String.class) + public static enum LdapMode { + @XmlEnumValue("NONE") NONE("NONE"), + @XmlEnumValue("SYSTEM") SYSTEM("SYSTEM"), + @XmlEnumValue("CUSTOM") CUSTOM("CUSTOM"), + UNRECOGNIZED("unrecognized"); + + public static final List ALL = ImmutableList.of( NONE, SYSTEM, CUSTOM ); - public static final class LdapMode { - public static final String NONE = "NONE"; - public static final String SYSTEM = "SYSTEM"; - public static final String CUSTOM = "CUSTOM"; + protected final String stringValue; - /** - * All acceptable {@link #getLdapMode()} values. - * - * This list must be updated whenever a new mode is added. - */ - public static final List ALL = Arrays.asList( - NONE, SYSTEM, CUSTOM - ); + LdapMode(String stringValue) { + this.stringValue = stringValue; + } + + public String value() { + return stringValue; + } + + protected final static Map LDAP_MODE_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(LdapMode.values()), new Function() { + @Override + public String apply(LdapMode input) { + return input.stringValue; + } + }); + + public static LdapMode fromValue(String value) { + LdapMode mode = LDAP_MODE_BY_ID.get(checkNotNull(value, "stringValue")); + return mode == null ? UNRECOGNIZED : mode; + } } public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Role.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Role.java index 1616f0ce1e..d79919bed3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Role.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Role.java @@ -1,27 +1,53 @@ package org.jclouds.vcloud.director.v1_5.domain; -import java.util.Arrays; -import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminQueryClient; +import java.util.List; +import java.util.Map; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; public class Role { //TODO: placeholder for implementation - public static final class DefaultRoles { - public static final String USER = "vApp User"; - public static final String AUTHOR = "vApp Author"; - public static final String CATALOG_AUTHOR = "Catalog Author"; - public static final String CONSOLE = "Console Access Only"; - public static final String ORG_ADMIN = "Organization Administrator"; + @XmlType + @XmlEnum(String.class) + public static enum DefaultRoles { + @XmlEnumValue("vApp User") USER("vApp User"), + @XmlEnumValue("vApp Author") AUTHOR("vApp Author"), + @XmlEnumValue("Catalog Author") CATALOG_AUTHOR("Catalog Author"), + @XmlEnumValue("Console Access Only") CONSOLE("Console Access Only"), + @XmlEnumValue("Organization Administrator") ORG_ADMIN("Organization Administrator"); - /** - * All default {@link AdminQueryClient#roleReferencesQueryAll()} values. - *

- * This list must be updated whenever a new default role is added. - */ - public static final List ALL = Arrays.asList( - USER, AUTHOR, CATALOG_AUTHOR, CONSOLE, ORG_ADMIN - ); + public static final List ALL = ImmutableList.of( + USER, AUTHOR, CATALOG_AUTHOR, CONSOLE, ORG_ADMIN); + + protected final String stringValue; + + DefaultRoles(String stringValue) { + this.stringValue = stringValue; + } + + public String value() { + return stringValue; + } + + protected final static Map DEFAULT_ROLES_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(DefaultRoles.values()), new Function() { + @Override + public String apply(DefaultRoles input) { + return input.stringValue; + } + }); + + public static DefaultRoles fromValue(String value) { + return DEFAULT_ROLES_BY_ID.get(checkNotNull(value, "stringValue")); + } } - } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java index 26dd73cb95..3ba255190c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java @@ -19,19 +19,27 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; /** * Represents an asynchronous or long-running task in the vCloud environment. @@ -48,20 +56,44 @@ import com.google.common.base.Objects.ToStringHelper; public class Task extends EntityType { public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASK; + + @XmlType + @XmlEnum(String.class) + public static enum Status { + @XmlEnumValue("queued") QUEUED("queued"), + @XmlEnumValue("preRunning") PRE_RUNNING("preRunning"), + @XmlEnumValue("running") RUNNING("running"), + @XmlEnumValue("success") SUCCESS("success"), + @XmlEnumValue("error") ERROR("error"), + @XmlEnumValue("canceled") CANCELED("canceled"), + @XmlEnumValue("aborted") ABORTED("aborted"), + UNRECOGNIZED("unrecognized"); + + public static final List ALL = ImmutableList.of( + QUEUED, PRE_RUNNING, RUNNING, SUCCESS, ERROR, CANCELED, ABORTED); - public static class Status { - public static final String QUEUED = "queued"; - public static final String PRE_RUNNING = "preRunning"; - public static final String RUNNING = "running"; - public static final String SUCCESS = "success"; - public static final String ERROR = "error"; - public static final String CANCELED = "canceled"; - public static final String ABORTED = "aborted"; + protected final String stringValue; - public static final List ALL = Arrays.asList( - QUEUED, PRE_RUNNING, RUNNING, SUCCESS, - ERROR, CANCELED, ABORTED - ); + Status(String stringValue) { + this.stringValue = stringValue; + } + + public String value() { + return stringValue; + } + + protected final static Map STATUS_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(Status.values()), new Function() { + @Override + public String apply(Status input) { + return input.stringValue; + } + }); + + public static Status fromValue(String value) { + Status status = STATUS_BY_ID.get(checkNotNull(value, "stringValue")); + return status == null ? UNRECOGNIZED : status; + } } public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UndeployVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UndeployVAppParams.java index ced084e9f5..9dae45bca0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UndeployVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UndeployVAppParams.java @@ -19,17 +19,24 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Arrays; import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import com.google.common.base.Function; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; /** * Represents vApp/VM undeployment parameters. @@ -42,20 +49,42 @@ import com.google.common.base.Objects; @XmlRootElement(name = "UndeployVAppParams") @XmlType(name = "UndeployVAppParamsType") public class UndeployVAppParams { + + public static final String MEDIA_TYPE = VCloudDirectorMediaType.UNDEPLOY_VAPP_PARAMS; + + @XmlType + @XmlEnum(String.class) + public static enum PowerAction { + @XmlEnumValue("powerOff") POWER_OFF("powerOff"), + @XmlEnumValue("suspend") SUSPEND("suspend"), + @XmlEnumValue("shutdown") SHUTDOWN("shutdown"), + @XmlEnumValue("force") FORCE("force"), + UNRECOGNIZED("unrecognized"); + + public static final List ALL = ImmutableList.of( POWER_OFF, SUSPEND, SHUTDOWN, FORCE ); - public static final String MEDIA_TYPe = VCloudDirectorMediaType.UNDEPLOY_VAPP_PARAMS; + protected final String stringValue; - public static class PowerAction { - /** Power off the VMs. This is the default action if this attribute is missing or empty) */ - public static final String POWER_OFF = "powerOff"; - /** Suspend the VMs. */ - public static final String SUSPEND = "suspend"; - /** Shut down the VMs. */ - public static final String SHUTDOWN = "shutdown"; - /** Attempt to power off the VMs. */ - public static final String FORCE = "force"; + PowerAction(String stringValue) { + this.stringValue = stringValue; + } - public static final List ALL = Arrays.asList(POWER_OFF, SUSPEND, SHUTDOWN, FORCE); + public String value() { + return stringValue; + } + + protected final static Map POWER_ACTION_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(PowerAction.values()), new Function() { + @Override + public String apply(PowerAction input) { + return input.stringValue; + } + }); + + public static PowerAction fromValue(String value) { + PowerAction action = POWER_ACTION_BY_ID.get(checkNotNull(value, "stringValue")); + return action == null ? UNRECOGNIZED : action; + } } public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java index 689b211f68..8b60ee1d63 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java @@ -20,12 +20,14 @@ package org.jclouds.vcloud.director.v1_5.predicates; import java.util.Collection; import java.util.Collections; +import java.util.Set; import javax.annotation.Resource; import org.jclouds.logging.Logger; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.Task.Status; import org.jclouds.vcloud.director.v1_5.features.TaskClient; import com.google.common.base.Predicate; @@ -42,15 +44,14 @@ public class TaskStatusEquals implements Predicate { @Resource protected Logger logger = Logger.NULL; - private Collection expectedStatuses; - private Collection failingStatuses; + private Collection expectedStatuses; + private Collection failingStatuses; - // TODO Use Task.Status, once it is turned into an enumeration - public TaskStatusEquals(TaskClient taskClient, String expectedStatus, Collection failingStatuses) { + public TaskStatusEquals(TaskClient taskClient, Status expectedStatus, Set failingStatuses) { this(taskClient, Collections.singleton(expectedStatus), failingStatuses); } - public TaskStatusEquals(TaskClient taskClient, Collection expectedStatuses, Collection failingStatuses) { + public TaskStatusEquals(TaskClient taskClient, Set expectedStatuses, Set failingStatuses) { this.taskClient = taskClient; this.expectedStatuses = expectedStatuses; this.failingStatuses = failingStatuses; @@ -68,13 +69,13 @@ public class TaskStatusEquals implements Predicate { if (task == null) return false; logger.trace("%s: looking for status %s: currently: %s", task, expectedStatuses, task.getStatus()); - for (String failingStatus : failingStatuses) { + for (Status failingStatus : failingStatuses) { if (task.getStatus().equals(failingStatus)) { throw new VCloudDirectorException(task); } } - for (String expectedStatus : expectedStatuses) { + for (Status expectedStatus : expectedStatuses) { if (task.getStatus().equals(expectedStatus)) { return true; } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 1fa7d6d113..f4f6a80d88 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -345,11 +345,6 @@ public class Checks { checkEntityType(catalogItem); } - public static void checkImageType(String imageType) { - assertTrue(Media.ImageType.ALL.contains(imageType), - "The Image type of a Media must be one of the allowed list"); - } - public static void checkNetwork(Network network) { // Check optional fields NetworkConfiguration config = network.getConfiguration(); @@ -756,7 +751,8 @@ public class Checks { public static void checkMediaFor(String client, Media media) { // required assertNotNull(media.getImageType(), String.format(OBJ_FIELD_REQ, client, "imageType")); - checkImageType(media.getImageType()); + assertTrue(Media.ImageType.ALL.contains(media.getImageType()), + "The Image type of a Media must be one of the allowed list"); assertNotNull(media.getSize(), String.format(OBJ_FIELD_REQ, client, "size")); assertTrue(media.getSize() >= 0, String.format(OBJ_FIELD_GTE_0, client, "size", media.getSize())); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java index 54f28366df..1350c0d714 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java @@ -31,6 +31,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.File; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; +import org.jclouds.vcloud.director.v1_5.domain.Media.ImageType; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; @@ -67,7 +68,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest { Media source = Media.builder() .size(0) - .imageType("iso") + .imageType(ImageType.ISO) .name("Test media 1") .type("application/vnd.vmware.vcloud.media+xml") .description("Test media generated by testCreateMedia()") @@ -346,7 +347,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest { static Media createMedia() { return Media.builder() .size(0) - .imageType("iso") + .imageType(ImageType.ISO) .status(0) .name("Test media 1") .id("urn:vcloud:media:d51b0b9d-099c-499f-97f8-4fbe40ba06d7") @@ -378,7 +379,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest { static Media cloneMedia() { return Media.builder() .size(175163392) - .imageType("iso") + .imageType(ImageType.ISO) .status(0) .name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2") .id("urn:vcloud:media:a6b023f2-7f90-4e89-a24d-56e0eba83a5a") @@ -433,7 +434,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest { private static Media getMedia() { return Media.builder() .size(175163392) - .imageType("iso") + .imageType(ImageType.ISO) .status(1) .name("DansTestMedia") .id("urn:vcloud:media:794eb334-754e-4917-b5a0-5df85cbd61d1") @@ -476,7 +477,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest { private static Media updateMedia() { return Media.builder() .size(175163392) - .imageType("iso") + .imageType(ImageType.ISO) .status(1) .name("new testMedia1") .id("urn:vcloud:media:c93e5cdc-f29a-4749-8ed2-093df04cc75e") diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index 51a2542c21..4fdb7fd8cb 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -37,6 +37,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Network; +import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; @@ -217,7 +218,7 @@ public class NetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest .build()) .build()) .build()) - .fenceMode("isolated") + .fenceMode(FenceMode.ISOLATED) .retainNetInfoAcrossDeployments(false) .features(NetworkFeatures.builder() .service(DhcpService.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java index 25e5863755..21a63f50d6 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java @@ -57,6 +57,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.NatOneToOneVmRule; import org.jclouds.vcloud.director.v1_5.domain.NatRule; import org.jclouds.vcloud.director.v1_5.domain.NatService; +import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures; @@ -679,7 +680,7 @@ public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpec .ipRanges(IpRanges.builder().ipRange(IpRange.builder().startAddress("10.147.56.1").endAddress("10.147.56.1").build()).build()) .build()) .parentNetwork(Reference.builder().href(URI.create("http://vcloud.example.com/api/v1.0/network/54")).type("application/vnd.vmware.vcloud.network+xml").name("Internet").build()) - .fenceMode("natRouted") + .fenceMode(FenceMode.NAT_ROUTED) .features(NetworkFeatures.builder().services(ImmutableSet.of(firewallService, natService)).build()) .build(); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index 1fb0d81610..69a9aff4db 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -38,6 +38,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; +import org.jclouds.vcloud.director.v1_5.domain.Media.ImageType; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Reference; @@ -297,7 +298,7 @@ public class VdcClientExpectTest extends VCloudDirectorAdminClientExpectTest { Media source = Media.builder() .size(0) - .imageType("iso") + .imageType(ImageType.ISO) .name("Test media 1") .type("application/vnd.vmware.vcloud.media+xml") .description("Test media generated by testCreateMedia()") diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 6724b662fa..472c2a0c10 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -40,6 +40,7 @@ import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiationParams; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; +import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.Reference; @@ -246,7 +247,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { NetworkConfiguration networkConfiguration = NetworkConfiguration.builder() .parentNetwork(parentNetwork.get()) - .fenceMode("bridged") + .fenceMode(FenceMode.BRIDGED) .build(); NetworkConfigSection networkConfigSection = NetworkConfigSection.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java index 93ad4f0ef9..fea82e4fc1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java @@ -119,7 +119,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { .password("newPassword") // TODO test setting other fields? // .name("new"+oldUser.getName()) - .role(getRoleReferenceFor(DefaultRoles.AUTHOR)) + .role(getRoleReferenceFor(DefaultRoles.AUTHOR.value())) .build(); userClient.updateUser(user.getHref(), newUser); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java index d40b9cc13c..7d6cae701b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java @@ -217,7 +217,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ } public User randomTestUser(String prefix) { - return randomTestUser(prefix, getRoleReferenceFor(DefaultRoles.USER)); + return randomTestUser(prefix, getRoleReferenceFor(DefaultRoles.USER.value())); } public User randomTestUser(String prefix, Reference role) { @@ -303,11 +303,11 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ assertTrue(retryTaskSuccessLong.apply(task), String.format(TASK_COMPLETE_TIMELY, task)); } - protected void assertTaskStatusEventually(Task task, String expectedStatus, Collection failingStatuses) { + protected void assertTaskStatusEventually(Task task, org.jclouds.vcloud.director.v1_5.domain.Task.Status running, ImmutableSet immutableSet) { TaskClient taskClient = context.getApi().getTaskClient(); - TaskStatusEquals predicate = new TaskStatusEquals(taskClient, expectedStatus, failingStatuses); + TaskStatusEquals predicate = new TaskStatusEquals(taskClient, running, immutableSet); RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, TASK_TIMEOUT_SECONDS * 1000L); - assertTrue(retryablePredicate.apply(task), "Task must enter status "+expectedStatus); + assertTrue(retryablePredicate.apply(task), "Task must enter status "+running); } protected void assertTaskDoneEventually(Task task) { @@ -315,7 +315,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ TaskStatusEquals predicate = new TaskStatusEquals( taskClient, ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), - Collections.emptySet()); + Collections.emptySet()); RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L); assertTrue(retryablePredicate.apply(task), "Task must be done"); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java index 940d18fccd..6bbc1d92b3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java @@ -124,7 +124,7 @@ public class VCloudDirectorTestSession { .name(userIdentity) .password(userCredential) .description("test user with user-level privileges") - .role(BaseVCloudDirectorClientLiveTest.getRoleReferenceFor(DefaultRoles.USER, adminContext)) + .role(BaseVCloudDirectorClientLiveTest.getRoleReferenceFor(DefaultRoles.USER.value(), adminContext)) .deployedVmQuota(BaseVCloudDirectorClientLiveTest.REQUIRED_USER_VM_QUOTA) .isEnabled(true) .build()); From a059a18ada9d5cbcca02c61f787e32af18c41045 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Tue, 10 Apr 2012 15:21:38 +0200 Subject: [PATCH 11/69] Pretty print in payload is now configurable --- .../jclouds/compute/internal/UtilsImpl.java | 5 +- core/src/main/java/org/jclouds/Constants.java | 7 + .../java/org/jclouds/PropertiesBuilder.java | 10 + .../src/main/java/org/jclouds/rest/Utils.java | 8 + .../org/jclouds/rest/internal/UtilsImpl.java | 15 +- .../org/jclouds/xml/internal/JAXBParser.java | 17 +- .../rest/binders/BindToXMLPayloadTest.java | 2 +- .../v1_5/AbstractVAppClientLiveTest.java | 520 ++++++++++-------- .../v1_5/NonClientOperationsLiveTest.java | 160 +++--- 9 files changed, 436 insertions(+), 308 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java b/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java index 511db6b67c..c360046f68 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java @@ -34,6 +34,7 @@ import org.jclouds.rest.HttpAsyncClient; import org.jclouds.rest.HttpClient; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient.Factory; +import org.jclouds.xml.XMLParser; import com.google.common.base.Function; import com.google.common.eventbus.EventBus; @@ -51,11 +52,11 @@ public class UtilsImpl extends org.jclouds.rest.internal.UtilsImpl implements Ut private final Function sshForNode; @Inject - UtilsImpl(Injector injector, Json json, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, + UtilsImpl(Injector injector, Json json, XMLParser xml, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, Crypto encryption, DateService date, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, EventBus eventBus, LoggerFactory loggerFactory, Function sshForNode) { - super(injector, json, simpleClient, simpleAsyncClient, encryption, date, userThreads, ioThreads, eventBus, + super(injector, json, xml, simpleClient, simpleAsyncClient, encryption, date, userThreads, ioThreads, eventBus, loggerFactory); this.sshForNode = sshForNode; } diff --git a/core/src/main/java/org/jclouds/Constants.java b/core/src/main/java/org/jclouds/Constants.java index cc81d4df78..3ec3293779 100644 --- a/core/src/main/java/org/jclouds/Constants.java +++ b/core/src/main/java/org/jclouds/Constants.java @@ -259,5 +259,12 @@ public interface Constants { * */ public static final String PROPERTY_TIMEOUTS_PREFIX = "jclouds.timeouts."; + + /** + * Boolean property. Default (true). + *

+ * Configures the response parsers to pretty print the payload when possible. + */ + public static final String PROPERTY_PRETTY_PRINT_PAYLOADS = "jclouds.payloads.pretty-print"; } diff --git a/core/src/main/java/org/jclouds/PropertiesBuilder.java b/core/src/main/java/org/jclouds/PropertiesBuilder.java index cd39355e3e..ceaba15898 100644 --- a/core/src/main/java/org/jclouds/PropertiesBuilder.java +++ b/core/src/main/java/org/jclouds/PropertiesBuilder.java @@ -45,6 +45,7 @@ import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS; import static org.jclouds.Constants.PROPERTY_USER_THREADS; +import static org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS; import java.util.Properties; @@ -204,6 +205,14 @@ public class PropertiesBuilder { properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, Integer.toString(connectionLimit)); return this; } + + /** + * @see org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS + */ + public PropertiesBuilder prettyPrintPayloads(boolean prettyPrintPayloads) { + properties.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, Boolean.toString(prettyPrintPayloads)); + return this; + } protected final Properties properties; @@ -226,6 +235,7 @@ public class PropertiesBuilder { props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); + props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "true"); return props; } diff --git a/core/src/main/java/org/jclouds/rest/Utils.java b/core/src/main/java/org/jclouds/rest/Utils.java index 5e06a1751a..b3f0408987 100644 --- a/core/src/main/java/org/jclouds/rest/Utils.java +++ b/core/src/main/java/org/jclouds/rest/Utils.java @@ -25,6 +25,7 @@ import org.jclouds.date.DateService; import org.jclouds.json.Json; import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.rest.internal.UtilsImpl; +import org.jclouds.xml.XMLParser; import com.google.common.annotations.Beta; import com.google.common.eventbus.EventBus; @@ -110,5 +111,12 @@ public interface Utils { */ @Beta Injector injector(); + + XMLParser getXml(); + + /** + * #see #getXml + */ + XMLParser xml(); } diff --git a/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java b/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java index daff67b488..4860bf94dc 100644 --- a/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java +++ b/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java @@ -31,6 +31,7 @@ import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.rest.HttpAsyncClient; import org.jclouds.rest.HttpClient; import org.jclouds.rest.Utils; +import org.jclouds.xml.XMLParser; import com.google.common.annotations.Beta; import com.google.common.eventbus.EventBus; @@ -53,9 +54,10 @@ public class UtilsImpl implements Utils { private final EventBus eventBus; private final LoggerFactory loggerFactory; private Injector injector; + private XMLParser xml; @Inject - protected UtilsImpl(Injector injector, Json json, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, + protected UtilsImpl(Injector injector, Json json, XMLParser xml, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, Crypto encryption, DateService date, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, EventBus eventBus, LoggerFactory loggerFactory) { @@ -69,6 +71,7 @@ public class UtilsImpl implements Utils { this.ioExecutor = ioThreads; this.eventBus = eventBus; this.loggerFactory = loggerFactory; + this.xml = xml; } @Override @@ -172,5 +175,15 @@ public class UtilsImpl implements Utils { public Injector injector() { return getInjector(); } + + @Override + public XMLParser getXml() { + return xml; + } + + @Override + public XMLParser xml() { + return xml; + } } diff --git a/core/src/main/java/org/jclouds/xml/internal/JAXBParser.java b/core/src/main/java/org/jclouds/xml/internal/JAXBParser.java index 2448bca40d..341dc8caff 100644 --- a/core/src/main/java/org/jclouds/xml/internal/JAXBParser.java +++ b/core/src/main/java/org/jclouds/xml/internal/JAXBParser.java @@ -22,15 +22,19 @@ import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; +import javax.inject.Inject; import javax.inject.Singleton; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; +import org.jclouds.Constants; import org.jclouds.http.functions.ParseXMLWithJAXB; import org.jclouds.xml.XMLParser; +import com.google.inject.name.Named; + /** * Parses XML documents using JAXB. * @@ -39,6 +43,16 @@ import org.jclouds.xml.XMLParser; */ @Singleton public class JAXBParser implements XMLParser { + + /** Boolean indicating if the output must be pretty printed. */ + private Boolean prettyPrint; + + @Inject + public JAXBParser(@Named(Constants.PROPERTY_PRETTY_PRINT_PAYLOADS) String prettyPrint) { + super(); + this.prettyPrint = Boolean.valueOf(prettyPrint); + } + @Override public String toXML(final Object src) throws IOException { return toXML(src, src.getClass()); @@ -49,7 +63,7 @@ public class JAXBParser implements XMLParser { try { JAXBContext context = JAXBContext.newInstance(type); Marshaller marshaller = context.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, prettyPrint); StringWriter writer = new StringWriter(); marshaller.marshal(src, writer); return writer.toString(); @@ -58,6 +72,7 @@ public class JAXBParser implements XMLParser { } } + @SuppressWarnings("unchecked") @Override public T fromXML(final String xml, final Class type) throws IOException { try { diff --git a/core/src/test/java/org/jclouds/rest/binders/BindToXMLPayloadTest.java b/core/src/test/java/org/jclouds/rest/binders/BindToXMLPayloadTest.java index 48ce2325f3..20080112ba 100644 --- a/core/src/test/java/org/jclouds/rest/binders/BindToXMLPayloadTest.java +++ b/core/src/test/java/org/jclouds/rest/binders/BindToXMLPayloadTest.java @@ -40,7 +40,7 @@ import com.google.common.collect.Multimap; */ @Test(groups = "unit", testName = "BindToXMLPayloadTest") public class BindToXMLPayloadTest { - XMLParser xml = new JAXBParser(); + XMLParser xml = new JAXBParser("true"); @Test public void testBindJAXBObject() throws SecurityException, NoSuchMethodException { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java index 4ed4d2cb73..78eed46dfd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java @@ -74,271 +74,329 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClientLiveTest { +public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClientLiveTest +{ - public static final String VAPP = "vApp"; - public static final String VAPP_TEMPLATE = "vAppTemplate"; - public static final String VDC = "vdc"; + public static final String VAPP = "vApp"; - /* - * Convenience reference to API clients. - */ + public static final String VAPP_TEMPLATE = "vAppTemplate"; - protected CatalogClient catalogClient; - protected QueryClient queryClient; - protected VAppClient vAppClient; - protected VAppTemplateClient vAppTemplateClient; - protected VdcClient vdcClient; - protected MetadataClient.Writeable metadataClient; + public static final String VDC = "vdc"; - /* - * Objects shared between tests. - */ + /* + * Convenience reference to API clients. + */ - protected Vdc vdc; - protected Vm vm; - protected URI vAppURI; - protected VApp vApp; - protected VAppTemplate vAppTemplate; + protected CatalogClient catalogClient; - /** - * Retrieves the required clients from the REST API context - * - * @see BaseVCloudDirectorClientLiveTest#setupRequiredClients() - */ - @Override - @BeforeClass(alwaysRun = true, description = "Retrieves the required clients from the REST API context") - protected void setupRequiredClients() { - assertNotNull(context.getApi()); + protected QueryClient queryClient; - catalogClient = context.getApi().getCatalogClient(); - queryClient = context.getApi().getQueryClient(); - vAppClient = context.getApi().getVAppClient(); - vAppTemplateClient = context.getApi().getVAppTemplateClient(); - vdcClient = context.getApi().getVdcClient(); - - setupEnvironment(); - } + protected VAppClient vAppClient; - /** - * Sets up the environment. - * - * Retrieves the test {@link Vdc} and {@link VAppTemplate} from their configured {@link URI}s. - * Instantiates a new test VApp. - */ - protected void setupEnvironment() { - // Get the configured Vdc for the tests - vdc = vdcClient.getVdc(vdcURI); - assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC)); + protected VAppTemplateClient vAppTemplateClient; - // Get the configured VAppTemplate for the tests - vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); - assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE)); + protected VdcClient vdcClient; - // Instantiate a new VApp - VApp vAppInstantiated = instantiateVApp(); - assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP)); - vAppURI = vAppInstantiated.getHref(); + protected MetadataClient.Writeable metadataClient; - // Wait for the task to complete - Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks()); - assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask")); + /* + * Objects shared between tests. + */ - // Get the instantiated VApp - vApp = vAppClient.getVApp(vAppURI); + protected Vdc vdc; - // Get the Vm - List vms = vApp.getChildren().getVms(); - vm = Iterables.getOnlyElement(vms); - assertFalse(vms.isEmpty(), "The VApp must have a Vm"); - } + protected Vm vm; - protected void getGuestCustomizationSection(Function getGuestCustomizationSection) { - // Get URI for child VM - URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); + protected URI vAppURI; - // The method under test - try { - GuestCustomizationSection section = getGuestCustomizationSection.apply(vmURI); + protected VApp vApp; - // Check the retrieved object is well formed - checkGuestCustomizationSection(section); - } catch (Exception e) { - Throwables.propagate(e); - } - } + protected VAppTemplate vAppTemplate; - protected void getNetworkConnectionSection(Function getNetworkConnectionSection) { - // Get URI for child VM - URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); + /** + * Retrieves the required clients from the REST API context + * + * @see BaseVCloudDirectorClientLiveTest#setupRequiredClients() + */ + @Override + @BeforeClass(alwaysRun = true, description = "Retrieves the required clients from the REST API context") + protected void setupRequiredClients() + { + assertNotNull(context.getApi()); - // The method under test - try { - NetworkConnectionSection section = getNetworkConnectionSection.apply(vmURI); + catalogClient = context.getApi().getCatalogClient(); + queryClient = context.getApi().getQueryClient(); + vAppClient = context.getApi().getVAppClient(); + vAppTemplateClient = context.getApi().getVAppTemplateClient(); + vdcClient = context.getApi().getVdcClient(); - // Check the retrieved object is well formed - checkNetworkConnectionSection(section); - } catch (Exception e) { - Throwables.propagate(e); - } - } + setupEnvironment(); + } - @AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps") - protected void cleanUp() { - vdc = vdcClient.getVdc(vdcURI); // Refresh - // Find references in the Vdc with the VApp type and in the list of instantiated VApp names - Iterable vApps = Iterables.filter( - vdc.getResourceEntities(), - Predicates.and( - ReferencePredicates.typeEquals(VCloudDirectorMediaType.VAPP), - ReferencePredicates.nameIn(vAppNames) - ) - ); + /** + * Sets up the environment. Retrieves the test {@link Vdc} and {@link VAppTemplate} from their + * configured {@link URI}s. Instantiates a new test VApp. + */ + protected void setupEnvironment() + { + // Get the configured Vdc for the tests + vdc = vdcClient.getVdc(vdcURI); + assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC)); - // If we found any references, delete the VApp they point to - if (!Iterables.isEmpty(vApps)) { - for (Reference ref : vApps) { - cleanUpVApp(ref.getHref()); // NOTE may fail, but should continue deleting - } - } else { - logger.warn("No VApps in list found in Vdc %s (%s)", vdc.getName(), Iterables.toString(vAppNames)); - } - } + // Get the configured VAppTemplate for the tests + vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); + assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE)); - protected static CimBoolean cimBoolean(boolean val) { - CimBoolean result = new CimBoolean(); - result.setValue(val); - return result; - } + // Instantiate a new VApp + VApp vAppInstantiated = instantiateVApp(); + assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP)); + vAppURI = vAppInstantiated.getHref(); - protected static CimUnsignedInt cimUnsignedInt(long val) { - CimUnsignedInt result = new CimUnsignedInt(); - result.setValue(val); - return result; - } + // Wait for the task to complete + Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks()); + assertTrue(retryTaskSuccessLong.apply(instantiateTask), + String.format(TASK_COMPLETE_TIMELY, "instantiateTask")); - protected static CimUnsignedLong cimUnsignedLong(BigInteger val) { - CimUnsignedLong result = new CimUnsignedLong(); - result.setValue(val); - return result; - } + // Get the instantiated VApp + vApp = vAppClient.getVApp(vAppURI); - protected static CimString cimString(String value) { - return new CimString(value); - } + // Get the Vm + List vms = vApp.getChildren().getVms(); + vm = Iterables.getOnlyElement(vms); + assertFalse(vms.isEmpty(), "The VApp must have a Vm"); + } - protected void checkHasMatchingItem(final String context, final RasdItemsList items, final String instanceId, final String elementName) { - Optional found = Iterables.tryFind(items.getItems(), new Predicate() { - @Override - public boolean apply(ResourceAllocationSettingData item) { - String itemInstanceId = item.getInstanceID(); - if (itemInstanceId.equals(instanceId)) { - Assert.assertEquals(item.getElementName(), elementName, - String.format(OBJ_FIELD_EQ, VAPP, context + "/" + instanceId + "/elementName", elementName, item.getElementName())); + protected void getGuestCustomizationSection( + final Function getGuestCustomizationSection) + { + // Get URI for child VM + URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); - return true; + // The method under test + try + { + GuestCustomizationSection section = getGuestCustomizationSection.apply(vmURI); + + // Check the retrieved object is well formed + checkGuestCustomizationSection(section); + } + catch (Exception e) + { + Throwables.propagate(e); + } + } + + protected void getNetworkConnectionSection( + final Function getNetworkConnectionSection) + { + // Get URI for child VM + URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); + + // The method under test + try + { + NetworkConnectionSection section = getNetworkConnectionSection.apply(vmURI); + + // Check the retrieved object is well formed + checkNetworkConnectionSection(section); + } + catch (Exception e) + { + Throwables.propagate(e); + } + } + + @AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps") + protected void cleanUp() + { + vdc = vdcClient.getVdc(vdcURI); // Refresh + // Find references in the Vdc with the VApp type and in the list of instantiated VApp names + Iterable vApps = + Iterables.filter(vdc.getResourceEntities(), Predicates.and( + ReferencePredicates. typeEquals(VCloudDirectorMediaType.VAPP), + ReferencePredicates. nameIn(vAppNames))); + + // If we found any references, delete the VApp they point to + if (!Iterables.isEmpty(vApps)) + { + for (Reference ref : vApps) + { + cleanUpVApp(ref.getHref()); // NOTE may fail, but should continue deleting } - return false; - } - }); - assertTrue(found.isPresent(), "no " + context + " item found with id " + instanceId + "; only found " + items); - } + } + else + { + logger.warn("No VApps in list found in Vdc %s (%s)", vdc.getName(), + Iterables.toString(vAppNames)); + } + } - /** - * Power on a {@link VApp}s {@link Vm}s. - * - * @see #powerOn(URI) - */ - protected VApp powerOn(VApp testVApp) { - return powerOn(testVApp.getHref()); - } + protected static CimBoolean cimBoolean(final boolean val) + { + CimBoolean result = new CimBoolean(); + result.setValue(val); + return result; + } - /** - * Power on a VApp. - */ - protected VApp powerOn(URI testVAppURI) { - VApp testVApp = vAppClient.getVApp(testVAppURI); - Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); - if (status != Status.POWERED_ON) { - Task powerOn = vAppClient.powerOn(vm.getHref()); - assertTaskSucceedsLong(powerOn); - } - assertVAppStatus(testVAppURI, Status.POWERED_ON); - return testVApp; - } + protected static CimUnsignedInt cimUnsignedInt(final long val) + { + CimUnsignedInt result = new CimUnsignedInt(); + result.setValue(val); + return result; + } - /** - * Power off a {@link VApp}s {@link Vm}s. - * - * @see #powerOff(URI) - */ - protected VApp powerOff(VApp testVApp) { - return powerOff(testVApp.getHref()); - } + protected static CimUnsignedLong cimUnsignedLong(final BigInteger val) + { + CimUnsignedLong result = new CimUnsignedLong(); + result.setValue(val); + return result; + } - /** - * Power off a {@link VApp}s {@link Vm}s. - */ - protected VApp powerOff(URI testVAppURI) { - VApp testVApp = vAppClient.getVApp(testVAppURI); - Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); - if (status != Status.POWERED_OFF) { - Task powerOff = vAppClient.powerOff(vm.getHref()); - assertTaskSucceedsLong(powerOff); - } - assertVAppStatus(testVAppURI, Status.POWERED_OFF); - return testVApp; - } + protected static CimString cimString(final String value) + { + return new CimString(value); + } - /** - * Suspend a {@link VApp}s {@link Vm}s. - * - * @see #suspend(URI) - */ - protected VApp suspend(VApp testVApp) { - return powerOff(testVApp.getHref()); - } + protected void checkHasMatchingItem(final String context, final RasdItemsList items, + final String instanceId, final String elementName) + { + Optional found = + Iterables.tryFind(items.getItems(), new Predicate() + { + @Override + public boolean apply(final ResourceAllocationSettingData item) + { + String itemInstanceId = item.getInstanceID(); + if (itemInstanceId.equals(instanceId)) + { + Assert.assertEquals( + item.getElementName(), + elementName, + String.format(OBJ_FIELD_EQ, VAPP, context + "/" + instanceId + + "/elementName", elementName, item.getElementName())); - /** - * Suspend a {@link VApp}s {@link Vm}s. - */ - protected VApp suspend(URI testVAppURI) { - VApp testVApp = vAppClient.getVApp(testVAppURI); - Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); - if (status != Status.SUSPENDED) { - Task suspend = vAppClient.suspend(vm.getHref()); - assertTaskSucceedsLong(suspend); - } - assertVAppStatus(testVAppURI, Status.SUSPENDED); - return testVApp; - } + return true; + } + return false; + } + }); + assertTrue(found.isPresent(), "no " + context + " item found with id " + instanceId + + "; only found " + items); + } - /** - * Check the {@link VApp}s {@link Vm}s current status. - */ - protected void assertVAppStatus(URI testVAppURI, Status status) { - VApp testVApp = vAppClient.getVApp(testVAppURI); - Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - assertEquals(vm.getStatus(), status.getValue(),String.format(OBJ_FIELD_EQ, VAPP, "status", status.toString(), Status.fromValue(vm.getStatus()).toString())); - } + /** + * Power on a {@link VApp}s {@link Vm}s. + * + * @see #powerOn(URI) + */ + protected VApp powerOn(final VApp testVApp) + { + return powerOn(testVApp.getHref()); + } - /** - * Marshals a JAXB annotated object into XML. - * - * The XML is output using {@link org.jclouds.logging.Logger#debug(String)} - */ - protected void debug(Object object) { - JAXBParser parser = new JAXBParser(); - try { - String xml = parser.toXML(object); - logger.debug(Strings.padStart(Strings.padEnd(" " + object.getClass().toString() + " ", 70, '-'), 80, '-')); - logger.debug(xml); - logger.debug(Strings.repeat("-", 80)); - } catch (IOException ioe) { - Throwables.propagate(ioe); - } - } + /** + * Power on a VApp. + */ + protected VApp powerOn(final URI testVAppURI) + { + VApp testVApp = vAppClient.getVApp(testVAppURI); + Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); + Status status = Status.fromValue(vm.getStatus()); + if (status != Status.POWERED_ON) + { + Task powerOn = vAppClient.powerOn(vm.getHref()); + assertTaskSucceedsLong(powerOn); + } + assertVAppStatus(testVAppURI, Status.POWERED_ON); + return testVApp; + } + + /** + * Power off a {@link VApp}s {@link Vm}s. + * + * @see #powerOff(URI) + */ + protected VApp powerOff(final VApp testVApp) + { + return powerOff(testVApp.getHref()); + } + + /** + * Power off a {@link VApp}s {@link Vm}s. + */ + protected VApp powerOff(final URI testVAppURI) + { + VApp testVApp = vAppClient.getVApp(testVAppURI); + Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); + Status status = Status.fromValue(vm.getStatus()); + if (status != Status.POWERED_OFF) + { + Task powerOff = vAppClient.powerOff(vm.getHref()); + assertTaskSucceedsLong(powerOff); + } + assertVAppStatus(testVAppURI, Status.POWERED_OFF); + return testVApp; + } + + /** + * Suspend a {@link VApp}s {@link Vm}s. + * + * @see #suspend(URI) + */ + protected VApp suspend(final VApp testVApp) + { + return powerOff(testVApp.getHref()); + } + + /** + * Suspend a {@link VApp}s {@link Vm}s. + */ + protected VApp suspend(final URI testVAppURI) + { + VApp testVApp = vAppClient.getVApp(testVAppURI); + Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); + Status status = Status.fromValue(vm.getStatus()); + if (status != Status.SUSPENDED) + { + Task suspend = vAppClient.suspend(vm.getHref()); + assertTaskSucceedsLong(suspend); + } + assertVAppStatus(testVAppURI, Status.SUSPENDED); + return testVApp; + } + + /** + * Check the {@link VApp}s {@link Vm}s current status. + */ + protected void assertVAppStatus(final URI testVAppURI, final Status status) + { + VApp testVApp = vAppClient.getVApp(testVAppURI); + Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); + assertEquals( + vm.getStatus(), + status.getValue(), + String.format(OBJ_FIELD_EQ, VAPP, "status", status.toString(), + Status.fromValue(vm.getStatus()).toString())); + } + + /** + * Marshals a JAXB annotated object into XML. The XML is output using + * {@link org.jclouds.logging.Logger#debug(String)} + */ + protected void debug(final Object object) + { + JAXBParser parser = new JAXBParser("true"); + try + { + String xml = parser.toXML(object); + logger.debug(Strings.padStart( + Strings.padEnd(" " + object.getClass().toString() + " ", 70, '-'), 80, '-')); + logger.debug(xml); + logger.debug(Strings.repeat("-", 80)); + } + catch (IOException ioe) + { + Throwables.propagate(ioe); + } + } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java index aa082c7aa2..3904d25d63 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java @@ -45,77 +45,93 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "user", "nonClient" }, singleThreaded = true, testName = "NonClientOperationsLiveTest") -public class NonClientOperationsLiveTest extends BaseVCloudDirectorClientLiveTest { - - private JAXBParser parser = new JAXBParser(); - private SessionWithToken sessionWithToken; +@Test(groups = {"live", "user", "nonClient"}, singleThreaded = true, testName = "NonClientOperationsLiveTest") +public class NonClientOperationsLiveTest extends BaseVCloudDirectorClientLiveTest +{ - @Override - protected void setupRequiredClients() throws Exception { - setupCredentials(); - } - - @Test(testName = "POST /login") - public void testPostLogin() throws IOException { - testLoginWithMethod("POST"); - } - - @Test(testName = "GET /login") - public void testGetLogin() throws IOException { - testLoginWithMethod("GET"); - } - - private void testLoginWithMethod(String method) throws IOException { - String user = identity.substring(0, identity.lastIndexOf('@')); - String org = identity.substring(identity.lastIndexOf('@') + 1); - String password = credential; - - String authHeader = "Basic " + CryptoStreams.base64(String.format("%s@%s:%s", - checkNotNull(user), - checkNotNull(org), - checkNotNull(password)).getBytes("UTF-8")); - - HttpResponse response = context.getUtils().getHttpClient().invoke(HttpRequest.builder() - .method(method) - .endpoint(URI.create(endpoint+"/login")) - .headers(ImmutableMultimap.of( - "Authorization", authHeader, - "Accept", "*/*")) - .build()); - - sessionWithToken = SessionWithToken.builder() - .session(session) - .token(response.getFirstHeaderOrNull("x-vcloud-authorization")) - .build(); - - assertEquals(sessionWithToken.getSession().getUser(), user); - assertEquals(sessionWithToken.getSession().getOrg(), org); - assertTrue(sessionWithToken.getSession().getLinks().size() > 0); - assertNotNull(sessionWithToken.getToken()); - - OrgList orgList = parser.fromXML( - Strings2.toStringAndClose(response.getPayload().getInput()), OrgList.class); - - assertTrue(orgList.getOrgs().size() > 0, "must have orgs"); - - context.getApi().getOrgClient().getOrg(Iterables.getLast(orgList.getOrgs()).getHref()); - } - - @Test(testName = "GET /schema/{schemaFileName}", - dependsOnMethods = {"testPostLogin", "testGetLogin"} ) - public void testGetSchema() throws IOException { - String schemafileName = "master.xsd"; - HttpResponse response = context.getUtils().getHttpClient().invoke(HttpRequest.builder() - .method("GET") - .endpoint(URI.create(endpoint+"/v1.5/schema/"+schemafileName)) - .headers(ImmutableMultimap.of( - "x-vcloud-authorization", sessionWithToken.getToken(), - "Accept", "*/*")) - .build()); - - String schema = Strings2.toStringAndClose(response.getPayload().getInput()); - - // TODO: asserting something about the schema - } + private JAXBParser parser = new JAXBParser("true"); + + private SessionWithToken sessionWithToken; + + @Override + protected void setupRequiredClients() throws Exception + { + setupCredentials(); + } + + @Test(testName = "POST /login") + public void testPostLogin() throws IOException + { + testLoginWithMethod("POST"); + } + + @Test(testName = "GET /login") + public void testGetLogin() throws IOException + { + testLoginWithMethod("GET"); + } + + private void testLoginWithMethod(final String method) throws IOException + { + String user = identity.substring(0, identity.lastIndexOf('@')); + String org = identity.substring(identity.lastIndexOf('@') + 1); + String password = credential; + + String authHeader = + "Basic " + + CryptoStreams.base64(String.format("%s@%s:%s", checkNotNull(user), + checkNotNull(org), checkNotNull(password)).getBytes("UTF-8")); + + HttpResponse response = + context + .getUtils() + .getHttpClient() + .invoke( + HttpRequest + .builder() + .method(method) + .endpoint(URI.create(endpoint + "/login")) + .headers(ImmutableMultimap.of("Authorization", authHeader, "Accept", "*/*")) + .build()); + + sessionWithToken = + SessionWithToken.builder().session(session) + .token(response.getFirstHeaderOrNull("x-vcloud-authorization")).build(); + + assertEquals(sessionWithToken.getSession().getUser(), user); + assertEquals(sessionWithToken.getSession().getOrg(), org); + assertTrue(sessionWithToken.getSession().getLinks().size() > 0); + assertNotNull(sessionWithToken.getToken()); + + OrgList orgList = + parser.fromXML(Strings2.toStringAndClose(response.getPayload().getInput()), + OrgList.class); + + assertTrue(orgList.getOrgs().size() > 0, "must have orgs"); + + context.getApi().getOrgClient().getOrg(Iterables.getLast(orgList.getOrgs()).getHref()); + } + + @Test(testName = "GET /schema/{schemaFileName}", dependsOnMethods = {"testPostLogin", + "testGetLogin"}) + public void testGetSchema() throws IOException + { + String schemafileName = "master.xsd"; + HttpResponse response = + context + .getUtils() + .getHttpClient() + .invoke( + HttpRequest + .builder() + .method("GET") + .endpoint(URI.create(endpoint + "/v1.5/schema/" + schemafileName)) + .headers( + ImmutableMultimap.of("x-vcloud-authorization", + sessionWithToken.getToken(), "Accept", "*/*")).build()); + + String schema = Strings2.toStringAndClose(response.getPayload().getInput()); + + // TODO: asserting something about the schema + } } From 6aab0d771668bc6b0a88c874db0943dc334ea887 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Tue, 10 Apr 2012 15:50:43 +0200 Subject: [PATCH 12/69] Added EventBus module to configure the sync and async EventBus --- .../config/ExecutorServiceModule.java | 8 -- .../events/config/ConfiguresEventBus.java | 38 +++++++++ .../jclouds/events/config/EventBusModule.java | 85 +++++++++++++++++++ .../events/config/annotations/AsyncBus.java | 50 +++++++++++ .../handlers/DeadEventLoggingHandler.java | 52 ++++++++++++ .../org/jclouds/rest/RestContextBuilder.java | 16 ++++ .../events/config/EventBusModuleTest.java | 80 +++++++++++++++++ .../jclouds/rest/RestContextBuilderTest.java | 12 +++ 8 files changed, 333 insertions(+), 8 deletions(-) create mode 100644 core/src/main/java/org/jclouds/events/config/ConfiguresEventBus.java create mode 100644 core/src/main/java/org/jclouds/events/config/EventBusModule.java create mode 100644 core/src/main/java/org/jclouds/events/config/annotations/AsyncBus.java create mode 100644 core/src/main/java/org/jclouds/events/handlers/DeadEventLoggingHandler.java create mode 100644 core/src/test/java/org/jclouds/events/config/EventBusModuleTest.java diff --git a/core/src/main/java/org/jclouds/concurrent/config/ExecutorServiceModule.java b/core/src/main/java/org/jclouds/concurrent/config/ExecutorServiceModule.java index 99d8601a4c..e61c7fc824 100644 --- a/core/src/main/java/org/jclouds/concurrent/config/ExecutorServiceModule.java +++ b/core/src/main/java/org/jclouds/concurrent/config/ExecutorServiceModule.java @@ -45,8 +45,6 @@ import org.jclouds.lifecycle.Closer; import org.jclouds.logging.Logger; import com.google.common.annotations.VisibleForTesting; -import com.google.common.eventbus.AsyncEventBus; -import com.google.common.eventbus.EventBus; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.inject.AbstractModule; import com.google.inject.Provides; @@ -323,12 +321,6 @@ public class ExecutorServiceModule extends AbstractModule { } - @Provides - @Singleton - EventBus provideEventBus(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads){ - return new AsyncEventBus(userThreads); - } - @Provides @Singleton @Named(Constants.PROPERTY_USER_THREADS) diff --git a/core/src/main/java/org/jclouds/events/config/ConfiguresEventBus.java b/core/src/main/java/org/jclouds/events/config/ConfiguresEventBus.java new file mode 100644 index 0000000000..13c9cd9481 --- /dev/null +++ b/core/src/main/java/org/jclouds/events/config/ConfiguresEventBus.java @@ -0,0 +1,38 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.events.config; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.google.common.eventbus.EventBus; + +/** + * Designates the module configures an {@link EventBus}. + * + * @author Ignasi Barrera + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface ConfiguresEventBus { + +} diff --git a/core/src/main/java/org/jclouds/events/config/EventBusModule.java b/core/src/main/java/org/jclouds/events/config/EventBusModule.java new file mode 100644 index 0000000000..d7aa3fd864 --- /dev/null +++ b/core/src/main/java/org/jclouds/events/config/EventBusModule.java @@ -0,0 +1,85 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.events.config; + +import java.util.concurrent.ExecutorService; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.Constants; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.events.config.annotations.AsyncBus; +import org.jclouds.events.handlers.DeadEventLoggingHandler; + +import com.google.common.eventbus.AsyncEventBus; +import com.google.common.eventbus.EventBus; +import com.google.inject.AbstractModule; +import com.google.inject.Provides; + +/** + * Configures the {@link EventBus} to be used in the platform. + *

+ * This class will provide an {@link AsyncEventBus} to be used to provide a basic pub/sub system for + * asynchronous operations. + * + * @author Ignasi Barrera + * + * @see ExecutorServiceModule + * @see AsyncEventBus + * @see EventBus + * @see AsyncBus + */ +@ConfiguresEventBus +public class EventBusModule extends AbstractModule { + /** + * Provides an {@link AsyncEventBus} that will use the configured executor service to dispatch + * events to subscribers. + */ + @Provides + @Singleton + AsyncEventBus provideAsyncEventBus( + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService executor, + final DeadEventLoggingHandler deadEventsHandler) { + AsyncEventBus asyncBus = new AsyncEventBus("jclouds-async-event-bus", executor); + asyncBus.register(deadEventsHandler); + return asyncBus; + } + + /** + * Provides asynchronous {@link EventBus}. + */ + @Provides + @Singleton + EventBus provideSyncEventBus(final DeadEventLoggingHandler deadEventsHandler) { + EventBus syncBus = new EventBus("jclouds-sync-event-bus"); + syncBus.register(deadEventsHandler); + return syncBus; + } + + /** + * Configures the {@link EventBus} to be singleton and enables the {@link AsyncBus} annotation. + */ + @Override + protected void configure() { + bind(EventBus.class).annotatedWith(AsyncBus.class).to(AsyncEventBus.class); + } + +} diff --git a/core/src/main/java/org/jclouds/events/config/annotations/AsyncBus.java b/core/src/main/java/org/jclouds/events/config/annotations/AsyncBus.java new file mode 100644 index 0000000000..d92dc367e3 --- /dev/null +++ b/core/src/main/java/org/jclouds/events/config/annotations/AsyncBus.java @@ -0,0 +1,50 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.events.config.annotations; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import org.jclouds.events.config.EventBusModule; + +import com.google.common.eventbus.AsyncEventBus; +import com.google.common.eventbus.EventBus; + +/** + * Used to configure {@link EventBus} injection, providing a flexible way to inject the + * {@link AsyncEventBus}. + * + * @author Ignasi Barrera + * + * @see EventBusModule + */ +@Target({ANNOTATION_TYPE, FIELD, PARAMETER}) +@Retention(RUNTIME) +@Qualifier +public @interface AsyncBus { + +} diff --git a/core/src/main/java/org/jclouds/events/handlers/DeadEventLoggingHandler.java b/core/src/main/java/org/jclouds/events/handlers/DeadEventLoggingHandler.java new file mode 100644 index 0000000000..20f709c1c4 --- /dev/null +++ b/core/src/main/java/org/jclouds/events/handlers/DeadEventLoggingHandler.java @@ -0,0 +1,52 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.events.handlers; + +import javax.annotation.Resource; +import javax.inject.Singleton; + +import org.jclouds.logging.Logger; + +import com.google.common.eventbus.DeadEvent; +import com.google.common.eventbus.Subscribe; + +/** + * Default handler for dead events. + *

+ * It simply logs all dead events to allow debugging and troubleshooting. + * + * @author Ignasi Barrera + */ +@Singleton +public class DeadEventLoggingHandler +{ + @Resource + private Logger logger = Logger.NULL; + + /** + * Due to Guava Issue + * 786 {@link #handleDeadEvent(DeadEvent)} is marked finalto avoid having + * duplicate events. + */ + @Subscribe + public final void handleDeadEvent(DeadEvent deadEvent) { + logger.warn("detected dead event %s", deadEvent.getEvent()); + } +} diff --git a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java index c77a721aa8..86f5c4f763 100644 --- a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java +++ b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java @@ -35,6 +35,8 @@ import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.SingleThreaded; import org.jclouds.concurrent.config.ConfiguresExecutorService; import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.events.config.ConfiguresEventBus; +import org.jclouds.events.config.EventBusModule; import org.jclouds.http.RequiresHttp; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; @@ -109,6 +111,7 @@ public class RestContextBuilder { addHttpModuleIfNeededAndNotPresent(modules); ifHttpConfigureRestOtherwiseGuiceClientFactory(modules); addExecutorServiceIfNotPresent(modules); + addEventBusIfNotPresent(modules); addCredentialStoreIfNotPresent(modules); modules.add(new LifeCycleModule()); modules.add(new BindPropertiesToAnnotations()); @@ -211,6 +214,19 @@ public class RestContextBuilder { protected void addClientModule(List modules) { modules.add(new RestClientModule(syncClientType, asyncClientType)); } + + @VisibleForTesting + protected void addEventBusIfNotPresent(List modules) { + if (!any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresEventBus.class); + } + } + + )) { + modules.add(new EventBusModule()); + } + } @VisibleForTesting protected void addExecutorServiceIfNotPresent(List modules) { diff --git a/core/src/test/java/org/jclouds/events/config/EventBusModuleTest.java b/core/src/test/java/org/jclouds/events/config/EventBusModuleTest.java new file mode 100644 index 0000000000..5deafb7df6 --- /dev/null +++ b/core/src/test/java/org/jclouds/events/config/EventBusModuleTest.java @@ -0,0 +1,80 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.events.config; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import org.jclouds.Constants; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.events.config.annotations.AsyncBus; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import com.google.common.eventbus.AsyncEventBus; +import com.google.common.eventbus.EventBus; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.name.Names; + +/** + * Unit tests for the {@link EventBusModule} class. + * + * @author Ignasi Barrera + */ +@Test(groups = "unit") +public class EventBusModuleTest +{ + private Injector injector; + + @BeforeMethod + public void setup() { + ExecutorServiceModule executorServiceModule = new ExecutorServiceModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Names.named(Constants.PROPERTY_IO_WORKER_THREADS)).to(1); + bindConstant().annotatedWith(Names.named(Constants.PROPERTY_USER_THREADS)).to(1); + super.configure(); + } + }; + EventBusModule eventBusModule = new EventBusModule(); + injector = Guice.createInjector(executorServiceModule, eventBusModule); + } + + public void testAsyncExecutorIsProvided() { + assertNotNull(injector.getInstance(AsyncEventBus.class)); + } + + public void testAsyncAnnotatedEventBusIsBound() { + Key eventBusKey = Key.get(EventBus.class, AsyncBus.class); + EventBus eventBus = injector.getInstance(eventBusKey); + + assertNotNull(eventBus); + assertTrue(eventBus instanceof AsyncEventBus); + } + + public void testEventBusIsSingleton() { + EventBus eventBus1 = injector.getInstance(EventBus.class); + EventBus eventBus2 = injector.getInstance(EventBus.class); + + assertTrue(eventBus1 == eventBus2); + } +} diff --git a/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java b/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java index a3a5b271ec..113be8c1cb 100644 --- a/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java +++ b/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Properties; import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.events.config.EventBusModule; import org.jclouds.http.RequiresHttp; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; @@ -77,6 +78,17 @@ public class RestContextBuilderTest { assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } + + @Test + public void testAddEventBusModuleIfNotPresent() { + List modules = new ArrayList(); + EventBusModule module = new EventBusModule(); + modules.add(module); + new RestContextBuilder(String.class, String.class, new Properties()) + .addEventBusIfNotPresent(modules); + assertEquals(modules.size(), 1); + assertEquals(modules.remove(0), module); + } @Test public void testAddExecutorServiceModuleIfNotPresent() { From f3c5bbf4dac8409ab90e2fd5d8edb16b9b7de75d Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 10 Apr 2012 17:10:56 +0100 Subject: [PATCH 13/69] carrenza-vcloud-director provider --- labs/carrenza-element-vcloud/pom.xml | 145 ++++++++++++++++ .../CarrenzaVCloudDirectorContextBuilder.java | 51 ++++++ ...rrenzaVCloudDirectorPropertiesBuilder.java | 47 ++++++ ...arrenzaVCloudDirectorProviderMetadata.java | 66 ++++++++ ...udDirectorComputeServiceContextModule.java | 34 ++++ ...arrenzaVCloudDirectorRestClientModule.java | 34 ++++ .../org.jclouds.providers.ProviderMetadata | 1 + ...udDirectorNonClientOperationsLiveTest.java | 35 ++++ .../CarrenzaVCloudDirectorProviderTest.java | 35 ++++ ...aVCloudDirectorComputeServiceLiveTest.java | 35 ++++ ...VCloudDirectorTemplateBuilderLiveTest.java | 77 +++++++++ ...zaVCloudDirectorCatalogClientLiveTest.java | 35 ++++ ...enzaVCloudDirectorMediaClientLiveTest.java | 35 ++++ ...zaVCloudDirectorNetworkClientLiveTest.java | 35 ++++ ...rrenzaVCloudDirectorOrgClientLiveTest.java | 35 ++++ ...enzaVCloudDirectorQueryClientLiveTest.java | 35 ++++ ...renzaVCloudDirectorTaskClientLiveTest.java | 35 ++++ ...nzaVCloudDirectorUploadClientLiveTest.java | 35 ++++ ...renzaVCloudDirectorVAppClientLiveTest.java | 35 ++++ ...oudDirectorVAppTemplateClientLiveTest.java | 35 ++++ ...rrenzaVCloudDirectorVdcClientLiveTest.java | 35 ++++ ...oudDirectorAdminCatalogClientLiveTest.java | 35 ++++ ...oudDirectorAdminNetworkClientLiveTest.java | 35 ++++ ...aVCloudDirectorAdminOrgClientLiveTest.java | 35 ++++ ...CloudDirectorAdminQueryClientLiveTest.java | 35 ++++ ...aVCloudDirectorAdminVdcClientLiveTest.java | 35 ++++ ...enzaVCloudDirectorGroupClientLiveTest.java | 35 ++++ ...renzaVCloudDirectorUserClientLiveTest.java | 35 ++++ ...zaVCloudDirectorSessionClientLiveTest.java | 35 ++++ .../src/test/resources/log4j.xml | 157 ++++++++++++++++++ 30 files changed, 1347 insertions(+) create mode 100644 labs/carrenza-element-vcloud/pom.xml create mode 100644 labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java create mode 100644 labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorPropertiesBuilder.java create mode 100644 labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java create mode 100644 labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java create mode 100644 labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java create mode 100644 labs/carrenza-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java create mode 100644 labs/carrenza-element-vcloud/src/test/resources/log4j.xml diff --git a/labs/carrenza-element-vcloud/pom.xml b/labs/carrenza-element-vcloud/pom.xml new file mode 100644 index 0000000000..fa7a2c811c --- /dev/null +++ b/labs/carrenza-element-vcloud/pom.xml @@ -0,0 +1,145 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.5.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.labs + carrenza-vcloud-director + jclouds Carrenza vCloud Director provider + vCloud implementation targeted to Carrenza + bundle + + + https://myvdc.carrenza.net/api + 1.5 + FIXME_VERSION + FIXME_IDENTITY + FIXME_CREDENTIAL + + + + + + + + org.jclouds.labs + vcloud-director + ${project.version} + + + org.jclouds.labs + vcloud-director + ${project.version} + test-jar + test + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.jclouds.driver + jclouds-sshj + ${project.version} + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.carrenza-vcloud.endpoint} + ${test.carrenza-vcloud.api-version} + ${test.carrenza-vcloud.build-version} + ${test.carrenza-vcloud.identity} + ${test.carrenza-vcloud.credential} + ${test.carrenza-vcloud.image-id} + ${test.carrenza-vcloud.image.login-user} + ${test.carrenza-vcloud.image.authenticate-sudo} + + + + + + + + + + + + + + org.apache.felix + maven-bundle-plugin + + + ${project.artifactId} + org.jclouds.carrenza.vcloud*;version="${project.version}" + + org.jclouds.compute.internal;version="${project.version}", + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + + + + diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java new file mode 100644 index 0000000000..39a3fd86ce --- /dev/null +++ b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java @@ -0,0 +1,51 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorComputeServiceContextModule; +import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorRestClientModule; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorContextBuilder; + +import com.google.inject.Module; + +/** + * {@inheritDoc} + * + * @author danikov + */ +public class CarrenzaVCloudDirectorContextBuilder extends VCloudDirectorContextBuilder { + + public CarrenzaVCloudDirectorContextBuilder(Properties props) { + super(props); + } + + @Override + protected void addContextModule(List modules) { +// modules.add(new CarrenzaVCloudDirectorComputeServiceContextModule()); FIXME: enable when compute service done + } + + @Override + protected void addClientModule(List modules) { + modules.add(new CarrenzaVCloudDirectorRestClientModule()); + } + +} diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorPropertiesBuilder.java b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorPropertiesBuilder.java new file mode 100644 index 0000000000..80a81e275a --- /dev/null +++ b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorPropertiesBuilder.java @@ -0,0 +1,47 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director; + +import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; + +import java.util.Properties; + +import org.jclouds.vcloud.director.v1_5.VCloudDirectorPropertiesBuilder; + +/** + * + * @author Adrian Cole + */ +public class CarrenzaVCloudDirectorPropertiesBuilder extends VCloudDirectorPropertiesBuilder { + @Override + public Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_ISO3166_CODES, "GB-LND"); + properties.setProperty(PROPERTY_ENDPOINT, "https://myvdc.carrenza.net/api"); + properties.setProperty(PROPERTY_BUILD_VERSION, "???"); //FIXME +// properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); FIXME: needed? + return properties; + } + + public CarrenzaVCloudDirectorPropertiesBuilder(Properties properties) { + super(properties); + } +} diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java new file mode 100644 index 0000000000..0d28b88cfb --- /dev/null +++ b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java @@ -0,0 +1,66 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director; + +import java.net.URI; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Carrenza vCloud Director + * + * @author dankov + */ +public class CarrenzaVCloudDirectorProviderMetadata extends BaseProviderMetadata { + + public CarrenzaVCloudDirectorProviderMetadata() { + this(builder() + .id("carrenza-vcloud-director") + .name("Carrenza vCloud Director") + .api(new VCloudDirectorApiMetadata()) + .homepage(URI.create("http://carrenza.com/")) + .console(URI.create("https://myvdc.carrenza.net/cloud/org/YOUR_ORG_HERE")) + .iso3166Codes("GB-LND")); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CarrenzaVCloudDirectorProviderMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public CarrenzaVCloudDirectorProviderMetadata build() { + return new CarrenzaVCloudDirectorProviderMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); + } + +} diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java new file mode 100644 index 0000000000..9f1e72b0a7 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java @@ -0,0 +1,34 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.config; + + +/** + * per docs, we are to use pool mode. + * + * @author danikov + */ +public class CarrenzaVCloudDirectorComputeServiceContextModule { // FIXME: enable when compute serivce done +//extends VCloudDirectorComputeServiceContextModule { +// +// @Override +// protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) { +// return options.as(VCloudDirectorTemplateOptions.class).ipAddressAllocationMode(IpAddressAllocationMode.POOL); +// } +} diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java new file mode 100644 index 0000000000..52d3647458 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java @@ -0,0 +1,34 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.config; + +import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; + +/** + * Configures the VCloud authentication service connection, including logging and http transport. + * + * @author danikov + */ +@RequiresHttp +@ConfiguresRestClient +public class CarrenzaVCloudDirectorRestClientModule extends VCloudDirectorRestClientModule { + +} diff --git a/labs/carrenza-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/carrenza-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..8577da069b --- /dev/null +++ b/labs/carrenza-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.carrenza.element.vcloud.CarrenzaElementVCloudProviderMetadata diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java new file mode 100644 index 0000000000..d9468075ba --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director; + +import org.jclouds.vcloud.director.v1_5.NonClientOperationsLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorNonClientOperationsLiveTest") +public class CarrenzaVCloudDirectorNonClientOperationsLiveTest extends NonClientOperationsLiveTest { + + public CarrenzaVCloudDirectorNonClientOperationsLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java new file mode 100644 index 0000000000..d5774cb7e6 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; +import org.testng.annotations.Test; + +/** + * + * @author danikov + */ +@Test(groups = "unit", testName = "CarrenzaVCloudDirectorProviderTest") +public class CarrenzaVCloudDirectorProviderTest extends BaseProviderMetadataTest { + + public CarrenzaVCloudDirectorProviderTest() { + super(new CarrenzaVCloudDirectorProviderMetadata(), new VCloudDirectorApiMetadata()); + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java new file mode 100644 index 0000000000..8a683297ec --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.compute; + +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorComputeServiceLiveTest") +public class CarrenzaVCloudDirectorComputeServiceLiveTest { // FIXME: enable when compute service done +// extends VCloudDirectorComputeServiceLiveTest { +// +// public CarrenzaVCloudDirectorComputeServiceLiveTest() { +// provider = "carrenza-vcloud-director"; +// } +} \ No newline at end of file diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..5295f9f3ea --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java @@ -0,0 +1,77 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Set; + +import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; + +/** + * + * @author danikov + */ +@Test(groups = "live", testName = "CarrenzaVCloudDirectorTemplateBuilderLiveTest") +public class CarrenzaVCloudDirectorTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public CarrenzaVCloudDirectorTemplateBuilderLiveTest() { + provider = "carrenza-vcloud-director"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return !input.version.equals("") || !input.is64Bit; + default: + return true; + } + } + + }; + } + + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = context.getComputeService().templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("GB-LND"); + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java new file mode 100644 index 0000000000..a31297f65f --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.CatalogClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorCatalogClientLiveTest") +public class CarrenzaVCloudDirectorCatalogClientLiveTest extends CatalogClientLiveTest { + + public CarrenzaVCloudDirectorCatalogClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java new file mode 100644 index 0000000000..6c50cfece5 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.MediaClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorMediaClientLiveTest") +public class CarrenzaVCloudDirectorMediaClientLiveTest extends MediaClientLiveTest { + + public CarrenzaVCloudDirectorMediaClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java new file mode 100644 index 0000000000..bd2fd95e09 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.NetworkClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorNetworkClientLiveTest") +public class CarrenzaVCloudDirectorNetworkClientLiveTest extends NetworkClientLiveTest { + + public CarrenzaVCloudDirectorNetworkClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java new file mode 100644 index 0000000000..0257fc879d --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.OrgClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorOrgClientLiveTest") +public class CarrenzaVCloudDirectorOrgClientLiveTest extends OrgClientLiveTest { + + public CarrenzaVCloudDirectorOrgClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java new file mode 100644 index 0000000000..a941813061 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.QueryClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorQueryClientLiveTest") +public class CarrenzaVCloudDirectorQueryClientLiveTest extends QueryClientLiveTest { + + public CarrenzaVCloudDirectorQueryClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java new file mode 100644 index 0000000000..2f7ea669f7 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.TaskClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorTaskClientLiveTest") +public class CarrenzaVCloudDirectorTaskClientLiveTest extends TaskClientLiveTest { + + public CarrenzaVCloudDirectorTaskClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java new file mode 100644 index 0000000000..9370962395 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.UploadClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorUploadClientLiveTest") +public class CarrenzaVCloudDirectorUploadClientLiveTest extends UploadClientLiveTest { + + public CarrenzaVCloudDirectorUploadClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java new file mode 100644 index 0000000000..0d02238828 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.VAppClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorVAppClientLiveTest") +public class CarrenzaVCloudDirectorVAppClientLiveTest extends VAppClientLiveTest { + + public CarrenzaVCloudDirectorVAppClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java new file mode 100644 index 0000000000..cac29c511f --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorVAppTemplateClientLiveTest") +public class CarrenzaVCloudDirectorVAppTemplateClientLiveTest extends VAppTemplateClientLiveTest { + + public CarrenzaVCloudDirectorVAppTemplateClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java new file mode 100644 index 0000000000..d50ab80dfe --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features; + +import org.jclouds.vcloud.director.v1_5.features.VdcClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorVDCClientLiveTest") +public class CarrenzaVCloudDirectorVdcClientLiveTest extends VdcClientLiveTest { + + public CarrenzaVCloudDirectorVdcClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java new file mode 100644 index 0000000000..01c8f151f6 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features.admin; + +import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminCatalogClientLiveTest") +public class CarrenzaVCloudDirectorAdminCatalogClientLiveTest extends AdminCatalogClientLiveTest { + + public CarrenzaVCloudDirectorAdminCatalogClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java new file mode 100644 index 0000000000..681af62394 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features.admin; + +import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminNetworkClientLiveTest") +public class CarrenzaVCloudDirectorAdminNetworkClientLiveTest extends AdminNetworkClientLiveTest { + + public CarrenzaVCloudDirectorAdminNetworkClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java new file mode 100644 index 0000000000..5381337629 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features.admin; + +import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorOrgClientLiveTest") +public class CarrenzaVCloudDirectorAdminOrgClientLiveTest extends AdminOrgClientLiveTest { + + public CarrenzaVCloudDirectorAdminOrgClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java new file mode 100644 index 0000000000..95d47884b8 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features.admin; + +import org.jclouds.vcloud.director.v1_5.features.admin.AdminQueryClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminQueryClientLiveTest") +public class CarrenzaVCloudDirectorAdminQueryClientLiveTest extends AdminQueryClientLiveTest { + + public CarrenzaVCloudDirectorAdminQueryClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java new file mode 100644 index 0000000000..73f2b4da45 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features.admin; + +import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminVdcClientLiveTest") +public class CarrenzaVCloudDirectorAdminVdcClientLiveTest extends AdminVdcClientLiveTest { + + public CarrenzaVCloudDirectorAdminVdcClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java new file mode 100644 index 0000000000..14dd740331 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features.admin; + +import org.jclouds.vcloud.director.v1_5.features.admin.GroupClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorGroupClientLiveTest") +public class CarrenzaVCloudDirectorGroupClientLiveTest extends GroupClientLiveTest { + + public CarrenzaVCloudDirectorGroupClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java new file mode 100644 index 0000000000..afbde8565d --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.features.admin; + +import org.jclouds.vcloud.director.v1_5.features.admin.UserClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorUserClientLiveTest") +public class CarrenzaVCloudDirectorUserClientLiveTest extends UserClientLiveTest { + + public CarrenzaVCloudDirectorUserClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java new file mode 100644 index 0000000000..24685c0d51 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.carrenza.vcloud.director.login; + +import org.jclouds.vcloud.director.v1_5.login.SessionClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author danikov + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorSessionClientLiveTest") +public class CarrenzaVCloudDirectorSessionClientLiveTest extends SessionClientLiveTest { + + public CarrenzaVCloudDirectorSessionClientLiveTest() { + provider = "carrenza-vcloud-director"; + } +} diff --git a/labs/carrenza-element-vcloud/src/test/resources/log4j.xml b/labs/carrenza-element-vcloud/src/test/resources/log4j.xml new file mode 100644 index 0000000000..daefa0e832 --- /dev/null +++ b/labs/carrenza-element-vcloud/src/test/resources/log4j.xml @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 74b5ef76e798e2477bb8c90234e5c4e8614a537d Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 10 Apr 2012 12:39:28 +0100 Subject: [PATCH 14/69] Creation of DMTF labs project --- labs/dmtf/pom.xml | 78 +++ .../java/org/jclouds/dmtf/DMTFConstants.java | 37 ++ .../jclouds/dmtf}/cim/CimAnySimpleType.java | 6 +- .../dmtf}/cim/CimAnySimpleTypeAdapter.java | 2 +- .../org/jclouds/dmtf}/cim/CimBoolean.java | 6 +- .../org/jclouds/dmtf}/cim/CimReference.java | 6 +- .../java/org/jclouds/dmtf}/cim/CimString.java | 2 +- .../org/jclouds/dmtf}/cim/CimUnsignedInt.java | 2 +- .../jclouds/dmtf}/cim/CimUnsignedLong.java | 2 +- .../jclouds/dmtf}/cim/CimUnsignedShort.java | 2 +- .../java/org/jclouds/dmtf}/cim/OSType.java | 2 +- .../dmtf}/cim/ResourceAllocationCaption.java | 2 +- .../cim/ResourceAllocationChangeableType.java | 2 +- .../cim/ResourceAllocationSettingData.java | 358 +++++------- .../dmtf}/cim/VirtualSystemCaption.java | 2 +- .../cim/VirtualSystemChangeableType.java | 2 +- .../dmtf}/cim/VirtualSystemSettingData.java | 224 ++++---- .../org/jclouds/dmtf}/cim/package-info.java | 23 +- .../org/jclouds/dmtf}/ovf/Configuration.java | 6 +- .../dmtf}/ovf/DeploymentOptionSection.java | 2 +- .../main/java/org/jclouds/dmtf}/ovf/Disk.java | 2 +- .../org/jclouds/dmtf}/ovf/DiskSection.java | 2 +- .../main/java/org/jclouds/dmtf}/ovf/Item.java | 2 +- .../java/org/jclouds/dmtf}/ovf/MsgType.java | 2 +- .../java/org/jclouds/dmtf}/ovf/Network.java | 2 +- .../org/jclouds/dmtf}/ovf/NetworkSection.java | 12 +- .../dmtf/ovf/OperatingSystemSection.java | 164 ++++++ .../org/jclouds/dmtf}/ovf/ProductSection.java | 22 +- .../dmtf}/ovf/ProductSectionProperty.java | 2 +- .../java/org/jclouds/dmtf}/ovf/Property.java | 2 +- .../ovf/PropertyConfigurationValueType.java | 2 +- .../org/jclouds/dmtf}/ovf/SectionType.java | 28 +- .../org/jclouds/dmtf}/ovf/StartupSection.java | 2 +- .../jclouds/dmtf}/ovf/StartupSectionItem.java | 2 +- .../dmtf}/ovf/VirtualHardwareSection.java | 115 +--- .../dmtf}/ovf/environment/EntityType.java | 8 +- .../ovf/environment/EnvironmentType.java | 8 +- .../ovf/environment/PlatformSectionType.java | 4 +- .../dmtf}/ovf/environment/Property.java | 8 +- .../ovf/environment/PropertySectionType.java | 2 +- .../dmtf}/ovf/environment/SectionType.java | 2 +- .../dmtf}/ovf/environment/package-info.java | 15 +- .../dmtf}/ovf/internal/BaseEnvelope.java | 85 +-- .../dmtf/ovf/internal/BaseVirtualSystem.java | 175 ++++++ .../dmtf}/ovf/internal/package-info.java | 11 +- .../org/jclouds/dmtf}/ovf/package-info.java | 15 +- labs/dmtf/src/test/resources/log4j.xml | 151 +++++ labs/pom.xml | 1 + labs/vcloud-director/pom.xml | 5 + .../v1_5/VCloudDirectorApiMetadata.java | 1 - .../v1_5/VCloudDirectorConstants.java | 10 - .../admin/VCloudDirectorAdminAsyncClient.java | 6 - .../v1_5/admin/VCloudDirectorAdminClient.java | 8 +- .../v1_5/domain/AbstractVAppType.java | 26 +- .../vcloud/director/v1_5/domain/AdminVdc.java | 1 + .../v1_5/domain/CapacityWithUsage.java | 5 + .../v1_5/domain/CaptureVAppParams.java | 4 +- .../vcloud/director/v1_5/domain/Catalog.java | 1 + .../director/v1_5/domain/CatalogItem.java | 1 + .../v1_5/domain/CloneMediaParams.java | 2 + .../v1_5/domain/ComposeVAppParams.java | 5 +- .../v1_5/domain/CustomizationSection.java | 2 +- .../director/v1_5/domain/DhcpService.java | 1 + .../vcloud/director/v1_5/domain/Entity.java | 1 + .../{ovf/VirtualSystem.java => Envelope.java} | 43 +- .../vcloud/director/v1_5/domain/File.java | 4 +- .../director/v1_5/domain/FirewallService.java | 2 + .../domain/GuestCustomizationSection.java | 2 +- .../v1_5/domain/InstantiateOvfParams.java | 5 +- .../v1_5/domain/InstantiateVAppParams.java | 4 +- .../domain/InstantiateVAppTemplateParams.java | 1 + .../v1_5/domain/InstantiationParams.java | 2 +- .../v1_5/domain/IpsecVpnManagedPeerType.java | 7 +- .../v1_5/domain/IpsecVpnRemotePeer.java | 2 +- .../director/v1_5/domain/IpsecVpnService.java | 2 + .../v1_5/domain/LeaseSettingsSection.java | 2 +- .../vcloud/director/v1_5/domain/Link.java | 1 + .../vcloud/director/v1_5/domain/Media.java | 1 + .../vcloud/director/v1_5/domain/Metadata.java | 1 + .../director/v1_5/domain/MetadataEntry.java | 1 + .../director/v1_5/domain/MetadataValue.java | 1 + .../vcloud/director/v1_5/domain/NatRule.java | 2 +- .../director/v1_5/domain/NatService.java | 1 + .../v1_5/domain/NetworkConfigSection.java | 2 +- .../v1_5/domain/NetworkConnectionSection.java | 2 +- .../{ovf => }/OperatingSystemSection.java | 115 ++-- .../vcloud/director/v1_5/domain/Org.java | 1 + .../v1_5/domain/OrgGeneralSettings.java | 2 + .../director/v1_5/domain/OrgSettings.java | 2 + .../vcloud/director/v1_5/domain/Owner.java | 1 + .../v1_5/domain/ProductSectionList.java | 14 +- .../vcloud/director/v1_5/domain/RasdItem.java | 191 +++++++ .../director/v1_5/domain/RasdItemsList.java | 22 +- .../v1_5/domain/RecomposeVAppParams.java | 1 + .../director/v1_5/domain/References.java | 1 - .../vcloud/director/v1_5/domain/Resource.java | 1 + .../v1_5/domain/RuntimeInfoSection.java | 2 +- .../v1_5/domain/StaticRoutingService.java | 2 + .../vcloud/director/v1_5/domain/Task.java | 1 + .../director/v1_5/domain/TasksList.java | 1 + .../v1_5/domain/UploadVAppTemplateParams.java | 2 + .../vcloud/director/v1_5/domain/User.java | 3 + .../vcloud/director/v1_5/domain/VApp.java | 1 + .../v1_5/domain/VAppCreationParams.java | 166 +++++- .../v1_5/domain/VAppCreationParamsType.java | 207 ------- .../director/v1_5/domain/VAppNetwork.java | 1 + .../v1_5/domain/VAppNetworkConfiguration.java | 1 + .../director/v1_5/domain/VAppTemplate.java | 34 +- .../v1_5/domain/VirtualHardwareSection.java | 189 +++++++ .../director/v1_5/domain/VirtualSystem.java | 149 +++++ .../vcloud/director/v1_5/domain/Vm.java | 3 +- .../v1_5/domain/VmPendingQuestion.java | 1 + .../director/v1_5/domain/ovf/Envelope.java | 136 ----- .../ovf/internal/BaseVirtualSystem.java | 224 -------- .../director/v1_5/domain/package-info.java | 9 +- .../director/v1_5/domain/query/QueryList.java | 1 + .../query/QueryResultNetworkRecord.java | 2 +- .../v1_5/domain/query/package-info.java | 9 +- .../v1_5/features/VAppAsyncClient.java | 18 +- .../director/v1_5/features/VAppClient.java | 18 +- .../features/VAppTemplateAsyncClient.java | 4 +- .../v1_5/features/VAppTemplateClient.java | 4 +- .../admin/AdminCatalogAsyncClient.java | 1 - .../features/admin/AdminCatalogClient.java | 1 - .../admin/AdminNetworkAsyncClient.java | 1 - .../features/admin/AdminNetworkClient.java | 1 - .../features/admin/AdminOrgAsyncClient.java | 1 - .../v1_5/features/admin/AdminOrgClient.java | 1 - .../features/admin/AdminVdcAsyncClient.java | 1 - .../v1_5/features/admin/AdminVdcClient.java | 1 - .../v1_5/user/VCloudDirectorAsyncClient.java | 8 - .../v1_5/user/VCloudDirectorClient.java | 9 - .../v1_5/AbstractVAppClientLiveTest.java | 521 ++++++++---------- .../v1_5/NonClientOperationsLiveTest.java | 1 - .../vcloud/director/v1_5/domain/Checks.java | 48 +- .../v1_5/features/VAppClientExpectTest.java | 26 +- .../v1_5/features/VAppClientLiveTest.java | 35 +- .../features/VAppTemplateClientLiveTest.java | 4 +- .../admin/AdminCatalogClientExpectTest.java | 1 - .../admin/AdminNetworkClientExpectTest.java | 1 - .../admin/AdminOrgClientExpectTest.java | 1 - .../admin/AdminQueryClientExpectTest.java | 1 - .../admin/AdminVdcClientExpectTest.java | 1 - .../admin/AdminVdcClientLiveTest.java | 2 - ...sionAndRetryOn401AndLogoutOnCloseTest.java | 1 - .../BaseVCloudDirectorExpectTest.java | 8 - 146 files changed, 2216 insertions(+), 1778 deletions(-) create mode 100644 labs/dmtf/pom.xml create mode 100644 labs/dmtf/src/main/java/org/jclouds/dmtf/DMTFConstants.java rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/CimAnySimpleType.java (90%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/CimAnySimpleTypeAdapter.java (95%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/CimBoolean.java (91%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/CimReference.java (93%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/CimString.java (97%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/CimUnsignedInt.java (97%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/CimUnsignedLong.java (97%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/CimUnsignedShort.java (97%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/OSType.java (99%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/ResourceAllocationCaption.java (94%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/ResourceAllocationChangeableType.java (94%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/ResourceAllocationSettingData.java (72%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/VirtualSystemCaption.java (94%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/VirtualSystemChangeableType.java (94%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/VirtualSystemSettingData.java (76%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/cim/package-info.java (54%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/Configuration.java (94%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/DeploymentOptionSection.java (98%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/Disk.java (99%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/DiskSection.java (98%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/Item.java (99%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/MsgType.java (98%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/Network.java (98%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/NetworkSection.java (91%) create mode 100644 labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/ProductSection.java (94%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/ProductSectionProperty.java (95%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/Property.java (99%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/PropertyConfigurationValueType.java (97%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/SectionType.java (78%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/StartupSection.java (98%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/StartupSectionItem.java (97%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/VirtualHardwareSection.java (66%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/environment/EntityType.java (90%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/environment/EnvironmentType.java (92%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/environment/PlatformSectionType.java (97%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/environment/Property.java (87%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/environment/PropertySectionType.java (98%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/environment/SectionType.java (97%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/environment/package-info.java (69%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/internal/BaseEnvelope.java (64%) create mode 100644 labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/internal/package-info.java (77%) rename labs/{vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain => dmtf/src/main/java/org/jclouds/dmtf}/ovf/package-info.java (64%) create mode 100644 labs/dmtf/src/test/resources/log4j.xml rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ovf/VirtualSystem.java => Envelope.java} (56%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ovf => }/OperatingSystemSection.java (61%) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RasdItem.java delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualSystem.java delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Envelope.java delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/BaseVirtualSystem.java diff --git a/labs/dmtf/pom.xml b/labs/dmtf/pom.xml new file mode 100644 index 0000000000..28ad055190 --- /dev/null +++ b/labs/dmtf/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.5.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.labs + dmtf + jclouds dmtf domain objects + jclouds implementation of DMTF OVF and CIM domain objects + bundle + + + + + + + org.jclouds + jclouds-compute + ${project.version} + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + + + + + org.apache.felix + maven-bundle-plugin + + + ${project.artifactId} + org.jclouds.dmtf.*;version="${project.version}" + + org.jclouds*;version="${project.version}", + * + + + + + + + diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/DMTFConstants.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/DMTFConstants.java new file mode 100644 index 0000000000..decf84dbb6 --- /dev/null +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/DMTFConstants.java @@ -0,0 +1,37 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.dmtf; + +/** + * Constants used by DMTF. + * + * @author grkvlt@apache.org + */ +public class DMTFConstants { + + public static final String OVF_NS = "http://schemas.dmtf.org/ovf/envelope/1"; + + public static final String OVF_ENV_NS = "http://schemas.dmtf.org/ovf/environment/1"; + + public static final String CIM_NS = "http://schemas.dmtf.org/wbem/wscim/1/common"; + + public static final String CIM_VSSD_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"; + + public static final String CIM_RASD_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"; +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimAnySimpleType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleType.java similarity index 90% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimAnySimpleType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleType.java index d527e3e76e..943a919bde 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimAnySimpleType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleType.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_NS; import java.util.HashMap; import java.util.Map; @@ -37,7 +37,7 @@ import javax.xml.namespace.QName; * <complexType name="cimAnySimpleType" /> *

*/ -@XmlType(name = "cimAnySimpleType", namespace = VCLOUD_CIM_NS) +@XmlType(name = "cimAnySimpleType", namespace = CIM_NS) public class CimAnySimpleType { @XmlValue diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimAnySimpleTypeAdapter.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleTypeAdapter.java similarity index 95% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimAnySimpleTypeAdapter.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleTypeAdapter.java index 8eff91d360..4c3238624d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimAnySimpleTypeAdapter.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleTypeAdapter.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimBoolean.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimBoolean.java similarity index 91% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimBoolean.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimBoolean.java index 7ca5cceb1a..ea185d0c28 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimBoolean.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimBoolean.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_NS; import java.util.HashMap; import java.util.Map; @@ -35,7 +35,7 @@ import javax.xml.namespace.QName; * <complexType name="cimBoolean" /> * */ -@XmlType(name = "cimBoolean", namespace = VCLOUD_CIM_NS) +@XmlType(name = "cimBoolean", namespace = CIM_NS) public class CimBoolean { @XmlValue diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimReference.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimReference.java similarity index 93% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimReference.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimReference.java index 8c90b242e9..9276c89c53 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimReference.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimReference.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_NS; import java.util.ArrayList; import java.util.HashMap; @@ -37,7 +37,7 @@ import javax.xml.namespace.QName; * <complexType name="cimReference" /> * */ -@XmlType(name = "cimReference", namespace = VCLOUD_CIM_NS) +@XmlType(name = "cimReference", namespace = CIM_NS) public class CimReference { @XmlAnyElement(lax = true) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimString.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimString.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimString.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimString.java index 08c9f20323..e0706e03e0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimString.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimString.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedInt.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedInt.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedInt.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedInt.java index e78d7f1c88..07f2bd902f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedInt.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedInt.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import java.util.HashMap; import java.util.Map; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedLong.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedLong.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedLong.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedLong.java index d920852b6e..1102d82135 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedLong.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedLong.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import java.math.BigInteger; import java.util.HashMap; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedShort.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedShort.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedShort.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedShort.java index 24114eac2b..47e420fbb1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CimUnsignedShort.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedShort.java @@ -6,7 +6,7 @@ // -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import java.util.HashMap; import java.util.Map; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/OSType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/OSType.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/OSType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/OSType.java index 7e4b9a4289..006776e78c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/OSType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/OSType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import org.jclouds.compute.domain.OsFamily; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationCaption.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationCaption.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationCaption.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationCaption.java index fdbba4e431..c2067437ee 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationCaption.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationCaption.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationChangeableType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationChangeableType.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationChangeableType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationChangeableType.java index 5a79ee798d..787313a9e6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationChangeableType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationChangeableType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationSettingData.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationSettingData.java similarity index 72% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationSettingData.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationSettingData.java index 67dbd71f64..33e0fbf7f7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationSettingData.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationSettingData.java @@ -16,35 +16,27 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_RASD_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_RASD_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import java.math.BigInteger; -import java.net.URI; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Set; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.Link; - import com.google.common.base.Function; import com.google.common.base.Objects; -import com.google.common.collect.ImmutableList; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -61,10 +53,9 @@ import com.google.common.collect.Sets; * * @author Adrian Cole * @author grkvlt@apache.org - * @see http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd + * @see CIM_ResourceAllocationSettingData */ -@XmlRootElement(name = "Item", namespace = VCLOUD_1_5_NS) -@XmlType(name = "CIM_ResourceAllocationSettingData_Type", namespace = VCLOUD_OVF_NS, +@XmlType(name = "CIM_ResourceAllocationSettingData_Type", namespace = OVF_NS, propOrder = { "address", "addressOnParent", @@ -88,21 +79,23 @@ import com.google.common.collect.Sets; "resourceType", "virtualQuantity", "virtualQuantityUnits", - "weight", - "links" + "weight" } ) public class ResourceAllocationSettingData { - public static Builder builder() { - return new Builder(); + public static Builder builder() { + return new ConcreteBuilder(); } - public Builder toBuilder() { + public Builder toBuilder() { return builder().fromResourceAllocationSettingData(this); } - public static class Builder { + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> { private String elementName; private String instanceID; @@ -125,254 +118,219 @@ public class ResourceAllocationSettingData { private BigInteger virtualQuantity; private String virtualQuantityUnits; private Long weight; - private List connections = Lists.newArrayList(); - private List hostResources = Lists.newArrayList(); - private URI href; - private String type; - private Set links = Sets.newLinkedHashSet(); + private Set connections = Sets.newLinkedHashSet(); + private Set hostResources = Sets.newLinkedHashSet(); + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } /** * @see ResourceAllocationSettingData#getElementName() */ - public Builder elementName(String elementName) { + public B elementName(String elementName) { this.elementName = elementName; - return this; + return self(); } /** *@see ResourceAllocationSettingData#getInstanceId() */ - public Builder instanceID(String instanceID) { + public B instanceID(String instanceID) { this.instanceID = instanceID; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getCaption() */ - public Builder caption(String caption) { + public B caption(String caption) { this.caption = caption; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getDescription() */ - public Builder description(String description) { + public B description(String description) { this.description = description; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getAddress */ - public Builder address(String address) { + public B address(String address) { this.address = address; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getAddressOnParent */ - public Builder addressOnParent(String addressOnParent) { + public B addressOnParent(String addressOnParent) { this.addressOnParent = addressOnParent; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getAllocationUnits */ - public Builder allocationUnits(String allocationUnits) { + public B allocationUnits(String allocationUnits) { this.allocationUnits = allocationUnits; - return this; + return self(); } /** * @see ResourceAllocationSettingData#isAutomaticAllocation() */ - public Builder automaticAllocation(Boolean automaticAllocation) { + public B automaticAllocation(Boolean automaticAllocation) { this.automaticAllocation = automaticAllocation; - return this; + return self(); } /** * @see ResourceAllocationSettingData#isAutomaticDeallocation() */ - public Builder automaticDeallocation(Boolean automaticDeallocation) { + public B automaticDeallocation(Boolean automaticDeallocation) { this.automaticDeallocation = automaticDeallocation; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getConsumerVisibility */ - public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { + public B consumerVisibility(ConsumerVisibility consumerVisibility) { this.consumerVisibility = consumerVisibility; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getLimit */ - public Builder limit(BigInteger limit) { + public B limit(BigInteger limit) { this.limit = limit; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getMappingBehavior */ - public Builder mappingBehavior(MappingBehavior mappingBehavior) { + public B mappingBehavior(MappingBehavior mappingBehavior) { this.mappingBehavior = mappingBehavior; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getOtherResourceType */ - public Builder otherResourceType(String otherResourceType) { + public B otherResourceType(String otherResourceType) { this.otherResourceType = otherResourceType; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getParent */ - public Builder parent(String parent) { + public B parent(String parent) { this.parent = parent; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getPoolID */ - public Builder poolID(String poolID) { + public B poolID(String poolID) { this.poolID = poolID; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getReservation */ - public Builder reservation(BigInteger reservation) { + public B reservation(BigInteger reservation) { this.reservation = reservation; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getResourceSubType */ - public Builder resourceSubType(String resourceSubType) { + public B resourceSubType(String resourceSubType) { this.resourceSubType = resourceSubType; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getResourceType */ - public Builder resourceType(ResourceType resourceType) { + public B resourceType(ResourceType resourceType) { this.resourceType = resourceType; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getVirtualQuantity */ - public Builder virtualQuantity(BigInteger virtualQuantity) { + public B virtualQuantity(BigInteger virtualQuantity) { this.virtualQuantity = virtualQuantity; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getVirtualQuantityUnits */ - public Builder virtualQuantityUnits(String virtualQuantityUnits) { + public B virtualQuantityUnits(String virtualQuantityUnits) { this.virtualQuantityUnits = virtualQuantityUnits; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getWeight */ - public Builder weight(Long weight) { + public B weight(Long weight) { this.weight = weight; - return this; + return self(); } /** * @see ResourceAllocationSettingData#getConnections() */ - public Builder connection(CimString connection) { + public B connection(CimString connection) { this.connections.add(checkNotNull(connection, "connection")); - return this; + return self(); } /** * @see ResourceAllocationSettingData#getConnections */ - public Builder connections(List connections) { - this.connections = Lists.newArrayList(checkNotNull(connections, "connections")); - return this; + public B connections(Iterable connections) { + this.connections = Sets.newLinkedHashSet(checkNotNull(connections, "connections")); + return self(); } /** * @see ResourceAllocationSettingData#getHostResources() */ - public Builder hostResource(CimString hostResource) { + public B hostResource(CimString hostResource) { this.hostResources.add(checkNotNull(hostResource, "hostResource")); - return this; + return self(); } /** * @see ResourceAllocationSettingData#getHostResources */ - public Builder hostResources(List hostResources) { - this.hostResources = Lists.newArrayList(checkNotNull(hostResources, "hostResources")); - return this; - } - - /** - * @see ResourceAllocationSettingData#getType() - */ - public Builder type(String type) { - this.type = type; - return this; - } - - /** - * @see ResourceAllocationSettingData#getHref() - */ - public Builder href(URI href) { - this.href = href; - return this; - } - - /** - * @see ResourceAllocationSettingData#getLinks() - */ - public Builder links(Set links) { - this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); - return this; - } - - /** - * @see ResourceAllocationSettingData#getLinks() - */ - public Builder link(Link link) { - if (links == null) - links = Sets.newLinkedHashSet(); - this.links.add(checkNotNull(link, "link")); - return this; + public B hostResources(Iterable hostResources) { + this.hostResources = Sets.newLinkedHashSet(checkNotNull(hostResources, "hostResources")); + return self(); } public ResourceAllocationSettingData build() { - return new ResourceAllocationSettingData(elementName, instanceID, caption, description, address, - addressOnParent, allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, - mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, - virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, type, href, links); + return new ResourceAllocationSettingData(this); } - public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { + public B fromResourceAllocationSettingData(ResourceAllocationSettingData in) { return elementName(in.getElementName()) .instanceID(in.getInstanceID()) .caption(in.getCaption()) @@ -395,10 +353,7 @@ public class ResourceAllocationSettingData { .virtualQuantityUnits(in.getVirtualQuantityUnits()) .weight(in.getWeight()) .connections(in.getConnections()) - .hostResources(in.getHostResources()) - .type(in.getType()) - .href(in.getHref()) - .links(Sets.newLinkedHashSet(in.getLinks())); + .hostResources(in.getHostResources()); } } @@ -560,96 +515,80 @@ public class ResourceAllocationSettingData { } } - // foo - - @XmlElement(name = "ElementName", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "ElementName", namespace = CIM_RASD_NS) private String elementName; - @XmlElement(name = "InstanceID", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "InstanceID", namespace = CIM_RASD_NS) private String instanceID; - @XmlElement(name = "Caption", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "Caption", namespace = CIM_RASD_NS) private String caption; - @XmlElement(name = "Description", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "Description", namespace = CIM_RASD_NS) private String description; - @XmlElement(name = "Address", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "Address", namespace = CIM_RASD_NS) private String address; - @XmlElement(name = "AddressOnParent", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "AddressOnParent", namespace = CIM_RASD_NS) private String addressOnParent; - @XmlElement(name = "AllocationUnits", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "AllocationUnits", namespace = CIM_RASD_NS) private String allocationUnits; - @XmlElement(name = "AutomaticAllocation", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "AutomaticAllocation", namespace = CIM_RASD_NS) private Boolean automaticAllocation; - @XmlElement(name = "AutomaticDeallocation", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "AutomaticDeallocation", namespace = CIM_RASD_NS) private Boolean automaticDeallocation; - @XmlElement(name = "ConsumerVisibility", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "ConsumerVisibility", namespace = CIM_RASD_NS) private ConsumerVisibility consumerVisibility; - @XmlElement(name = "Limit", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "Limit", namespace = CIM_RASD_NS) private BigInteger limit; - @XmlElement(name = "MappingBehavior", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "MappingBehavior", namespace = CIM_RASD_NS) private MappingBehavior mappingBehavior; - @XmlElement(name = "OtherResourceType", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "OtherResourceType", namespace = CIM_RASD_NS) private String otherResourceType; - @XmlElement(name = "Parent", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "Parent", namespace = CIM_RASD_NS) private String parent; - @XmlElement(name = "PoolID", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "PoolID", namespace = CIM_RASD_NS) private String poolID; - @XmlElement(name = "Reservation", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "Reservation", namespace = CIM_RASD_NS) private BigInteger reservation; - @XmlElement(name = "ResourceSubType", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "ResourceSubType", namespace = CIM_RASD_NS) private String resourceSubType; - @XmlElement(name = "ResourceType", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "ResourceType", namespace = CIM_RASD_NS) private ResourceType resourceType; - @XmlElement(name = "VirtualQuantity", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "VirtualQuantity", namespace = CIM_RASD_NS) private BigInteger virtualQuantity; - @XmlElement(name = "VirtualQuantityUnits", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "VirtualQuantityUnits", namespace = CIM_RASD_NS) private String virtualQuantityUnits; - @XmlElement(name = "Weight", namespace = VCLOUD_CIM_RASD_NS) + @XmlElement(name = "Weight", namespace = CIM_RASD_NS) private Long weight; - @XmlElement(name = "Connection", namespace = VCLOUD_CIM_RASD_NS) - private List connections = Lists.newArrayList(); - @XmlElement(name = "HostResource", namespace = VCLOUD_CIM_RASD_NS) - private List hostResources = Lists.newArrayList(); - @XmlAttribute(name = "type", namespace = VCLOUD_1_5_NS) - private String type; - @XmlAttribute(name = "href", namespace = VCLOUD_1_5_NS) - private URI href; - @XmlElement(name = "Link", namespace = VCLOUD_1_5_NS) - private Set links = Sets.newLinkedHashSet(); + @XmlElement(name = "Connection", namespace = CIM_RASD_NS) + private Set connections = Sets.newLinkedHashSet(); + @XmlElement(name = "HostResource", namespace = CIM_RASD_NS) + private Set hostResources = Sets.newLinkedHashSet(); - private ResourceAllocationSettingData(String elementName, String instanceID, String caption, String description, - String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation, - Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, BigInteger limit, - MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, BigInteger reservation, - String resourceSubType, ResourceType resourceType, BigInteger virtualQuantity, String virtualQuantityUnits, - Long weight, List connections, List hostResources, String type, URI href, Set links) { - this.elementName = elementName; - this.instanceID = instanceID; - this.caption = caption; - this.description = description; - this.address = address; - this.addressOnParent = addressOnParent; - this.allocationUnits = allocationUnits; - this.automaticAllocation = automaticAllocation; - this.automaticDeallocation = automaticDeallocation; - this.consumerVisibility = consumerVisibility; - this.limit = limit; - this.mappingBehavior = mappingBehavior; - this.otherResourceType = otherResourceType; - this.parent = parent; - this.poolID = poolID; - this.reservation = reservation; - this.resourceSubType = resourceSubType; - this.resourceType = resourceType; - this.virtualQuantity = virtualQuantity; - this.virtualQuantityUnits = virtualQuantityUnits; - this.weight = weight; - this.connections = ImmutableList.copyOf(connections); - this.hostResources = ImmutableList.copyOf(hostResources); - this.type = type; - this.href = href; - this.links = links != null ? ImmutableSet.copyOf(links) : Collections.emptySet(); + protected ResourceAllocationSettingData(Builder builder) { + this.elementName = builder.elementName; + this.instanceID = builder.instanceID; + this.caption = builder.caption; + this.description = builder.description; + this.address = builder.address; + this.addressOnParent = builder.addressOnParent; + this.allocationUnits = builder.allocationUnits; + this.automaticAllocation = builder.automaticAllocation; + this.automaticDeallocation = builder.automaticDeallocation; + this.consumerVisibility = builder.consumerVisibility; + this.limit = builder.limit; + this.mappingBehavior = builder.mappingBehavior; + this.otherResourceType = builder.otherResourceType; + this.parent = builder.parent; + this.poolID = builder.poolID; + this.reservation = builder.reservation; + this.resourceSubType = builder.resourceSubType; + this.resourceType = builder.resourceType; + this.virtualQuantity = builder.virtualQuantity; + this.virtualQuantityUnits = builder.virtualQuantityUnits; + this.weight = builder.weight; + this.connections = builder.connections != null ? ImmutableSet.copyOf(builder.connections) : Collections.emptySet(); + this.hostResources = builder.hostResources != null ? ImmutableSet.copyOf(builder.hostResources) : Collections.emptySet(); } - private ResourceAllocationSettingData() { + protected ResourceAllocationSettingData() { // for JAXB } @@ -808,7 +747,6 @@ public class ResourceAllocationSettingData { /** * A string describing an implementation specific sub-type for this resource. - * F */ public String getResourceSubType() { return resourceSubType; @@ -864,8 +802,8 @@ public class ResourceAllocationSettingData { * The thing to which this resource is connected. For example, a named * network or switch port. */ - public List getConnections() { - return Collections.unmodifiableList(connections); + public Set getConnections() { + return ImmutableSet.copyOf(connections); } /** @@ -886,30 +824,19 @@ public class ResourceAllocationSettingData { * value(s) to indicate that the requested virtual resource allocation be * based on host resources that are identified by element values. */ - public List getHostResources() { - return Collections.unmodifiableList(hostResources); - } - - public String getType() { - return type; - } - - public URI getHref() { - return href; - } - - /** - * Set of optional links to an entity or operation associated with this object. - */ - public Set getLinks() { - return links != null ? ImmutableSet.copyOf(links) : Collections.emptySet(); + public Set getHostResources() { + return ImmutableSet.copyOf(hostResources); } @Override public String toString() { + return string().toString(); + } + + public ToStringHelper string() { return Objects.toStringHelper("") - .add("elementname", elementName) - .add("instanceId", instanceID) + .add("elementName", elementName) + .add("instanceID", instanceID) .add("caption", caption) .add("description", description) .add("address", address) @@ -930,11 +857,7 @@ public class ResourceAllocationSettingData { .add("resourceType", resourceType) .add("virtualQuantity", virtualQuantity) .add("virtualQuantityUnits", virtualQuantityUnits) - .add("weight", weight) - .add("type", type) - .add("href", href) - .add("links", links) - .toString(); + .add("weight", weight); } @Override @@ -944,7 +867,7 @@ public class ResourceAllocationSettingData { automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, - resourceType, virtualQuantity, virtualQuantityUnits, weight, type, href, links); + resourceType, virtualQuantity, virtualQuantityUnits, weight); } @Override @@ -978,10 +901,7 @@ public class ResourceAllocationSettingData { equal(this.resourceType, that.resourceType) && equal(this.virtualQuantity, that.virtualQuantity) && equal(this.virtualQuantityUnits, that.virtualQuantityUnits) && - equal(this.weight, that.weight) && - equal(this.type, that.type) && - equal(this.href, that.href) && - equal(this.links, that.links); + equal(this.weight, that.weight); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemCaption.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemCaption.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemCaption.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemCaption.java index 26defdac88..3a469d780c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemCaption.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemCaption.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemChangeableType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemChangeableType.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemChangeableType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemChangeableType.java index 38847d644a..b5fd366e1b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemChangeableType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemChangeableType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemSettingData.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java similarity index 76% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemSettingData.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java index 062368073c..0402a6b842 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/VirtualSystemSettingData.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.cim; +package org.jclouds.dmtf.cim; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_VSSD_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_VSSD_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import java.math.BigInteger; import java.util.Date; @@ -58,9 +58,9 @@ import com.google.common.collect.Maps; * * @author Adrian Cole * @author grkvlt@apache.org - * @see http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd + * @see CIM_VirtualSystemSettingData */ -@XmlType(name = "CIM_VirtualSystemSettingData_Type", namespace = VCLOUD_OVF_NS, +@XmlType(name = "CIM_VirtualSystemSettingData_Type", namespace = OVF_NS, propOrder = { "automaticRecoveryAction", "automaticShutdownAction", @@ -87,15 +87,18 @@ import com.google.common.collect.Maps; ) public class VirtualSystemSettingData { - public static Builder builder() { - return new Builder(); + public static Builder builder() { + return new ConcreteBuilder(); } - public Builder toBuilder() { + public Builder toBuilder() { return builder().fromVirtualSystemSettingData(this); } - public static class Builder { + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> { private String elementName; private String instanceID; @@ -119,120 +122,121 @@ public class VirtualSystemSettingData { private String virtualSystemType; private String notes; - public Builder elementName(String elementName) { + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + + public B elementName(String elementName) { this.elementName = elementName; - return this; + return self(); } - public Builder instanceID(String instanceID) { + public B instanceID(String instanceID) { this.instanceID = instanceID; - return this; + return self(); } - public Builder caption(String caption) { + public B caption(String caption) { this.caption = caption; - return this; + return self(); } - public Builder description(String description) { + public B description(String description) { this.description = description; - return this; + return self(); } - public Builder automaticRecoveryAction(AutomaticRecoveryAction automaticRecoveryAction) { + public B automaticRecoveryAction(AutomaticRecoveryAction automaticRecoveryAction) { this.automaticRecoveryAction = automaticRecoveryAction; - return this; + return self(); } - public Builder automaticShutdownAction(AutomaticShutdownAction automaticShutdownAction) { + public B automaticShutdownAction(AutomaticShutdownAction automaticShutdownAction) { this.automaticShutdownAction = automaticShutdownAction; - return this; + return self(); } - public Builder automaticStartupAction(AutomaticStartupAction automaticStartupAction) { + public B automaticStartupAction(AutomaticStartupAction automaticStartupAction) { this.automaticStartupAction = automaticStartupAction; - return this; + return self(); } - public Builder automaticStartupActionDelay(BigInteger automaticStartupActionDelay) { + public B automaticStartupActionDelay(BigInteger automaticStartupActionDelay) { this.automaticStartupActionDelay = automaticStartupActionDelay; - return this; + return self(); } - public Builder automaticStartupActionSequenceNumber(Long automaticStartupActionSequenceNumber) { + public B automaticStartupActionSequenceNumber(Long automaticStartupActionSequenceNumber) { this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber; - return this; + return self(); } - public Builder configurationDataRoot(String configurationDataRoot) { + public B configurationDataRoot(String configurationDataRoot) { this.configurationDataRoot = configurationDataRoot; - return this; + return self(); } - public Builder configurationFile(String configurationFile) { + public B configurationFile(String configurationFile) { this.configurationFile = configurationFile; - return this; + return self(); } - public Builder configurationID(String configurationID) { + public B configurationID(String configurationID) { this.configurationID = configurationID; - return this; + return self(); } - public Builder creationTime(Date creationTime) { + public B creationTime(Date creationTime) { this.creationTime = creationTime; - return this; + return self(); } - public Builder logDataRoot(String logDataRoot) { + public B logDataRoot(String logDataRoot) { this.logDataRoot = logDataRoot; - return this; + return self(); } - public Builder recoveryFile(String recoveryFile) { + public B recoveryFile(String recoveryFile) { this.recoveryFile = recoveryFile; - return this; + return self(); } - public Builder snapshotDataRoot(String snapshotDataRoot) { + public B snapshotDataRoot(String snapshotDataRoot) { this.snapshotDataRoot = snapshotDataRoot; - return this; + return self(); } - public Builder suspendDataRoot(String suspendDataRoot) { + public B suspendDataRoot(String suspendDataRoot) { this.suspendDataRoot = suspendDataRoot; - return this; + return self(); } - public Builder swapFileDataRoot(String swapFileDataRoot) { + public B swapFileDataRoot(String swapFileDataRoot) { this.swapFileDataRoot = swapFileDataRoot; - return this; + return self(); } - public Builder virtualSystemIdentifier(String virtualSystemIdentifier) { + public B virtualSystemIdentifier(String virtualSystemIdentifier) { this.virtualSystemIdentifier = virtualSystemIdentifier; - return this; + return self(); } - public Builder virtualSystemType(String virtualSystemType) { + public B virtualSystemType(String virtualSystemType) { this.virtualSystemType = virtualSystemType; - return this; + return self(); } - public Builder notes(String notes) { + public B notes(String notes) { this.notes = notes; - return this; + return self(); } public VirtualSystemSettingData build() { - return new VirtualSystemSettingData(elementName, instanceID, caption, description, automaticRecoveryAction, - automaticShutdownAction, automaticStartupAction, automaticStartupActionDelay, - automaticStartupActionSequenceNumber, configurationDataRoot, configurationFile, configurationID, - creationTime, logDataRoot, recoveryFile, snapshotDataRoot, suspendDataRoot, swapFileDataRoot, - virtualSystemIdentifier, virtualSystemType, notes); + return new VirtualSystemSettingData(this); } - public Builder fromVirtualSystemSettingData(VirtualSystemSettingData in) { + public B fromVirtualSystemSettingData(VirtualSystemSettingData in) { return elementName(in.getElementName()) .instanceID(in.getInstanceID()) .caption(in.getCaption()) @@ -363,49 +367,73 @@ public class VirtualSystemSettingData { } } - @XmlElement(name = "ElementName", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "ElementName", namespace = CIM_VSSD_NS) private String elementName; - @XmlElement(name = "InstanceID", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "InstanceID", namespace = CIM_VSSD_NS) private String instanceID; - @XmlElement(name = "Caption", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "Caption", namespace = CIM_VSSD_NS) private String caption; - @XmlElement(name = "Description", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "Description", namespace = CIM_VSSD_NS) private String description; - @XmlElement(name = "VirtualSystemIdentifier", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "VirtualSystemIdentifier", namespace = CIM_VSSD_NS) private String virtualSystemIdentifier; - @XmlElement(name = "VirtualSystemType", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "VirtualSystemType", namespace = CIM_VSSD_NS) private String virtualSystemType; - @XmlElement(name = "AutomaticRecoveryAction", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "AutomaticRecoveryAction", namespace = CIM_VSSD_NS) private AutomaticRecoveryAction automaticRecoveryAction; - @XmlElement(name = "AutomaticShutdownAction", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "AutomaticShutdownAction", namespace = CIM_VSSD_NS) private AutomaticShutdownAction automaticShutdownAction; - @XmlElement(name = "AutomaticStartupAction", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "AutomaticStartupAction", namespace = CIM_VSSD_NS) private AutomaticStartupAction automaticStartupAction; - @XmlElement(name = "AutomaticStartupActionDelay", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "AutomaticStartupActionDelay", namespace = CIM_VSSD_NS) private BigInteger automaticStartupActionDelay; - @XmlElement(name = "AutomaticStartupActionSequenceNumber", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "AutomaticStartupActionSequenceNumber", namespace = CIM_VSSD_NS) private Long automaticStartupActionSequenceNumber; - @XmlElement(name = "ConfigurationDataRoot", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "ConfigurationDataRoot", namespace = CIM_VSSD_NS) private String configurationDataRoot; - @XmlElement(name = "ConfigurationFile", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "ConfigurationFile", namespace = CIM_VSSD_NS) private String configurationFile; - @XmlElement(name = "ConfigurationID", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "ConfigurationID", namespace = CIM_VSSD_NS) private String configurationID; - @XmlElement(name = "CreationTime", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "CreationTime", namespace = CIM_VSSD_NS) private Date creationTime; - @XmlElement(name = "LogDataRoot", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "LogDataRoot", namespace = CIM_VSSD_NS) private String logDataRoot; - @XmlElement(name = "RecoveryFile", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "RecoveryFile", namespace = CIM_VSSD_NS) private String recoveryFile; - @XmlElement(name = "SnapshotDataRoot", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "SnapshotDataRoot", namespace = CIM_VSSD_NS) private String snapshotDataRoot; - @XmlElement(name = "SuspendDataRoot", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "SuspendDataRoot", namespace = CIM_VSSD_NS) private String suspendDataRoot; - @XmlElement(name = "SwapFileDataRoot", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "SwapFileDataRoot", namespace = CIM_VSSD_NS) private String swapFileDataRoot; - @XmlElement(name = "Notes", namespace = VCLOUD_CIM_VSSD_NS) + @XmlElement(name = "Notes", namespace = CIM_VSSD_NS) private String notes; + private VirtualSystemSettingData(Builder builder) { + this.elementName = builder.elementName; + this.instanceID = builder.instanceID; + this.caption = builder.caption; + this.description = builder.description; + this.automaticRecoveryAction = builder.automaticRecoveryAction; + this.automaticShutdownAction = builder.automaticShutdownAction; + this.automaticStartupAction = builder.automaticStartupAction; + this.automaticStartupActionDelay = builder.automaticStartupActionDelay; + this.automaticStartupActionSequenceNumber = builder.automaticStartupActionSequenceNumber; + this.configurationDataRoot = builder.configurationDataRoot; + this.configurationFile = builder.configurationFile; + this.configurationID = builder.configurationID; + this.creationTime = builder.creationTime; + this.logDataRoot = builder.logDataRoot; + this.recoveryFile = builder.recoveryFile; + this.snapshotDataRoot = builder.snapshotDataRoot; + this.suspendDataRoot = builder.suspendDataRoot; + this.swapFileDataRoot = builder.swapFileDataRoot; + this.virtualSystemIdentifier = builder.virtualSystemIdentifier; + this.virtualSystemType = builder.virtualSystemType; + this.notes = builder.notes; + } + private VirtualSystemSettingData(String elementName, String instanceID, String caption, String description, AutomaticRecoveryAction automaticRecoveryAction, AutomaticShutdownAction automaticShutdownAction, AutomaticStartupAction automaticStartupAction, BigInteger automaticStartupActionDelay, @@ -644,26 +672,26 @@ public class VirtualSystemSettingData { if (getClass() != obj.getClass()) return false; VirtualSystemSettingData that = VirtualSystemSettingData.class.cast(obj); - return equal(this.elementName, that.elementName) && - equal(this.instanceID, that.instanceID) && - equal(this.caption, that.caption) && - equal(this.description, that.description) && - equal(this.automaticRecoveryAction, that.automaticRecoveryAction) && - equal(this.automaticShutdownAction, that.automaticShutdownAction) && - equal(this.automaticStartupAction, that.automaticStartupAction) && - equal(this.automaticStartupActionDelay, that.automaticStartupActionDelay) && - equal(this.automaticStartupActionSequenceNumber, that.automaticStartupActionSequenceNumber) && - equal(this.configurationDataRoot, that.configurationDataRoot) && - equal(this.configurationFile, that.configurationFile) && - equal(this.configurationID, that.configurationID) && - equal(this.creationTime, that.creationTime) && - equal(this.logDataRoot, that.logDataRoot) && - equal(this.recoveryFile, that.recoveryFile) && - equal(this.snapshotDataRoot, that.snapshotDataRoot) && - equal(this.suspendDataRoot, that.suspendDataRoot) && - equal(this.swapFileDataRoot, that.swapFileDataRoot) && - equal(this.virtualSystemIdentifier, that.virtualSystemIdentifier) && - equal(this.virtualSystemType, that.virtualSystemType); + return equal(this.elementName, that.elementName) + && equal(this.instanceID, that.instanceID) + && equal(this.caption, that.caption) + && equal(this.description, that.description) + && equal(this.automaticRecoveryAction, that.automaticRecoveryAction) + && equal(this.automaticShutdownAction, that.automaticShutdownAction) + && equal(this.automaticStartupAction, that.automaticStartupAction) + && equal(this.automaticStartupActionDelay, that.automaticStartupActionDelay) + && equal(this.automaticStartupActionSequenceNumber, that.automaticStartupActionSequenceNumber) + && equal(this.configurationDataRoot, that.configurationDataRoot) + && equal(this.configurationFile, that.configurationFile) + && equal(this.configurationID, that.configurationID) + && equal(this.creationTime, that.creationTime) + && equal(this.logDataRoot, that.logDataRoot) + && equal(this.recoveryFile, that.recoveryFile) + && equal(this.snapshotDataRoot, that.snapshotDataRoot) + && equal(this.suspendDataRoot, that.suspendDataRoot) + && equal(this.swapFileDataRoot, that.swapFileDataRoot) + && equal(this.virtualSystemIdentifier, that.virtualSystemIdentifier) + && equal(this.virtualSystemType, that.virtualSystemType); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/package-info.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/package-info.java similarity index 54% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/package-info.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/cim/package-info.java index eab73abaf2..99b3064a1c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/package-info.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/package-info.java @@ -16,22 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -@XmlSchema(namespace = VCLOUD_CIM_NS, elementFormDefault = XmlNsForm.QUALIFIED, +@XmlSchema(namespace = CIM_NS, elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { - @XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS), - @XmlNs(prefix = "ovf", namespaceURI = VCLOUD_OVF_NS), - @XmlNs(prefix = "vssd", namespaceURI = VCLOUD_CIM_VSSD_NS), - @XmlNs(prefix = "rasd", namespaceURI = VCLOUD_CIM_RASD_NS), - @XmlNs(prefix = "vcloud", namespaceURI = VCLOUD_1_5_NS) + @XmlNs(prefix = "cim", namespaceURI = CIM_NS), + @XmlNs(prefix = "ovf", namespaceURI = OVF_NS), + @XmlNs(prefix = "vssd", namespaceURI = CIM_VSSD_NS), + @XmlNs(prefix = "rasd", namespaceURI = CIM_RASD_NS) } ) @XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.vcloud.director.v1_5.domain.cim; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_RASD_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_VSSD_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; +package org.jclouds.dmtf.cim; + +import static org.jclouds.dmtf.DMTFConstants.CIM_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_RASD_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_VSSD_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Configuration.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Configuration.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Configuration.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Configuration.java index dcc7c2d3aa..a35cc7afbf 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Configuration.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Configuration.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -30,7 +30,7 @@ import com.google.common.base.Objects; * @author Adrian Cole * @author Adam Lowe */ -@XmlType(name = "Configuration", namespace = VCLOUD_OVF_NS, propOrder = { +@XmlType(name = "Configuration", namespace = OVF_NS, propOrder = { "label", "description" }) public class Configuration { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DeploymentOptionSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DeploymentOptionSection.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java index a9fb6707c1..8cb3161d47 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DeploymentOptionSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Disk.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Disk.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Disk.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Disk.java index e869d5e9f8..0227061cfa 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Disk.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Disk.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import java.net.URI; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DiskSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DiskSection.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java index a697545f6b..69567fbde0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DiskSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Item.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Item.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Item.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Item.java index 8f35ce8487..ae3e15e13e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Item.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Item.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/MsgType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/MsgType.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/MsgType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/MsgType.java index e0695793c5..cb18197068 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/MsgType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/MsgType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Network.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Network.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Network.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Network.java index d58df57f62..14850834c3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Network.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Network.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import javax.xml.bind.annotation.XmlRootElement; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/NetworkSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java similarity index 91% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/NetworkSection.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java index 06c4ff6f3e..c165436a1a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/NetworkSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Preconditions.checkNotNull; @@ -84,7 +84,7 @@ public class NetworkSection extends SectionType { private NetworkSection(Builder builder) { super(builder); - this.networks = ImmutableSet. copyOf(checkNotNull(networks, "networks")); + this.networks = ImmutableSet.copyOf(checkNotNull(networks, "networks")); } private NetworkSection() { @@ -94,8 +94,6 @@ public class NetworkSection extends SectionType { /** * All networks referred to from Connection elements in all {@link VirtualHardwareSection} * elements shall be defined in the NetworkSection. - * - * @return */ public Set getNetworks() { return networks; @@ -115,12 +113,14 @@ public class NetworkSection extends SectionType { if (getClass() != obj.getClass()) return false; NetworkSection other = (NetworkSection) obj; - return super.equals(other) && Objects.equal(networks, other.networks); + return super.equals(other) + && Objects.equal(networks, other.networks); } @Override protected Objects.ToStringHelper string() { - return super.string().add("networks", networks); + return super.string() + .add("networks", networks); } } \ No newline at end of file diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java new file mode 100644 index 0000000000..14e8dd6a5b --- /dev/null +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java @@ -0,0 +1,164 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.dmtf.ovf; + +import static com.google.common.base.Objects.equal; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + +/** + * An OperatingSystemSection specifies the operating system installed on a virtual machine. + * + * @author Adrian Cole + * @author Adam Lowe + */ +@XmlRootElement(name = "OperatingSystemSection") +@XmlType(name = "OperatingSystemSection_Type") +public class OperatingSystemSection extends SectionType { + + public static Builder builder() { + return new ConcreteBuilder(); + } + + public Builder toBuilder() { + return builder().fromOperatingSystemSection(this); + } + + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> extends SectionType.Builder { + + private int id; + private String description; + private String version; + + /** + * @see OperatingSystemSection#getId() + */ + public B id(int id) { + this.id = id; + return self(); + } + + /** + * @see OperatingSystemSection#getVersion() + */ + public B version(String version) { + this.version = version; + return self(); + } + + /** + * @see OperatingSystemSection#getDescription + */ + public B description(String description) { + this.description = description; + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public OperatingSystemSection build() { + return new OperatingSystemSection(this); + } + + public B fromOperatingSystemSection(OperatingSystemSection in) { + return fromSectionType(in) + .id(in.getId()) + .version(in.getVersion()) + .description(in.getDescription()); + } + } + + @XmlAttribute(namespace = OVF_NS, required = true) + protected int id; + @XmlAttribute(namespace = OVF_NS) + protected String version; + @XmlElement(name = "Description") + protected String description; + + public OperatingSystemSection(Builder builder) { + super(builder); + this.id = builder.id; + this.description = builder.description; + this.version = builder.version; + } + + protected OperatingSystemSection() { + // For Builders and JAXB + } + + /** + * Gets the OVF id + * + * @see org.jclouds.vcloud.director.v1_5.domain.cim.OSType#getCode() + */ + public int getId() { + return id; + } + + /** + * Gets the version + */ + public String getVersion() { + return version; + } + + /** + * Gets the description or null + */ + public String getDescription() { + return description; + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), id, version, description); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + + OperatingSystemSection that = (OperatingSystemSection) obj; + return super.equals(that) + && equal(this.id, that.id) + && equal(this.version, that.version) + && equal(this.description, that.description); + } + + @Override + protected Objects.ToStringHelper string() { + return super.string() + .add("id", id) + .add("version", version) + .add("description", description); + } +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/ProductSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/ProductSection.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java index 4f384910ce..f75f8db476 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/ProductSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java @@ -16,11 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_NS; import java.util.Collections; import java.util.Set; @@ -29,7 +29,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.cim.CimString; +import org.jclouds.dmtf.cim.CimString; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; @@ -69,6 +69,12 @@ public class ProductSection extends SectionType { private CimString appUrl; protected Set properties = Sets.newLinkedHashSet(); + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + /** * @see ProductSection#getProduct() */ @@ -190,15 +196,15 @@ public class ProductSection extends SectionType { private MsgType product; @XmlElement(name = "Vendor") private MsgType vendor; - @XmlElement(name = "Version", namespace = VCLOUD_CIM_NS) + @XmlElement(name = "Version", namespace = CIM_NS) private CimString version; - @XmlElement(name = "FullVersion", namespace = VCLOUD_CIM_NS) + @XmlElement(name = "FullVersion", namespace = CIM_NS) private CimString fullVersion; - @XmlElement(name = "ProductUrl", namespace = VCLOUD_CIM_NS) + @XmlElement(name = "ProductUrl", namespace = CIM_NS) private CimString productUrl; - @XmlElement(name = "VendorUrl", namespace = VCLOUD_CIM_NS) + @XmlElement(name = "VendorUrl", namespace = CIM_NS) private CimString vendorUrl; - @XmlElement(name = "AppUrl", namespace = VCLOUD_CIM_NS) + @XmlElement(name = "AppUrl", namespace = CIM_NS) private CimString appUrl; @XmlElement(name = "Property") private Set properties = Sets.newLinkedHashSet(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/ProductSectionProperty.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSectionProperty.java similarity index 95% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/ProductSectionProperty.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSectionProperty.java index 235e1dbd27..22f04cbcfa 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/ProductSectionProperty.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSectionProperty.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Property.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Property.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Property.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Property.java index 0cbc300b75..4a8ba382e1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Property.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Property.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/PropertyConfigurationValueType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/PropertyConfigurationValueType.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/PropertyConfigurationValueType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/PropertyConfigurationValueType.java index 210594fc88..19d1bbe924 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/PropertyConfigurationValueType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/PropertyConfigurationValueType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/SectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java similarity index 78% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/SectionType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java index ed058d489c..7b03911274 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/SectionType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java @@ -16,23 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Objects.equal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; -import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection; - import com.google.common.base.Objects; /** @@ -45,21 +38,6 @@ import com.google.common.base.Objects; * @author grkvlt@apache.org */ @XmlType(name = "Section_Type") -@XmlSeeAlso({ - CustomizationSection.class, - DeploymentOptionSection.class, - DiskSection.class, - LeaseSettingsSection.class, - GuestCustomizationSection.class, - NetworkSection.class, - NetworkConfigSection.class, - NetworkConnectionSection.class, - OperatingSystemSection.class, - ProductSection.class, - RuntimeInfoSection.class, - StartupSection.class, - VirtualHardwareSection.class, - VirtualSystem.class }) public abstract class SectionType { public static abstract class Builder> { @@ -112,7 +90,7 @@ public abstract class SectionType { @XmlElement(name = "Info", required = true) private String info; - @XmlAttribute(namespace = VCLOUD_OVF_NS) + @XmlAttribute(namespace = OVF_NS) private Boolean required; protected SectionType(Builder builder) { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/StartupSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/StartupSection.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java index 991acfe6bb..7fd5071789 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/StartupSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/StartupSectionItem.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSectionItem.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/StartupSectionItem.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSectionItem.java index 3b5beec298..ca2c716ab1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/StartupSectionItem.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSectionItem.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/VirtualHardwareSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java similarity index 66% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/VirtualHardwareSection.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java index 3332b28d58..ed3c2c1806 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/VirtualHardwareSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java @@ -16,24 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import java.net.URI; import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.Link; -import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData; -import org.jclouds.vcloud.director.v1_5.domain.cim.VirtualSystemSettingData; +import org.jclouds.dmtf.cim.ResourceAllocationSettingData; +import org.jclouds.dmtf.cim.VirtualSystemSettingData; import com.google.common.base.Joiner; import com.google.common.base.Objects; @@ -71,12 +67,9 @@ public class VirtualHardwareSection extends SectionType { private VirtualSystemSettingData virtualSystem; private String transport; private Set items = Sets.newLinkedHashSet(); - private Set links = Sets.newLinkedHashSet(); - private URI href; - private String type; /** - * @see VirtualHardwareSection#getSystem + * @see VirtualHardwareSection#getSystem() */ public B system(VirtualSystemSettingData virtualSystem) { this.virtualSystem = virtualSystem; @@ -123,38 +116,6 @@ public class VirtualHardwareSection extends SectionType { return self(); } - /** - * @see VirtualHardwareSection#getLinks() - */ - public B links(Set links) { - this.links = checkNotNull(links, "links"); - return self(); - } - - /** - * @see VirtualHardwareSection#getLinks() - */ - public B link(Link link) { - this.links.add(checkNotNull(link, "link")); - return self(); - } - - /** - * @see VirtualHardwareSection#getHref() - */ - public B href(URI href) { - this.href = href; - return self(); - } - - /** - * @see VirtualHardwareSection#getType() - */ - public B type(String type) { - this.type = type; - return self(); - } - /** * {@inheritDoc} */ @@ -167,38 +128,25 @@ public class VirtualHardwareSection extends SectionType { return fromSectionType(in) .items(in.getItems()) .transport(in.getTransport()) - .system(in.getSystem()) - .links(Sets.newLinkedHashSet(in.getLinks())) - .href(in.getHref()) - .type(in.getType()); + .system(in.getSystem()); } } @XmlElement(name = "System") - private VirtualSystemSettingData virtualSystem; + protected VirtualSystemSettingData virtualSystem; @XmlAttribute(name = "transport") - private String transport; + protected String transport; @XmlElement(name = "Item") - private Set items = Sets.newLinkedHashSet(); - @XmlElement(name = "Link", namespace = VCLOUD_1_5_NS) - protected Set links = Sets.newLinkedHashSet(); - @XmlAttribute(namespace = VCLOUD_1_5_NS) - @XmlSchemaType(name = "anyURI") - protected URI href; - @XmlAttribute(namespace = VCLOUD_1_5_NS) - protected String type; + protected Set items = Sets.newLinkedHashSet(); - private VirtualHardwareSection(Builder builder) { + protected VirtualHardwareSection(Builder builder) { super(builder); this.virtualSystem = builder.virtualSystem; this.transport = builder.transport; this.items = builder.items != null ? ImmutableSet.copyOf(builder.items) : Sets.newLinkedHashSet(); - this.links = builder.links != null ? ImmutableSet.copyOf(builder.links) : Sets.newLinkedHashSet(); - this.href = builder.href; - this.type = builder.type; } - private VirtualHardwareSection() { + protected VirtualHardwareSection() { // For JAXB } @@ -229,36 +177,13 @@ public class VirtualHardwareSection extends SectionType { return virtualSystem; } - public Set getItems() { + public Set getItems() { return ImmutableSet.copyOf(items); } - /** - * Gets the value of the link property. - */ - public Set getLinks() { - return ImmutableSet.copyOf(links); - } - - /** - * @return the value of the href property. - */ - public URI getHref() { - return href; - } - - /** - * Gets the value of the type property. - * - * @return possible object is {@link String } - */ - public String getType() { - return type; - } - @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), transport, virtualSystem, items, links, href, type); + return Objects.hashCode(super.hashCode(), transport, virtualSystem, items); } @Override @@ -267,17 +192,17 @@ public class VirtualHardwareSection extends SectionType { if (obj == null) return false; if (getClass() != obj.getClass()) return false; VirtualHardwareSection that = VirtualHardwareSection.class.cast(obj); - return super.equals(that) && - equal(this.transport, that.transport) && - equal(this.virtualSystem, that.virtualSystem) && - equal(this.items, that.items) && - equal(this.links, that.links) && - equal(this.href, that.href) && - equal(this.type, that.type); + return super.equals(that) + && equal(this.transport, that.transport) + && equal(this.virtualSystem, that.virtualSystem) + && equal(this.items, that.items); } @Override protected Objects.ToStringHelper string() { - return super.string().add("transport", transport).add("virtualSystem", virtualSystem).add("items", items).add("links", links).add("href", href).add("type", type); + return super.string() + .add("transport", transport) + .add("virtualSystem", virtualSystem) + .add("items", items); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/EntityType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EntityType.java similarity index 90% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/EntityType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EntityType.java index 41e67ec2bc..57d38e238a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/EntityType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EntityType.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf.environment; +package org.jclouds.dmtf.ovf.environment; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_ENV_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_ENV_NS; import java.util.Map; import java.util.Set; @@ -54,11 +54,11 @@ import com.google.common.collect.Sets; @XmlType(name = "Entity_Type") public class EntityType { - @XmlElementRef(name = "Section", namespace = VCLOUD_OVF_ENV_NS) + @XmlElementRef(name = "Section", namespace = OVF_ENV_NS) protected Set> sections = Sets.newLinkedHashSet(); @XmlAnyElement(lax = true) protected Set any = Sets.newLinkedHashSet(); - @XmlAttribute(namespace = VCLOUD_OVF_ENV_NS, required = true) + @XmlAttribute(namespace = OVF_ENV_NS, required = true) protected String id; @XmlAnyAttribute private Map otherAttributes = Maps.newLinkedHashMap(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/EnvironmentType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EnvironmentType.java similarity index 92% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/EnvironmentType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EnvironmentType.java index d7356beea4..75127666a9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/EnvironmentType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EnvironmentType.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf.environment; +package org.jclouds.dmtf.ovf.environment; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_ENV_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_ENV_NS; import java.util.Map; import java.util.Set; @@ -56,13 +56,13 @@ import com.google.common.collect.Sets; @XmlType(name = "Environment_Type") public class EnvironmentType { - @XmlElementRef(name = "Section", namespace = VCLOUD_OVF_ENV_NS) + @XmlElementRef(name = "Section", namespace = OVF_ENV_NS) protected Set> sections = Sets.newLinkedHashSet(); @XmlElement(name = "Entity") protected Set entities = Sets.newLinkedHashSet(); @XmlAnyElement(lax = true) protected Set any = Sets.newLinkedHashSet(); - @XmlAttribute(namespace = VCLOUD_OVF_ENV_NS) + @XmlAttribute(namespace = OVF_ENV_NS) protected String id; @XmlAnyAttribute private Map otherAttributes = Maps.newLinkedHashMap(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/PlatformSectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PlatformSectionType.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/PlatformSectionType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PlatformSectionType.java index 10424e41a6..026bbac131 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/PlatformSectionType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PlatformSectionType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf.environment; +package org.jclouds.dmtf.ovf.environment; import java.util.Set; @@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.cim.CimString; +import org.jclouds.dmtf.cim.CimString; import com.google.common.base.Objects; import com.google.common.collect.Sets; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/Property.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/Property.java similarity index 87% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/Property.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/Property.java index b370113d7c..0b06dc05d4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/Property.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/Property.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf.environment; +package org.jclouds.dmtf.ovf.environment; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_ENV_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_ENV_NS; import java.util.HashMap; import java.util.Map; @@ -34,9 +34,9 @@ import javax.xml.namespace.QName; @XmlType(name = "") public class Property { - @XmlAttribute(namespace = VCLOUD_OVF_ENV_NS, required = true) + @XmlAttribute(namespace = OVF_ENV_NS, required = true) protected String key; - @XmlAttribute(namespace = VCLOUD_OVF_ENV_NS, required = true) + @XmlAttribute(namespace = OVF_ENV_NS, required = true) protected String value; @XmlAnyAttribute private Map otherAttributes = new HashMap(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/PropertySectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PropertySectionType.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/PropertySectionType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PropertySectionType.java index e56fc04904..f60913dbed 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/PropertySectionType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PropertySectionType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf.environment; +package org.jclouds.dmtf.ovf.environment; import java.util.Set; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/SectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/SectionType.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/SectionType.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/SectionType.java index 2da26a0076..ea60969848 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/SectionType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/SectionType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf.environment; +package org.jclouds.dmtf.ovf.environment; import java.util.Map; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/package-info.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/package-info.java similarity index 69% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/package-info.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/package-info.java index b7217a07d6..4c5614427f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/environment/package-info.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/package-info.java @@ -16,19 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -@XmlSchema(namespace = VCLOUD_OVF_ENV_NS, +@XmlSchema(namespace = OVF_ENV_NS, elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { - @XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS), - @XmlNs(prefix = "ovf", namespaceURI = VCLOUD_OVF_NS) + @XmlNs(prefix = "cim", namespaceURI = CIM_NS), + @XmlNs(prefix = "ovf", namespaceURI = OVF_NS), + @XmlNs(prefix = "env", namespaceURI = OVF_ENV_NS) } ) @XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.vcloud.director.v1_5.domain.ovf.environment; +package org.jclouds.dmtf.ovf.environment; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_ENV_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_ENV_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/BaseEnvelope.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java similarity index 64% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/BaseEnvelope.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java index f74ea65e6f..8303ac6aec 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/BaseEnvelope.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java @@ -16,15 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf.internal; +package org.jclouds.dmtf.ovf.internal; import static com.google.common.base.Preconditions.checkNotNull; import java.util.Set; -import org.jclouds.vcloud.director.v1_5.domain.ovf.DiskSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.ovf.DiskSection; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; @@ -32,80 +32,87 @@ import com.google.common.collect.Sets; /** * @author Adrian Cole + * @author grkvlt@apache.org */ public abstract class BaseEnvelope> { - - // FIXME Fix builder pattern used - public abstract Builder toBuilder(); + public abstract Builder toBuilder(); + + public static abstract class Builder, V extends BaseVirtualSystem, E extends BaseEnvelope> { - public static abstract class Builder> { protected Set diskSections = Sets.newLinkedHashSet(); protected Set networkSections = Sets.newLinkedHashSet(); protected Set additionalSections = Sets.newLinkedHashSet(); protected V virtualSystem; + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + /** * @see BaseEnvelope#getDiskSections */ - public Builder diskSection(DiskSection diskSection) { + public B diskSection(DiskSection diskSection) { this.diskSections.add(checkNotNull(diskSection, "diskSection")); - return this; + return self(); } /** * @see BaseEnvelope#getDiskSections */ - public Builder diskSections(Iterable diskSections) { + public B diskSections(Iterable diskSections) { this.diskSections = ImmutableSet. copyOf(checkNotNull(diskSections, "diskSections")); - return this; + return self(); } /** * @see BaseEnvelope#getNetworkSections */ - public Builder networkSection(NetworkSection networkSection) { + public B networkSection(NetworkSection networkSection) { this.networkSections.add(checkNotNull(networkSection, "networkSection")); - return this; + return self(); } /** * @see BaseEnvelope#getNetworkSections */ - public Builder networkSections(Iterable networkSections) { + public B networkSections(Iterable networkSections) { this.networkSections = ImmutableSet. copyOf(checkNotNull(networkSections, "networkSections")); - return this; + return self(); } /** * @see BaseEnvelope#getAdditionalSections */ - public Builder additionalSection(SectionType additionalSection) { + public B additionalSection(SectionType additionalSection) { this.additionalSections.add(checkNotNull(additionalSection, "additionalSection")); - return this; + return self(); } /** * @see BaseEnvelope#getAdditionalSections */ - public Builder additionalSections(Iterable additionalSections) { + public B additionalSections(Iterable additionalSections) { this.additionalSections = ImmutableSet. copyOf(checkNotNull(additionalSections, "additionalSections")); - return this; + return self(); } /** * @see BaseEnvelope#getVirtualSystem */ - public Builder virtualSystem(V virtualSystem) { + public B virtualSystem(V virtualSystem) { this.virtualSystem = virtualSystem; - return this; + return self(); } - public abstract E build() ; + public abstract E build(); - public Builder fromEnvelope(BaseEnvelope in) { - return virtualSystem(in.getVirtualSystem()).diskSections(in.getDiskSections()) - .networkSections(networkSections).additionalSections(in.getAdditionalSections()); + public B fromEnvelope(BaseEnvelope in) { + return virtualSystem(in.getVirtualSystem()) + .diskSections(in.getDiskSections()) + .networkSections(networkSections) + .additionalSections(in.getAdditionalSections()); } } @@ -115,12 +122,11 @@ public abstract class BaseEnvelope additionalSections; private V virtualSystem; - protected BaseEnvelope(Iterable diskSections, Iterable networkSections, - Iterable additionalSections, V virtualSystem) { - this.diskSections = ImmutableSet.copyOf(checkNotNull(diskSections, "diskSections")); - this.networkSections = ImmutableSet.copyOf(checkNotNull(networkSections, "networkSections")); - this.additionalSections = ImmutableSet.copyOf(checkNotNull(additionalSections, "additionalSections")); - this.virtualSystem = checkNotNull(virtualSystem, "virtualSystem"); + protected BaseEnvelope(Builder builder) { + this.diskSections = ImmutableSet.copyOf(checkNotNull(builder.diskSections, "diskSections")); + this.networkSections = ImmutableSet.copyOf(checkNotNull(builder.networkSections, "networkSections")); + this.additionalSections = ImmutableSet.copyOf(checkNotNull(builder.additionalSections, "additionalSections")); + this.virtualSystem = checkNotNull(builder.virtualSystem, "virtualSystem"); } protected BaseEnvelope() { @@ -134,6 +140,10 @@ public abstract class BaseEnvelope getDiskSections() { return diskSections; } + + public Set getNetworkSections() { + return networkSections; + } public Set getAdditionalSections() { return additionalSections; @@ -163,11 +173,10 @@ public abstract class BaseEnvelope getNetworkSections() { - return networkSections; + return Objects.toStringHelper("") + .add("diskSections", diskSections) + .add("networkSections", networkSections) + .add("additionalSections", additionalSections) + .add("virtualSystem", virtualSystem); } } \ No newline at end of file diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java new file mode 100644 index 0000000000..74bd231a3c --- /dev/null +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java @@ -0,0 +1,175 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.dmtf.ovf.internal; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; + +import org.jclouds.dmtf.ovf.ProductSection; +import org.jclouds.dmtf.ovf.SectionType; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * @author Adrian Cole + */ +public abstract class BaseVirtualSystem extends SectionType { + + public static abstract class Builder> extends SectionType.Builder { + + private String id; + private String name; + private Set productSections = Sets.newLinkedHashSet(); + private Set additionalSections = Sets.newLinkedHashSet(); + + /** + * @see BaseVirtualSystem#getName() + */ + public B name(String name) { + this.name = name; + return self(); + } + + /** + * @see BaseVirtualSystem#getId() + */ + public B id(String id) { + this.id = id; + return self(); + } + + /** + * @see BaseVirtualSystem#getProductSections() + */ + public B productSection(ProductSection productSection) { + this.productSections.add(checkNotNull(productSection, "productSection")); + return self(); + } + + /** + * @see BaseVirtualSystem#getProductSections() + */ + public B productSections(Iterable productSections) { + this.productSections = Sets.newLinkedHashSet(checkNotNull(productSections, "productSections")); + return self(); + } + + /** + * @see BaseVirtualSystem#getAdditionalSections() + */ + public B additionalSection(SectionType additionalSection) { + this.additionalSections.add(checkNotNull(additionalSection, "additionalSection")); + return self(); + } + + /** + * @see BaseVirtualSystem#getAdditionalSections() + */ + public B additionalSections(Iterable additionalSections) { + this.additionalSections = Sets.newLinkedHashSet(checkNotNull(additionalSections, "additionalSections")); + return self(); + } + + public B fromBaseVirtualSystem(BaseVirtualSystem in) { + return fromSectionType(in) + .id(in.getId()) + .name(in.getName()) + .productSections(in.getProductSections()) + .additionalSections(in.getAdditionalSections()); + } + } + + @XmlAttribute(namespace = OVF_NS) + private String id; + @XmlElement(name = "Name") + private String name; + @XmlElement(name = "ProductSection") + private Set productSections; + @XmlElementRef + private Set additionalSections; + + protected BaseVirtualSystem(Builder builder) { + super(builder); + this.id = builder.id; + this.name = builder.name; + this.productSections = ImmutableSet.copyOf(checkNotNull(builder.productSections, "productSections")); + this.additionalSections = ImmutableSet.copyOf(checkNotNull(builder.additionalSections, "additionalSections")); + } + + protected BaseVirtualSystem() { + // For JAXB + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + /** + * Specifies product-information for a package, such as product name and version, along with a + * set of properties that can be configured + */ + public Set getProductSections() { + return productSections; + } + + public Set getAdditionalSections() { + return additionalSections; + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), id, name, productSections, additionalSections); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + + BaseVirtualSystem other = (BaseVirtualSystem) obj; + return super.equals(other) + && equal(id, other.id) + && equal(name, other.name) + && equal(productSections, other.productSections) + && equal(additionalSections, other.additionalSections); + } + + @Override + protected Objects.ToStringHelper string() { + return super.string() + .add("id", id) + .add("name", name) + .add("productSections", productSections) + .add("additionalSections", additionalSections); + } +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/package-info.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/package-info.java similarity index 77% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/package-info.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/package-info.java index b08a2ea879..b9f8c9df30 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/package-info.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/package-info.java @@ -16,17 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -@XmlSchema(namespace = VCLOUD_OVF_NS, +@XmlSchema(namespace = OVF_NS, elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { - @XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS) + @XmlNs(prefix = "cim", namespaceURI = CIM_NS), + @XmlNs(prefix = "ovf", namespaceURI = OVF_NS) } ) @XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.vcloud.director.v1_5.domain.ovf.internal; +package org.jclouds.dmtf.ovf.internal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/package-info.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/package-info.java similarity index 64% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/package-info.java rename to labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/package-info.java index f93613590f..48a2043de0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/package-info.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/package-info.java @@ -16,21 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -@XmlSchema(namespace = VCLOUD_OVF_NS, +@XmlSchema(namespace = OVF_NS, elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { - @XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS), - @XmlNs(prefix = "vmv", namespaceURI = VCLOUD_VMW_NS), - @XmlNs(prefix = "vcloud", namespaceURI = VCLOUD_1_5_NS) + @XmlNs(prefix = "cim", namespaceURI = CIM_NS), + @XmlNs(prefix = "ovf", namespaceURI = OVF_NS) } ) @XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.dmtf.ovf; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS; +import static org.jclouds.dmtf.DMTFConstants.CIM_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/labs/dmtf/src/test/resources/log4j.xml b/labs/dmtf/src/test/resources/log4j.xml new file mode 100644 index 0000000000..63810d3ca0 --- /dev/null +++ b/labs/dmtf/src/test/resources/log4j.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/labs/pom.xml b/labs/pom.xml index a2dc41f3be..c0c4ae9725 100644 --- a/labs/pom.xml +++ b/labs/pom.xml @@ -39,5 +39,6 @@ elb aws-elb savvis-symphonyvpdc + dmtf diff --git a/labs/vcloud-director/pom.xml b/labs/vcloud-director/pom.xml index 3deb2d64b7..32e12456a7 100644 --- a/labs/vcloud-director/pom.xml +++ b/labs/vcloud-director/pom.xml @@ -57,6 +57,11 @@ jclouds-compute ${project.version} + + org.jclouds.labs + dmtf + ${project.version} + org.jclouds jclouds-core diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java index 293275c8c4..62a837d3c8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java @@ -20,7 +20,6 @@ package org.jclouds.vcloud.director.v1_5; import java.net.URI; -import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; import org.jclouds.apis.BaseApiMetadata; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorConstants.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorConstants.java index 4ebd2eb96b..3ac2dee73b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorConstants.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorConstants.java @@ -30,16 +30,6 @@ public class VCloudDirectorConstants { public static final String VCLOUD_VMW_NS = "http://www.vmware.com/schema/ovf"; - public static final String VCLOUD_OVF_NS = "http://schemas.dmtf.org/ovf/envelope/1"; - - public static final String VCLOUD_OVF_ENV_NS = "http://schemas.dmtf.org/ovf/environment/1"; - - public static final String VCLOUD_CIM_NS = "http://schemas.dmtf.org/wbem/wscim/1/common"; - - public static final String VCLOUD_CIM_VSSD_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"; - - public static final String VCLOUD_CIM_RASD_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"; - /** The property used to configure the timeout for task completion. */ public static final String PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud-director.timeout.task-complete"; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/admin/VCloudDirectorAdminAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/admin/VCloudDirectorAdminAsyncClient.java index 97837c7ca7..d99efbb7b1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/admin/VCloudDirectorAdminAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/admin/VCloudDirectorAdminAsyncClient.java @@ -19,12 +19,6 @@ package org.jclouds.vcloud.director.v1_5.admin; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; -import org.jclouds.vcloud.director.v1_5.domain.AdminVdc; -import org.jclouds.vcloud.director.v1_5.domain.Catalog; -import org.jclouds.vcloud.director.v1_5.domain.Group; -import org.jclouds.vcloud.director.v1_5.domain.User; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogAsyncClient; import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgAsyncClient; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/admin/VCloudDirectorAdminClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/admin/VCloudDirectorAdminClient.java index fe257065dd..e747962391 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/admin/VCloudDirectorAdminClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/admin/VCloudDirectorAdminClient.java @@ -22,12 +22,6 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; -import org.jclouds.vcloud.director.v1_5.domain.AdminVdc; -import org.jclouds.vcloud.director.v1_5.domain.Catalog; -import org.jclouds.vcloud.director.v1_5.domain.Group; -import org.jclouds.vcloud.director.v1_5.domain.User; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient; import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkClient; import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgClient; @@ -35,7 +29,6 @@ import org.jclouds.vcloud.director.v1_5.features.admin.AdminQueryClient; import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClient; import org.jclouds.vcloud.director.v1_5.features.admin.GroupClient; import org.jclouds.vcloud.director.v1_5.features.admin.UserClient; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; /** @@ -82,6 +75,7 @@ public interface VCloudDirectorAdminClient extends VCloudDirectorClient { /** * @return synchronous access to {@link AdminVdc} features */ + @Override @Delegate AdminVdcClient getVdcClient(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java index 3003ae7add..a1a062f893 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java @@ -28,8 +28,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.DMTFConstants; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -100,9 +100,8 @@ public abstract class AbstractVAppType extends ResourceEntityType { /** * @see AbstractVAppType#getSections() */ - public B sections(List sections) { - if (checkNotNull(sections, "sections").size() > 0) - this.sections = Lists.newArrayList(sections); + public B sections(Iterable sections) { + this.sections = Lists.newArrayList(checkNotNull(sections, "sections")); return self(); } @@ -123,8 +122,8 @@ public abstract class AbstractVAppType extends ResourceEntityType { @XmlElement(name = "VAppParent") private Reference vAppParent; - @XmlElementRef(name = "Section", namespace = VCloudDirectorConstants.VCLOUD_OVF_NS) - private List sections = Lists.newArrayList(); + @XmlElementRef(namespace = DMTFConstants.OVF_NS) + private List sections = Lists.newArrayList(); @XmlAttribute private Boolean deployed; @@ -171,7 +170,7 @@ public abstract class AbstractVAppType extends ResourceEntityType { *
  • InstallSectionType * */ - public List getSections() { + public List getSections() { return this.sections; } @@ -189,8 +188,10 @@ public abstract class AbstractVAppType extends ResourceEntityType { if (o == null || getClass() != o.getClass()) return false; AbstractVAppType that = AbstractVAppType.class.cast(o); - return super.equals(that) && - equal(this.vAppParent, that.vAppParent) && equal(this.sections, that.sections) && equal(this.deployed, that.deployed); + return super.equals(that) + && equal(this.vAppParent, that.vAppParent) + && equal(this.sections, that.sections) + && equal(this.deployed, that.deployed); } @Override @@ -200,6 +201,9 @@ public abstract class AbstractVAppType extends ResourceEntityType { @Override public ToStringHelper string() { - return super.string().add("vAppParent", vAppParent).add("sections", sections).add("deployed", deployed); + return super.string() + .add("vAppParent", vAppParent) + .add("sections", sections) + .add("deployed", deployed); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminVdc.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminVdc.java index dcd945ec1c..6b6cabc4e4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminVdc.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminVdc.java @@ -131,6 +131,7 @@ public class AdminVdc extends Vdc { return self(); } + @Override public AdminVdc build() { return new AdminVdc(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java index 75e7275981..9e50423f66 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java @@ -61,6 +61,7 @@ public class CapacityWithUsage extends CapacityType return new Builder(); } + @Override public Builder toBuilder() { return new Builder().fromCapacityWithUsage(this); } @@ -87,6 +88,7 @@ public class CapacityWithUsage extends CapacityType } + @Override public CapacityWithUsage build() { return new CapacityWithUsage(units, allocated, limit, used, overhead); } @@ -94,6 +96,7 @@ public class CapacityWithUsage extends CapacityType /** * @see CapacityType#getUnits() */ + @Override public Builder units(String units) { this.units = units; return this; @@ -102,6 +105,7 @@ public class CapacityWithUsage extends CapacityType /** * @see CapacityType#getAllocated() */ + @Override public Builder allocated(Long allocated) { this.allocated = allocated; return this; @@ -110,6 +114,7 @@ public class CapacityWithUsage extends CapacityType /** * @see CapacityType#getLimit() */ + @Override public Builder limit(Long limit) { this.limit = limit; return this; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java index 3e2271f9e0..071da5176c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java @@ -31,8 +31,7 @@ import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; @@ -111,6 +110,7 @@ public class CaptureVAppParams extends ParamsType { return self(); } + @Override public CaptureVAppParams build() { return new CaptureVAppParams(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java index eeeb825f4d..915751e600 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java @@ -42,6 +42,7 @@ public class Catalog extends CatalogType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromCatalog(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java index baa364dd00..55e7fe756a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java @@ -49,6 +49,7 @@ public class CatalogItem extends EntityType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromCatalogItem(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java index aa12a68bc6..1988a5f5ed 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java @@ -61,6 +61,7 @@ public class CloneMediaParams extends ParamsType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromCloneMediaParams(this); } @@ -89,6 +90,7 @@ public class CloneMediaParams extends ParamsType { return self(); } + @Override public CloneMediaParams build() { return new CloneMediaParams(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java index 116c1ec802..4e149a2920 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java @@ -44,12 +44,13 @@ import com.google.common.collect.Lists; */ @XmlRootElement(name = "ComposeVAppParams") @XmlType(name = "ComposeVAppParamsType") -public class ComposeVAppParams extends VAppCreationParamsType { +public class ComposeVAppParams extends VAppCreationParams { public static Builder builder() { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromComposeVAppParams(this); } @@ -57,7 +58,7 @@ public class ComposeVAppParams extends VAppCreationParamsType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends VAppCreationParamsType.Builder { + public static abstract class Builder> extends VAppCreationParams.Builder { private List sourcedItems = Lists.newArrayList(); private Boolean allEULAsAccepted; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java index 31bf250c43..471395d1bf 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java @@ -30,7 +30,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DhcpService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DhcpService.java index 1d16051727..ca8b6b848f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DhcpService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DhcpService.java @@ -88,6 +88,7 @@ public class DhcpService extends NetworkServiceType { return this; } + @Override public DhcpService build() { return new DhcpService(isEnabled, defaultLeaseTime, maxLeaseTime, ipRange); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java index 16f92a2f04..9bb44e4d1c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java @@ -33,6 +33,7 @@ public class Entity extends EntityType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromEntity(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/VirtualSystem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Envelope.java similarity index 56% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/VirtualSystem.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Envelope.java index 15f9a545c7..a23500485a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/VirtualSystem.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Envelope.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to jclouds, Inc. (jclouds) under one or more * contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,52 +16,49 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.vcloud.director.v1_5.domain; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlRootElement; -import org.jclouds.vcloud.director.v1_5.domain.ovf.internal.BaseVirtualSystem; +import org.jclouds.dmtf.ovf.internal.BaseEnvelope; /** - * @author Adrian Cole - * @author Adam Lowe + * @author grkvlt@apache.org */ -@XmlRootElement(name = "VirtualSystem", namespace = VCLOUD_OVF_NS) -public class VirtualSystem extends BaseVirtualSystem { +@XmlRootElement(name = "Envelope", namespace = OVF_NS) +public class Envelope extends BaseEnvelope { + @SuppressWarnings("rawtypes") public static Builder builder() { - return new ConcreteBuilder(); + return new Builder(); } + /** + * {@inheritDoc} + */ + @Override public Builder toBuilder() { - return builder().fromVirtualSystem(this); + return builder().fromEnvelope(this); } - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends BaseVirtualSystem.Builder { + public static class Builder> extends BaseEnvelope.Builder { /** * {@inheritDoc} */ @Override - public VirtualSystem build() { - return new VirtualSystem(this); - } - - public B fromVirtualSystem(VirtualSystem in) { - return fromBaseVirtualSystem(in); + public Envelope build() { + return new Envelope(this); } } - private VirtualSystem(Builder builder) { + protected Envelope(Builder builder) { super(builder); } - private VirtualSystem() { - // for JAXB + protected Envelope() { + // For JaxB } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java index 7d706ed678..2190de4f5f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java @@ -59,6 +59,7 @@ public class File extends EntityType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromFile(this); } @@ -96,12 +97,13 @@ public class File extends EntityType { return self(); } + @Override public File build() { return new File(this); } - public Builder fromFile(File in) { + public B fromFile(File in) { return fromEntityType(in) .size(in.getSize()) .bytesTransferred(in.getBytesTransferred()) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallService.java index ff31582edd..caa26ec66d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallService.java @@ -69,6 +69,7 @@ public class FirewallService extends NetworkServiceType { return new Builder(); } + @Override public Builder toBuilder() { return new Builder().fromFirewallService(this); } @@ -102,6 +103,7 @@ public class FirewallService extends NetworkServiceType { return this; } + @Override public FirewallService build() { return new FirewallService(isEnabled, defaultAction, logDefaultAction, firewallRules); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java index 4d8f2f75b3..3d0d17bbac 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java @@ -31,7 +31,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateOvfParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateOvfParams.java index 2640106f52..0c62584046 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateOvfParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateOvfParams.java @@ -37,12 +37,13 @@ import com.google.common.base.Objects.ToStringHelper; * @author grkvlt@apache.org */ @XmlType(name = "InstantiateOvfParams") -public class InstantiateOvfParams extends VAppCreationParamsType { +public class InstantiateOvfParams extends VAppCreationParams { public static Builder builder() { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromInstantiateOvfParams(this); } @@ -50,7 +51,7 @@ public class InstantiateOvfParams extends VAppCreationParamsType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends VAppCreationParamsType.Builder { + public static abstract class Builder> extends VAppCreationParams.Builder { private Boolean allEULAsAccepted; private String transferFormat; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java index aeed48a8f5..2c4baef1c4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java @@ -42,7 +42,7 @@ import com.google.common.base.Objects.ToStringHelper; */ @XmlRootElement(name = "InstantiateVAppParams") @XmlType(name = "InstantiateVAppParamsType") -public class InstantiateVAppParams extends VAppCreationParamsType { +public class InstantiateVAppParams extends VAppCreationParams { public static final String MEDIA_TYPe = VCloudDirectorMediaType.INSTANTIATE_VAPP_TEMPLATE_PARAMS; @@ -58,7 +58,7 @@ public class InstantiateVAppParams extends VAppCreationParamsType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends VAppCreationParamsType.Builder { + public static abstract class Builder> extends VAppCreationParams.Builder { private Reference source; private Boolean sourceDelete; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java index 9d515662d8..d004efc0cd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java @@ -40,6 +40,7 @@ public class InstantiateVAppTemplateParams extends InstantiateVAppParams { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromInstantiateVAppTemplateParams(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java index f9ef0e1f8e..43073147f2 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java @@ -27,7 +27,7 @@ import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnManagedPeerType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnManagedPeerType.java index c1f30df663..a268f41a68 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnManagedPeerType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnManagedPeerType.java @@ -39,7 +39,7 @@ public abstract class IpsecVpnManagedPeerType id(String id) { this.id = id; return this; } @@ -47,13 +47,14 @@ public abstract class IpsecVpnManagedPeerType name(String name) { this.name = name; return this; } public Builder fromIpsecVpnManagedPeerType(IpsecVpnManagedPeerType in) { - return id(in.getId()).name(in.getName()); + return id(in.getId()) + .name(in.getName()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnRemotePeer.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnRemotePeer.java index 652ed93981..f7aeb13dc1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnRemotePeer.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnRemotePeer.java @@ -58,7 +58,7 @@ import com.google.common.base.Objects; "vcdUsername" }) public class IpsecVpnRemotePeer extends IpsecVpnManagedPeerType { - @SuppressWarnings("unchecked") + public static Builder builder() { return new Builder(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnService.java index 198f43d958..0a7cdd17ce 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnService.java @@ -69,6 +69,7 @@ public class IpsecVpnService extends NetworkServiceType { return new Builder(); } + @Override public Builder toBuilder() { return new Builder().fromIpsecVpnService(this); } @@ -103,6 +104,7 @@ public class IpsecVpnService extends NetworkServiceType { return this; } + @Override public IpsecVpnService build() { return new IpsecVpnService(isEnabled, externalIpAddress, publicIpAddress, ipsecVpnTunnels); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java index 8d9cee0fba..8d838d828a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java @@ -33,7 +33,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index f5bce3a2db..dd4a13ebbb 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -153,6 +153,7 @@ public class Link extends Reference { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromLink(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java index ab00a90710..963a603977 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java @@ -85,6 +85,7 @@ public class Media extends ResourceEntityType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromMedia(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java index 59c0fb89ed..4e590fdf05 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java @@ -52,6 +52,7 @@ public class Metadata extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromMetadata(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java index 04cd7f1038..910df170d3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java @@ -51,6 +51,7 @@ public class MetadataEntry extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromMetadataEntry(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java index da1e367d5d..cd4a79ed18 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java @@ -51,6 +51,7 @@ public class MetadataValue extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromMetadataValue(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatRule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatRule.java index 1fe1625f27..c713226072 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatRule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatRule.java @@ -62,7 +62,7 @@ import com.google.common.base.Objects; "vmRule" }) public class NatRule { - @SuppressWarnings("unchecked") + public static Builder builder() { return new Builder(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatService.java index ee1d401b0d..5727e22aba 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatService.java @@ -102,6 +102,7 @@ public class NatService extends NetworkServiceType { return this; } + @Override public NatService build() { return new NatService(isEnabled, natType, policy, natRules); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java index 21db1e672c..4da43d2fcd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java @@ -31,7 +31,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java index 7cbd25ccaa..65b37518f6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java @@ -30,7 +30,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/OperatingSystemSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java similarity index 61% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/OperatingSystemSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java index a7c8dc35e5..50fab311ce 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/OperatingSystemSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java @@ -16,12 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain.ovf; +package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS; import java.net.URI; @@ -30,11 +29,10 @@ import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.jclouds.vcloud.director.v1_5.domain.Link; +import javax.xml.bind.annotation.XmlSeeAlso; import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -43,15 +41,17 @@ import com.google.common.collect.Sets; * * @author Adrian Cole * @author Adam Lowe + * @author grkvlt@apache.org */ @XmlRootElement(name = "OperatingSystemSection") -@XmlType -public class OperatingSystemSection extends SectionType { +@XmlSeeAlso({ org.jclouds.dmtf.ovf.OperatingSystemSection.class }) +public class OperatingSystemSection extends org.jclouds.dmtf.ovf.OperatingSystemSection { public static Builder builder() { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromOperatingSystemSection(this); } @@ -59,39 +59,13 @@ public class OperatingSystemSection extends SectionType { private static class ConcreteBuilder extends Builder { } - public static class Builder> extends SectionType.Builder { - private int id; - private String description; - private String version; + public static class Builder> extends org.jclouds.dmtf.ovf.OperatingSystemSection.Builder { + private String osType; private URI href; private String type; private Set links; - /** - * @see OperatingSystemSection#getId() - */ - public B id(int id) { - this.id = id; - return self(); - } - - /** - * @see OperatingSystemSection#getVersion() - */ - public B version(String version) { - this.version = version; - return self(); - } - - /** - * @see OperatingSystemSection#getDescription - */ - public B description(String description) { - this.description = description; - return self(); - } - /** * @see OperatingSystemSection#getOsType() */ @@ -125,11 +99,9 @@ public class OperatingSystemSection extends SectionType { } /** - * @see ResourceType#getLinks() + * @see OperatingSystemSection#getLinks() */ public B link(Link link) { - if (links == null) - links = Sets.newLinkedHashSet(); this.links.add(checkNotNull(link, "link")); return self(); } @@ -143,18 +115,14 @@ public class OperatingSystemSection extends SectionType { } public B fromOperatingSystemSection(OperatingSystemSection in) { - return fromSectionType(in) - .id(in.getId()).version(in.getVersion()).description(in.getDescription()) - .osType(in.getOsType()).href(in.getHref()).type(in.getType()).links(in.getLinks()); + return super.fromOperatingSystemSection(in) + .osType(in.getOsType()) + .href(in.getHref()) + .type(in.getType()) + .links(in.getLinks()); } } - @XmlAttribute(namespace = VCLOUD_OVF_NS, required = true) - protected int id; - @XmlAttribute - protected String version; - @XmlElement(name = "Description") - protected String description; @XmlAttribute(namespace = VCLOUD_VMW_NS) protected String osType; @XmlAttribute(namespace = VCLOUD_1_5_NS) @@ -162,46 +130,20 @@ public class OperatingSystemSection extends SectionType { @XmlAttribute(namespace = VCLOUD_1_5_NS) private String type; @XmlElement(name = "Link", namespace = VCLOUD_1_5_NS) - private Set links; + private Set links = Sets.newLinkedHashSet(); public OperatingSystemSection(Builder builder) { super(builder); - this.id = builder.id; - this.description = builder.description; - this.version = builder.version; this.osType = builder.osType; this.href = builder.href; this.type = builder.type; - this.links = builder.links; + this.links = builder.links != null && builder.links.isEmpty() ? null : builder.links;; } protected OperatingSystemSection() { // For Builders and JAXB } - /** - * Gets the OVF id - * - * @see org.jclouds.vcloud.director.v1_5.domain.cim.OSType#getCode() - */ - public int getId() { - return id; - } - - /** - * Gets the version - */ - public String getVersion() { - return version; - } - - /** - * Gets the description or null - */ - public String getDescription() { - return description; - } - /** * Gets the osType */ @@ -233,12 +175,12 @@ public class OperatingSystemSection extends SectionType { * @see ResourceType#getLinks() */ public Set getLinks() { - return links == null ? Sets.newLinkedHashSet() : ImmutableSet.copyOf(links); + return links != null ? ImmutableSet.copyOf(links) : Sets.newLinkedHashSet(); } @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), id, version, description, osType, href, type, links); + return Objects.hashCode(super.hashCode(), osType, href, type, links); } @Override @@ -246,16 +188,21 @@ public class OperatingSystemSection extends SectionType { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - + OperatingSystemSection that = (OperatingSystemSection) obj; - return super.equals(that) && - equal(this.id, that.id) && equal(this.version, that.version) && equal(this.description, that.description) && - equal(this.osType, that.osType) && equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type); + return super.equals(that) + && equal(this.osType, that.osType) + && equal(this.href, that.href) + && equal(this.links, that.links) + && equal(this.type, that.type); } @Override - protected Objects.ToStringHelper string() { - return super.string().add("id", id).add("version", version).add("description", description).add("osType", osType) - .add("href", href).add("links", links).add("type", type); + public ToStringHelper string() { + return super.string() + .add("osType", osType) + .add("type", type) + .add("href", href) + .add("links", links); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java index 5969579b76..766f743bf5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java @@ -50,6 +50,7 @@ public class Org extends EntityType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromOrg(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgGeneralSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgGeneralSettings.java index ffb4d39a12..b6da767354 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgGeneralSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgGeneralSettings.java @@ -61,6 +61,7 @@ public class OrgGeneralSettings extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromOrgGeneralSettings(this); } @@ -116,6 +117,7 @@ public class OrgGeneralSettings extends ResourceType { return self(); } + @Override public OrgGeneralSettings build() { return new OrgGeneralSettings(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java index 3bdc674082..64aa4b1b65 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java @@ -64,6 +64,7 @@ public class OrgSettings extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromOrgSettings(this); } @@ -128,6 +129,7 @@ public class OrgSettings extends ResourceType { return self(); } + @Override public OrgSettings build() { return new OrgSettings(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java index ac5fb1c9bc..b06d483e68 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java @@ -44,6 +44,7 @@ public class Owner extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromOwner(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java index a382e31063..80472eeb2b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java @@ -30,8 +30,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants; -import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection; +import org.jclouds.dmtf.DMTFConstants; +import org.jclouds.dmtf.ovf.ProductSection; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -78,8 +78,7 @@ public class ProductSectionList extends ResourceType implements Set productSections) { - if (checkNotNull(productSections, "productSections").size() > 0) - this.productSections = Sets.newLinkedHashSet(productSections); + this.productSections = Sets.newLinkedHashSet(checkNotNull(productSections, "productSections")); return self(); } @@ -87,8 +86,6 @@ public class ProductSectionList extends ResourceType implements Set productSections; /** @@ -131,7 +128,8 @@ public class ProductSectionList extends ResourceType implements Set builder() { + return new ConcreteBuilder(); + } + + @Override + public Builder toBuilder() { + return builder().fromRasdItem(this); + } + + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> extends ResourceAllocationSettingData.Builder>{ + + private URI href; + private String type; + private Set links = Sets.newLinkedHashSet(); + + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + + /** + * @see ResourceAllocationSettingData#getType() + */ + public B type(String type) { + this.type = type; + return self(); + } + + /** + * @see ResourceAllocationSettingData#getHref() + */ + public B href(URI href) { + this.href = href; + return self(); + } + + /** + * @see ResourceAllocationSettingData#getLinks() + */ + public B links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return self(); + } + + /** + * @see ResourceAllocationSettingData#getLinks() + */ + public B link(Link link) { + this.links.add(checkNotNull(link, "link")); + return self(); + } + + @Override + public RasdItem build() { + return new RasdItem(this); + } + + public B fromRasdItem(RasdItem in) { + return fromResourceAllocationSettingData(in) + .type(in.getType()) + .href(in.getHref()) + .links(in.getLinks()); + } + } + + @XmlAttribute(name = "type", namespace = VCLOUD_1_5_NS) + private String type; + @XmlAttribute(name = "href", namespace = VCLOUD_1_5_NS) + @XmlSchemaType(name = "anyURI") + private URI href; + @XmlElement(name = "Link", namespace = VCLOUD_1_5_NS) + private Set links = Sets.newLinkedHashSet(); + + protected RasdItem(Builder builder) { + super(builder); + this.type = builder.type; + this.href = builder.href; + this.links = builder.links != null && builder.links.isEmpty() ? null : builder.links;; + } + + protected RasdItem() { + // for JAXB + } + + /** + * Contains the URI to the entity. + * + * @see ResourceType#getHref() + */ + public String getType() { + return type; + } + + /** + * Contains the type of the the entity. + * + * @see ResourceType#getType() + */ + public URI getHref() { + return href; + } + + /** + * Set of optional links to an entity or operation associated with this object. + * + * @see ResourceType#getLinks() + */ + public Set getLinks() { + return links != null ? ImmutableSet.copyOf(links) : Sets.newLinkedHashSet(); + } + + @Override + public ToStringHelper string() { + return super.string() + .add("type", type) + .add("href", href) + .add("links", links); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), type, href, links); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + + RasdItem that = RasdItem.class.cast(obj); + return super.equals(that) + && equal(this.type, that.type) + && equal(this.href, that.href) + && equal(this.links, that.links); + } + +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RasdItemsList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RasdItemsList.java index 8f8a444699..e271539728 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RasdItemsList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RasdItemsList.java @@ -29,8 +29,6 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData; - import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; @@ -46,7 +44,7 @@ import com.google.common.collect.Sets; */ @XmlRootElement(name = "RasdItemsList") @XmlType(name = "RasdItemsList") -public class RasdItemsList extends ResourceType implements Set { +public class RasdItemsList extends ResourceType implements Set { public static Builder builder() { return new ConcreteBuilder(); @@ -62,12 +60,12 @@ public class RasdItemsList extends ResourceType implements Set> extends ResourceType.Builder { - private Set items = Sets.newLinkedHashSet(); + private Set items = Sets.newLinkedHashSet(); /** * @see RasdItemsList#getItems() */ - public B items(Set items) { + public B items(Set items) { this.items = checkNotNull(items, "items"); return self(); } @@ -75,7 +73,7 @@ public class RasdItemsList extends ResourceType implements Set items = Sets.newLinkedHashSet(); + protected Set items = Sets.newLinkedHashSet(); /** * A RASD item content. */ - public Set getItems() { + public Set getItems() { return items; } @@ -137,17 +135,17 @@ public class RasdItemsList extends ResourceType implements Set * NOTE Annoying lack of multiple inheritance for using ForwardingList! */ - private Set delegate() { + private Set delegate() { return getItems(); } @Override - public boolean add(ResourceAllocationSettingData arg0) { + public boolean add(RasdItem arg0) { return delegate().add(arg0); } @Override - public boolean addAll(Collection arg0) { + public boolean addAll(Collection arg0) { return delegate().addAll(arg0); } @@ -172,7 +170,7 @@ public class RasdItemsList extends ResourceType implements Set iterator() { + public Iterator iterator() { return delegate().iterator(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RecomposeVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RecomposeVAppParams.java index 78c26343a4..db4549871a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RecomposeVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RecomposeVAppParams.java @@ -55,6 +55,7 @@ public class RecomposeVAppParams extends ComposeVAppParams { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromRecomposeVAppParams(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/References.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/References.java index 2df6c38c0e..f47bbf9a1d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/References.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/References.java @@ -22,7 +22,6 @@ import static com.google.common.base.Objects.equal; import java.util.Set; -import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java index 1467b925e7..279137df6d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java @@ -32,6 +32,7 @@ public class Resource extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromResource(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RuntimeInfoSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RuntimeInfoSection.java index f1b55de8c5..a923eff86f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RuntimeInfoSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RuntimeInfoSection.java @@ -27,7 +27,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.dmtf.ovf.SectionType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoutingService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoutingService.java index 995b65a3d2..4202bd17bf 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoutingService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoutingService.java @@ -65,6 +65,7 @@ public class StaticRoutingService extends NetworkServiceType toBuilder() { return builder().fromTask(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java index 9cb8f2347c..1a8e4851b0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java @@ -47,6 +47,7 @@ public class TasksList extends ResourceType implements Set { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromTasksList(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java index 15d18a455d..d40715e3df 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java @@ -43,6 +43,7 @@ public class UploadVAppTemplateParams extends ParamsType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromUploadVAppTemplateParams(this); } @@ -72,6 +73,7 @@ public class UploadVAppTemplateParams extends ParamsType { } + @Override public UploadVAppTemplateParams build() { return new UploadVAppTemplateParams(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java index accc0ece1a..20a54c287e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java @@ -97,6 +97,7 @@ public class User extends EntityType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromUser(this); } @@ -128,6 +129,7 @@ public class User extends EntityType { /** * @see EntityType#getName() */ + @Override public B name(String name) { return super.name(name.toLowerCase()); } @@ -284,6 +286,7 @@ public class User extends EntityType { return self(); } + @Override public User build() { return new User(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VApp.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VApp.java index 44781a7531..09b1ceefd7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VApp.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VApp.java @@ -45,6 +45,7 @@ public class VApp extends AbstractVAppType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromVApp(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParams.java index 7fea3e9dda..41da48e1e6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParams.java @@ -18,51 +18,165 @@ */ package org.jclouds.vcloud.director.v1_5.domain; +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; /** * Represents vApp creation parameters. * - *
    - * <complexType name="VAppCreationParams" />
    - * 
    - * * @author grkvlt@apache.org + * @see + * vCloud REST API - VAppCreationParamsType + * @since 0.9 */ -@XmlType(name = "VAppCreationParams") -public class VAppCreationParams extends VAppCreationParamsType { +@XmlRootElement(name = "VAppCreationParams") +@XmlType(name = "VAppCreationParamsType") +public class VAppCreationParams extends ParamsType { public static Builder builder() { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { - return builder().fromVAppCreationParams(this); + return builder().fromVAppCreationParamsType(this); } private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends VAppCreationParamsType.Builder { + public static abstract class Builder> extends ParamsType.Builder { - @Override - public VAppCreationParams build() { - VAppCreationParams vAppCreationParams = new VAppCreationParams(this); - return vAppCreationParams; + private Reference vAppParent; + private InstantiationParams instantiationParams; + private Boolean deploy; + private Boolean powerOn; + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public B vAppParent(Reference vAppParent) { + this.vAppParent = vAppParent; + return self(); } - public B fromVAppCreationParams(VAppCreationParams in) { - return fromVAppCreationParamsType(in); + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public B instantiationParams(InstantiationParams instantiationParams) { + this.instantiationParams = instantiationParams; + return self(); + } + + /** + * @see VAppCreationParamsType#isDeploy() + */ + public B deploy(Boolean deploy) { + this.deploy = deploy; + return self(); + } + + /** + * @see VAppCreationParamsType#isDeploy() + */ + public B deploy() { + this.deploy = Boolean.TRUE; + return self(); + } + + /** + * @see VAppCreationParamsType#isDeploy() + */ + public B notDeploy() { + this.deploy = Boolean.FALSE; + return self(); + } + + /** + * @see VAppCreationParamsType#isPowerOn() + */ + public B powerOn(Boolean powerOn) { + this.powerOn = powerOn; + return self(); + } + + /** + * @see VAppCreationParamsType#isPowerOn() + */ + public B powerOn() { + this.powerOn = Boolean.TRUE; + return self(); + } + + /** + * @see VAppCreationParamsType#isPowerOn() + */ + public B notPowerOn() { + this.powerOn = Boolean.FALSE; + return self(); + } + + public B fromVAppCreationParamsType(VAppCreationParams in) { + return fromParamsType(in).vAppParent(in.getVAppParent()).instantiationParams(in.getInstantiationParams()).deploy(in.isDeploy()).powerOn(in.isPowerOn()); } } protected VAppCreationParams() { - // For JAXB and builder use + // For JAXB and B use } - protected VAppCreationParams(Builder builder) { + public VAppCreationParams(Builder builder) { super(builder); + this.vAppParent = builder.vAppParent; + this.instantiationParams = builder.instantiationParams; + this.deploy = builder.deploy; + this.powerOn = builder.powerOn; + } + + @XmlElement(name = "VAppParent") + protected Reference vAppParent; + @XmlElement(name = "InstantiationParams") + protected InstantiationParams instantiationParams; + @XmlAttribute + protected Boolean deploy; + @XmlAttribute + protected Boolean powerOn; + + /** + * Reserved. + * + * Unimplemented. + */ + public Reference getVAppParent() { + return vAppParent; + } + + /** + * Instantiation parameters of a VApp. + */ + public InstantiationParams getInstantiationParams() { + return instantiationParams; + } + + /** + * Flag to deploy the VApp after successful creation. + */ + public Boolean isDeploy() { + return deploy; + } + + /** + * Flag to deploy and power on the VApp after successful creation. + */ + public Boolean isPowerOn() { + return powerOn; } @Override @@ -72,6 +186,24 @@ public class VAppCreationParams extends VAppCreationParamsType { if (o == null || getClass() != o.getClass()) return false; VAppCreationParams that = VAppCreationParams.class.cast(o); - return super.equals(that); + return super.equals(that) && + equal(vAppParent, that.vAppParent) && + equal(instantiationParams, that.instantiationParams) && + equal(deploy, that.deploy) && + equal(powerOn, that.powerOn); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), vAppParent, instantiationParams, deploy, powerOn); + } + + @Override + public ToStringHelper string() { + return Objects.toStringHelper("") + .add("vAppParent", vAppParent) + .add("instantiationParams", instantiationParams) + .add("deploy", deploy) + .add("powerOn", powerOn); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java deleted file mode 100644 index 5f25f98701..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5.domain; - -import static com.google.common.base.Objects.equal; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * Represents vApp creation parameters. - * - * @author grkvlt@apache.org - * @see - * vCloud REST API - VAppCreationParamsType - * @since 0.9 - */ -@XmlType(name = "VAppCreationParamsType") -public class VAppCreationParamsType extends ParamsType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - @Override - public Builder toBuilder() { - return builder().fromVAppCreationParamsType(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static abstract class Builder> extends ParamsType.Builder { - - private Reference vAppParent; - private InstantiationParams instantiationParams; - private Boolean deploy; - private Boolean powerOn; - - /** - * @see VAppCreationParamsType#getVAppParent() - */ - public B vAppParent(Reference vAppParent) { - this.vAppParent = vAppParent; - return self(); - } - - /** - * @see VAppCreationParamsType#getInstantiationParams() - */ - public B instantiationParams(InstantiationParams instantiationParams) { - this.instantiationParams = instantiationParams; - return self(); - } - - /** - * @see VAppCreationParamsType#isDeploy() - */ - public B deploy(Boolean deploy) { - this.deploy = deploy; - return self(); - } - - /** - * @see VAppCreationParamsType#isDeploy() - */ - public B deploy() { - this.deploy = Boolean.TRUE; - return self(); - } - - /** - * @see VAppCreationParamsType#isDeploy() - */ - public B notDeploy() { - this.deploy = Boolean.FALSE; - return self(); - } - - /** - * @see VAppCreationParamsType#isPowerOn() - */ - public B powerOn(Boolean powerOn) { - this.powerOn = powerOn; - return self(); - } - - /** - * @see VAppCreationParamsType#isPowerOn() - */ - public B powerOn() { - this.powerOn = Boolean.TRUE; - return self(); - } - - /** - * @see VAppCreationParamsType#isPowerOn() - */ - public B notPowerOn() { - this.powerOn = Boolean.FALSE; - return self(); - } - - public B fromVAppCreationParamsType(VAppCreationParamsType in) { - return fromParamsType(in).vAppParent(in.getVAppParent()).instantiationParams(in.getInstantiationParams()).deploy(in.isDeploy()).powerOn(in.isPowerOn()); - } - } - - protected VAppCreationParamsType() { - // For JAXB and B use - } - - public VAppCreationParamsType(Builder builder) { - super(builder); - this.vAppParent = builder.vAppParent; - this.instantiationParams = builder.instantiationParams; - this.deploy = builder.deploy; - this.powerOn = builder.powerOn; - } - - @XmlElement(name = "VAppParent") - protected Reference vAppParent; - @XmlElement(name = "InstantiationParams") - protected InstantiationParams instantiationParams; - @XmlAttribute - protected Boolean deploy; - @XmlAttribute - protected Boolean powerOn; - - /** - * Reserved. - * - * Unimplemented. - */ - public Reference getVAppParent() { - return vAppParent; - } - - /** - * Instantiation parameters of a VApp. - */ - public InstantiationParams getInstantiationParams() { - return instantiationParams; - } - - /** - * Flag to deploy the VApp after successful creation. - */ - public Boolean isDeploy() { - return deploy; - } - - /** - * Flag to deploy and power on the VApp after successful creation. - */ - public Boolean isPowerOn() { - return powerOn; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - VAppCreationParamsType that = VAppCreationParamsType.class.cast(o); - return super.equals(that) && - equal(vAppParent, that.vAppParent) && - equal(instantiationParams, that.instantiationParams) && - equal(deploy, that.deploy) && - equal(powerOn, that.powerOn); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), vAppParent, instantiationParams, deploy, powerOn); - } - - @Override - public ToStringHelper string() { - return Objects.toStringHelper("") - .add("vAppParent", vAppParent) - .add("instantiationParams", instantiationParams) - .add("deploy", deploy) - .add("powerOn", powerOn); - } -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetwork.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetwork.java index dd60ec9d21..1ecbbf9a61 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetwork.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetwork.java @@ -41,6 +41,7 @@ public class VAppNetwork extends Network { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromVAppNetwork(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java index 1d84820f5b..8f4874dc71 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java @@ -43,6 +43,7 @@ public class VAppNetworkConfiguration extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromVAppNetworkConfiguration(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java index 7d8e3781f4..751ead8e36 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java @@ -27,10 +27,18 @@ import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection; +import org.jclouds.dmtf.ovf.DeploymentOptionSection; +import org.jclouds.dmtf.ovf.DiskSection; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.OperatingSystemSection; +import org.jclouds.dmtf.ovf.ProductSection; +import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.dmtf.ovf.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; @@ -50,6 +58,7 @@ public class VAppTemplate extends ResourceEntityType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromVAppTemplate(this); } @@ -133,7 +142,26 @@ public class VAppTemplate extends ResourceEntityType { private Owner owner; @XmlElement(name = "Children") private VAppTemplateChildren children = VAppTemplateChildren.builder().build(); - @XmlElementRef + @XmlElementRefs({ + @XmlElementRef(type = SectionType.class), + @XmlElementRef(type = VirtualHardwareSection.class), + @XmlElementRef(type = LeaseSettingsSection.class), +// @XmlElementRef(type = EulaSection.class), + @XmlElementRef(type = RuntimeInfoSection.class), +// @XmlElementRef(type = AnnotationSection.class), + @XmlElementRef(type = DeploymentOptionSection.class), + @XmlElementRef(type = StartupSection.class), +// @XmlElementRef(type = ResourceAllocationSection.class), + @XmlElementRef(type = NetworkConnectionSection.class), + @XmlElementRef(type = CustomizationSection.class), + @XmlElementRef(type = ProductSection.class), + @XmlElementRef(type = GuestCustomizationSection.class), + @XmlElementRef(type = OperatingSystemSection.class), + @XmlElementRef(type = NetworkConfigSection.class), + @XmlElementRef(type = NetworkSection.class), +// @XmlElementRef(type = InstallSection.class), + @XmlElementRef(type = DiskSection.class) + }) private Set sections = Sets.newLinkedHashSet(); @XmlElement(name = "VAppScopedLocalId") private String vAppScopedLocalId; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java new file mode 100644 index 0000000000..a5c216a7df --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java @@ -0,0 +1,189 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlSeeAlso; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * The virtual hardware required by a virtual machine is specified in VirtualHardwareSection. + * + * @author grkvlt@apache.org + */ +@XmlRootElement(name = "VirtualHardwareSection", namespace = VCLOUD_1_5_NS) +@XmlSeeAlso({ org.jclouds.dmtf.ovf.VirtualHardwareSection.class }) +public class VirtualHardwareSection extends org.jclouds.dmtf.ovf.VirtualHardwareSection { + + public static Builder builder() { + return new ConcreteBuilder(); + } + + @Override + public Builder toBuilder() { + return builder().fromVirtualHardwareSection(this); + } + + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> extends org.jclouds.dmtf.ovf.VirtualHardwareSection.Builder { + + private URI href; + private String type; + private Set links = Sets.newLinkedHashSet(); + + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + + /** + * @see VirtualHardwareSection#getType() + */ + public B type(String type) { + this.type = type; + return self(); + } + + /** + * @see VirtualHardwareSection#getHref() + */ + public B href(URI href) { + this.href = href; + return self(); + } + + /** + * @see VirtualHardwareSection#getLinks() + */ + public B links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return self(); + } + + /** + * @see VirtualHardwareSection#getLinks() + */ + public B link(Link link) { + this.links.add(checkNotNull(link, "link")); + return self(); + } + + @Override + public VirtualHardwareSection build() { + return new VirtualHardwareSection(this); + } + + public B fromVirtualHardwareSection(VirtualHardwareSection in) { + return super.fromVirtualHardwareSection(in) + .type(in.getType()) + .href(in.getHref()) + .links(in.getLinks()); + } + } + + @XmlAttribute(namespace = VCLOUD_1_5_NS) + protected String type; + @XmlAttribute(namespace = VCLOUD_1_5_NS) + @XmlSchemaType(name = "anyURI") + protected URI href; + @XmlElement(name = "Link", namespace = VCLOUD_1_5_NS) + protected Set links = Sets.newLinkedHashSet(); + + + protected VirtualHardwareSection(Builder builder) { + super(builder); + this.type = builder.type; + this.href = builder.href; + this.links = builder.links != null && builder.links.isEmpty() ? null : builder.links;; + } + + protected VirtualHardwareSection() { + // for JAXB + } + + /** + * Contains the URI to the entity. + * + * @see ResourceType#getHref() + */ + public String getType() { + return type; + } + + /** + * Contains the type of the the entity. + * + * @see ResourceType#getType() + */ + public URI getHref() { + return href; + } + + /** + * Set of optional links to an entity or operation associated with this object. + * + * @see ResourceType#getLinks() + */ + public Set getLinks() { + return links != null ? ImmutableSet.copyOf(links) : Sets.newLinkedHashSet(); + } + + @Override + public ToStringHelper string() { + return super.string() + .add("type", type) + .add("href", href) + .add("links", links); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), type, href, links); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + + VirtualHardwareSection that = VirtualHardwareSection.class.cast(obj); + return super.equals(that) + && equal(this.type, that.type) + && equal(this.href, that.href) + && equal(this.links, that.links); + } +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualSystem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualSystem.java new file mode 100644 index 0000000000..2f1eb49d48 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualSystem.java @@ -0,0 +1,149 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.dmtf.ovf.internal.BaseVirtualSystem; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * @author Adrian Cole + * @author Adam Lowe + */ +@XmlRootElement(name = "VirtualSystem", namespace = OVF_NS) +public class VirtualSystem extends BaseVirtualSystem { + + public static Builder builder() { + return new ConcreteBuilder(); + } + + public Builder toBuilder() { + return builder().fromVirtualSystem(this); + } + + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> extends BaseVirtualSystem.Builder { + + private OperatingSystemSection operatingSystem; + private Set virtualHardwareSections = Sets.newLinkedHashSet(); + + + /** + * @see BaseVirtualSystem#getOperatingSystemSection() + */ + public B operatingSystemSection(OperatingSystemSection operatingSystem) { + this.operatingSystem = operatingSystem; + return self(); + } + + /** + * @see BaseVirtualSystem#getVirtualHardwareSections() + */ + public B virtualHardwareSection(VirtualHardwareSection virtualHardwareSection) { + this.virtualHardwareSections.add(checkNotNull(virtualHardwareSection, "virtualHardwareSection")); + return self(); + } + + /** + * @see BaseVirtualSystem#getVirtualHardwareSections() + */ + public B virtualHardwareSections(Iterable virtualHardwareSections) { + this.virtualHardwareSections = Sets.newLinkedHashSet(checkNotNull(virtualHardwareSections, "virtualHardwareSections")); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public VirtualSystem build() { + return new VirtualSystem(this); + } + + public B fromVirtualSystem(VirtualSystem in) { + return fromBaseVirtualSystem(in) + .operatingSystemSection(in.getOperatingSystemSection()) + .virtualHardwareSections(in.getVirtualHardwareSections()); + } + } + + @XmlElement(name = "OperatingSystemSection", namespace = OVF_NS) + private OperatingSystemSection operatingSystem; + @XmlElement(name = "VirtualHardwareSection", namespace = OVF_NS) + private Set virtualHardwareSections; + + private VirtualSystem(Builder builder) { + super(builder); + this.operatingSystem = checkNotNull(builder.operatingSystem, "operatingSystem"); + this.virtualHardwareSections = ImmutableSet.copyOf(checkNotNull(builder.virtualHardwareSections, "virtualHardwareSections")); + } + + private VirtualSystem() { + // for JAXB + } + + public OperatingSystemSection getOperatingSystemSection() { + return operatingSystem; + } + + /** + * Each VirtualSystem element may contain one or more VirtualHardwareSection elements, each of + * which describes the virtual virtualHardwareSections required by the virtual system. + */ + public Set getVirtualHardwareSections() { + return virtualHardwareSections; + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), operatingSystem, virtualHardwareSections); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + + VirtualSystem other = (VirtualSystem) obj; + return super.equals(other) + && equal(operatingSystem, other.operatingSystem) + && equal(virtualHardwareSections, other.virtualHardwareSections); + } + + @Override + protected Objects.ToStringHelper string() { + return super.string() + .add("operatingSystem", operatingSystem) + .add("virtualHardwareSections", virtualHardwareSections); + } +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vm.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vm.java index a7d71d3bd7..d961091764 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vm.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vm.java @@ -24,7 +24,7 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.environment.EnvironmentType; +import org.jclouds.dmtf.ovf.environment.EnvironmentType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -45,6 +45,7 @@ public class Vm extends AbstractVAppType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromVm(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VmPendingQuestion.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VmPendingQuestion.java index bce76e6e30..a2d51d9bed 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VmPendingQuestion.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VmPendingQuestion.java @@ -45,6 +45,7 @@ public class VmPendingQuestion extends ResourceType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromVmPendingQuestion(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Envelope.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Envelope.java deleted file mode 100644 index 6352083217..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Envelope.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5.domain.ovf; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; - -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.vcloud.director.v1_5.domain.ovf.internal.BaseEnvelope; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - * @author Adam Lowe - */ -@XmlRootElement(name = "Envelope", namespace = VCLOUD_OVF_NS) -public class Envelope extends BaseEnvelope { - - public static Builder builder() { - return new Builder(); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder toBuilder() { - return new Builder().fromEnvelope(this); - } - - public static class Builder extends BaseEnvelope.Builder { - - /** - * {@inheritDoc} - */ - @Override - public Envelope build() { - return new Envelope(diskSections, networkSections, additionalSections, virtualSystem); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder additionalSection(SectionType additionalSection) { - this.additionalSections.add(checkNotNull(additionalSection, "additionalSection")); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder additionalSections(Iterable additionalSections) { - this.additionalSections = ImmutableSet. copyOf(checkNotNull(additionalSections, "additionalSections")); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder diskSection(DiskSection diskSection) { - return Builder.class.cast(super.diskSection(diskSection)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder diskSections(Iterable diskSections) { - return Builder.class.cast(super.diskSections(diskSections)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder fromEnvelope(BaseEnvelope in) { - return Builder.class.cast(super.fromEnvelope(in)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder networkSection(NetworkSection networkSection) { - return Builder.class.cast(super.networkSection(networkSection)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder networkSections(Iterable networkSections) { - return Builder.class.cast(super.networkSections(networkSections)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder virtualSystem(VirtualSystem virtualSystem) { - return Builder.class.cast(super.virtualSystem(virtualSystem)); - } - - } - - private Envelope(Iterable diskSections, Iterable networkSections, - Iterable additionalSections, VirtualSystem virtualSystem) { - super(diskSections, networkSections, additionalSections, virtualSystem); - } - - private Envelope() { - // For JaxB - } - -} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/BaseVirtualSystem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/BaseVirtualSystem.java deleted file mode 100644 index 498e9b6819..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/internal/BaseVirtualSystem.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5.domain.ovf.internal; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; - -import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public abstract class BaseVirtualSystem extends SectionType { - - public static abstract class Builder> extends SectionType.Builder { - - private String id; - private String name; - private OperatingSystemSection operatingSystem; - private Set virtualHardwareSections = Sets.newLinkedHashSet(); - private Set productSections = Sets.newLinkedHashSet(); - private Set additionalSections = Sets.newLinkedHashSet(); - - /** - * @see BaseVirtualSystem#getName - */ - public B name(String name) { - this.name = name; - return self(); - } - - /** - * @see BaseVirtualSystem#getId - */ - public B id(String id) { - this.id = id; - return self(); - } - - /** - * @see BaseVirtualSystem#getOperatingSystemSection - */ - public B operatingSystemSection(OperatingSystemSection operatingSystem) { - this.operatingSystem = operatingSystem; - return self(); - } - - /** - * @see BaseVirtualSystem#getVirtualHardwareSections - */ - public B virtualHardwareSection(VirtualHardwareSection virtualHardwareSection) { - this.virtualHardwareSections.add(checkNotNull(virtualHardwareSection, "virtualHardwareSection")); - return self(); - } - - /** - * @see BaseVirtualSystem#getVirtualHardwareSections - */ - public B virtualHardwareSections(Iterable virtualHardwareSections) { - this.virtualHardwareSections = ImmutableSet. copyOf(checkNotNull(virtualHardwareSections, - "virtualHardwareSections")); - return self(); - } - - /** - * @see BaseVirtualSystem#getProductSections - */ - public B productSection(ProductSection productSection) { - this.productSections.add(checkNotNull(productSection, "productSection")); - return self(); - } - - /** - * @see BaseVirtualSystem#getProductSections - */ - public B productSections(Iterable productSections) { - this.productSections = ImmutableSet. copyOf(checkNotNull(productSections, "productSections")); - return self(); - } - - /** - * @see BaseVirtualSystem#getAdditionalSections - */ - public B additionalSection(SectionType additionalSection) { - this.additionalSections.add(checkNotNull(additionalSection, "additionalSection")); - return self(); - } - - /** - * @see BaseVirtualSystem#getAdditionalSections - */ - public B additionalSections(Set additionalSections) { - this.additionalSections = checkNotNull(additionalSections, "additionalSections"); - return self(); - } - - public B fromBaseVirtualSystem(BaseVirtualSystem in) { - return fromSectionType(in).id(in.getId()).name(in.getName()) - .operatingSystemSection(in.getOperatingSystemSection()) - .virtualHardwareSections(in.getVirtualHardwareSections()) - .productSections(in.getProductSections()) - .additionalSections(in.getAdditionalSections()); - } - } - - @XmlAttribute(namespace = VCLOUD_OVF_NS) - private String id; - @XmlElement(name = "Name") - private String name; - @XmlElement(name = "OperatingSystemSection") - private OperatingSystemSection operatingSystem; - @XmlElement(name = "VirtualHardwareSection") - private Set virtualHardwareSections; - @XmlElement(name = "ProductSection") - private Set productSections; - - // NOTE what is the right annotation here? - private Set additionalSections; - - protected BaseVirtualSystem(Builder builder) { - super(builder); - this.id = builder.id; - this.name = builder.name; - this.operatingSystem = checkNotNull(builder.operatingSystem, "operatingSystem"); - this.virtualHardwareSections = ImmutableSet.copyOf(checkNotNull(builder.virtualHardwareSections, "virtualHardwareSections")); - this.productSections = ImmutableSet.copyOf(checkNotNull(builder.productSections, "productSections")); - this.additionalSections = ImmutableSet.copyOf(checkNotNull(builder.additionalSections, "additionalSections")); - } - - protected BaseVirtualSystem() { - // For JAXB - } - - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public OperatingSystemSection getOperatingSystemSection() { - return operatingSystem; - } - - /** - * Each VirtualSystem element may contain one or more VirtualHardwareSection elements, each of - * which describes the virtual virtualHardwareSections required by the virtual system. - */ - public Set getVirtualHardwareSections() { - return virtualHardwareSections; - } - - /** - * Specifies product-information for a package, such as product name and version, along with a - * set of properties that can be configured - */ - public Set getProductSections() { - return productSections; - } - - public Set getAdditionalSections() { - return additionalSections; - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), id, name, operatingSystem, virtualHardwareSections, productSections, additionalSections); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - - BaseVirtualSystem other = (BaseVirtualSystem) obj; - return super.equals(other) - && equal(id, other.id) - && equal(name, other.name) - && equal(operatingSystem, other.operatingSystem) - && equal(virtualHardwareSections, other.virtualHardwareSections) - && equal(productSections, other.productSections) - && equal(additionalSections, other.additionalSections); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string().add("id", id).add("name", name) - .add("operatingSystem", operatingSystem).add("virtualHardwareSections", virtualHardwareSections) - .add("productSections", productSections).add("additionalSections", additionalSections) - .add("additionalSections", additionalSections); - } -} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/package-info.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/package-info.java index d479475fde..fe2926586c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/package-info.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/package-info.java @@ -17,22 +17,15 @@ * under the License. */ @XmlSchema(namespace = VCLOUD_1_5_NS, - location = "http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd", elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { - @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS), - @XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS), - @XmlNs(prefix = "ovf", namespaceURI = VCLOUD_OVF_NS), - @XmlNs(prefix = "env", namespaceURI = VCLOUD_OVF_ENV_NS) + @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS) } ) @XmlAccessorType(XmlAccessType.FIELD) package org.jclouds.vcloud.director.v1_5.domain; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_ENV_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryList.java index e194c65530..b8949e7075 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryList.java @@ -41,6 +41,7 @@ public class QueryList extends ContainerType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromQueryList(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultNetworkRecord.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultNetworkRecord.java index ad974f3949..b6f9a415bc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultNetworkRecord.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultNetworkRecord.java @@ -169,7 +169,7 @@ public class QueryResultNetworkRecord extends QueryResultRecordType { } private QueryResultNetworkRecord() { - // Qfor JAXB + // for JAXB } @XmlAttribute diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/package-info.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/package-info.java index 58514959d2..899fb3ac1d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/package-info.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/package-info.java @@ -17,22 +17,15 @@ * under the License. */ @XmlSchema(namespace = VCLOUD_1_5_NS, - location = "http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd", elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { - @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS), - @XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS), - @XmlNs(prefix = "ovf", namespaceURI = VCLOUD_OVF_NS), - @XmlNs(prefix = "env", namespaceURI = VCLOUD_OVF_ENV_NS) + @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS) } ) @XmlAccessorType(XmlAccessType.FIELD) package org.jclouds.vcloud.director.v1_5.domain.query; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_ENV_NS; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncClient.java index 585f3fe063..6793f86307 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncClient.java @@ -50,6 +50,8 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; @@ -66,8 +68,10 @@ import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; +import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; @@ -76,13 +80,9 @@ import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer; -import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.functions.ReturnPayloadBytes; @@ -575,7 +575,7 @@ public interface VAppAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionCpu(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSectionCpu(@EndpointParam URI vmURI); /** * @see VAppClient#modifyVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData) @@ -586,7 +586,7 @@ public interface VAppAsyncClient { @Consumes(TASK) @JAXBResponseParser ListenableFuture modifyVirtualHardwareSectionCpu(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) ResourceAllocationSettingData rasd); + @BinderParam(BindToXMLPayload.class) RasdItem rasd); /** * @see VAppClient#getVirtualHardwareSectionDisks(URI) @@ -627,7 +627,7 @@ public interface VAppAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionMemory(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSectionMemory(@EndpointParam URI vmURI); /** * @see VAppClient#modifyVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData) @@ -638,7 +638,7 @@ public interface VAppAsyncClient { @Consumes(TASK) @JAXBResponseParser ListenableFuture modifyVirtualHardwareSectionMemory(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) ResourceAllocationSettingData rasd); + @BinderParam(BindToXMLPayload.class) RasdItem rasd); /** * @see VAppClient#getVirtualHardwareSectionNetworkCards(URI) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java index 2daa5e0da8..4dbc9aae6f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java @@ -22,6 +22,8 @@ import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams; @@ -30,8 +32,10 @@ import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; +import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; @@ -40,13 +44,9 @@ import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer; -import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection; /** * Provides synchronous access to {@link VApp} objects. @@ -674,7 +674,7 @@ public interface VAppClient { * * @since 0.9 */ - ResourceAllocationSettingData getVirtualHardwareSectionCpu(URI vmURI); + RasdItem getVirtualHardwareSectionCpu(URI vmURI); /** * Modifies the CPU properties in virtual hardware section of a VM. @@ -685,7 +685,7 @@ public interface VAppClient { * * @since 0.9 */ - Task modifyVirtualHardwareSectionCpu(URI vmURI, ResourceAllocationSettingData rasd); + Task modifyVirtualHardwareSectionCpu(URI vmURI, RasdItem rasd); /** * Retrieves a list of ResourceAllocationSettingData items for disks from virtual hardware section of a VM. @@ -729,7 +729,7 @@ public interface VAppClient { * * @since 0.9 */ - ResourceAllocationSettingData getVirtualHardwareSectionMemory(URI vmURI); + RasdItem getVirtualHardwareSectionMemory(URI vmURI); /** * Modifies the memory properties in virtual hardware section of a VM. @@ -740,7 +740,7 @@ public interface VAppClient { * * @since 0.9 */ - Task modifyVirtualHardwareSectionMemory(URI vmURI, ResourceAllocationSettingData rasd); + Task modifyVirtualHardwareSectionMemory(URI vmURI, RasdItem rasd); /** * Retrieves a list of ResourceAllocationSettingData items for network cards from virtual hardware section of a VM. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java index 7219a37fc4..e49e85d604 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java @@ -40,6 +40,7 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; @@ -49,6 +50,7 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.Envelope; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; @@ -59,8 +61,6 @@ import org.jclouds.vcloud.director.v1_5.domain.References; import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java index bdc154750a..4f5a74a5bb 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java @@ -22,8 +22,10 @@ import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.Envelope; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; @@ -34,8 +36,6 @@ import org.jclouds.vcloud.director.v1_5.domain.References; import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; /** * Provides synchronous access to {@link VAppTemplate} objects. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncClient.java index fe1996a5de..418c09358f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncClient.java @@ -42,7 +42,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClient.java index 110ae3b4d8..5cffad6c3b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClient.java @@ -24,7 +24,6 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; -import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncClient.java index d0b6f90056..883a8f4a85 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncClient.java @@ -41,7 +41,6 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClient.java index 44fca80ede..01e4884ebc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClient.java @@ -28,7 +28,6 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataClient.Writeable; /** * Provides synchronous access to admin {@link Network} objects. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncClient.java index d4294f9fea..11c303cda9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncClient.java @@ -45,7 +45,6 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClient.java index 5b1bcbfa84..ac86ada421 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClient.java @@ -33,7 +33,6 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataClient.Writeable; /** * Provides synchronous access to {@link Org} objects. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcAsyncClient.java index 984d623bef..6f593d4361 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcAsyncClient.java @@ -39,7 +39,6 @@ import org.jclouds.vcloud.director.v1_5.domain.AdminVdc; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClient.java index 735402dae4..7ad436c377 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClient.java @@ -28,7 +28,6 @@ import org.jclouds.vcloud.director.v1_5.domain.AdminVdc; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.VdcClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable; /** * Provides synchronous access to {@link AdminVdc}. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorAsyncClient.java index 9488ba7fda..90b848b5e9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorAsyncClient.java @@ -19,15 +19,7 @@ package org.jclouds.vcloud.director.v1_5.user; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.Catalog; -import org.jclouds.vcloud.director.v1_5.domain.Media; -import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; -import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; -import org.jclouds.vcloud.director.v1_5.domain.Vdc; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorClient.java index f0a3f02574..fda7a3686e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorClient.java @@ -22,16 +22,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient; -import org.jclouds.vcloud.director.v1_5.domain.Catalog; -import org.jclouds.vcloud.director.v1_5.domain.Media; -import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; -import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; -import org.jclouds.vcloud.director.v1_5.domain.Vdc; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.MediaClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java index 78eed46dfd..9f341d7be1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java @@ -33,8 +33,13 @@ import java.math.BigInteger; import java.net.URI; import java.util.List; +import org.jclouds.dmtf.cim.CimBoolean; +import org.jclouds.dmtf.cim.CimString; +import org.jclouds.dmtf.cim.CimUnsignedInt; +import org.jclouds.dmtf.cim.CimUnsignedLong; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status; @@ -43,11 +48,6 @@ import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.Vm; -import org.jclouds.vcloud.director.v1_5.domain.cim.CimBoolean; -import org.jclouds.vcloud.director.v1_5.domain.cim.CimString; -import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedInt; -import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedLong; -import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.QueryClient; @@ -74,329 +74,262 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClientLiveTest -{ +public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClientLiveTest { - public static final String VAPP = "vApp"; + public static final String VAPP = "vApp"; + public static final String VAPP_TEMPLATE = "vAppTemplate"; + public static final String VDC = "vdc"; - public static final String VAPP_TEMPLATE = "vAppTemplate"; + /* + * Convenience reference to API clients. + */ - public static final String VDC = "vdc"; + protected CatalogClient catalogClient; + protected QueryClient queryClient; + protected VAppClient vAppClient; + protected VAppTemplateClient vAppTemplateClient; + protected VdcClient vdcClient; + protected MetadataClient.Writeable metadataClient; - /* - * Convenience reference to API clients. - */ + /* + * Objects shared between tests. + */ - protected CatalogClient catalogClient; + protected Vdc vdc; + protected Vm vm; + protected URI vAppURI; + protected VApp vApp; + protected VAppTemplate vAppTemplate; - protected QueryClient queryClient; + /** + * Retrieves the required clients from the REST API context + * + * @see BaseVCloudDirectorClientLiveTest#setupRequiredClients() + */ + @Override + @BeforeClass(alwaysRun = true, description = "Retrieves the required clients from the REST API context") + protected void setupRequiredClients() { + assertNotNull(context.getApi()); - protected VAppClient vAppClient; + catalogClient = context.getApi().getCatalogClient(); + queryClient = context.getApi().getQueryClient(); + vAppClient = context.getApi().getVAppClient(); + vAppTemplateClient = context.getApi().getVAppTemplateClient(); + vdcClient = context.getApi().getVdcClient(); - protected VAppTemplateClient vAppTemplateClient; + setupEnvironment(); + } - protected VdcClient vdcClient; + /** + * Sets up the environment. Retrieves the test {@link Vdc} and {@link VAppTemplate} from their + * configured {@link URI}s. Instantiates a new test VApp. + */ + protected void setupEnvironment() { + // Get the configured Vdc for the tests + vdc = vdcClient.getVdc(vdcURI); + assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC)); - protected MetadataClient.Writeable metadataClient; + // Get the configured VAppTemplate for the tests + vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); + assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE)); - /* - * Objects shared between tests. - */ + // Instantiate a new VApp + VApp vAppInstantiated = instantiateVApp(); + assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP)); + vAppURI = vAppInstantiated.getHref(); - protected Vdc vdc; + // Wait for the task to complete + Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks()); + assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask")); - protected Vm vm; + // Get the instantiated VApp + vApp = vAppClient.getVApp(vAppURI); - protected URI vAppURI; + // Get the Vm + List vms = vApp.getChildren().getVms(); + vm = Iterables.getOnlyElement(vms); + assertFalse(vms.isEmpty(), "The VApp must have a Vm"); + } - protected VApp vApp; + protected void getGuestCustomizationSection(final Function getGuestCustomizationSection) { + // Get URI for child VM + URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); - protected VAppTemplate vAppTemplate; + // The method under test + try { + GuestCustomizationSection section = getGuestCustomizationSection.apply(vmURI); - /** - * Retrieves the required clients from the REST API context - * - * @see BaseVCloudDirectorClientLiveTest#setupRequiredClients() - */ - @Override - @BeforeClass(alwaysRun = true, description = "Retrieves the required clients from the REST API context") - protected void setupRequiredClients() - { - assertNotNull(context.getApi()); + // Check the retrieved object is well formed + checkGuestCustomizationSection(section); + } catch (Exception e) { + Throwables.propagate(e); + } + } - catalogClient = context.getApi().getCatalogClient(); - queryClient = context.getApi().getQueryClient(); - vAppClient = context.getApi().getVAppClient(); - vAppTemplateClient = context.getApi().getVAppTemplateClient(); - vdcClient = context.getApi().getVdcClient(); + protected void getNetworkConnectionSection(final Function getNetworkConnectionSection) { + // Get URI for child VM + URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); - setupEnvironment(); - } + // The method under test + try { + NetworkConnectionSection section = getNetworkConnectionSection.apply(vmURI); - /** - * Sets up the environment. Retrieves the test {@link Vdc} and {@link VAppTemplate} from their - * configured {@link URI}s. Instantiates a new test VApp. - */ - protected void setupEnvironment() - { - // Get the configured Vdc for the tests - vdc = vdcClient.getVdc(vdcURI); - assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC)); + // Check the retrieved object is well formed + checkNetworkConnectionSection(section); + } catch (Exception e) { + Throwables.propagate(e); + } + } - // Get the configured VAppTemplate for the tests - vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); - assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE)); + @AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps") + protected void cleanUp() { + vdc = vdcClient.getVdc(vdcURI); // Refresh + // Find references in the Vdc with the VApp type and in the list of instantiated VApp names + Iterable vApps = Iterables.filter(vdc.getResourceEntities(), + Predicates.and(ReferencePredicates. typeEquals(VCloudDirectorMediaType.VAPP), ReferencePredicates. nameIn(vAppNames))); - // Instantiate a new VApp - VApp vAppInstantiated = instantiateVApp(); - assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP)); - vAppURI = vAppInstantiated.getHref(); + // If we found any references, delete the VApp they point to + if (!Iterables.isEmpty(vApps)) { + for (Reference ref : vApps) { + cleanUpVApp(ref.getHref()); // NOTE may fail, but should continue deleting + } + } else { + logger.warn("No VApps in list found in Vdc %s (%s)", vdc.getName(), Iterables.toString(vAppNames)); + } + } - // Wait for the task to complete - Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks()); - assertTrue(retryTaskSuccessLong.apply(instantiateTask), - String.format(TASK_COMPLETE_TIMELY, "instantiateTask")); + protected static CimBoolean cimBoolean(boolean val) { + CimBoolean result = new CimBoolean(); + result.setValue(val); + return result; + } - // Get the instantiated VApp - vApp = vAppClient.getVApp(vAppURI); + protected static CimUnsignedInt cimUnsignedInt(long val) { + CimUnsignedInt result = new CimUnsignedInt(); + result.setValue(val); + return result; + } - // Get the Vm - List vms = vApp.getChildren().getVms(); - vm = Iterables.getOnlyElement(vms); - assertFalse(vms.isEmpty(), "The VApp must have a Vm"); - } + protected static CimUnsignedLong cimUnsignedLong(BigInteger val) { + CimUnsignedLong result = new CimUnsignedLong(); + result.setValue(val); + return result; + } - protected void getGuestCustomizationSection( - final Function getGuestCustomizationSection) - { - // Get URI for child VM - URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); + protected static CimString cimString(String value) { + return new CimString(value); + } - // The method under test - try - { - GuestCustomizationSection section = getGuestCustomizationSection.apply(vmURI); - - // Check the retrieved object is well formed - checkGuestCustomizationSection(section); - } - catch (Exception e) - { - Throwables.propagate(e); - } - } - - protected void getNetworkConnectionSection( - final Function getNetworkConnectionSection) - { - // Get URI for child VM - URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); - - // The method under test - try - { - NetworkConnectionSection section = getNetworkConnectionSection.apply(vmURI); - - // Check the retrieved object is well formed - checkNetworkConnectionSection(section); - } - catch (Exception e) - { - Throwables.propagate(e); - } - } - - @AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps") - protected void cleanUp() - { - vdc = vdcClient.getVdc(vdcURI); // Refresh - // Find references in the Vdc with the VApp type and in the list of instantiated VApp names - Iterable vApps = - Iterables.filter(vdc.getResourceEntities(), Predicates.and( - ReferencePredicates. typeEquals(VCloudDirectorMediaType.VAPP), - ReferencePredicates. nameIn(vAppNames))); - - // If we found any references, delete the VApp they point to - if (!Iterables.isEmpty(vApps)) - { - for (Reference ref : vApps) - { - cleanUpVApp(ref.getHref()); // NOTE may fail, but should continue deleting + protected void checkHasMatchingItem(final String context, final RasdItemsList items, final String instanceId, final String elementName) { + Optional found = Iterables.tryFind(items.getItems(), new Predicate() { + @Override + public boolean apply(RasdItem item) { + String itemInstanceId = item.getInstanceID(); + if (itemInstanceId.equals(instanceId)) { + Assert.assertEquals(item.getElementName(), elementName, + String.format(OBJ_FIELD_EQ, VAPP, context + "/" + instanceId + "/elementName", elementName, item.getElementName())); + return true; } - } - else - { - logger.warn("No VApps in list found in Vdc %s (%s)", vdc.getName(), - Iterables.toString(vAppNames)); - } - } + return false; + } + }); + assertTrue(found.isPresent(), "no " + context + " item found with id " + instanceId + "; only found " + items); + } - protected static CimBoolean cimBoolean(final boolean val) - { - CimBoolean result = new CimBoolean(); - result.setValue(val); - return result; - } + /** + * Power on a {@link VApp}s {@link Vm}s. + * + * @see #powerOn(URI) + */ + protected VApp powerOn(final VApp testVApp) { + return powerOn(testVApp.getHref()); + } - protected static CimUnsignedInt cimUnsignedInt(final long val) - { - CimUnsignedInt result = new CimUnsignedInt(); - result.setValue(val); - return result; - } + /** + * Power on a VApp. + */ + protected VApp powerOn(final URI testVAppURI) { + VApp testVApp = vAppClient.getVApp(testVAppURI); + Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); + Status status = Status.fromValue(vm.getStatus()); + if (status != Status.POWERED_ON) { + Task powerOn = vAppClient.powerOn(vm.getHref()); + assertTaskSucceedsLong(powerOn); + } + assertVAppStatus(testVAppURI, Status.POWERED_ON); + return testVApp; + } - protected static CimUnsignedLong cimUnsignedLong(final BigInteger val) - { - CimUnsignedLong result = new CimUnsignedLong(); - result.setValue(val); - return result; - } + /** + * Power off a {@link VApp}s {@link Vm}s. + * + * @see #powerOff(URI) + */ + protected VApp powerOff(final VApp testVApp) { + return powerOff(testVApp.getHref()); + } - protected static CimString cimString(final String value) - { - return new CimString(value); - } + /** + * Power off a {@link VApp}s {@link Vm}s. + */ + protected VApp powerOff(final URI testVAppURI) { + VApp testVApp = vAppClient.getVApp(testVAppURI); + Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); + Status status = Status.fromValue(vm.getStatus()); + if (status != Status.POWERED_OFF) { + Task powerOff = vAppClient.powerOff(vm.getHref()); + assertTaskSucceedsLong(powerOff); + } + assertVAppStatus(testVAppURI, Status.POWERED_OFF); + return testVApp; + } - protected void checkHasMatchingItem(final String context, final RasdItemsList items, - final String instanceId, final String elementName) - { - Optional found = - Iterables.tryFind(items.getItems(), new Predicate() - { - @Override - public boolean apply(final ResourceAllocationSettingData item) - { - String itemInstanceId = item.getInstanceID(); - if (itemInstanceId.equals(instanceId)) - { - Assert.assertEquals( - item.getElementName(), - elementName, - String.format(OBJ_FIELD_EQ, VAPP, context + "/" + instanceId - + "/elementName", elementName, item.getElementName())); + /** + * Suspend a {@link VApp}s {@link Vm}s. + * + * @see #suspend(URI) + */ + protected VApp suspend(final VApp testVApp) { + return powerOff(testVApp.getHref()); + } - return true; - } - return false; - } - }); - assertTrue(found.isPresent(), "no " + context + " item found with id " + instanceId - + "; only found " + items); - } + /** + * Suspend a {@link VApp}s {@link Vm}s. + */ + protected VApp suspend(final URI testVAppURI) { + VApp testVApp = vAppClient.getVApp(testVAppURI); + Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); + Status status = Status.fromValue(vm.getStatus()); + if (status != Status.SUSPENDED) { + Task suspend = vAppClient.suspend(vm.getHref()); + assertTaskSucceedsLong(suspend); + } + assertVAppStatus(testVAppURI, Status.SUSPENDED); + return testVApp; + } - /** - * Power on a {@link VApp}s {@link Vm}s. - * - * @see #powerOn(URI) - */ - protected VApp powerOn(final VApp testVApp) - { - return powerOn(testVApp.getHref()); - } + /** + * Check the {@link VApp}s {@link Vm}s current status. + */ + protected void assertVAppStatus(final URI testVAppURI, final Status status) { + VApp testVApp = vAppClient.getVApp(testVAppURI); + Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); + assertEquals(vm.getStatus(), status.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", status.toString(), Status.fromValue(vm.getStatus()).toString())); + } - /** - * Power on a VApp. - */ - protected VApp powerOn(final URI testVAppURI) - { - VApp testVApp = vAppClient.getVApp(testVAppURI); - Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); - if (status != Status.POWERED_ON) - { - Task powerOn = vAppClient.powerOn(vm.getHref()); - assertTaskSucceedsLong(powerOn); - } - assertVAppStatus(testVAppURI, Status.POWERED_ON); - return testVApp; - } - - /** - * Power off a {@link VApp}s {@link Vm}s. - * - * @see #powerOff(URI) - */ - protected VApp powerOff(final VApp testVApp) - { - return powerOff(testVApp.getHref()); - } - - /** - * Power off a {@link VApp}s {@link Vm}s. - */ - protected VApp powerOff(final URI testVAppURI) - { - VApp testVApp = vAppClient.getVApp(testVAppURI); - Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); - if (status != Status.POWERED_OFF) - { - Task powerOff = vAppClient.powerOff(vm.getHref()); - assertTaskSucceedsLong(powerOff); - } - assertVAppStatus(testVAppURI, Status.POWERED_OFF); - return testVApp; - } - - /** - * Suspend a {@link VApp}s {@link Vm}s. - * - * @see #suspend(URI) - */ - protected VApp suspend(final VApp testVApp) - { - return powerOff(testVApp.getHref()); - } - - /** - * Suspend a {@link VApp}s {@link Vm}s. - */ - protected VApp suspend(final URI testVAppURI) - { - VApp testVApp = vAppClient.getVApp(testVAppURI); - Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); - if (status != Status.SUSPENDED) - { - Task suspend = vAppClient.suspend(vm.getHref()); - assertTaskSucceedsLong(suspend); - } - assertVAppStatus(testVAppURI, Status.SUSPENDED); - return testVApp; - } - - /** - * Check the {@link VApp}s {@link Vm}s current status. - */ - protected void assertVAppStatus(final URI testVAppURI, final Status status) - { - VApp testVApp = vAppClient.getVApp(testVAppURI); - Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - assertEquals( - vm.getStatus(), - status.getValue(), - String.format(OBJ_FIELD_EQ, VAPP, "status", status.toString(), - Status.fromValue(vm.getStatus()).toString())); - } - - /** - * Marshals a JAXB annotated object into XML. The XML is output using - * {@link org.jclouds.logging.Logger#debug(String)} - */ - protected void debug(final Object object) - { - JAXBParser parser = new JAXBParser("true"); - try - { - String xml = parser.toXML(object); - logger.debug(Strings.padStart( - Strings.padEnd(" " + object.getClass().toString() + " ", 70, '-'), 80, '-')); - logger.debug(xml); - logger.debug(Strings.repeat("-", 80)); - } - catch (IOException ioe) - { - Throwables.propagate(ioe); - } - } + /** + * Marshals a JAXB annotated object into XML. The XML is output using + * {@link org.jclouds.logging.Logger#debug(String)} + */ + protected void debug(final Object object) { + JAXBParser parser = new JAXBParser("true"); + try { + String xml = parser.toXML(object); + logger.debug(Strings.padStart(Strings.padEnd(" " + object.getClass().toString() + " ", 70, '-'), 80, '-')); + logger.debug(xml); + logger.debug(Strings.repeat("-", 80)); + } catch (IOException ioe) { + Throwables.propagate(ioe); + } + } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java index 3904d25d63..65f4aa31e5 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java @@ -32,7 +32,6 @@ import org.jclouds.http.HttpResponse; import org.jclouds.util.Strings2; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.xml.internal.JAXBParser; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index f4f6a80d88..9779ec5efe 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -46,24 +46,20 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import org.jclouds.dmtf.cim.ResourceAllocationSettingData; +import org.jclouds.dmtf.cim.VirtualSystemSettingData; +import org.jclouds.dmtf.ovf.Disk; +import org.jclouds.dmtf.ovf.DiskSection; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.ProductSection; +import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.dmtf.ovf.environment.EnvironmentType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.CustomOrgLdapSettings.AuthenticationMechanism; import org.jclouds.vcloud.director.v1_5.domain.CustomOrgLdapSettings.ConnectorType; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection.IpAddressAllocationMode; import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings.LdapMode; -import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData; -import org.jclouds.vcloud.director.v1_5.domain.cim.VirtualSystemSettingData; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Disk; -import org.jclouds.vcloud.director.v1_5.domain.ovf.DiskSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualSystem; -import org.jclouds.vcloud.director.v1_5.domain.ovf.environment.EnvironmentType; import org.jclouds.vcloud.director.v1_5.domain.query.ContainerType; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType; @@ -713,7 +709,7 @@ public class Checks { // NOTE transport cannot be checked if (hardware.getItems() != null) { for (ResourceAllocationSettingData item : hardware.getItems()) { - checkResourceAllocationSettingData(item); + checkResourceAllocationSettingData((RasdItem) item); } } @@ -744,7 +740,7 @@ public class Checks { // assertNotNull(virtualSystem.getVirtualSystemType(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "virtualSystemType")); } - public static void checkResourceAllocationSettingData(ResourceAllocationSettingData item) { + public static void checkResourceAllocationSettingData(RasdItem item) { // TODO } @@ -1101,8 +1097,8 @@ public class Checks { // Check optional fields if (section.getNetworks() != null) { - for (org.jclouds.vcloud.director.v1_5.domain.ovf.Network network : section.getNetworks()) { - checkNetwork(network); + for (org.jclouds.dmtf.ovf.Network network : section.getNetworks()) { + checkOvfNetwork(network); } } @@ -1110,7 +1106,7 @@ public class Checks { checkOvfSectionType(section); } - public static void checkNetwork(org.jclouds.vcloud.director.v1_5.domain.ovf.Network network) { + public static void checkOvfNetwork(org.jclouds.dmtf.ovf.Network network) { assertNotNull(network, String.format(NOT_NULL_OBJ_FMT, "Network")); // Check optional fields @@ -1222,7 +1218,7 @@ public class Checks { // Check fields // TODO - for (ResourceAllocationSettingData item : items.getItems()) { + for (RasdItem item : items.getItems()) { checkResourceAllocationSettingData(item); } } @@ -1235,7 +1231,7 @@ public class Checks { assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "ProductSection")); if (val.getProperties() != null) { - for (org.jclouds.vcloud.director.v1_5.domain.ovf.Property property : val.getProperties()) { + for (org.jclouds.dmtf.ovf.Property property : val.getProperties()) { checkOvfProperty(property); } } @@ -1244,7 +1240,7 @@ public class Checks { checkOvfSectionType(val); } - private static void checkOvfProperty(org.jclouds.vcloud.director.v1_5.domain.ovf.Property val) { + private static void checkOvfProperty(org.jclouds.dmtf.ovf.Property val) { assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "Property")); } @@ -1252,7 +1248,7 @@ public class Checks { assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "NetworkSection")); if (val.getNetworks() != null) { - for (org.jclouds.vcloud.director.v1_5.domain.ovf.Network network : val.getNetworks()) { + for (org.jclouds.dmtf.ovf.Network network : val.getNetworks()) { checkOvfNetwork(network); } } @@ -1260,10 +1256,6 @@ public class Checks { checkOvfSectionType(val); } - private static void checkOvfNetwork(org.jclouds.vcloud.director.v1_5.domain.ovf.Network val) { - assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "Network")); - } - public static void checkOvfEnvelope(Envelope val) { assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "Envelope")); @@ -1329,7 +1321,7 @@ public class Checks { if (section.getItems() != null) { for (ResourceAllocationSettingData item : section.getItems()) { - checkCimResourceAllocationSettingData(item); + checkCimResourceAllocationSettingData((RasdItem) item); } } if (section.getSystem() != null) { @@ -1345,7 +1337,7 @@ public class Checks { assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "VirtualSystemSettingData")); } - private static void checkCimResourceAllocationSettingData(ResourceAllocationSettingData val) { + private static void checkCimResourceAllocationSettingData(RasdItem val) { // TODO Could do more assertions... assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "ResouorceAllocatoinSettingData")); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java index c8d273b91d..ebf622b700 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java @@ -22,6 +22,8 @@ import static org.testng.Assert.assertEquals; import java.net.URI; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams; @@ -32,8 +34,10 @@ import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; +import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Reference; @@ -43,13 +47,9 @@ import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer; -import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import org.testng.annotations.BeforeClass; @@ -898,7 +898,7 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest { .xmlFilePayload("/vApp/getVirtualHardwareSectionCpu.xml", VCloudDirectorMediaType.OVF_RASD_ITEM) .httpResponseBuilder().build()); - ResourceAllocationSettingData expected = getVirtualHardwareSectionCpu(); + RasdItem expected = getVirtualHardwareSectionCpu(); assertEquals(client.getVAppClient().getVirtualHardwareSectionCpu(vAppURI), expected); } @@ -915,7 +915,7 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest { .xmlFilePayload("/vApp/modifyVirtualHardwareSectionCpuTask.xml", VCloudDirectorMediaType.TASK) .httpResponseBuilder().build()); - ResourceAllocationSettingData cpu = getVirtualHardwareSectionCpu(); // .toBuilder(); + RasdItem cpu = getVirtualHardwareSectionCpu(); // .toBuilder(); // .build(); Task expected = modifyVirtualHardwareSectionCpuTask(); @@ -986,7 +986,7 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest { .xmlFilePayload("/vApp/getVirtualHardwareSectionMemory.xml", VCloudDirectorMediaType.OVF_RASD_ITEM) .httpResponseBuilder().build()); - ResourceAllocationSettingData expected = getVirtualHardwareSectionMemory(); + RasdItem expected = getVirtualHardwareSectionMemory(); assertEquals(client.getVAppClient().getVirtualHardwareSectionMemory(vAppURI), expected); } @@ -1003,7 +1003,7 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest { .xmlFilePayload("/vApp/modifyVirtualHardwareSectionMemoryTask.xml", VCloudDirectorMediaType.TASK) .httpResponseBuilder().build()); - ResourceAllocationSettingData memory = getVirtualHardwareSectionCpu(); // .toBuilder(); + RasdItem memory = getVirtualHardwareSectionCpu(); // .toBuilder(); // .build(); Task expected = modifyVirtualHardwareSectionMemoryTask(); @@ -1414,8 +1414,8 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest { return task; } - public static ResourceAllocationSettingData getVirtualHardwareSectionCpu() { - ResourceAllocationSettingData cpu = ResourceAllocationSettingData.builder() + public static RasdItem getVirtualHardwareSectionCpu() { + RasdItem cpu = RasdItem.builder() .build(); return cpu; @@ -1449,8 +1449,8 @@ public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest { return media; } - public static ResourceAllocationSettingData getVirtualHardwareSectionMemory() { - ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder() + public static RasdItem getVirtualHardwareSectionMemory() { + RasdItem memory = RasdItem.builder() .build(); return memory; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java index ade21eef5c..0f0879696e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java @@ -69,6 +69,12 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.io.Payloads; +import org.jclouds.dmtf.cim.OSType; +import org.jclouds.dmtf.cim.ResourceAllocationSettingData; +import org.jclouds.dmtf.ovf.MsgType; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.ProductSection; +import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.vcloud.director.v1_5.AbstractVAppClientLiveTest; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; @@ -88,8 +94,10 @@ import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection.IpAddressAllocationMode; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; +import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Reference; @@ -100,17 +108,10 @@ import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswerChoice; -import org.jclouds.vcloud.director.v1_5.domain.cim.OSType; -import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData; -import org.jclouds.vcloud.director.v1_5.domain.ovf.MsgType; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection; -import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; import org.testng.annotations.AfterClass; @@ -966,7 +967,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { // Copy existing section and update fields VirtualHardwareSection oldSection = vAppClient.getVirtualHardwareSection(vm.getHref()); - Set oldItems = oldSection.getItems(); + Set oldItems = oldSection.getItems(); Set newItems = Sets.newLinkedHashSet(oldItems); ResourceAllocationSettingData oldMemory = Iterables.find(oldItems, new Predicate() { @Override @@ -1010,7 +1011,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testGetVirtualHardwareSectionCpu() { // Method under test - ResourceAllocationSettingData rasd = vAppClient.getVirtualHardwareSectionCpu(vm.getHref()); + RasdItem rasd = vAppClient.getVirtualHardwareSectionCpu(vm.getHref()); // Check the retrieved object is well formed checkResourceAllocationSettingData(rasd); @@ -1019,8 +1020,8 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { @Test(description = "PUT /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSectionCpu" }) public void testModifyVirtualHardwareSectionCpu() { // Copy existing section and update fields - ResourceAllocationSettingData oldItem = vAppClient.getVirtualHardwareSectionCpu(vm.getHref()); - ResourceAllocationSettingData newItem = oldItem.toBuilder() + RasdItem oldItem = vAppClient.getVirtualHardwareSectionCpu(vm.getHref()); + RasdItem newItem = oldItem.toBuilder() .elementName("2 virtual CPU(s)") .virtualQuantity(new BigInteger("2")) .build(); @@ -1030,7 +1031,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionCpu), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionCpu")); // Retrieve the modified section - ResourceAllocationSettingData modified = vAppClient.getVirtualHardwareSectionCpu(vm.getHref()); + RasdItem modified = vAppClient.getVirtualHardwareSectionCpu(vm.getHref()); // Check the retrieved object checkResourceAllocationSettingData(modified); @@ -1098,7 +1099,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testGetVirtualHardwareSectionMemory() { // Method under test - ResourceAllocationSettingData rasd = vAppClient.getVirtualHardwareSectionCpu(vm.getHref()); + RasdItem rasd = vAppClient.getVirtualHardwareSectionCpu(vm.getHref()); // Check the retrieved object is well formed checkResourceAllocationSettingData(rasd); @@ -1106,8 +1107,8 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { @Test(description = "PUT /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSectionMemory" }) public void testModifyVirtualHardwareSectionMemory() { - ResourceAllocationSettingData origItem = vAppClient.getVirtualHardwareSectionMemory(vm.getHref()); - ResourceAllocationSettingData newItem = origItem.toBuilder() + RasdItem origItem = vAppClient.getVirtualHardwareSectionMemory(vm.getHref()); + RasdItem newItem = origItem.toBuilder() .elementName("1024 MB of memory") .virtualQuantity(new BigInteger("1024")) .build(); @@ -1117,7 +1118,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionMemory), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionMemory")); // Retrieve the modified section - ResourceAllocationSettingData modified = vAppClient.getVirtualHardwareSectionMemory(vm.getHref()); + RasdItem modified = vAppClient.getVirtualHardwareSectionMemory(vm.getHref()); // Check the retrieved object checkResourceAllocationSettingData(modified); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java index 1f1b2a9982..14f8254657 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java @@ -41,11 +41,13 @@ import java.net.URI; import java.util.Map; import java.util.Set; +import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.vcloud.director.v1_5.AbstractVAppClientLiveTest; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.Envelope; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.Link; @@ -63,8 +65,6 @@ import org.jclouds.vcloud.director.v1_5.domain.References; import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; -import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java index 6391ce39ed..5f2c3a71ff 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java @@ -30,7 +30,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java index 5fe8699d89..380f14c061 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java @@ -29,7 +29,6 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.features.NetworkClientExpectTest; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkClient; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java index 11c725d072..2539fce13d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java @@ -35,7 +35,6 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgClient; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java index 531c35aeb2..aac0747ce1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java @@ -29,7 +29,6 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRoleRecord; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminQueryClient; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java index 59e962be29..b34dad2d43 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java @@ -27,7 +27,6 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.domain.AdminVdc; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.features.VdcClientExpectTest; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClient; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java index baed95de50..6ef70f5087 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java @@ -34,8 +34,6 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.features.MetadataClient; -import org.jclouds.vcloud.director.v1_5.features.VdcClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataClient.Writeable; import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/handlers/InvalidateSessionAndRetryOn401AndLogoutOnCloseTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/handlers/InvalidateSessionAndRetryOn401AndLogoutOnCloseTest.java index ec0f1dc55e..24183b5695 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/handlers/InvalidateSessionAndRetryOn401AndLogoutOnCloseTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/handlers/InvalidateSessionAndRetryOn401AndLogoutOnCloseTest.java @@ -42,7 +42,6 @@ import com.google.common.cache.LoadingCache; */ @Test(groups = "unit", testName = "InvalidateSessionAndRetryOn401AndLogoutOnCloseTest") public class InvalidateSessionAndRetryOn401AndLogoutOnCloseTest { - @SuppressWarnings("unchecked") @Test public void test401ShouldInvalidateSessionAndRetry() { HttpCommand command = createMock(HttpCommand.class); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java index 75a45c3327..d55ee72a6d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.director.v1_5.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.rest.RestContextFactory.createContext; import static org.testng.Assert.assertNotNull; import java.net.URI; @@ -29,22 +28,15 @@ import org.jclouds.Constants; import org.jclouds.date.DateService; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.rest.BaseRestClientExpectTest; -import org.jclouds.rest.RestContextSpec; -import org.jclouds.rest.BaseRestClientExpectTest.ExpectModule; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import org.testng.annotations.BeforeGroups; -import com.google.common.base.Function; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Multimap; import com.google.inject.Guice; -import com.google.inject.Module; /** * Base class for writing KeyStone Rest Client Expect tests From 98f0c51b288228b33bb417661495a5b44418e454 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 10 Apr 2012 13:13:25 +0100 Subject: [PATCH 15/69] Update usage of collections of OVF sections --- .../dmtf/ovf/internal/BaseEnvelope.java | 2 +- .../dmtf/ovf/internal/BaseVirtualSystem.java | 10 +- .../v1_5/domain/AbstractVAppType.java | 86 ++++++++---- .../v1_5/domain/CaptureVAppParams.java | 117 +++++++++------- .../v1_5/domain/InstantiationParams.java | 125 +++++++++++++++-- .../director/v1_5/domain/VAppTemplate.java | 87 +++++------- .../v1_5/domain/VAppTemplateChildren.java | 132 ------------------ .../VAppTemplateClientExpectTest.java | 4 + 8 files changed, 286 insertions(+), 277 deletions(-) delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplateChildren.java diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java index 8303ac6aec..c513c0d293 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java @@ -137,7 +137,7 @@ public abstract class BaseEnvelope getDiskSections() { + public Set getDiskSections() { return diskSections; } diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java index 74bd231a3c..d499ef423f 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java @@ -74,7 +74,7 @@ public abstract class BaseVirtualSystem extends SectionType { /** * @see BaseVirtualSystem#getProductSections() */ - public B productSections(Iterable productSections) { + public B productSections(Iterable productSections) { this.productSections = Sets.newLinkedHashSet(checkNotNull(productSections, "productSections")); return self(); } @@ -109,9 +109,9 @@ public abstract class BaseVirtualSystem extends SectionType { @XmlElement(name = "Name") private String name; @XmlElement(name = "ProductSection") - private Set productSections; + private Set productSections; @XmlElementRef - private Set additionalSections; + private Set additionalSections; protected BaseVirtualSystem(Builder builder) { super(builder); @@ -137,11 +137,11 @@ public abstract class BaseVirtualSystem extends SectionType { * Specifies product-information for a package, such as product name and version, along with a * set of properties that can be configured */ - public Set getProductSections() { + public Set getProductSections() { return productSections; } - public Set getAdditionalSections() { + public Set getAdditionalSections() { return additionalSections; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java index a1a062f893..18e7963dcc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java @@ -21,19 +21,28 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import java.util.List; +import java.util.Collections; +import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlType; -import org.jclouds.dmtf.DMTFConstants; +import org.jclouds.dmtf.ovf.DeploymentOptionSection; +import org.jclouds.dmtf.ovf.DiskSection; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.OperatingSystemSection; +import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.dmtf.ovf.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; /** * Represents a base type for VAppType and VmType. @@ -63,7 +72,7 @@ public abstract class AbstractVAppType extends ResourceEntityType { private Boolean deployed; private Reference vAppParent; - private List sections = Lists.newArrayList(); + private Set sections = Sets.newLinkedHashSet(); /** * @see AbstractVAppType#isDeployed() @@ -101,7 +110,7 @@ public abstract class AbstractVAppType extends ResourceEntityType { * @see AbstractVAppType#getSections() */ public B sections(Iterable sections) { - this.sections = Lists.newArrayList(checkNotNull(sections, "sections")); + this.sections = Sets.newLinkedHashSet(checkNotNull(sections, "sections")); return self(); } @@ -109,8 +118,6 @@ public abstract class AbstractVAppType extends ResourceEntityType { * @see AbstractVAppType#getSections() */ public B section(SectionType section) { - if (this.sections == null) - this.sections = Lists.newArrayList(); this.sections.add(checkNotNull(section, "section")); return self(); } @@ -122,8 +129,26 @@ public abstract class AbstractVAppType extends ResourceEntityType { @XmlElement(name = "VAppParent") private Reference vAppParent; - @XmlElementRef(namespace = DMTFConstants.OVF_NS) - private List sections = Lists.newArrayList(); + @XmlElementRefs({ + @XmlElementRef(type = VirtualHardwareSection.class), + @XmlElementRef(type = LeaseSettingsSection.class), +// @XmlElementRef(type = EulaSection.class), + @XmlElementRef(type = RuntimeInfoSection.class), +// @XmlElementRef(type = AnnotationSection.class), + @XmlElementRef(type = DeploymentOptionSection.class), + @XmlElementRef(type = StartupSection.class), +// @XmlElementRef(type = ResourceAllocationSection.class), + @XmlElementRef(type = NetworkConnectionSection.class), + @XmlElementRef(type = CustomizationSection.class), + @XmlElementRef(type = ProductSection.class), + @XmlElementRef(type = GuestCustomizationSection.class), + @XmlElementRef(type = OperatingSystemSection.class), + @XmlElementRef(type = NetworkConfigSection.class), + @XmlElementRef(type = NetworkSection.class), +// @XmlElementRef(type = InstallSection.class), + @XmlElementRef(type = DiskSection.class) + }) + private Set sections = Sets.newLinkedHashSet(); @XmlAttribute private Boolean deployed; @@ -134,7 +159,7 @@ public abstract class AbstractVAppType extends ResourceEntityType { protected AbstractVAppType(Builder builder) { super(builder); this.vAppParent = builder.vAppParent; - this.sections = builder.sections; + this.sections = builder.sections.isEmpty() ? null : ImmutableSet.copyOf(builder.sections); this.deployed = builder.deployed; } @@ -146,32 +171,31 @@ public abstract class AbstractVAppType extends ResourceEntityType { } /** - * Specific ovf:Section with additional information for the vApp. + * Specific {@code ovf:Section} with additional information for the vApp. * * Objects of the following type(s) are allowed in the list: *
      - *
    • SectionType - *
    • VirtualHardwareSectionType - *
    • LeaseSettingsSectionType - *
    • EulaSectionType - *
    • RuntimeInfoSectionType - *
    • AnnotationSectionType - *
    • DeploymentOptionSectionType - *
    • StartupSectionType - *
    • ResourceAllocationSectionType - *
    • NetworkConnectionSectionType - *
    • CustomizationSectionType - *
    • ProductSectionType - *
    • GuestCustomizationSectionType - *
    • OperatingSystemSectionType - *
    • NetworkConfigSectionType - *
    • NetworkSectionType - *
    • DiskSectionType - *
    • InstallSectionType + *
    • {@link VirtualHardwareSectionType} + *
    • {@link LeaseSettingsSectionType} + *
    • {@link EulaSectionType} + *
    • {@link RuntimeInfoSectionType} + *
    • {@link AnnotationSectionType} + *
    • {@link DeploymentOptionSectionType} + *
    • {@link StartupSectionType} + *
    • {@link ResourceAllocationSectionType} + *
    • {@link NetworkConnectionSectionType} + *
    • {@link CustomizationSectionType} + *
    • {@link ProductSectionType} + *
    • {@link GuestCustomizationSectionType} + *
    • {@link OperatingSystemSectionType} + *
    • {@link NetworkConfigSectionType} + *
    • {@link NetworkSectionType} + *
    • {@link DiskSectionType} + *
    • {@link InstallSectionType} *
    */ - public List getSections() { - return this.sections; + public Set getSections() { + return sections != null ? ImmutableSet.copyOf(sections) : Collections.emptySet(); } /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java index 071da5176c..8a0093365c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to jclouds, Inc. (jclouds) under one or more * contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; @@ -28,24 +27,26 @@ import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.dmtf.ovf.DeploymentOptionSection; +import org.jclouds.dmtf.ovf.DiskSection; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.OperatingSystemSection; +import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.dmtf.ovf.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; - /** * Represents the parameters for capturing a vApp to a vApp template. - *

    - *

    - *

    Java class for CaptureVAppParams complex type. - *

    - *

    The following schema fragment specifies the expected content contained within this class. - *

    + * *

      * <complexType name="CaptureVAppParams">
      *   <complexContent>
    @@ -78,11 +79,11 @@ public class CaptureVAppParams extends ParamsType {
     
        private static class ConcreteBuilder extends Builder {
        }
    -   
    +
        public static abstract class Builder> extends ParamsType.Builder {
     
           private Reference source;
    -      private Set sections = Sets.newLinkedHashSet();
    +      private Set sections = Sets.newLinkedHashSet();
     
           /**
            * @see CaptureVAppParams#getSource()
    @@ -94,19 +95,27 @@ public class CaptureVAppParams extends ParamsType {
     
           /**
            * Sets source to a new Reference that uses this URI as the href.
    -       * 
    +       *
            * @see CaptureVAppParams#getSource()
            */
           public B source(URI source) {
              this.source = Reference.builder().href(source).build();
              return self();
           }
    -      
    +
           /**
            * @see CaptureVAppParams#getSections()
            */
    -      public B sections(Set sections) {
    -         this.sections = checkNotNull(sections, "sections");
    +      public B section(SectionType section) {
    +         this.sections.add(checkNotNull(section, "section"));
    +         return self();
    +      }
    +
    +      /**
    +       * @see CaptureVAppParams#getSections()
    +       */
    +      public B sections(Iterable sections) {
    +         this.sections = Sets.newLinkedHashSet(checkNotNull(sections, "sections"));
              return self();
           }
     
    @@ -125,7 +134,7 @@ public class CaptureVAppParams extends ParamsType {
        private CaptureVAppParams(Builder builder) {
           super(builder);
           this.source = builder.source;
    -      this.sections = builder.sections;
    +      this.sections = builder.sections.isEmpty() ? null : ImmutableSet.copyOf(builder.sections);
        }
     
        private CaptureVAppParams() {
    @@ -138,46 +147,60 @@ public class CaptureVAppParams extends ParamsType {
     
        @XmlElement(name = "Source", required = true)
        protected Reference source;
    -   @XmlElementRef
    -   protected Set sections = Sets.newLinkedHashSet();
    +   @XmlElementRefs({
    +      @XmlElementRef(type = VirtualHardwareSection.class),
    +      @XmlElementRef(type = LeaseSettingsSection.class),
    +//      @XmlElementRef(type = EulaSection.class),
    +      @XmlElementRef(type = RuntimeInfoSection.class),
    +//      @XmlElementRef(type = AnnotationSection.class),
    +      @XmlElementRef(type = DeploymentOptionSection.class),
    +      @XmlElementRef(type = StartupSection.class),
    +//      @XmlElementRef(type = ResourceAllocationSection.class),
    +      @XmlElementRef(type = NetworkConnectionSection.class),
    +      @XmlElementRef(type = CustomizationSection.class),
    +      @XmlElementRef(type = ProductSection.class),
    +      @XmlElementRef(type = GuestCustomizationSection.class),
    +      @XmlElementRef(type = OperatingSystemSection.class),
    +      @XmlElementRef(type = NetworkConfigSection.class),
    +      @XmlElementRef(type = NetworkSection.class),
    +//      @XmlElementRef(type = InstallSection.class),
    +      @XmlElementRef(type = DiskSection.class)
    +   })
    +   protected Set sections = Sets.newLinkedHashSet();
     
        /**
         * Gets the value of the source property.
    -    *
    -    * @return possible object is
    -    *         {@link Reference }
         */
        public Reference getSource() {
           return source;
        }
     
        /**
    -    * An ovf:Section to configure the captured vAppTemplate.
    +    * An {@code ovf:Section} to configure the captured vAppTemplate.
         *
    -    *  Gets the value of the section property.
    -    *    
    -    * Objects of the following type(s) are allowed in the list
    -    * {@link SectionType }
    -    * {@link VirtualHardwareSection }
    -    * {@link LeaseSettingsSection }
    -    * {@link EulaSection }
    -    * {@link RuntimeInfoSection }
    -    * {@link AnnotationSection }
    -    * {@link DeploymentOptionSection }
    -    * {@link StartupSection }
    -    * {@link ResourceAllocationSection }
    -    * {@link NetworkConnectionSection }
    -    * {@link CustomizationSection }
    -    * {@link ProductSection }
    -    * {@link GuestCustomizationSection }
    -    * {@link OperatingSystemSection }
    -    * {@link NetworkConfigSection }
    -    * {@link NetworkSection }
    -    * {@link DiskSection }
    -    * {@link InstallSection }
    +    * Objects of the following type(s) are allowed in the list:
    +    * 
      + *
    • {@link VirtualHardwareSectionType} + *
    • {@link LeaseSettingsSectionType} + *
    • {@link EulaSectionType} + *
    • {@link RuntimeInfoSectionType} + *
    • {@link AnnotationSectionType} + *
    • {@link DeploymentOptionSectionType} + *
    • {@link StartupSectionType} + *
    • {@link ResourceAllocationSectionType} + *
    • {@link NetworkConnectionSectionType} + *
    • {@link CustomizationSectionType} + *
    • {@link ProductSectionType} + *
    • {@link GuestCustomizationSectionType} + *
    • {@link OperatingSystemSectionType} + *
    • {@link NetworkConfigSectionType} + *
    • {@link NetworkSectionType} + *
    • {@link DiskSectionType} + *
    • {@link InstallSectionType} + *
    */ - public Set getSections() { - return Collections.unmodifiableSet(this.sections); + public Set getSections() { + return sections != null ? ImmutableSet.copyOf(sections) : Collections.emptySet(); } @Override @@ -187,8 +210,8 @@ public class CaptureVAppParams extends ParamsType { if (o == null || getClass() != o.getClass()) return false; CaptureVAppParams that = CaptureVAppParams.class.cast(o); - return equal(source, that.source) && - equal(sections, that.sections); + return equal(source, that.source) + && equal(sections, that.sections); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java index 43073147f2..c07dd5fc47 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java @@ -21,21 +21,32 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; import java.util.Set; import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.dmtf.ovf.DeploymentOptionSection; +import org.jclouds.dmtf.ovf.DiskSection; +import org.jclouds.dmtf.ovf.NetworkSection; +import org.jclouds.dmtf.ovf.OperatingSystemSection; +import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.dmtf.ovf.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; /** - * Represents a list of ovf:Section to configure for instantiating a VApp. - * + * Represents a list of {@code ovf:Section} to configure for instantiating a VApp. + * * @author grkvlt@apache.org * @see * vCloud REST API - InstantiationParamsType @@ -43,7 +54,7 @@ import com.google.common.collect.Sets; */ @XmlRootElement(name = "InstantiationParams") @XmlType(name = "InstantiationParamsType") -public class InstantiationParams { +public class InstantiationParams implements Set { public static Builder builder() { return new Builder(); @@ -87,18 +98,35 @@ public class InstantiationParams { } private InstantiationParams(Set sections) { - this.sections = ImmutableSet.copyOf(sections); + this.sections = sections.isEmpty() ? null : ImmutableSet.copyOf(sections); } - @XmlElementRef - protected Set sections = Sets.newLinkedHashSet(); + @XmlElementRefs({ + @XmlElementRef(type = VirtualHardwareSection.class), + @XmlElementRef(type = LeaseSettingsSection.class), +// @XmlElementRef(type = EulaSection.class), + @XmlElementRef(type = RuntimeInfoSection.class), +// @XmlElementRef(type = AnnotationSection.class), + @XmlElementRef(type = DeploymentOptionSection.class), + @XmlElementRef(type = StartupSection.class), +// @XmlElementRef(type = ResourceAllocationSection.class), + @XmlElementRef(type = NetworkConnectionSection.class), + @XmlElementRef(type = CustomizationSection.class), + @XmlElementRef(type = ProductSection.class), + @XmlElementRef(type = GuestCustomizationSection.class), + @XmlElementRef(type = OperatingSystemSection.class), + @XmlElementRef(type = NetworkConfigSection.class), + @XmlElementRef(type = NetworkSection.class), +// @XmlElementRef(type = InstallSection.class), + @XmlElementRef(type = DiskSection.class) + }) + protected Set sections = Sets.newLinkedHashSet(); /** * An {@code ovf:Section} to configure for instantiation. * - * Objects of the following type(s) are allowed in the list + * Objects of the following type(s) are allowed in the list: *
      - *
    • {@link SectionType} *
    • {@link VirtualHardwareSection} *
    • {@link LeaseSettingsSection} *
    • {@link EulaSection} @@ -118,8 +146,8 @@ public class InstantiationParams { *
    • {@link InstallSection} *
    */ - public Set getSections() { - return sections; + public Set getSections() { + return sections != null ? ImmutableSet.copyOf(sections) : Collections.emptySet(); } @Override @@ -141,4 +169,81 @@ public class InstantiationParams { public String toString() { return Objects.toStringHelper("").add("sections", sections).toString(); } + + /** + * The delegate always returns a {@link Set} even if {@link #sections} is {@literal null}. + * + * The delegated {@link Set} is used by the methods implementing its interface. + *

    + * NOTE Annoying lack of multiple inheritance for using ForwardingList! + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + private Set delegate() { + return (Set) getSections(); + } + + @Override + public boolean add(SectionType arg0) { + return delegate().add(arg0); + } + + @Override + public boolean addAll(Collection arg0) { + return delegate().addAll(arg0); + } + + @Override + public void clear() { + delegate().clear(); + } + + @Override + public boolean contains(Object arg0) { + return delegate().contains(arg0); + } + + @Override + public boolean containsAll(Collection arg0) { + return delegate().containsAll(arg0); + } + + @Override + public boolean isEmpty() { + return delegate().isEmpty(); + } + + @Override + public Iterator iterator() { + return delegate().iterator(); + } + + @Override + public boolean remove(Object arg0) { + return delegate().remove(arg0); + } + + @Override + public boolean removeAll(Collection arg0) { + return delegate().removeAll(arg0); + } + + @Override + public boolean retainAll(Collection arg0) { + return delegate().retainAll(arg0); + } + + @Override + public int size() { + return delegate().size(); + } + + @Override + public Object[] toArray() { + return delegate().toArray(); + } + + @Override + public T[] toArray(T[] arg0) { + return delegate().toArray(arg0); + } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java index 751ead8e36..8b24e38410 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java @@ -28,8 +28,8 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRefs; +import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSeeAlso; import org.jclouds.dmtf.ovf.DeploymentOptionSection; import org.jclouds.dmtf.ovf.DiskSection; @@ -69,7 +69,7 @@ public class VAppTemplate extends ResourceEntityType { public static abstract class Builder> extends ResourceEntityType.Builder { private Owner owner; private Set children = Sets.newLinkedHashSet(); - private Set sections = Sets.newLinkedHashSet(); + private Set sections = Sets.newLinkedHashSet(); private String vAppScopedLocalId; private Boolean ovfDescriptorUploaded; private Boolean goldMaster; @@ -85,16 +85,16 @@ public class VAppTemplate extends ResourceEntityType { /** * @see VAppTemplate#getChildren() */ - public B children(Set children) { - this.children = checkNotNull(children, "children"); + public B children(Iterable children) { + this.children = Sets.newLinkedHashSet(checkNotNull(children, "children")); return self(); } /** * @see VAppTemplate#getSections() */ - public B sections(Set sections) { - this.sections = checkNotNull(sections, "sections"); + public B sections(Iterable sections) { + this.sections = Sets.newLinkedHashSet(checkNotNull(sections, "sections")); return self(); } @@ -140,10 +140,10 @@ public class VAppTemplate extends ResourceEntityType { @XmlElement(name = "Owner") private Owner owner; - @XmlElement(name = "Children") - private VAppTemplateChildren children = VAppTemplateChildren.builder().build(); + @XmlElementWrapper(name = "Children") + @XmlElement(name = "Vm") + private Set children = Sets.newLinkedHashSet(); @XmlElementRefs({ - @XmlElementRef(type = SectionType.class), @XmlElementRef(type = VirtualHardwareSection.class), @XmlElementRef(type = LeaseSettingsSection.class), // @XmlElementRef(type = EulaSection.class), @@ -162,7 +162,7 @@ public class VAppTemplate extends ResourceEntityType { // @XmlElementRef(type = InstallSection.class), @XmlElementRef(type = DiskSection.class) }) - private Set sections = Sets.newLinkedHashSet(); + private Set sections = Sets.newLinkedHashSet(); @XmlElement(name = "VAppScopedLocalId") private String vAppScopedLocalId; @XmlAttribute @@ -173,8 +173,8 @@ public class VAppTemplate extends ResourceEntityType { protected VAppTemplate(Builder builder) { super(builder); this.owner = builder.owner; - this.children = VAppTemplateChildren.builder().vms(builder.children).build(); - this.sections = ImmutableSet.copyOf(builder.sections); + this.children = builder.children.isEmpty() ? Collections.emptySet() : ImmutableSet.copyOf(builder.children); + this.sections = builder.sections.isEmpty() ? null : ImmutableSet.copyOf(builder.sections); this.vAppScopedLocalId = builder.vAppScopedLocalId; this.ovfDescriptorUploaded = builder.ovfDescriptorUploaded; this.goldMaster = builder.goldMaster; @@ -186,9 +186,6 @@ public class VAppTemplate extends ResourceEntityType { /** * Gets the value of the owner property. - * - * @return possible object is - * {@link Owner } */ public Owner getOwner() { return owner; @@ -196,47 +193,41 @@ public class VAppTemplate extends ResourceEntityType { /** * Gets the value of the children property. - * - * @return possible object is - * {@link VAppTemplateChildren } */ public Set getChildren() { - return children.getVms(); + return children; } /** * Contains ovf sections for vApp template. - * Gets the value of the section property. - *

    - * Objects of the following type(s) are allowed in the list - * {@link SectionType } - * {@link VirtualHardwareSection } - * {@link LeaseSettingsSection } - * {@link EulaSection } - * {@link RuntimeInfoSection } - * {@link AnnotationSection } - * {@link DeploymentOptionSection } - * {@link StartupSection } - * {@link ResourceAllocationSection } - * {@link NetworkConnectionSection } - * {@link CustomizationSection } - * {@link ProductSection } - * {@link GuestCustomizationSection } - * {@link OperatingSystemSection } - * {@link NetworkConfigSection } - * {@link NetworkSection } - * {@link DiskSection } - * {@link InstallSection } + * + * Objects of the following type(s) are allowed in the list: + *

      + *
    • {@link VirtualHardwareSectionType} + *
    • {@link LeaseSettingsSectionType} + *
    • {@link EulaSectionType} + *
    • {@link RuntimeInfoSectionType} + *
    • {@link AnnotationSectionType} + *
    • {@link DeploymentOptionSectionType} + *
    • {@link StartupSectionType} + *
    • {@link ResourceAllocationSectionType} + *
    • {@link NetworkConnectionSectionType} + *
    • {@link CustomizationSectionType} + *
    • {@link ProductSectionType} + *
    • {@link GuestCustomizationSectionType} + *
    • {@link OperatingSystemSectionType} + *
    • {@link NetworkConfigSectionType} + *
    • {@link NetworkSectionType} + *
    • {@link DiskSectionType} + *
    • {@link InstallSectionType} + *
    */ - public Set getSections() { - return Collections.unmodifiableSet(this.sections); + public Set getSections() { + return sections != null ? ImmutableSet.copyOf(sections) : Collections.emptySet(); } /** * Gets the value of the vAppScopedLocalId property. - * - * @return possible object is - * {@link String } */ public String getVAppScopedLocalId() { return vAppScopedLocalId; @@ -244,9 +235,6 @@ public class VAppTemplate extends ResourceEntityType { /** * Gets the value of the ovfDescriptorUploaded property. - * - * @return possible object is - * {@link Boolean } */ public Boolean isOvfDescriptorUploaded() { return ovfDescriptorUploaded; @@ -254,9 +242,6 @@ public class VAppTemplate extends ResourceEntityType { /** * Gets the value of the goldMaster property. - * - * @return possible object is - * {@link Boolean } */ public boolean isGoldMaster() { if (goldMaster == null) { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplateChildren.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplateChildren.java deleted file mode 100644 index c81c8b51c1..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplateChildren.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - - -/** - * Represents vApp template children. - *

    - *

    - *

    Java class for VAppTemplateChildren complex type. - *

    - *

    The following schema fragment specifies the expected content contained within this class. - *

    - *

    - * <complexType name="VAppTemplateChildren">
    - *   <complexContent>
    - *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
    - *       <sequence>
    - *         <element name="Vm" type="{http://www.vmware.com/vcloud/v1.5}VAppTemplateType" maxOccurs="unbounded" minOccurs="0"/>
    - *       </sequence>
    - *       <anyAttribute processContents='lax' namespace='##other'/>
    - *     </extension>
    - *   </complexContent>
    - * </complexType>
    - * 
    - */ -@XmlRootElement(name = "Children") -@XmlType(propOrder = { - "vms" -}) -public class VAppTemplateChildren { - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromVAppTemplateChildren(this); - } - - public static class Builder { - private Set vms = Sets.newLinkedHashSet(); - - /** - * @see VAppTemplateChildren#getVms() - */ - public Builder vms(Set vms) { - this.vms = checkNotNull(vms, "vms"); - return this; - } - - - public VAppTemplateChildren build() { - return new VAppTemplateChildren(vms); - } - - - public Builder fromVAppTemplateChildren(VAppTemplateChildren in) { - return vms(in.getVms()); - } - } - - private VAppTemplateChildren(Set vm) { - this.vms = ImmutableSet.copyOf(vm); - } - - private VAppTemplateChildren() { - // For JAXB - } - - @XmlElement(name = "Vm") - protected Set vms = Sets.newLinkedHashSet(); - - /** - * Gets the value of the vm property. - */ - public Set getVms() { - return Collections.unmodifiableSet(this.vms); - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - VAppTemplateChildren that = VAppTemplateChildren.class.cast(o); - return equal(vms, that.vms); - } - - @Override - public int hashCode() { - return Objects.hashCode(vms); - } - - @Override - public String toString() { - return Objects.toStringHelper("") - .add("vms", vms).toString(); - } - -} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java index 21a63f50d6..c2213b08c9 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java @@ -33,6 +33,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; +import java.io.IOException; import java.net.URI; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -68,8 +69,11 @@ import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; +import org.jclouds.xml.internal.JAXBParser; import org.testng.annotations.Test; +import com.google.common.base.Strings; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableSet; /** From 0e0152024090e81fac3ed9dacd57ce188fdd85e5 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 10 Apr 2012 15:23:39 +0100 Subject: [PATCH 16/69] Updated types to fix some failing tests --- .../v1_5/domain/InstantiationParams.java | 82 +------------------ .../v1_5/domain/NetworkConfigSection.java | 2 + 2 files changed, 4 insertions(+), 80 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java index c07dd5fc47..be4b74b9d0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java @@ -21,9 +21,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.Set; import javax.xml.bind.annotation.XmlElementRef; @@ -54,7 +52,7 @@ import com.google.common.collect.Sets; */ @XmlRootElement(name = "InstantiationParams") @XmlType(name = "InstantiationParamsType") -public class InstantiationParams implements Set { +public class InstantiationParams { public static Builder builder() { return new Builder(); @@ -169,81 +167,5 @@ public class InstantiationParams implements Set { public String toString() { return Objects.toStringHelper("").add("sections", sections).toString(); } - - /** - * The delegate always returns a {@link Set} even if {@link #sections} is {@literal null}. - * - * The delegated {@link Set} is used by the methods implementing its interface. - *

    - * NOTE Annoying lack of multiple inheritance for using ForwardingList! - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - private Set delegate() { - return (Set) getSections(); - } - - @Override - public boolean add(SectionType arg0) { - return delegate().add(arg0); - } - - @Override - public boolean addAll(Collection arg0) { - return delegate().addAll(arg0); - } - - @Override - public void clear() { - delegate().clear(); - } - - @Override - public boolean contains(Object arg0) { - return delegate().contains(arg0); - } - - @Override - public boolean containsAll(Collection arg0) { - return delegate().containsAll(arg0); - } - - @Override - public boolean isEmpty() { - return delegate().isEmpty(); - } - - @Override - public Iterator iterator() { - return delegate().iterator(); - } - - @Override - public boolean remove(Object arg0) { - return delegate().remove(arg0); - } - - @Override - public boolean removeAll(Collection arg0) { - return delegate().removeAll(arg0); - } - - @Override - public boolean retainAll(Collection arg0) { - return delegate().retainAll(arg0); - } - - @Override - public int size() { - return delegate().size(); - } - - @Override - public Object[] toArray() { - return delegate().toArray(); - } - - @Override - public T[] toArray(T[] arg0) { - return delegate().toArray(arg0); - } + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java index 4da43d2fcd..a7a258d7a9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.SectionType; @@ -45,6 +46,7 @@ import com.google.common.collect.Sets; *

    */ @XmlRootElement(name = "NetworkConfigSection") +@XmlType(name = "NetworkConfigSectionType") public class NetworkConfigSection extends SectionType { public static Builder builder() { From 2cfe2155921c22194c6b63b0431d64a68bc424fa Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 10 Apr 2012 18:06:16 +0100 Subject: [PATCH 17/69] Updated XmlType annotations --- .../main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java | 2 ++ .../dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java | 2 ++ .../main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java | 2 -- .../dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java | 2 ++ .../main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java | 2 -- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java index 8cb3161d47..39cf441a4d 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java @@ -25,6 +25,7 @@ import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; @@ -41,6 +42,7 @@ import com.google.common.collect.Sets; * @author Adam Lowe */ @XmlRootElement(name = "DeploymentOptionSection") +@XmlType(name = "DeploymentOptionSection_Type") public class DeploymentOptionSection extends SectionType { public static Builder builder() { diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java index c165436a1a..5e8698b602 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Set; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; @@ -35,6 +36,7 @@ import com.google.common.collect.Sets; * @author Adam Lowe */ @XmlRootElement(name = "NetworkSection") +@XmlType(name = "NetworkSection_Type") public class NetworkSection extends SectionType { public static Builder builder() { diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java index 14e8dd6a5b..724eb9fa21 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java @@ -23,7 +23,6 @@ import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; @@ -34,7 +33,6 @@ import com.google.common.base.Objects; * @author Adrian Cole * @author Adam Lowe */ -@XmlRootElement(name = "OperatingSystemSection") @XmlType(name = "OperatingSystemSection_Type") public class OperatingSystemSection extends SectionType { diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java index 7fd5071789..03f70b95ff 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java @@ -26,6 +26,7 @@ import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -40,6 +41,7 @@ import com.google.common.collect.Lists; * */ @XmlRootElement(name = "StartupSection") +@XmlType(name = "StartupSection_Type") public class StartupSection extends SectionType { public static Builder builder() { diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java index ed3c2c1806..3b5dbadeec 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java @@ -25,7 +25,6 @@ import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.cim.ResourceAllocationSettingData; @@ -47,7 +46,6 @@ import com.google.common.collect.Sets; * @author Adam Lowe * @author grkvlt@apache.org */ -@XmlRootElement(name = "VirtualHardwareSection") @XmlType(name = "VirtualHardwareSection_Type") public class VirtualHardwareSection extends SectionType { From a4d433d513b1b9f022a4a0ea57adf24fa2691cf2 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 10 Apr 2012 18:14:14 +0100 Subject: [PATCH 18/69] Update DMTF dependencies (removed log4j) --- labs/dmtf/pom.xml | 13 --- labs/dmtf/src/test/resources/log4j.xml | 151 ------------------------- 2 files changed, 164 deletions(-) delete mode 100644 labs/dmtf/src/test/resources/log4j.xml diff --git a/labs/dmtf/pom.xml b/labs/dmtf/pom.xml index 28ad055190..cde6657685 100644 --- a/labs/dmtf/pom.xml +++ b/labs/dmtf/pom.xml @@ -42,19 +42,6 @@ jclouds-compute ${project.version} - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-log4j - ${project.version} - test - diff --git a/labs/dmtf/src/test/resources/log4j.xml b/labs/dmtf/src/test/resources/log4j.xml deleted file mode 100644 index 63810d3ca0..0000000000 --- a/labs/dmtf/src/test/resources/log4j.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 9dbdbb13a77018d802e05cc3a1ed6f85722f5374 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 10 Apr 2012 15:24:30 +0100 Subject: [PATCH 19/69] Fix failing tests due to new ReturnNullOnNotFoundOr404 behaviour --- .../v1_5/features/CatalogClientLiveTest.java | 26 +++------------- .../VAppTemplateClientExpectTest.java | 4 --- .../features/admin/UserClientLiveTest.java | 31 +++++-------------- 3 files changed, 13 insertions(+), 48 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index d52fc46e35..bf0284a2fc 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -33,6 +33,7 @@ import static org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates.relEqua import static org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates.typeEquals; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -42,7 +43,6 @@ import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; import org.jclouds.vcloud.director.v1_5.domain.CatalogType; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; @@ -189,16 +189,8 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(description = "DELETE /catalogItem/{id}", dependsOnMethods = "testDeleteCatalogItemMetadataValue") public void testDeleteCatalogItem() { catalogClient.deleteCatalogItem(catalogItem.getHref()); - try { - catalogClient.getCatalogItem(catalogItem.getHref()); - fail("The CatalogItem should have been deleted"); - } catch (VCloudDirectorException vcde) { - checkError(vcde.getError()); - // XXX - assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted"); - } finally { - catalogItem = null; - } + catalogItem = catalogClient.getCatalogItem(catalogItem.getHref()); + assertNull(catalogItem); } @Test(description = "GET /catalog/{id}/metadata") @@ -283,15 +275,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { checkTask(deleteCatalogItemMetadataValue); assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue")); - try { - catalogClient.getMetadataClient().getMetadataValue(catalogItem.getHref(), "KEY"); - fail("The CatalogItem MetadataValue for KEY should have been deleted"); - } catch (VCloudDirectorException vcde) { - Error error = vcde.getError(); - checkError(error); - Integer majorErrorCode = error.getMajorErrorCode(); - assertEquals(majorErrorCode, Integer.valueOf(403), - String.format(CORRECT_VALUE_OBJECT_FMT, "MajorErrorCode", "Error", "403",Integer.toString(majorErrorCode))); - } + MetadataValue deleted = catalogClient.getMetadataClient().getMetadataValue(catalogItem.getHref(), "KEY"); + assertNull(deleted); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java index c2213b08c9..21a63f50d6 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java @@ -33,7 +33,6 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; -import java.io.IOException; import java.net.URI; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -69,11 +68,8 @@ import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; -import org.jclouds.xml.internal.JAXBParser; import org.testng.annotations.Test; -import com.google.common.base.Strings; -import com.google.common.base.Throwables; import com.google.common.collect.ImmutableSet; /** diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java index fea82e4fc1..9ca09a523f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java @@ -20,8 +20,9 @@ package org.jclouds.vcloud.director.v1_5.features.admin; import static com.google.common.base.Objects.equal; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE; -import static org.testng.Assert.assertEquals; +import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkUser; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import static org.testng.AssertJUnit.assertFalse; @@ -30,15 +31,11 @@ import java.net.URI; import org.jclouds.rest.AuthorizationException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; -import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.jclouds.vcloud.director.v1_5.domain.User; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgClient; -import org.jclouds.vcloud.director.v1_5.features.admin.UserClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.login.SessionClient; import org.testng.annotations.AfterClass; @@ -90,7 +87,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { public void testCreateUser() { User newUser = randomTestUser("testCreateUser"); user = userClient.createUser(orgRef.getHref(), newUser); - Checks.checkUser(newUser); + checkUser(newUser); } @Test(description = "GET /admin/user/{id}", @@ -98,7 +95,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { public void testGetUser() { user = userClient.getUser(user.getHref()); - Checks.checkUser(user); + checkUser(user); } @Test(description = "PUT /admin/user/{id}", @@ -125,7 +122,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { userClient.updateUser(user.getHref(), newUser); user = userClient.getUser(user.getHref()); - Checks.checkUser(user); + checkUser(user); assertTrue(equal(user.getFullName(), newUser.getFullName()), String.format(OBJ_FIELD_UPDATABLE, USER, "fullName")); assertTrue(equal(user.getEmailAddress(), newUser.getEmailAddress()), @@ -213,8 +210,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { } } - @Test(description = "DELETE /admin/user/{id}", - dependsOnMethods = { "testCreateUser" } ) + @Test(description = "DELETE /admin/user/{id}", dependsOnMethods = { "testCreateUser" }) public void testDeleteUser() { // Create a user to be deleted (so we remove dependencies on test ordering) User newUser = randomTestUser("testDeleteUser"+getTestDateTimeStamp()); @@ -224,18 +220,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { userClient.deleteUser(userToBeDeleted.getHref()); // Confirm cannot no longer be accessed - Error expected = Error.builder() - .message("No access to entity \"(com.vmware.vcloud.entity.user:"+ - userToBeDeleted.getId().substring("urn:vcloud:user:".length())+")\".") - .majorErrorCode(403) - .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") - .build(); - - try { - userClient.getUser(userToBeDeleted.getHref()); - fail("Should give HTTP 403 error for accessing user after deleting it ("+userToBeDeleted+")"); - } catch (VCloudDirectorException vde) { - assertEquals(vde.getError(), expected); - } + User deleted = userClient.getUser(userToBeDeleted.getHref()); + assertNull(deleted); } } From ad1250984bce2abce18bc5c8bea6cebdc92a85df Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 10 Apr 2012 15:54:47 +0100 Subject: [PATCH 20/69] Use value of Role enum --- .../director/v1_5/internal/VCloudDirectorTestSession.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java index 6bbc1d92b3..a5e4800ad0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java @@ -99,7 +99,7 @@ public class VCloudDirectorTestSession { User user = adminContext.getApi().getUserClient().getUser(userRef.getHref()); Reference orgAdmin = user.getRole(); - assertTrue(equal(orgAdmin.getName(), DefaultRoles.ORG_ADMIN), "must give org admin or user-only credentials"); + assertTrue(equal(orgAdmin.getName(), DefaultRoles.ORG_ADMIN.value()), "must give org admin or user-only credentials"); String adminIdentity = "testAdmin"+BaseVCloudDirectorClientLiveTest.getTestDateTimeStamp(); String adminCredential = "testAdminPassword"; From 4de062c636dc2ed71403e84c96cb8e5e962547eb Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Tue, 10 Apr 2012 17:53:01 +0100 Subject: [PATCH 21/69] Fixing live test failures due to new enums and DMTF changes --- .../v1_5/domain/ControlAccessParams.java | 3 +- .../director/v1_5/domain/EntityType.java | 18 ++--- .../vcloud/director/v1_5/domain/Link.java | 17 +++- .../director/v1_5/domain/OrgLdapSettings.java | 33 ++++---- .../v1_5/domain/ResourceEntityType.java | 58 ++++++++------ .../vcloud/director/v1_5/domain/Task.java | 32 ++++---- .../v1_5/predicates/LinkPredicates.java | 14 +++- .../v1_5/predicates/TaskStatusEquals.java | 16 ++-- .../v1_5/AbstractVAppClientLiveTest.java | 8 +- .../vcloud/director/v1_5/domain/Checks.java | 26 ++++++- .../v1_5/features/MediaClientLiveTest.java | 78 ++++--------------- .../v1_5/features/VAppClientLiveTest.java | 3 +- .../features/VAppTemplateClientLiveTest.java | 51 ++++++------ .../v1_5/features/VdcClientLiveTest.java | 4 +- .../admin/AdminCatalogClientLiveTest.java | 38 ++------- .../BaseVCloudDirectorClientLiveTest.java | 2 +- .../v1_5/predicates/LinkPredicatesTest.java | 5 ++ 17 files changed, 190 insertions(+), 216 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java index de030657e9..05eedca941 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java @@ -129,8 +129,9 @@ public class ControlAccessParams { public ControlAccessParams(Boolean sharedToEveryone, String everyoneAccessLevel, Iterable accessSettings) { this.sharedToEveryone = sharedToEveryone; - this.everyoneAccessLevel = everyoneAccessLevel; if (sharedToEveryone) { + this.everyoneAccessLevel = checkNotNull(everyoneAccessLevel, "everyoneAccessLevel"); + } else { checkNotNull(accessSettings, "accessSettings"); } this.accessSettings = Iterables.isEmpty(accessSettings) ? null : ImmutableList.copyOf(accessSettings); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index 59f7985d8a..2184300250 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -21,7 +21,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Set; +import java.util.List; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -30,8 +30,8 @@ import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; /** * Basic entity type in the vCloud object model. @@ -63,7 +63,7 @@ public class EntityType extends ResourceType { public static abstract class Builder> extends ResourceType.Builder { private String description; - private Set tasks = Sets.newLinkedHashSet(); + private List tasks = Lists.newArrayList(); private String name; private String id; @@ -95,7 +95,7 @@ public class EntityType extends ResourceType { * @see EntityType#getTasks() */ public B tasks(Iterable tasks) { - this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); + this.tasks = Lists.newArrayList(checkNotNull(tasks, "tasks")); return self(); } @@ -124,7 +124,7 @@ public class EntityType extends ResourceType { private String description; @XmlElementWrapper(name = "Tasks") @XmlElement(name = "Task") - private Set tasks; + private List tasks; @XmlAttribute private String id; @XmlAttribute(required = true) @@ -133,7 +133,7 @@ public class EntityType extends ResourceType { protected EntityType(Builder builder) { super(builder); this.description = builder.description; - this.tasks = builder.tasks == null || builder.tasks.isEmpty() ? null : ImmutableSet.copyOf(builder.tasks); + this.tasks = builder.tasks == null || builder.tasks.isEmpty() ? null : ImmutableList.copyOf(builder.tasks); this.id = builder.id; this.name = builder.name; } @@ -156,8 +156,8 @@ public class EntityType extends ResourceType { /** * A list of queued, running, or recently completed tasks associated with this entity. */ - public Set getTasks() { - return tasks == null ? ImmutableSet.of() : ImmutableSet.copyOf(tasks); + public List getTasks() { + return tasks == null ? ImmutableList.of() : ImmutableList.copyOf(tasks); } /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index dd4a13ebbb..6aad1d69ae 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -69,6 +69,7 @@ public class Link extends Reference { @XmlEnumValue("download:default") DOWNLOAD_DEFAULT("download:default"), @XmlEnumValue("edit") EDIT("edit"), @XmlEnumValue("enable") ENABLE("enable"), + @XmlEnumValue("entityResolver") ENTITY_RESOLVER("entityResolver"), @XmlEnumValue("firstPage") FIRST_PAGE("firstPage"), @XmlEnumValue("installVmwareTools") INSTALL_VMWARE_TOOLS("installVmwareTools"), @XmlEnumValue("lastPage") LAST_PAGE("lastPage"), @@ -115,7 +116,7 @@ public class Link extends Reference { ADD, ALTERNATE, CATALOG_ITEM, COLLABORATION_ABORT, COLLABORATION_FAIL, COLLABORATION_RESUME, CONSOLIDATE, CONTROL_ACCESS, COPY, DEPLOY, DISABLE, DISCARD_STATE, DOWN, - DOWNLOAD_ALTERNATE, DOWNLOAD_DEFAULT, EDIT, ENABLE, FIRST_PAGE, + DOWNLOAD_ALTERNATE, DOWNLOAD_DEFAULT, EDIT, ENABLE, ENTITY_RESOLVER, FIRST_PAGE, INSTALL_VMWARE_TOOLS, LAST_PAGE, EJECT_MEDIA, INSERT_MEDIA, MOVE, NEXT_PAGE, OVA, OVF, POWER_OFF, POWER_ON, REBOOT, RESET, SHUTDOWN, SUSPEND, PREVIOUS_PAGE, PUBLISH, RECOMPOSE, RECONNECT, REGISTER, @@ -163,12 +164,20 @@ public class Link extends Reference { public static class Builder> extends Reference.Builder { - private String rel; + private Rel rel; /** * @see Link#getRel() */ public B rel(String rel) { + this.rel = Rel.fromValue(rel); + return self(); + } + + /** + * @see Link#getRel() + */ + public B rel(Rel rel) { this.rel = rel; return self(); } @@ -194,7 +203,7 @@ public class Link extends Reference { } @XmlAttribute(required = true) - private String rel; + private Rel rel; protected Link(Builder builder) { super(builder); @@ -213,7 +222,7 @@ public class Link extends Reference { * * @return relationship of the link to the object that contains it. */ - public String getRel() { + public Rel getRel() { return rel; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java index 913019a20e..93df7dd3b7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java @@ -110,18 +110,26 @@ public class OrgLdapSettings extends ResourceType { public static abstract class Builder> extends ResourceType.Builder { - private String ldapMode; + private LdapMode ldapMode; private String customUsersOu; private CustomOrgLdapSettings customOrgLdapSettings; /** * @see OrgLdapSettings#getLdapMode() */ - public B ldapMode(String ldapMode) { + public B ldapMode(LdapMode ldapMode) { this.ldapMode = ldapMode; return self(); } + /** + * @see OrgLdapSettings#getLdapMode() + */ + public B ldapMode(String ldapMode) { + this.ldapMode = LdapMode.fromValue(ldapMode); + return self(); + } + /** * @see OrgLdapSettings#getCustomUsersOu() */ @@ -162,8 +170,8 @@ public class OrgLdapSettings extends ResourceType { this.customOrgLdapSettings = builder.customOrgLdapSettings; } - @XmlElement(name = "OrgLdapMode") - private String ldapMode; + @XmlElement(name = "OrgLdapMode") + private LdapMode ldapMode; @XmlElement(name = "CustomUsersOu") private String customUsersOu; @XmlElement(name = "CustomOrgLdapSettings") @@ -171,23 +179,13 @@ public class OrgLdapSettings extends ResourceType { /** * Gets the value of the orgLdapMode property. - * - * @return - * possible object is - * {@link String } - * */ - public String getLdapMode() { + public LdapMode getLdapMode() { return ldapMode; } /** * Gets the value of the customUsersOu property. - * - * @return - * possible object is - * {@link String } - * */ public String getCustomUsersOu() { return customUsersOu; @@ -195,11 +193,6 @@ public class OrgLdapSettings extends ResourceType { /** * Gets the value of the customOrgLdapSettings property. - * - * @return - * possible object is - * {@link CustomOrgLdapSettings } - * */ public CustomOrgLdapSettings getCustomOrgLdapSettings() { return customOrgLdapSettings; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java index d0ac707d74..b0d4fbed5f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java @@ -27,6 +27,8 @@ import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; @@ -49,27 +51,30 @@ import com.google.common.collect.Iterables; @XmlType(name = "ResourceEntityType") public abstract class ResourceEntityType extends EntityType { + @XmlType + @XmlEnum(Integer.class) public static enum Status { - FAILED_CREATION(-1, "The object could not be created.", true, true, true), - NOT_READY(0, "Not ready", true, false, false), // TODO duplicate code, but mentioned in `POST /vdc/{id}/action/uploadVAppTemplate` - UNRESOLVED(0, "The object is unresolved.", true, true, true), - RESOLVED(1, "The object is resolved.", true, true, true), - DEPLOYED(2, "The object is deployed.", false, false, false), - SUSPENDED(3, "The object is suspended.", false, true, true), - POWERED_ON(4, "The object is powered on.", false, true, true), - WAITING_FOR_INPUT(5, "The object is waiting for user input.", false, true, true), - UNKNOWN(6, "The object is in an unknown state.", true, true, true), - UNRECOGNIZED(7, "The object is in an unrecognized state.", true, true, true), - POWERED_OFF(8, "The object is powered off.", true, true, true), - INCONSISTENT_STATE(9, "The object is in an inconsistent state.", false, true, true), - MIXED(10, "Children do not all have the same status.", true, true, false), - UPLOAD_OVF_PENDING(11, "Upload initiated, OVF descriptor pending.", true, false, false), - UPLOAD_COPYING(12, "Upload initiated, copying contents.", true, false, false), - UPLOAD_DISK_PENDING(13, "Upload initiated , disk contents pending.", true, false, false), - UPLOAD_QUARANTINED(14, "Upload has been quarantined.", true, false, false), - UPLOAD_QUARANTINE_EXPIRED(15, "Upload quarantine period has expired.", true, false, false), + @XmlEnumValue("-1") FAILED_CREATION(-1, "The object could not be created.", true, true, true), + @XmlEnumValue("0") UNRESOLVED(0, "The object is unresolved.", true, true, true), + @XmlEnumValue("1") RESOLVED(1, "The object is resolved.", true, true, true), + @XmlEnumValue("2") DEPLOYED(2, "The object is deployed.", false, false, false), + @XmlEnumValue("3") SUSPENDED(3, "The object is suspended.", false, true, true), + @XmlEnumValue("4") POWERED_ON(4, "The object is powered on.", false, true, true), + @XmlEnumValue("5") WAITING_FOR_INPUT(5, "The object is waiting for user input.", false, true, true), + @XmlEnumValue("6") UNKNOWN(6, "The object is in an unknown state.", true, true, true), + @XmlEnumValue("7") UNRECOGNIZED(7, "The object is in an unrecognized state.", true, true, true), + @XmlEnumValue("8") POWERED_OFF(8, "The object is powered off.", true, true, true), + @XmlEnumValue("9") INCONSISTENT_STATE(9, "The object is in an inconsistent state.", false, true, true), + @XmlEnumValue("10") MIXED(10, "Children do not all have the same status.", true, true, false), + @XmlEnumValue("11") UPLOAD_OVF_PENDING(11, "Upload initiated, OVF descriptor pending.", true, false, false), + @XmlEnumValue("12") UPLOAD_COPYING(12, "Upload initiated, copying contents.", true, false, false), + @XmlEnumValue("13") UPLOAD_DISK_PENDING(13, "Upload initiated , disk contents pending.", true, false, false), + @XmlEnumValue("14") UPLOAD_QUARANTINED(14, "Upload has been quarantined.", true, false, false), + @XmlEnumValue("15") UPLOAD_QUARANTINE_EXPIRED(15, "Upload quarantine period has expired.", true, false, false), + // TODO duplicate code, but mentioned in `POST /vdc/{id}/action/uploadVAppTemplate` + NOT_READY(0, "Not ready", true, false, false), // Convention is "UNRECOGNIZED", but that is already a valid state name! so using UNRECOGNIZED_VALUE UNRECOGNIZED_VALUE(404, "Unrecognized", false, false, false); @@ -137,7 +142,7 @@ public abstract class ResourceEntityType extends EntityType { public static abstract class Builder> extends EntityType.Builder { private Set files; - private Integer status; + private Status status; /** * @see ResourceEntityType#getFiles() @@ -150,11 +155,19 @@ public abstract class ResourceEntityType extends EntityType { /** * @see ResourceEntityType#getStatus() */ - public B status(Integer status) { + public B status(Status status) { this.status = status; return self(); } + /** + * @see ResourceEntityType#getStatus() + */ + public B status(Integer status) { + this.status = Status.fromValue(status); + return self(); + } + public B fromResourceEntityType(ResourceEntityType in) { return fromEntityType(in).files(in.getFiles()).status(in.getStatus()); } @@ -163,9 +176,8 @@ public abstract class ResourceEntityType extends EntityType { @XmlElementWrapper(name = "Files") @XmlElement(name = "File") private Set files; - @XmlAttribute - private Integer status; + private Status status; public ResourceEntityType(Builder builder) { super(builder); @@ -187,7 +199,7 @@ public abstract class ResourceEntityType extends EntityType { /** * Gets the value of the status property. */ - public Integer getStatus() { + public Status getStatus() { return status; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java index 9527369211..35536b1180 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java @@ -60,12 +60,19 @@ public class Task extends EntityType { @XmlType @XmlEnum(String.class) public static enum Status { + /** The task has been queued for execution. */ @XmlEnumValue("queued") QUEUED("queued"), + /** The task is awaiting preprocessing or, if it is a blocking task, administrative action. */ @XmlEnumValue("preRunning") PRE_RUNNING("preRunning"), + /** The task is runnning.*/ @XmlEnumValue("running") RUNNING("running"), + /** The task completed with a status of success. */ @XmlEnumValue("success") SUCCESS("success"), + /** The task encountered an error while running. */ @XmlEnumValue("error") ERROR("error"), + /** The task was canceled by the owner or an administrator. */ @XmlEnumValue("canceled") CANCELED("canceled"), + /** The task was aborted by an administrative action. */ @XmlEnumValue("aborted") ABORTED("aborted"), UNRECOGNIZED("unrecognized"); @@ -116,7 +123,7 @@ public class Task extends EntityType { private Reference user; private Object params; private Integer progress; - private String status; + private Status status; private String operation; private String operationName; private Date startTime; @@ -175,6 +182,14 @@ public class Task extends EntityType { * @see Task#getStatus() */ public B status(String status) { + this.status = Status.fromValue(status); + return self(); + } + + /** + * @see Task#getStatus() + */ + public B status(Status status) { this.status = status; return self(); } @@ -274,7 +289,7 @@ public class Task extends EntityType { @XmlElement(name = "Params") private Object params; @XmlAttribute - private String status; + private Status status; @XmlAttribute private String operation; @XmlAttribute @@ -333,19 +348,8 @@ public class Task extends EntityType { /** * The execution status of the task. - * - * One of: - *
      - *
    • queued - The task has been queued for execution. - *
    • preRunning - The task is awaiting preprocessing or, if it is a blocking task, administrative action. - *
    • running - The task is runnning. - *
    • success - The task completed with a status of success. - *
    • error - The task encountered an error while running. - *
    • canceled - The task was canceled by the owner or an administrator. - *
    • aborted - The task was aborted by an administrative action. - *
    */ - public String getStatus() { + public Status getStatus() { return status; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicates.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicates.java index 51e9a063b0..7cfe5119e9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicates.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicates.java @@ -35,22 +35,28 @@ public class LinkPredicates { /** * matches links of the given relation * - * @param rel - * ex. {@code context.getApi().getCurrentSession().getOrg().getLinks()} + * @param rel from {@code context.getApi().getCurrentSession().getOrg().getLinks()} * @return predicate that will match links of the given rel */ public static Predicate relEquals(final String rel) { checkNotNull(rel, "rel must be defined"); + return relEquals(Link.Rel.fromValue(rel)); + } + + /** @see #relEquals(String) */ + public static Predicate relEquals(final Link.Rel rel) { + checkNotNull(rel, "rel must be defined"); + return new Predicate() { @Override public boolean apply(Link link) { - return rel.equals(link.getRel()); + return rel == link.getRel(); } @Override public String toString() { - return "relEquals(" + rel + ")"; + return "relEquals(" + rel.value() + ")"; } }; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java index 8b60ee1d63..4ba0faca7e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java @@ -31,6 +31,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Task.Status; import org.jclouds.vcloud.director.v1_5.features.TaskClient; import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; /** * Test a {@link Task} to see if it has succeeded. @@ -69,22 +70,17 @@ public class TaskStatusEquals implements Predicate { if (task == null) return false; logger.trace("%s: looking for status %s: currently: %s", task, expectedStatuses, task.getStatus()); - for (Status failingStatus : failingStatuses) { - if (task.getStatus().equals(failingStatus)) { - throw new VCloudDirectorException(task); - } + if (failingStatuses.contains(task.getStatus())) { + throw new VCloudDirectorException(task); } - - for (Status expectedStatus : expectedStatuses) { - if (task.getStatus().equals(expectedStatus)) { - return true; - } + if (expectedStatuses.contains(task.getStatus())) { + return true; } return false; } @Override public String toString() { - return "checkTaskSuccess()"; + return "taskStatusEquals(" + Iterables.toString(expectedStatuses) + ")"; } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java index 9f341d7be1..b74fcf888a 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java @@ -251,7 +251,7 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien protected VApp powerOn(final URI testVAppURI) { VApp testVApp = vAppClient.getVApp(testVAppURI); Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); + Status status = vm.getStatus(); if (status != Status.POWERED_ON) { Task powerOn = vAppClient.powerOn(vm.getHref()); assertTaskSucceedsLong(powerOn); @@ -275,7 +275,7 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien protected VApp powerOff(final URI testVAppURI) { VApp testVApp = vAppClient.getVApp(testVAppURI); Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); + Status status = vm.getStatus(); if (status != Status.POWERED_OFF) { Task powerOff = vAppClient.powerOff(vm.getHref()); assertTaskSucceedsLong(powerOff); @@ -299,7 +299,7 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien protected VApp suspend(final URI testVAppURI) { VApp testVApp = vAppClient.getVApp(testVAppURI); Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - Status status = Status.fromValue(vm.getStatus()); + Status status = vm.getStatus(); if (status != Status.SUSPENDED) { Task suspend = vAppClient.suspend(vm.getHref()); assertTaskSucceedsLong(suspend); @@ -314,7 +314,7 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien protected void assertVAppStatus(final URI testVAppURI, final Status status) { VApp testVApp = vAppClient.getVApp(testVAppURI); Vm vm = Iterables.getOnlyElement(testVApp.getChildren().getVms()); - assertEquals(vm.getStatus(), status.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", status.toString(), Status.fromValue(vm.getStatus()).toString())); + assertEquals(vm.getStatus(), status, String.format(OBJ_FIELD_EQ, VAPP, "status", status.toString(), vm.getStatus().toString())); } /** diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 9779ec5efe..512173b720 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -42,6 +42,7 @@ import static org.testng.Assert.fail; import java.net.URI; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -96,7 +97,7 @@ public class Checks { // Check optional fields // NOTE description cannot be checked - Set tasks = entity.getTasks(); + List tasks = entity.getTasks(); if (tasks != null && tasks != null && !tasks.isEmpty()) { for (Task task : tasks) checkTask(task); } @@ -133,12 +134,28 @@ public class Checks { // NOTE name cannot be checked } + /** + * Assumes the validTypes to be vcloud-specific types. + * + * @see #checkResourceType(ResourceType, Collection) + */ public static void checkResourceType(ResourceType resource) { + checkResourceType(resource, VCloudDirectorMediaType.ALL); + } + + /** + * @see #checkResourceType(ResourceType, Collection) + */ + public static void checkResourceType(ResourceType resource, String type) { + checkResourceType(resource, ImmutableSet.of(type)); + } + + public static void checkResourceType(ResourceType resource, Collection validTypes) { // Check optional fields URI href = resource.getHref(); if (href != null) checkHref(href); String type = resource.getType(); - if (type != null) checkType(type); + if (type != null) checkType(type, validTypes); Set links = resource.getLinks(); if (links != null && !links.isEmpty()) { for (Link link : links) checkLink(link); @@ -286,6 +303,7 @@ public class Checks { public static void checkAdminOrg(AdminOrg org) { // required assertNotNull(org.getSettings(), String.format(NOT_NULL_OBJ_FIELD_FMT, "settings", "AdminOrg")); + checkResourceType(org, VCloudDirectorMediaType.ADMIN_ORG); // optional for (Reference user : org.getUsers()) { @@ -298,7 +316,7 @@ public class Checks { checkReferenceType(catalog, VCloudDirectorMediaType.ADMIN_CATALOG); } for (Reference vdc : org.getVdcs()) { - checkReferenceType(vdc, VCloudDirectorMediaType.ADMIN_VDC); + checkReferenceType(vdc, VCloudDirectorMediaType.VDC); } for (Reference network : org.getNetworks()) { checkReferenceType(network, VCloudDirectorMediaType.ADMIN_NETWORK); @@ -841,7 +859,7 @@ public class Checks { // NOTE customUsersOu cannot be checked if (settings.getLdapMode() != null) { assertTrue(LdapMode.ALL.contains(settings.getLdapMode()), - String.format(REQUIRED_VALUE_OBJECT_FMT, "LdapMode", "OrdLdapSettings", settings.getLdapMode(), + String.format(REQUIRED_VALUE_OBJECT_FMT, "LdapMode", "OrgLdapSettings", settings.getLdapMode(), Iterables.toString(OrgLdapSettings.LdapMode.ALL))); } if (settings.getCustomOrgLdapSettings() != null) { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index 43dad42c11..1759f04f94 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -177,8 +177,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMediaFor(MEDIA, media); } - @Test(description = "GET /media/{id}/owner", - dependsOnMethods = { "testGetMedia" }) + @Test(description = "GET /media/{id}/owner", dependsOnMethods = { "testGetMedia" }) public void testGetMediaOwner() { Owner directOwner = mediaClient.getOwner(media.getHref()); assertEquals(owner.toBuilder() @@ -196,8 +195,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkReferenceType(directOwner.getUser()); } - @Test(description = "POST /vdc/{id}/action/cloneMedia", - dependsOnMethods = { "testGetMediaOwner" }) + @Test(description = "POST /vdc/{id}/action/cloneMedia", dependsOnMethods = { "testGetMediaOwner" }) public void testCloneMedia() { oldMedia = media; media = vdcClient.cloneMedia(vdcURI, CloneMediaParams.builder() @@ -246,8 +244,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { media.toString(), oldMedia.toString())); } - @Test(description = "PUT /media/{id}", - dependsOnMethods = { "testCloneMedia" }) + @Test(description = "PUT /media/{id}", dependsOnMethods = { "testCloneMedia" }) public void testSetMedia() { String oldName = media.getName(); String newName = "new "+oldName; @@ -276,8 +273,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { media = mediaClient.getMedia(media.getHref()); } - @Test(description = "GET /media/{id}/metadata", - dependsOnMethods = { "testSetMetadataValue" }) + @Test(description = "GET /media/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" }) public void testGetMetadata() { metadata = mediaClient.getMetadataClient().getMetadata(media.getHref()); // required for testing @@ -287,8 +283,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMetadataFor(MEDIA, metadata); } - @Test(description = "POST /media/{id}/metadata", - dependsOnMethods = { "testGetMedia" }) + @Test(description = "POST /media/{id}/metadata", dependsOnMethods = { "testGetMedia" }) public void testMergeMetadata() { // test new Set inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "testValue").build()); @@ -340,15 +335,13 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { } } - @Test(description = "GET /media/{id}/metadata/{key}", - dependsOnMethods = { "testSetMetadataValue" }) + @Test(description = "GET /media/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }) public void testGetMetadataValue() { metadataValue = mediaClient.getMetadataClient().getMetadataValue(media.getHref(), "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } - @Test(description = "PUT /media/{id}/metadata/{key}", - dependsOnMethods = { "testMergeMetadata" }) + @Test(description = "PUT /media/{id}/metadata/{key}", dependsOnMethods = { "testMergeMetadata" }) public void testSetMetadataValue() { metadataEntryValue = "value"; MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build(); @@ -361,35 +354,17 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMetadataValueFor(MEDIA, metadataValue); } - @Test(description = "DELETE /media/{id}/metadata/{key}", - dependsOnMethods = { "testGetMetadata", "testGetMetadataValue" } ) + @Test(description = "DELETE /media/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata", "testGetMetadataValue" } ) public void testDeleteMetadata() { Task deleteMetadataEntry = mediaClient.getMetadataClient().deleteMetadataEntry(media.getHref(), "testKey"); Checks.checkTask(deleteMetadataEntry); assertTrue(retryTaskSuccess.apply(deleteMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "deleteMetadataEntry")); - Error expected = Error.builder() - .message("The access to the resource metadata_item with id testKey is forbidden") - .majorErrorCode(403) - .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") - .build(); - - try { - metadataValue = mediaClient.getMetadataClient().getMetadataValue(media.getHref(), "testKey"); - fail("Should give HTTP 403 error"); - } catch (VCloudDirectorException vde) { - assertEquals(vde.getError(), expected); - metadataValue = null; - } catch (Exception e) { - fail("Should have thrown a VCloudDirectorException"); - } - - if (metadataValue != null) { // guard against NPE on the .toStrings - assertNull(metadataValue, String.format(OBJ_FIELD_ATTRB_DEL, MEDIA, - "Metadata", metadataValue.toString(), - "metadataEntry", metadataValue.toString())); - } + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media.getHref(), "testKey"); + assertNull(metadataValue, String.format(OBJ_FIELD_ATTRB_DEL, MEDIA, + "Metadata", metadataValue != null ? metadataValue.toString() : "", + "MetadataEntry", metadataValue != null ? metadataValue.toString() : "")); metadataValue = mediaClient.getMetadataClient().getMetadataValue(media.getHref(), "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); @@ -398,40 +373,19 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMediaFor(MEDIA, media); } - @Test(description = "DELETE /media/{id}", - dependsOnMethods = { "testDeleteMetadata" } ) + @Test(description = "DELETE /media/{id}", dependsOnMethods = { "testDeleteMetadata" } ) public void testDeleteMedia() { Task deleteMedia = mediaClient.deleteMedia(media.getHref()); Checks.checkTask(deleteMedia); assertTrue(retryTaskSuccess.apply(deleteMedia), String.format(TASK_COMPLETE_TIMELY, "deleteMedia")); - Error expected = Error.builder() - .message(String.format( - "No access to entity \"(com.vmware.vcloud.entity.media:%s)\".", - media.getId().substring("urn:vcloud:media:".length()))) - .majorErrorCode(403) - .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") - .build(); - - try { - media = mediaClient.getMedia(media.getHref()); - fail("Should give HTTP 403 error"); - } catch (VCloudDirectorException vde) { - assertEquals(vde.getError(), expected); - media = null; - } catch (Exception e) { - fail("Should have thrown a VCloudDirectorException"); - } - - if (media != null) { // guard against NPE on the .toStrings - assertNull(metadataValue, String.format(OBJ_DEL, MEDIA, media.toString())); - } + media = mediaClient.getMedia(media.getHref()); + assertNull(media, String.format(OBJ_DEL, MEDIA, media != null ? media.toString() : "")); deleteMedia = mediaClient.deleteMedia(oldMedia.getHref()); Checks.checkTask(deleteMedia); - assertTrue(retryTaskSuccess.apply(deleteMedia), - String.format(TASK_COMPLETE_TIMELY, "deleteMedia")); + assertTrue(retryTaskSuccess.apply(deleteMedia), String.format(TASK_COMPLETE_TIMELY, "deleteMedia")); oldMedia = null; } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java index 0f0879696e..773d292aac 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java @@ -166,7 +166,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { if (media.getTasks().size() == 1) { Task uploadTask = Iterables.getOnlyElement(media.getTasks()); Checks.checkTask(uploadTask); - assertEquals(uploadTask.getStatus(), "running"); + assertEquals(uploadTask.getStatus(), Task.Status.RUNNING); assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask")); media = context.getApi().getMediaClient().getMedia(media.getHref()); } @@ -184,6 +184,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { } } + @Override @AfterClass(alwaysRun = true) public void cleanUp() { if (adminContext != null && mediaURI != null) { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java index 14f8254657..15d43555de 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java @@ -35,15 +35,18 @@ import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVAppTemplate; import static org.jclouds.vcloud.director.v1_5.domain.Checks.metadataToMap; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import java.net.URI; +import java.util.EnumSet; +import java.util.List; import java.util.Map; import java.util.Set; import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.vcloud.director.v1_5.AbstractVAppClientLiveTest; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; @@ -51,6 +54,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Envelope; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.Link; +import org.jclouds.vcloud.director.v1_5.domain.Link.Rel; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; @@ -69,6 +73,7 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.Test; import com.google.common.base.Function; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -404,11 +409,8 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { retryTaskSuccess.apply(task); // Confirm that can't access post-delete, i.e. template has been deleted - try { - vAppTemplateClient.getVAppTemplate(clonedVappTemplate.getHref()); - } catch (VCloudDirectorException e) { - // success; should get a 403 because vAppTemplate no longer exists - } + VAppTemplate deleted = vAppTemplateClient.getVAppTemplate(clonedVappTemplate.getHref()); + assertNull(deleted); } @Test(description = "POST /vAppTemplate/{id}/action/disableDownload") @@ -418,11 +420,10 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { // TODO Check that it really is disabled. The only thing I can see for determining this // is the undocumented "download" link in the VAppTemplate. But that is brittle and we // don't know what timing guarantees there are for adding/removing the link. - // - // For example: - // VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); - // Set links = vAppTemplate.getLinks(); - // assertFalse(hasLinkMatchingRel(links, "download.*"), "Should not offer download link after disabling download: "+vAppTemplate); + VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); + Set links = vAppTemplate.getLinks(); + assertTrue(Iterables.all(Iterables.transform(links, rel), Predicates.not(Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE)))), + "Should not offer download link after disabling download: "+vAppTemplate); } @Test(description = "POST /vAppTemplate/{id}/action/enableDownload") @@ -435,22 +436,18 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { // TODO Check that it really is enabled. The only thing I can see for determining this // is the undocumented "download" link in the VAppTemplate. But that is brittle and we // don't know what timing guarantees there are for adding/removing the link. - // - // For example: - // VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); - // Set links = vAppTemplate.getLinks(); - // assertTrue(hasLinkMatchingRel(links, "download.*"), "Should offer download link after enabling download: "+vAppTemplate); + VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); + Set links = vAppTemplate.getLinks(); + assertTrue(Iterables.any(Iterables.transform(links, rel), Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE))), + "Should offer download link after enabling download: "+vAppTemplate); } - @SuppressWarnings("unused") - private boolean hasLinkMatchingRel(Set links, String regex) { - for (Link link : links) { - if (link.getRel() != null && link.getRel().matches(regex)) { - return true; - } + private Function rel = new Function() { + @Override + public Rel apply(Link input) { + return input.getRel(); } - return false; - } + }; @Test(description = "POST /vAppTemplate/{id}/action/consolidate") public void testConsolidateVAppTemplate() throws Exception { @@ -490,11 +487,11 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { // Ask the VAppTemplate for its tasks, and the status of the matching task if it exists VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); - Set tasks = vAppTemplate.getTasks(); + List tasks = vAppTemplate.getTasks(); for (Task contender : tasks) { if (task.getId().equals(contender.getId())) { - String status = contender.getStatus(); - if (status.equals(Task.Status.QUEUED) || status.equals(Task.Status.PRE_RUNNING) || status.equals(Task.Status.RUNNING)) { + Task.Status status = contender.getStatus(); + if (EnumSet.of(Task.Status.QUEUED, Task.Status.PRE_RUNNING, Task.Status.RUNNING).contains(status)) { fail("Task "+contender+" reported complete, but is included in VAppTemplate in status "+status); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 472c2a0c10..7fc9150eb1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -305,8 +305,8 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { String.format(OBJ_FIELD_EQ, "VAppTemplate", "name", name, uploadedVAppTemplate.getName())); ResourceEntityType.Status expectedStatus = ResourceEntityType.Status.NOT_READY; - Integer actualStatus = uploadedVAppTemplate.getStatus(); - assertEquals(actualStatus, expectedStatus.getValue(), + ResourceEntityType.Status actualStatus = uploadedVAppTemplate.getStatus(); + assertEquals(actualStatus, expectedStatus, String.format(OBJ_FIELD_EQ, "VAppTemplate", "status", expectedStatus, actualStatus)); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java index 6a6b19ef2c..e8c73cc02a 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java @@ -107,23 +107,20 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest // FIXME: documentation suggests we should wait for a task here } - @Test(description = "GET /admin/catalog/{id}", - dependsOnMethods = { "testCreateCatalog" }) + @Test(description = "GET /admin/catalog/{id}", dependsOnMethods = { "testCreateCatalog" }) public void testGetCatalog() { catalog = catalogClient.getCatalog(catalog.getHref()); Checks.checkAdminCatalog(catalog); } - @Test(description = "GET /admin/catalog/{id}/owner", - dependsOnMethods = { "testGetCatalog" }) + @Test(description = "GET /admin/catalog/{id}/owner", dependsOnMethods = { "testGetCatalog" }) public void testGetCatalogOwner() { owner = catalogClient.getOwner(catalog.getHref()); Checks.checkOwner(owner); } - @Test(description = "PUT /admin/catalog/{id}/owner", - dependsOnMethods = { "testGetCatalog" }) + @Test(description = "PUT /admin/catalog/{id}/owner", dependsOnMethods = { "testGetCatalog" }) public void updateCatalogOwner() { User newOwnerUser = randomTestUser("testUpdateCatalogOwner"); newOwnerUser = adminContext.getApi().getUserClient().createUser(orgRef.getHref(), newOwnerUser); @@ -187,8 +184,8 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest } } - @Test(description = "POST /admin/catalog/{id}/action/publish", - dependsOnMethods = { "testUpdateCatalog" } ) // FIXME: fails with a 403 + // FIXME fails with a 403 + @Test(description = "POST /admin/catalog/{id}/action/publish", dependsOnMethods = { "testUpdateCatalog" } ) public void testPublishCatalog() { assertNotNull(catalog, String.format(NOT_NULL_OBJ_FMT, "Catalog")); assertTrue(!catalog.isPublished(), String.format(OBJ_FIELD_EQ, @@ -205,8 +202,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest CATALOG, "isPublished", true, catalog.isPublished())); } - @Test(description = "DELETE /admin/catalog/{id}", - dependsOnMethods = { "testCreateCatalog" } ) + @Test(description = "DELETE /admin/catalog/{id}", dependsOnMethods = { "testCreateCatalog" } ) public void testDeleteCatalog() { // assertEquals(catalog.getCatalogItems().getCatalogItems().size(), 0, // String.format(OBJ_FIELD_EMPTY_TO_DELETE, "Catalog", "CatalogItems", @@ -218,25 +214,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest deleteCatalog = catalogClient.createCatalog(orgRef.getHref(), deleteCatalog); catalogClient.deleteCatalog(deleteCatalog.getHref()); - Error expected = Error.builder() - .message("No access to entity \"(com.vmware.vcloud.entity.catalog:"+ - deleteCatalog.getId().substring("urn:vcloud:catalog:".length())+")\".") - .majorErrorCode(403) - .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") - .build(); - - try { - deleteCatalog = catalogClient.getCatalog(deleteCatalog.getHref()); - fail("Should give HTTP 403 error"); - } catch (VCloudDirectorException vde) { - assertEquals(vde.getError(), expected); - deleteCatalog = null; - } catch (Exception e) { - fail("Should have thrown a VCloudDirectorException"); - } - - if (deleteCatalog != null) { // guard against NPE on the .toStrings - assertNull(deleteCatalog, String.format(OBJ_DEL, CATALOG, deleteCatalog.toString())); - } + deleteCatalog = catalogClient.getCatalog(deleteCatalog.getHref()); + assertNull(deleteCatalog, String.format(OBJ_DEL, CATALOG, deleteCatalog != null ? deleteCatalog.toString() : "")); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java index 7d6cae701b..dc415d9de6 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java @@ -303,7 +303,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ assertTrue(retryTaskSuccessLong.apply(task), String.format(TASK_COMPLETE_TIMELY, task)); } - protected void assertTaskStatusEventually(Task task, org.jclouds.vcloud.director.v1_5.domain.Task.Status running, ImmutableSet immutableSet) { + protected void assertTaskStatusEventually(Task task, Task.Status running, ImmutableSet immutableSet) { TaskClient taskClient = context.getApi().getTaskClient(); TaskStatusEquals predicate = new TaskStatusEquals(taskClient, running, immutableSet); RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, TASK_TIMEOUT_SECONDS * 1000L); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicatesTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicatesTest.java index 0b9dec1b77..be7d7505b2 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicatesTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicatesTest.java @@ -39,6 +39,11 @@ public class LinkPredicatesTest { @Test public void testRelEqualsWhenEqual() { + assert relEquals(Link.Rel.ADD).apply(ref); + } + + @Test + public void testRelEqualsWhenEqualString() { assert relEquals("add").apply(ref); } From ef66989727f3aebeab15035f0eccf6e5aad6f0cb Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 01:00:02 +0100 Subject: [PATCH 22/69] Corrections to fix expect and live test errors, including JAXB type naming for enumerations --- .../vcloud/director/v1_5/domain/AbstractVAppType.java | 2 -- .../vcloud/director/v1_5/domain/CaptureVAppParams.java | 2 -- .../vcloud/director/v1_5/domain/InstantiationParams.java | 2 -- .../vcloud/director/v1_5/domain/ResourceEntityType.java | 8 +++----- .../org/jclouds/vcloud/director/v1_5/domain/Task.java | 9 ++++----- .../vcloud/director/v1_5/domain/VAppTemplate.java | 2 -- .../director/v1_5/features/TaskClientExpectTest.java | 4 ++-- .../vcloud/director/v1_5/features/VdcClientLiveTest.java | 2 +- 8 files changed, 10 insertions(+), 21 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java index 18e7963dcc..b25b64cb15 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java @@ -33,11 +33,9 @@ import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.DeploymentOptionSection; import org.jclouds.dmtf.ovf.DiskSection; import org.jclouds.dmtf.ovf.NetworkSection; -import org.jclouds.dmtf.ovf.OperatingSystemSection; import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; -import org.jclouds.dmtf.ovf.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java index 8a0093365c..4836a09b6c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java @@ -34,11 +34,9 @@ import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.DeploymentOptionSection; import org.jclouds.dmtf.ovf.DiskSection; import org.jclouds.dmtf.ovf.NetworkSection; -import org.jclouds.dmtf.ovf.OperatingSystemSection; import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; -import org.jclouds.dmtf.ovf.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java index be4b74b9d0..c3e3e59255 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java @@ -32,11 +32,9 @@ import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.DeploymentOptionSection; import org.jclouds.dmtf.ovf.DiskSection; import org.jclouds.dmtf.ovf.NetworkSection; -import org.jclouds.dmtf.ovf.OperatingSystemSection; import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; -import org.jclouds.dmtf.ovf.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java index b0d4fbed5f..ff3b64de00 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java @@ -51,12 +51,12 @@ import com.google.common.collect.Iterables; @XmlType(name = "ResourceEntityType") public abstract class ResourceEntityType extends EntityType { - @XmlType + @XmlType(name = "ResourceEntityTypeStatus") @XmlEnum(Integer.class) public static enum Status { @XmlEnumValue("-1") FAILED_CREATION(-1, "The object could not be created.", true, true, true), - @XmlEnumValue("0") UNRESOLVED(0, "The object is unresolved.", true, true, true), + @XmlEnumValue("0") UNRESOLVED(0, "The object is unresolved or not ready.", true, true, true), @XmlEnumValue("1") RESOLVED(1, "The object is resolved.", true, true, true), @XmlEnumValue("2") DEPLOYED(2, "The object is deployed.", false, false, false), @XmlEnumValue("3") SUSPENDED(3, "The object is suspended.", false, true, true), @@ -73,10 +73,8 @@ public abstract class ResourceEntityType extends EntityType { @XmlEnumValue("14") UPLOAD_QUARANTINED(14, "Upload has been quarantined.", true, false, false), @XmlEnumValue("15") UPLOAD_QUARANTINE_EXPIRED(15, "Upload quarantine period has expired.", true, false, false), - // TODO duplicate code, but mentioned in `POST /vdc/{id}/action/uploadVAppTemplate` - NOT_READY(0, "Not ready", true, false, false), // Convention is "UNRECOGNIZED", but that is already a valid state name! so using UNRECOGNIZED_VALUE - UNRECOGNIZED_VALUE(404, "Unrecognized", false, false, false); + @XmlEnumValue("65535") UNRECOGNIZED_VALUE(65535, "Unrecognized", false, false, false); private Integer value; private String description; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java index 35536b1180..293811e34c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java @@ -57,14 +57,14 @@ public class Task extends EntityType { public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASK; - @XmlType + @XmlType(name = "TaskStatus") @XmlEnum(String.class) public static enum Status { /** The task has been queued for execution. */ @XmlEnumValue("queued") QUEUED("queued"), /** The task is awaiting preprocessing or, if it is a blocking task, administrative action. */ @XmlEnumValue("preRunning") PRE_RUNNING("preRunning"), - /** The task is runnning.*/ + /** The task is runnning. */ @XmlEnumValue("running") RUNNING("running"), /** The task completed with a status of success. */ @XmlEnumValue("success") SUCCESS("success"), @@ -74,10 +74,9 @@ public class Task extends EntityType { @XmlEnumValue("canceled") CANCELED("canceled"), /** The task was aborted by an administrative action. */ @XmlEnumValue("aborted") ABORTED("aborted"), - UNRECOGNIZED("unrecognized"); + @XmlEnumValue("") UNRECOGNIZED("unrecognized"); - public static final List ALL = ImmutableList.of( - QUEUED, PRE_RUNNING, RUNNING, SUCCESS, ERROR, CANCELED, ABORTED); + public static final List ALL = ImmutableList.of(QUEUED, PRE_RUNNING, RUNNING, SUCCESS, ERROR, CANCELED, ABORTED); protected final String stringValue; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java index 8b24e38410..76813ab1db 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java @@ -34,11 +34,9 @@ import javax.xml.bind.annotation.XmlRootElement; import org.jclouds.dmtf.ovf.DeploymentOptionSection; import org.jclouds.dmtf.ovf.DiskSection; import org.jclouds.dmtf.ovf.NetworkSection; -import org.jclouds.dmtf.ovf.OperatingSystemSection; import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; -import org.jclouds.dmtf.ovf.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java index 5539424c47..f62745bf1e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java @@ -82,11 +82,11 @@ public class TaskClientExpectTest extends VCloudDirectorAdminClientExpectTest { .name("Tasks Lists") .type("application/vnd.vmware.vcloud.tasksList+xml") .href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) - .task(taskTwo()) .task(taskOne()) + .task(taskTwo()) .build(); - assertEquals(client.getTaskClient().getTaskList(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")).toString(), expected.toString()); + assertEquals(client.getTaskClient().getTaskList(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")), expected); } @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 7fc9150eb1..7ae512dc31 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -304,7 +304,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { assertEquals(uploadedVAppTemplate.getName(), name, String.format(OBJ_FIELD_EQ, "VAppTemplate", "name", name, uploadedVAppTemplate.getName())); - ResourceEntityType.Status expectedStatus = ResourceEntityType.Status.NOT_READY; + ResourceEntityType.Status expectedStatus = ResourceEntityType.Status.UNRESOLVED; ResourceEntityType.Status actualStatus = uploadedVAppTemplate.getStatus(); assertEquals(actualStatus, expectedStatus, String.format(OBJ_FIELD_EQ, "VAppTemplate", "status", expectedStatus, actualStatus)); From 9c40c3a34dd309a686fd2d76a7071f139f368545 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 01:06:17 +0100 Subject: [PATCH 23/69] Fixed NPE in error handler --- .../director/v1_5/handlers/VCloudDirectorErrorHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java index eb04ca48c0..5d209865c7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java @@ -53,7 +53,7 @@ public class VCloudDirectorErrorHandler implements HttpErrorHandler { String message = data != null ? new String(data) : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); - Exception exception = new HttpResponseException(command, response, response.getPayload().getContentMetadata().getContentType()); + Exception exception = new HttpResponseException(command, response, message); // Try to create a VCloudDirectorException from XML payload if (response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) { From d1fc23301dd936b783c941cba3b59b2e8a0d952e Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:32:17 -0400 Subject: [PATCH 24/69] Stopping the local DevAppServer after integration tests --- .../demo/tweetstore/integration/TweetStoreLiveTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 28eae7dbc8..0bf21ce2ec 100644 --- a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -44,6 +44,7 @@ import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.AuthorizationException; import org.jclouds.util.Strings2; +import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -229,4 +230,9 @@ public class TweetStoreLiveTest { String string = Strings2.toStringAndClose(i); assert string.indexOf("Tweets in Clouds") >= 0 : string; } + + @AfterTest + public void stopDevAppServer() throws Exception { + server.stop(); + } } From cac8b9136bbf8bb9e61ac4b58f9283186849156f Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:36:06 -0400 Subject: [PATCH 25/69] Removed an unused 'address' parameter to the RunAtCloudServer and now also stopping the server after integration tests --- .../demo/tweetstore/integration/RunAtCloudServer.java | 6 +++--- .../demo/tweetstore/integration/TweetStoreLiveTest.java | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RunAtCloudServer.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RunAtCloudServer.java index 0272aea3b1..2ce1ec21aa 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RunAtCloudServer.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RunAtCloudServer.java @@ -38,9 +38,9 @@ import org.apache.commons.cli.ParseException; public class RunAtCloudServer { protected StaxSdkAppServer2 server; - public void writePropertiesAndStartServer(final String address, final String port, - final String warfile, final String environments, - final String serverBaseDirectory, Properties props) throws IOException, InterruptedException, ParseException, ServletException { + public void writePropertiesAndStartServer(final String port, final String warfile, + final String environments, final String serverBaseDirectory, + Properties props) throws IOException, InterruptedException, ParseException, ServletException { String filename = String.format( "%1$s/WEB-INF/jclouds.properties", warfile); System.err.println("file: " + filename); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index f972aace6e..7219e4df21 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -44,6 +44,7 @@ import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.AuthorizationException; import org.jclouds.util.Strings2; +import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -176,7 +177,7 @@ public class TweetStoreLiveTest { url = new URL(String.format("http://%s:%s", address, port)); server = new RunAtCloudServer(); - server.writePropertiesAndStartServer(address, port, warfile, "itest", + server.writePropertiesAndStartServer(port, warfile, "itest", serverBaseDirectory, props); } @@ -229,4 +230,9 @@ public class TweetStoreLiveTest { String string = Strings2.toStringAndClose(i); assert string.indexOf("Tweets in Clouds") >= 0 : string; } + + @AfterTest + public void stopDevAppServer() throws Exception { + server.stop(); + } } From e852a9d94bc5671d632ac80f91812255b0bcc325 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:37:19 -0400 Subject: [PATCH 26/69] Stopping the local DevAppServer in gae-tweetstore-spring after integration tests --- .../demo/tweetstore/integration/TweetStoreLiveTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 7f314232f9..974bafb9f0 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -43,6 +43,7 @@ import org.jclouds.demo.tweetstore.config.SpringServletConfig; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.util.Strings2; +import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -224,4 +225,9 @@ public class TweetStoreLiveTest { String string = Strings2.toStringAndClose(i); assert string.indexOf("Tweets in Clouds") >= 0 : string; } + + @AfterTest + public void stopDevAppServer() throws Exception { + server.stop(); + } } From ae22bde4adb459dd142b44c4093e906f545f1cec Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:38:04 -0400 Subject: [PATCH 27/69] Supporting jclouds drivers by retrieving the configured logger factory using LoggingModules --- .../demo/tweetstore/config/LoggingConfig.java | 12 +++------- .../config/SpringServletConfig.java | 23 +++++++++++-------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java index de2bf2b913..9852ae59ce 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java @@ -18,9 +18,9 @@ */ package org.jclouds.demo.tweetstore.config; -import org.jclouds.logging.Logger; +import static org.jclouds.logging.LoggingModules.firstOrJDKLoggingModule; + import org.jclouds.logging.Logger.LoggerFactory; -import org.jclouds.logging.jdk.JDKLogger; /** * Spring config that provides a logger. @@ -28,11 +28,5 @@ import org.jclouds.logging.jdk.JDKLogger; * @author Andrew Phillips */ abstract class LoggingConfig { - private static final LoggerFactory FACTORY = new JDKLogger.JDKLoggerFactory(); - protected final Logger logger; - - protected LoggingConfig() { - logger = FACTORY.getLogger(this.getClass().getName()); - } - + protected static final LoggerFactory LOGGER_FACTORY = firstOrJDKLoggingModule().createLoggerFactory(); } diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java index 53189d47b3..ba49ded13a 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java @@ -50,6 +50,7 @@ import org.jclouds.demo.tweetstore.controller.EnqueueStoresController; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; import org.jclouds.gae.config.GoogleAppEngineConfigurationModule; +import org.jclouds.logging.Logger; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -81,6 +82,8 @@ import com.google.inject.Module; public class SpringServletConfig extends LoggingConfig implements ServletConfigAware { public static final String PROPERTY_BLOBSTORE_CONTEXTS = "blobstore.contexts"; + private static final Logger LOGGER = LOGGER_FACTORY.getLogger(SpringServletConfig.class.getName()); + private ServletConfig servletConfig; private Map providerTypeToBlobStoreMap; @@ -93,7 +96,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory(); Properties props = loadJCloudsProperties(); - logger.trace("About to initialize members."); + LOGGER.trace("About to initialize members."); Module googleModule = new GoogleAppEngineConfigurationModule(); Set modules = ImmutableSet. of(googleModule); @@ -121,7 +124,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA // get a queue for submitting store tweet requests queue = QueueFactory.getQueue("twitter"); - logger.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient, + LOGGER.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient, container, providerTypeToBlobStoreMap.keySet()); } @@ -136,7 +139,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA } private Properties loadJCloudsProperties() { - logger.trace("About to read properties from '%s'", "/WEB-INF/jclouds.properties"); + LOGGER.trace("About to read properties from '%s'", "/WEB-INF/jclouds.properties"); Properties props = new Properties(); InputStream input = servletConfig.getServletContext().getResourceAsStream("/WEB-INF/jclouds.properties"); try { @@ -146,7 +149,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA } finally { Closeables.closeQuietly(input); } - logger.trace("Properties successfully read."); + LOGGER.trace("Properties successfully read."); return props; } @@ -171,13 +174,13 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA } private void injectServletConfig(Servlet servlet) { - logger.trace("About to inject servlet config '%s'", servletConfig); + LOGGER.trace("About to inject servlet config '%s'", servletConfig); try { servlet.init(checkNotNull(servletConfig)); } catch (ServletException exception) { throw new BeanCreationException("Unable to instantiate " + servlet, exception); } - logger.trace("Successfully injected servlet config."); + LOGGER.trace("Successfully injected servlet config."); } @Bean @@ -208,14 +211,14 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA @PreDestroy public void destroy() throws Exception { - logger.trace("About to close contexts."); + LOGGER.trace("About to close contexts."); for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { context.close(); } - logger.trace("Contexts closed."); - logger.trace("About to purge request queue."); + LOGGER.trace("Contexts closed."); + LOGGER.trace("About to purge request queue."); queue.purge(); - logger.trace("Request queue purged."); + LOGGER.trace("Request queue purged."); } /* From d9098e6d2a1a3d86740cb5a62439627e80732d2b Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:39:11 -0400 Subject: [PATCH 28/69] Excluding .gitignore from WAR files. It's present in some TweetStore instances' empty src/main/platform directory to ensure that directory is stored in Git --- demos/tweetstore/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/demos/tweetstore/pom.xml b/demos/tweetstore/pom.xml index 30a4245bbf..008a7a899a 100644 --- a/demos/tweetstore/pom.xml +++ b/demos/tweetstore/pom.xml @@ -148,6 +148,10 @@ src/main/platform WEB-INF true + + + .gitignore + ${remoteResourcesDirectory}/META-INF @@ -196,6 +200,10 @@ src/main/platform WEB-INF true + + + .gitignore + ${remoteResourcesDirectory}/META-INF From eb5d50762e75de38afe705ca59fc852dab19dc7d Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:40:46 -0400 Subject: [PATCH 29/69] Using a root-based link for local images --- demos/tweetstore/rhcloud-tweetstore/src/main/webapp/index.jsp | 2 +- demos/tweetstore/rhcloud-tweetstore/src/main/webapp/tweets.jsp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/tweetstore/rhcloud-tweetstore/src/main/webapp/index.jsp b/demos/tweetstore/rhcloud-tweetstore/src/main/webapp/index.jsp index 977ad5a303..12101d3865 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/main/webapp/index.jsp +++ b/demos/tweetstore/rhcloud-tweetstore/src/main/webapp/index.jsp @@ -25,6 +25,6 @@

    Welcome!

    Click here to see tweets about jclouds.

    -

    Powered by OpenShift Express

    +

    Powered by OpenShift Express

    diff --git a/demos/tweetstore/rhcloud-tweetstore/src/main/webapp/tweets.jsp b/demos/tweetstore/rhcloud-tweetstore/src/main/webapp/tweets.jsp index 351af2f4fd..bfdf462dde 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/main/webapp/tweets.jsp +++ b/demos/tweetstore/rhcloud-tweetstore/src/main/webapp/tweets.jsp @@ -101,7 +101,7 @@ overflow-y:auto; - Powered by OpenShift Express + Powered by OpenShift Express From da23bfae1afe437b0bde18e6b72c06b34b7a8fb3 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:42:07 -0400 Subject: [PATCH 30/69] Using plexus-archiver to make the WAR file for testing --- demos/tweetstore/rhcloud-tweetstore/pom.xml | 6 ++ .../tweetstore/integration/RhcloudServer.java | 4 +- .../tweetstore/integration/util/Zips.java | 55 +++---------------- 3 files changed, 17 insertions(+), 48 deletions(-) diff --git a/demos/tweetstore/rhcloud-tweetstore/pom.xml b/demos/tweetstore/rhcloud-tweetstore/pom.xml index 82ce8d4684..b9135fb3ca 100644 --- a/demos/tweetstore/rhcloud-tweetstore/pom.xml +++ b/demos/tweetstore/rhcloud-tweetstore/pom.xml @@ -60,6 +60,12 @@ + + org.codehaus.plexus + plexus-archiver + 2.1.1 + test + diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RhcloudServer.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RhcloudServer.java index ce4096f669..07b695ab65 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RhcloudServer.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RhcloudServer.java @@ -21,7 +21,7 @@ package org.jclouds.demo.tweetstore.integration; import static com.google.common.collect.Iterables.find; import static com.google.common.io.Closeables.closeQuietly; import static java.lang.String.format; -import static org.jclouds.demo.tweetstore.integration.util.Zips.zipFile; +import static org.jclouds.demo.tweetstore.integration.util.Zips.zipDir; import java.io.File; import java.io.FileOutputStream; @@ -88,7 +88,7 @@ public class RhcloudServer { protected ServerDeploymentActionResult deploy(String explodedWar) throws IOException, InterruptedException, ExecutionException { - File war = zipFile(explodedWar, format("%s-rhcloud.war", explodedWar), true); + File war = zipDir(explodedWar, format("%s-rhcloud.war", explodedWar)); final String deploymentName = war.getName(); DeploymentPlan plan = diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/util/Zips.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/util/Zips.java index a9c201dca9..571c9083a3 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/util/Zips.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/util/Zips.java @@ -19,55 +19,18 @@ package org.jclouds.demo.tweetstore.integration.util; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; + +import org.codehaus.plexus.archiver.zip.ZipArchiver; public class Zips { - private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; - - public static File zipFile(String fileToZip, String zipFile, - boolean excludeToplevelFolder) throws IOException { - ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile)); - try { - File srcFile = new File(fileToZip); - if (excludeToplevelFolder && srcFile.isDirectory()) { - for (String fileName : srcFile.list()) { - addToZip("", fileToZip + "/" + fileName, zipOut); - } - } else { - addToZip("", fileToZip, zipOut); - } - zipOut.flush(); - } finally { - zipOut.close(); - } - return new File(zipFile); - } - private static void addToZip(String path, String srcFile, - ZipOutputStream zipOut) throws IOException { - File file = new File(srcFile); - String filePath = ("".equals(path) ? file.getName() - : path + "/" + file.getName()); - if (file.isDirectory()) { - for (String fileName : file.list()) { - addToZip(filePath, srcFile + "/" + fileName, zipOut); - } - } else { - zipOut.putNextEntry(new ZipEntry(filePath)); - FileInputStream in = new FileInputStream(srcFile); - try { - byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; - int len; - while ((len = in.read(buffer)) != -1) { - zipOut.write(buffer, 0, len); - } - } finally { - in.close(); - } - } + public static File zipDir(String dirToZip, String zipFile) throws IOException { + ZipArchiver archiver = new ZipArchiver(); + archiver.addDirectory(new File(dirToZip)); + File zip = new File(zipFile); + archiver.setDestFile(zip); + archiver.createArchive(); + return zip; } } \ No newline at end of file From e670ae0c4e2f7cdd909c04e234e636d71ef936ec Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:42:45 -0400 Subject: [PATCH 31/69] Stopping the local JBoss test server for rhcloud-tweetstore after integration tests --- .../demo/tweetstore/integration/TweetStoreLiveTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index aa0a6833de..6698931488 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -44,6 +44,7 @@ import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.AuthorizationException; import org.jclouds.util.Strings2; +import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -228,4 +229,9 @@ public class TweetStoreLiveTest { String string = Strings2.toStringAndClose(i); assert string.indexOf("Tweets in Clouds") >= 0 : string; } + + @AfterTest + public void stopDevAppServer() throws Exception { + server.stop(); + } } From 4e5fe4ece3ae854f744ed17ef55309bba8058778 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 01:46:29 -0400 Subject: [PATCH 32/69] Added Cloud Foundry TweetStore example using Spring for dependency injection --- .../cf-tweetstore-spring/README.txt | 41 ++ demos/tweetstore/cf-tweetstore-spring/pom.xml | 184 ++++++++ .../jclouds/demo/paas/PlatformServices.java | 64 +++ .../demo/paas/RunnableHttpRequest.java | 126 ++++++ .../config/PlatformServicesInitializer.java | 104 +++++ .../demo/paas/reference/PaasConstants.java | 28 ++ .../service/scheduler/HttpRequestJob.java | 69 +++ .../paas/service/scheduler/Scheduler.java | 41 ++ ...nlessXmlSchedulingDataProcessorPlugin.java | 401 ++++++++++++++++++ .../paas/service/taskqueue/TaskQueue.java | 107 +++++ .../DelegatingAutowireCapableBeanFactory.java | 129 ++++++ .../demo/tweetstore/config/LoggingConfig.java | 88 ++++ .../config/SpringServletConfig.java | 236 +++++++++++ .../config/util/CredentialsCollector.java | 153 +++++++ .../config/util/PropertiesLoader.java | 59 +++ .../controller/AddTweetsController.java | 101 +++++ .../controller/EnqueueStoresController.java | 101 +++++ .../controller/StoreTweetsController.java | 130 ++++++ .../tweetstore/domain/StoredTweetStatus.java | 149 +++++++ .../functions/KeyToStoredTweetStatus.java | 71 ++++ .../ServiceToStoredTweetStatuses.java | 71 ++++ .../reference/TweetStoreConstants.java | 34 ++ .../reference/TwitterConstants.java | 31 ++ .../src/main/platform/.gitignore | 1 + .../src/main/resources/jobs.xml | 29 ++ .../src/main/resources/quartz.properties | 28 ++ .../src/main/webapp/WEB-INF/web.xml | 64 +++ .../main/webapp/images/cloudfoundry-logo.png | Bin 0 -> 6042 bytes .../src/main/webapp/index.jsp | 30 ++ .../src/main/webapp/tweets.jsp | 108 +++++ .../config/util/CredentialsCollectorTest.java | 82 ++++ .../controller/AddTweetsControllerTest.java | 77 ++++ .../EnqueueStoresControllerTest.java | 83 ++++ .../controller/StoreTweetsControllerTest.java | 118 ++++++ .../functions/KeyToStoredTweetStatusTest.java | 68 +++ .../ServiceToStoredTweetStatusesTest.java | 74 ++++ .../integration/CloudFoundryServer.java | 106 +++++ .../integration/TweetStoreLiveTest.java | 233 ++++++++++ .../tweetstore/integration/util/Zips.java | 36 ++ .../src/test/resources/log4j.xml | 95 +++++ 40 files changed, 3750 insertions(+) create mode 100644 demos/tweetstore/cf-tweetstore-spring/README.txt create mode 100644 demos/tweetstore/cf-tweetstore-spring/pom.xml create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/PlatformServices.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/RunnableHttpRequest.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/reference/PaasConstants.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/HttpRequestJob.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/Scheduler.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/quartz/plugins/TransactionlessXmlSchedulingDataProcessorPlugin.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/taskqueue/TaskQueue.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/DelegatingAutowireCapableBeanFactory.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollector.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/util/PropertiesLoader.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TweetStoreConstants.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/platform/.gitignore create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/resources/jobs.xml create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/resources/quartz.properties create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/webapp/WEB-INF/web.xml create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/webapp/images/cloudfoundry-logo.png create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/webapp/index.jsp create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/main/webapp/tweets.jsp create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollectorTest.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/CloudFoundryServer.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/util/Zips.java create mode 100644 demos/tweetstore/cf-tweetstore-spring/src/test/resources/log4j.xml diff --git a/demos/tweetstore/cf-tweetstore-spring/README.txt b/demos/tweetstore/cf-tweetstore-spring/README.txt new file mode 100644 index 0000000000..c2af578674 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/README.txt @@ -0,0 +1,41 @@ +==== + Licensed to jclouds, Inc. (jclouds) under one or more + contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. jclouds licenses this file + to you 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. +==== + +A guide to generating Twitter consumer keys and access tokens is at http://tinyurl.com/2fhebgb + +Please modify your maven settings.xml like below before attempting to run 'mvn -Plive install' + + + keys + + true + + + YOUR_ACCESS_KEY_ID + YOUR_SECRET_KEY + YOUR_USER + YOUR_HEX_KEY + YOUR_ACCOUNT + YOUR_BASE64_ENCODED_KEY + YOUR_TWITTER_CONSUMER_KEY + YOUR_TWITTER_CONSUMER_SECRET + YOUR_TWITTER_ACCESSTOKEN + YOUR_TWITTER_ACCESSTOKEN_SECRET + + \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/pom.xml b/demos/tweetstore/cf-tweetstore-spring/pom.xml new file mode 100644 index 0000000000..657c2a972b --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/pom.xml @@ -0,0 +1,184 @@ + + + + 4.0.0 + + org.jclouds + jclouds-demos-tweetstore-project + 1.5.0-SNAPSHOT + + jclouds-demo-cf-tweetstore-spring + war + jclouds TweetStore for Cloud Foundry + jclouds TweetStore for Cloud Foundry using Spring for Dependency Injection + + + 0.8.1 + jclouds-tweetstore + http://api.cloudfoundry.com + test-${cloudfoundry.applicationid}.cloudfoundry.com + 80 + jclouds-cf-tweetstore-spring + + + + + + org.springframework + spring-context + 3.0.5.RELEASE + + + org.springframework + spring-webmvc + 3.0.5.RELEASE + + + cglib + cglib-nodep + 2.2 + runtime + + + + org.quartz-scheduler + quartz + 2.1.3 + + + org.slf4j + slf4j-api + + + + + + + org.cloudfoundry + cloudfoundry-runtime + ${cloudfoundry.version} + + + org.cloudfoundry + cloudfoundry-client-lib + 0.7.1 + test + + + org.codehaus.plexus + plexus-archiver + 2.1.1 + test + + + + + + org.springframework.maven.milestone + http://maven.springframework.org/milestone + + false + + + + + + + live + + + + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.twitter.gae-tweetstore-spring.consumer.identity} + ${test.twitter.gae-tweetstore-spring.consumer.credential} + ${test.twitter.gae-tweetstore-spring.access.identity} + ${test.twitter.gae-tweetstore-spring.access.credential} + ${test.azureblob.identity} + ${test.azureblob.credential} + ${test.cloudfiles-us.identity} + ${test.cloudfiles-us.credential} + ${test.aws-s3.identity} + ${test.aws-s3.credential} + ${test.cloudonestorage.identity} + ${test.cloudonestorage.credential} + ${test.ninefold-storage.identity} + ${test.ninefold-storage.credential} + ${test.cloudfoundry.address} + ${test.cloudfoundry.port} + ${test.cloudfoundry.target} + ${cloudfoundry.username} + ${cloudfoundry.password} + ${jclouds.tweetstore.blobstores} + test.${jclouds.tweetstore.container} + ${project.build.directory}/${project.build.finalName} + + + + + + + + + + + deploy + + + cf-tweetstore-spring + + + + org.springframework.maven.milestone + http://maven.springframework.org/milestone + + false + + + + + + + org.cloudfoundry + cf-maven-plugin + 1.0.0.M1 + + http://api.cloudfoundry.com + ${cloudfoundry.username} + ${cloudfoundry.password} + ${cloudfoundry.applicationid} + 256 + + + + + + + diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/PlatformServices.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/PlatformServices.java new file mode 100644 index 0000000000..0997005157 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/PlatformServices.java @@ -0,0 +1,64 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.paas; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.demo.paas.config.PlatformServicesInitializer.PLATFORM_SERVICES_ATTRIBUTE_NAME; + +import java.util.Map; + +import javax.servlet.ServletContext; + +import org.jclouds.demo.paas.service.scheduler.Scheduler; +import org.jclouds.demo.paas.service.taskqueue.TaskQueue; +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.collect.ImmutableMap; + +/** + * @author Andrew Phillips + */ +public class PlatformServices { + protected final String baseUrl; + protected final Scheduler scheduler; + private ImmutableMap taskQueues; + + public PlatformServices(String baseUrl, Scheduler scheduler, Map taskQueues) { + this.baseUrl = baseUrl; + this.scheduler = scheduler; + this.taskQueues = ImmutableMap.copyOf(taskQueues); + } + + public String getBaseUrl() { + return baseUrl; + } + + public Scheduler getScheduler() { + return scheduler; + } + + public @Nullable TaskQueue getTaskQueue(String name) { + return taskQueues.get(name); + } + + public static PlatformServices get(ServletContext context) { + return (PlatformServices) checkNotNull(context.getAttribute( + PLATFORM_SERVICES_ATTRIBUTE_NAME), PLATFORM_SERVICES_ATTRIBUTE_NAME); + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/RunnableHttpRequest.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/RunnableHttpRequest.java new file mode 100644 index 0000000000..ad72a1a58d --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/RunnableHttpRequest.java @@ -0,0 +1,126 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.paas; + +import static java.lang.String.format; + +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpCommandExecutorService; +import org.jclouds.http.HttpRequest; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Multimap; + +public class RunnableHttpRequest implements Runnable { + public static final String PLATFORM_REQUEST_ORIGINATOR_HEADER = "X-Platform-Originator"; + + public static Factory factory(HttpCommandExecutorService httpClient) { + return factory(httpClient, format("%s@%d", Factory.class.getName(), System.currentTimeMillis())); + } + + public static Factory factory(HttpCommandExecutorService httpClient, String originator) { + return new Factory(httpClient, originator); + } + + public static class Factory { + protected final HttpCommandExecutorService httpClient; + protected final String originator; + + private Factory(HttpCommandExecutorService httpClient, String originator) { + this.httpClient = httpClient; + this.originator = originator; + } + + public RunnableHttpRequest create(HttpRequest request) { + HttpRequest requestWithSubmitter = request.toBuilder() + .headers(copyOfWithEntry(request.getHeaders(), + PLATFORM_REQUEST_ORIGINATOR_HEADER, originator)).build(); + return new RunnableHttpRequest(httpClient, requestWithSubmitter); + } + + private static Multimap copyOfWithEntry( + Multimap multimap, K k1, V v1) { + return ImmutableMultimap.builder().putAll(multimap).put(k1, v1).build(); + } + } + + private final HttpCommandExecutorService httpClient; + private final HttpRequest request; + + private RunnableHttpRequest(HttpCommandExecutorService httpClient, HttpRequest request) { + this.httpClient = httpClient; + this.request = request; + } + + @Override + public void run() { + httpClient.submit(new ImmutableHttpCommand(request)); + } + + private class ImmutableHttpCommand implements HttpCommand { + private final HttpRequest request; + + public ImmutableHttpCommand(HttpRequest request) { + this.request = request; + } + + @Override + public void setException(Exception exception) { + } + + @Override + public void setCurrentRequest(HttpRequest request) { + } + + @Override + public boolean isReplayable() { + return false; + } + + @Override + public int incrementRedirectCount() { + return 0; + } + + @Override + public int incrementFailureCount() { + return 0; + } + + @Override + public int getRedirectCount() { + return 0; + } + + @Override + public int getFailureCount() { + return 0; + } + + @Override + public Exception getException() { + return null; + } + + @Override + public HttpRequest getCurrentRequest() { + return request; + } + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java new file mode 100644 index 0000000000..f034b2a3e4 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java @@ -0,0 +1,104 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.paas.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.inject.name.Names.bindProperties; +import static java.util.concurrent.TimeUnit.SECONDS; + +import java.util.Properties; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.ws.rs.core.UriBuilder; + +import org.cloudfoundry.runtime.env.ApplicationInstanceInfo; +import org.cloudfoundry.runtime.env.CloudEnvironment; +import org.jclouds.PropertiesBuilder; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.demo.paas.PlatformServices; +import org.jclouds.demo.paas.service.scheduler.Scheduler; +import org.jclouds.demo.paas.service.taskqueue.TaskQueue; +import org.jclouds.demo.tweetstore.config.util.PropertiesLoader; +import org.jclouds.http.HttpCommandExecutorService; +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.sun.jersey.api.uri.UriBuilderImpl; + +/** + * @author Andrew Phillips + */ +public class PlatformServicesInitializer implements ServletContextListener { + public static final String PLATFORM_SERVICES_ATTRIBUTE_NAME = PlatformServices.class.getName(); + + @Override + public void contextInitialized(ServletContextEvent contextEvent) { + ServletContext context = contextEvent.getServletContext(); + context.setAttribute(PLATFORM_SERVICES_ATTRIBUTE_NAME, createServices(context)); + } + + protected static PlatformServices createServices(ServletContext context) { + HttpCommandExecutorService httpClient = createHttpClient(context); + return new PlatformServices(getBaseUrl(context), new Scheduler(httpClient), + createTaskQueues(httpClient)); + } + + protected static HttpCommandExecutorService createHttpClient( + final ServletContext context) { + return Guice.createInjector(new ExecutorServiceModule(), + new JavaUrlHttpCommandExecutorServiceModule(), + new AbstractModule() { + @Override + protected void configure() { + // URL connection defaults + Properties toBind = new PropertiesBuilder().build(); + toBind.putAll(checkNotNull(new PropertiesLoader(context).get(), "properties")); + toBind.putAll(System.getProperties()); + bindProperties(binder(), toBind); + bind(UriBuilder.class).to(UriBuilderImpl.class); + } + }).getInstance(HttpCommandExecutorService.class); + } + + protected static String getBaseUrl(ServletContext context) { + ApplicationInstanceInfo instanceInfo = new CloudEnvironment().getInstanceInfo(); + return "http://" + checkNotNull(instanceInfo.getHost(), "instanceInfo.getHost()") + + ":" + instanceInfo.getPort() + context.getContextPath(); + } + + // TODO: make the number and names of queues configurable + protected static ImmutableMap createTaskQueues(HttpCommandExecutorService httpClient) { + Builder taskQueues = ImmutableMap.builder(); + taskQueues.put("twitter", TaskQueue.builder(httpClient) + .name("twitter").period(SECONDS.toMillis(30)) + .build()); + return taskQueues.build(); + } + + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + ServletContext context = servletContextEvent.getServletContext(); + context.removeAttribute(PLATFORM_SERVICES_ATTRIBUTE_NAME); + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/reference/PaasConstants.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/reference/PaasConstants.java new file mode 100644 index 0000000000..8af7021bd2 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/reference/PaasConstants.java @@ -0,0 +1,28 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.paas.reference; + +/** + * Configuration properties and constants used in PaaS applications. + * + * @author Andrew Phillips + */ +public interface PaasConstants { + static final String PROPERTY_PLATFORM_BASE_URL = "jclouds.paas.baseurl"; +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/HttpRequestJob.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/HttpRequestJob.java new file mode 100644 index 0000000000..902f5fe356 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/HttpRequestJob.java @@ -0,0 +1,69 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.paas.service.scheduler; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; + +import javax.servlet.ServletContext; + +import org.jclouds.demo.paas.PlatformServices; +import org.jclouds.demo.paas.RunnableHttpRequest; +import org.jclouds.http.HttpRequest; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.quartz.SchedulerException; + +/** + * @author Andrew Phillips + */ +public class HttpRequestJob implements Job { + protected static final String URL_ATTRIBUTE_NAME = "url"; + + // keep in sync with "quartz:scheduler-context-servlet-context-key" param in web.xml + protected static final String SERVLET_CONTEXT_KEY = "servlet-context"; + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + PlatformServices platform = JobContexts.getPlatform(context); + RunnableHttpRequest request = platform.getScheduler().getHttpRequestFactory().create( + HttpRequest.builder() + .endpoint(JobContexts.getTargetUrl(platform.getBaseUrl(), context)) + .method("GET").build()); + request.run(); + } + + private static class JobContexts { + private static URI getTargetUrl(String baseUrl, JobExecutionContext context) { + return URI.create(baseUrl + (String) checkNotNull( + context.getMergedJobDataMap().get(URL_ATTRIBUTE_NAME), URL_ATTRIBUTE_NAME)); + } + + private static PlatformServices getPlatform(JobExecutionContext jobContext) throws JobExecutionException { + try { + return PlatformServices.get((ServletContext) checkNotNull( + jobContext.getScheduler().getContext().get(SERVLET_CONTEXT_KEY), SERVLET_CONTEXT_KEY)); + } catch (SchedulerException exception) { + throw new JobExecutionException("Unable to get platform services from the job execution context", exception); + } + } + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/Scheduler.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/Scheduler.java new file mode 100644 index 0000000000..dabdff877b --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/Scheduler.java @@ -0,0 +1,41 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.paas.service.scheduler; + +import org.jclouds.demo.paas.RunnableHttpRequest; +import org.jclouds.demo.paas.RunnableHttpRequest.Factory; +import org.jclouds.http.HttpCommandExecutorService; + +/** + * @author Andrew Phillips + */ +public class Scheduler { + protected static final String SCHEDULER_ORIGINATOR_NAME = "scheduler"; + + protected final Factory httpRequestFactory; + + public Scheduler(HttpCommandExecutorService httpClient) { + httpRequestFactory = + RunnableHttpRequest.factory(httpClient, SCHEDULER_ORIGINATOR_NAME); + } + + public Factory getHttpRequestFactory() { + return httpRequestFactory; + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/quartz/plugins/TransactionlessXmlSchedulingDataProcessorPlugin.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/quartz/plugins/TransactionlessXmlSchedulingDataProcessorPlugin.java new file mode 100644 index 0000000000..91659d9b16 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/scheduler/quartz/plugins/TransactionlessXmlSchedulingDataProcessorPlugin.java @@ -0,0 +1,401 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.paas.service.scheduler.quartz.plugins; + +import static org.quartz.SimpleScheduleBuilder.simpleSchedule; +import static org.quartz.TriggerBuilder.newTrigger; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLDecoder; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; + +import org.jclouds.logging.Logger; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.SimpleTrigger; +import org.quartz.TriggerKey; +import org.quartz.jobs.FileScanJob; +import org.quartz.jobs.FileScanListener; +import org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin; +import org.quartz.simpl.CascadingClassLoadHelper; +import org.quartz.spi.ClassLoadHelper; +import org.quartz.spi.SchedulerPlugin; +import org.quartz.xml.XMLSchedulingDataProcessor; + +/** + * A copy of {@link XMLSchedulingDataProcessorPlugin} that does not reference + * {@code javax.transaction.UserTransaction} as so does not require a dependency + * on JTA. + * + * @author Andrew Phillips + * @see XMLSchedulingDataProcessorPlugin + */ +public class TransactionlessXmlSchedulingDataProcessorPlugin implements + FileScanListener, SchedulerPlugin { + + /* + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Data members. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + private static final int MAX_JOB_TRIGGER_NAME_LEN = 80; + private static final String JOB_INITIALIZATION_PLUGIN_NAME = "JobSchedulingDataLoaderPlugin"; + private static final String FILE_NAME_DELIMITERS = ","; + + private String name; + private Scheduler scheduler; + private final Logger log = Logger.CONSOLE; + + private boolean failOnFileNotFound = true; + + private String fileNames = XMLSchedulingDataProcessor.QUARTZ_XML_DEFAULT_FILE_NAME; + + // Populated by initialization + private Map jobFiles = new LinkedHashMap(); + + private long scanInterval = 0; + + boolean started = false; + + protected ClassLoadHelper classLoadHelper = null; + + private Set jobTriggerNameSet = new HashSet(); + + /* + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Interface. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + + /** + * Comma separated list of file names (with paths) to the XML files that should be read. + */ + public String getFileNames() { + return fileNames; + } + + /** + * The file name (and path) to the XML file that should be read. + */ + public void setFileNames(String fileNames) { + this.fileNames = fileNames; + } + + /** + * The interval (in seconds) at which to scan for changes to the file. + * If the file has been changed, it is re-loaded and parsed. The default + * value for the interval is 0, which disables scanning. + * + * @return Returns the scanInterval. + */ + public long getScanInterval() { + return scanInterval / 1000; + } + + /** + * The interval (in seconds) at which to scan for changes to the file. + * If the file has been changed, it is re-loaded and parsed. The default + * value for the interval is 0, which disables scanning. + * + * @param scanInterval The scanInterval to set. + */ + public void setScanInterval(long scanInterval) { + this.scanInterval = scanInterval * 1000; + } + + /** + * Whether or not initialization of the plugin should fail (throw an + * exception) if the file cannot be found. Default is true. + */ + public boolean isFailOnFileNotFound() { + return failOnFileNotFound; + } + + /** + * Whether or not initialization of the plugin should fail (throw an + * exception) if the file cannot be found. Default is true. + */ + public void setFailOnFileNotFound(boolean failOnFileNotFound) { + this.failOnFileNotFound = failOnFileNotFound; + } + + /* + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * SchedulerPlugin Interface. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + + /** + *

    + * Called during creation of the Scheduler in order to give + * the SchedulerPlugin a chance to initialize. + *

    + * + * @throws org.quartz.SchedulerConfigException + * if there is an error initializing. + */ + @Override + public void initialize(String name, Scheduler scheduler) + throws SchedulerException { + this.name = name; + this.scheduler = scheduler; + + classLoadHelper = new CascadingClassLoadHelper(); + classLoadHelper.initialize(); + + log.info("Registering Quartz Job Initialization Plug-in."); + + // Create JobFile objects + StringTokenizer stok = new StringTokenizer(fileNames, FILE_NAME_DELIMITERS); + while (stok.hasMoreTokens()) { + final String fileName = stok.nextToken(); + final JobFile jobFile = new JobFile(fileName); + jobFiles.put(fileName, jobFile); + } + } + + @Override + public void start() { + try { + if (jobFiles.isEmpty() == false) { + + if (scanInterval > 0) { + scheduler.getContext().put(JOB_INITIALIZATION_PLUGIN_NAME + '_' + name, this); + } + + Iterator iterator = jobFiles.values().iterator(); + while (iterator.hasNext()) { + JobFile jobFile = iterator.next(); + + if (scanInterval > 0) { + String jobTriggerName = buildJobTriggerName(jobFile.getFileBasename()); + TriggerKey tKey = new TriggerKey(jobTriggerName, JOB_INITIALIZATION_PLUGIN_NAME); + + // remove pre-existing job/trigger, if any + scheduler.unscheduleJob(tKey); + + // TODO: convert to use builder + SimpleTrigger trig = newTrigger() + .withIdentity(jobTriggerName, JOB_INITIALIZATION_PLUGIN_NAME) + .startNow() + .endAt(null) + .withSchedule(simpleSchedule() + .repeatForever() + .withIntervalInMilliseconds(scanInterval)) + .build(); + + JobDetail job = JobBuilder.newJob(FileScanJob.class) + .withIdentity(jobTriggerName, JOB_INITIALIZATION_PLUGIN_NAME) + .build(); + job.getJobDataMap().put(FileScanJob.FILE_NAME, jobFile.getFileName()); + job.getJobDataMap().put(FileScanJob.FILE_SCAN_LISTENER_NAME, JOB_INITIALIZATION_PLUGIN_NAME + '_' + name); + + scheduler.scheduleJob(job, trig); + log.debug("Scheduled file scan job for data file: {}, at interval: {}", jobFile.getFileName(), scanInterval); + } + + processFile(jobFile); + } + } + } catch(SchedulerException se) { + log.error("Error starting background-task for watching jobs file.", se); + } finally { + started = true; + } + } + + /** + * Helper method for generating unique job/trigger name for the + * file scanning jobs (one per FileJob). The unique names are saved + * in jobTriggerNameSet. + */ + private String buildJobTriggerName( + String fileBasename) { + // Name w/o collisions will be prefix + _ + filename (with '.' of filename replaced with '_') + // For example: JobInitializationPlugin_jobInitializer_myjobs_xml + String jobTriggerName = JOB_INITIALIZATION_PLUGIN_NAME + '_' + name + '_' + fileBasename.replace('.', '_'); + + // If name is too long (DB column is 80 chars), then truncate to max length + if (jobTriggerName.length() > MAX_JOB_TRIGGER_NAME_LEN) { + jobTriggerName = jobTriggerName.substring(0, MAX_JOB_TRIGGER_NAME_LEN); + } + + // Make sure this name is unique in case the same file name under different + // directories is being checked, or had a naming collision due to length truncation. + // If there is a conflict, keep incrementing a _# suffix on the name (being sure + // not to get too long), until we find a unique name. + int currentIndex = 1; + while (jobTriggerNameSet.add(jobTriggerName) == false) { + // If not our first time through, then strip off old numeric suffix + if (currentIndex > 1) { + jobTriggerName = jobTriggerName.substring(0, jobTriggerName.lastIndexOf('_')); + } + + String numericSuffix = "_" + currentIndex++; + + // If the numeric suffix would make the name too long, then make room for it. + if (jobTriggerName.length() > (MAX_JOB_TRIGGER_NAME_LEN - numericSuffix.length())) { + jobTriggerName = jobTriggerName.substring(0, (MAX_JOB_TRIGGER_NAME_LEN - numericSuffix.length())); + } + + jobTriggerName += numericSuffix; + } + + return jobTriggerName; + } + + @Override + public void shutdown() { + // nothing to do + } + + private void processFile(JobFile jobFile) { + if (jobFile == null || !jobFile.getFileFound()) { + return; + } + + try { + XMLSchedulingDataProcessor processor = + new XMLSchedulingDataProcessor(this.classLoadHelper); + + processor.addJobGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME); + processor.addTriggerGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME); + + processor.processFileAndScheduleJobs( + jobFile.getFileName(), + jobFile.getFileName(), // systemId + scheduler); + } catch (Exception e) { + log.error("Error scheduling jobs: " + e.getMessage(), e); + } + } + + public void processFile(String filePath) { + processFile((JobFile)jobFiles.get(filePath)); + } + + /** + * @see org.quartz.jobs.FileScanListener#fileUpdated(java.lang.String) + */ + public void fileUpdated(String fileName) { + if (started) { + processFile(fileName); + } + } + + class JobFile { + private String fileName; + + // These are set by initialize() + private String filePath; + private String fileBasename; + private boolean fileFound; + + protected JobFile(String fileName) throws SchedulerException { + this.fileName = fileName; + initialize(); + } + + protected String getFileName() { + return fileName; + } + + protected boolean getFileFound() { + return fileFound; + } + + protected String getFilePath() { + return filePath; + } + + protected String getFileBasename() { + return fileBasename; + } + + private void initialize() throws SchedulerException { + InputStream f = null; + try { + String furl = null; + + File file = new File(getFileName()); // files in filesystem + if (!file.exists()) { + URL url = classLoadHelper.getResource(getFileName()); + if(url != null) { + try { + furl = URLDecoder.decode(url.getPath(), "UTF-8"); + } catch (UnsupportedEncodingException e) { + furl = url.getPath(); + } + file = new File(furl); + try { + f = url.openStream(); + } catch (IOException ignor) { + // Swallow the exception + } + } + } else { + try { + f = new java.io.FileInputStream(file); + }catch (FileNotFoundException e) { + // ignore + } + } + + if (f == null) { + if (isFailOnFileNotFound()) { + throw new SchedulerException( + "File named '" + getFileName() + "' does not exist."); + } else { + log.warn("File named '" + getFileName() + "' does not exist."); + } + } else { + fileFound = true; + } + filePath = (furl != null) ? furl : file.getAbsolutePath(); + fileBasename = file.getName(); + } finally { + try { + if (f != null) { + f.close(); + } + } catch (IOException ioe) { + log.warn("Error closing jobs file " + getFileName(), ioe); + } + } + } + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/taskqueue/TaskQueue.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/taskqueue/TaskQueue.java new file mode 100644 index 0000000000..e317a305cf --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/service/taskqueue/TaskQueue.java @@ -0,0 +1,107 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.paas.service.taskqueue; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; + +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.TimeUnit; + +import org.jclouds.demo.paas.RunnableHttpRequest; +import org.jclouds.demo.paas.RunnableHttpRequest.Factory; +import org.jclouds.http.HttpCommandExecutorService; + +import com.google.inject.Provider; + +public class TaskQueue { + protected final Factory httpRequestFactory; + private final Timer timer; + private final ConcurrentLinkedQueue tasks = new ConcurrentLinkedQueue(); + + private TaskQueue(String name, long pollingIntervalMillis, Factory httpRequestFactory) { + this.httpRequestFactory = httpRequestFactory; + timer = new Timer(name); + timer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + Runnable task = tasks.poll(); + if (task != null) { + task.run(); + } + } + }, 0, pollingIntervalMillis); + } + + public void add(final Runnable task) { + tasks.add(task); + } + + public Factory getHttpRequestFactory() { + return httpRequestFactory; + } + + public void destroy() { + timer.cancel(); + tasks.clear(); + } + + public static Builder builder(HttpCommandExecutorService httpClient) { + return new Builder(httpClient); + } + + public static class Builder implements Provider { + protected final HttpCommandExecutorService httpClient; + protected String name = "default"; + protected long pollingIntervalMillis = TimeUnit.SECONDS.toMillis(1); + + private Builder(HttpCommandExecutorService httpClient) { + this.httpClient = checkNotNull(httpClient, "httpClient"); + } + + public Builder name(String name) { + this.name = checkNotNull(name, "name"); + return this; + } + + public Builder period(TimeUnit period) { + this.pollingIntervalMillis = checkNotNull(period, "period").toMillis(1); + return this; + } + + public Builder period(long pollingIntervalMillis) { + checkArgument(pollingIntervalMillis > 0, "pollingIntervalMillis"); + this.pollingIntervalMillis = pollingIntervalMillis; + return this; + } + + public TaskQueue build() { + return new TaskQueue(name, pollingIntervalMillis, + RunnableHttpRequest.factory(httpClient, format("taskqueue-%s", name))); + } + + @Override + public TaskQueue get() { + return build(); + } + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/DelegatingAutowireCapableBeanFactory.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/DelegatingAutowireCapableBeanFactory.java new file mode 100644 index 0000000000..7fda1bb2f0 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/DelegatingAutowireCapableBeanFactory.java @@ -0,0 +1,129 @@ +package org.jclouds.demo.tweetstore.config; + +import java.util.Set; + +import org.springframework.beans.BeansException; +import org.springframework.beans.TypeConverter; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import org.springframework.beans.factory.config.DependencyDescriptor; + +class DelegatingAutowireCapableBeanFactory implements AutowireCapableBeanFactory { + private final AutowireCapableBeanFactory delegate; + + DelegatingAutowireCapableBeanFactory(AutowireCapableBeanFactory delegate) { + this.delegate = delegate; + } + + public T createBean(Class beanClass) throws BeansException { + return delegate.createBean(beanClass); + } + + public void autowireBean(Object existingBean) throws BeansException { + delegate.autowireBean(existingBean); + } + + public Object configureBean(Object existingBean, String beanName) + throws BeansException { + return delegate.configureBean(existingBean, beanName); + } + + public Object getBean(String name) throws BeansException { + return delegate.getBean(name); + } + + public Object resolveDependency(DependencyDescriptor descriptor, + String beanName) throws BeansException { + return delegate.resolveDependency(descriptor, beanName); + } + + public T getBean(String name, Class requiredType) + throws BeansException { + return delegate.getBean(name, requiredType); + } + + @SuppressWarnings("rawtypes") + public Object createBean(Class beanClass, int autowireMode, + boolean dependencyCheck) throws BeansException { + return delegate.createBean(beanClass, autowireMode, dependencyCheck); + } + + public T getBean(Class requiredType) throws BeansException { + return delegate.getBean(requiredType); + } + + @SuppressWarnings("rawtypes") + public Object autowire(Class beanClass, int autowireMode, + boolean dependencyCheck) throws BeansException { + return delegate.autowire(beanClass, autowireMode, dependencyCheck); + } + + public Object getBean(String name, Object... args) throws BeansException { + return delegate.getBean(name, args); + } + + public void autowireBeanProperties(Object existingBean, int autowireMode, + boolean dependencyCheck) throws BeansException { + delegate.autowireBeanProperties(existingBean, autowireMode, + dependencyCheck); + } + + public boolean containsBean(String name) { + return delegate.containsBean(name); + } + + public boolean isSingleton(String name) + throws NoSuchBeanDefinitionException { + return delegate.isSingleton(name); + } + + public void applyBeanPropertyValues(Object existingBean, String beanName) + throws BeansException { + delegate.applyBeanPropertyValues(existingBean, beanName); + } + + public boolean isPrototype(String name) + throws NoSuchBeanDefinitionException { + return delegate.isPrototype(name); + } + + @SuppressWarnings("rawtypes") + public boolean isTypeMatch(String name, Class targetType) + throws NoSuchBeanDefinitionException { + return delegate.isTypeMatch(name, targetType); + } + + public Object initializeBean(Object existingBean, String beanName) + throws BeansException { + return delegate.initializeBean(existingBean, beanName); + } + + public Class getType(String name) throws NoSuchBeanDefinitionException { + return delegate.getType(name); + } + + public Object applyBeanPostProcessorsBeforeInitialization( + Object existingBean, String beanName) throws BeansException { + return delegate.applyBeanPostProcessorsBeforeInitialization( + existingBean, beanName); + } + + public String[] getAliases(String name) { + return delegate.getAliases(name); + } + + public Object applyBeanPostProcessorsAfterInitialization( + Object existingBean, String beanName) throws BeansException { + return delegate.applyBeanPostProcessorsAfterInitialization( + existingBean, beanName); + } + + public Object resolveDependency(DependencyDescriptor descriptor, + String beanName, Set autowiredBeanNames, + TypeConverter typeConverter) throws BeansException { + return delegate.resolveDependency(descriptor, beanName, + autowiredBeanNames, typeConverter); + } + + +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java new file mode 100644 index 0000000000..fc3a28dc1b --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java @@ -0,0 +1,88 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.config; + +import static com.google.common.base.Preconditions.checkArgument; +import static org.jclouds.logging.LoggingModules.firstOrJDKLoggingModule; + +import java.util.Set; + +import javax.annotation.PostConstruct; + +import org.jclouds.logging.Logger; +import org.jclouds.logging.Logger.LoggerFactory; +import org.springframework.beans.BeansException; +import org.springframework.beans.TypeConverter; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import org.springframework.beans.factory.config.DependencyDescriptor; +import org.springframework.context.annotation.AnnotationConfigUtils; +import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor; + +/** + * Spring config that sets up {@link CommonAnnotationBeanPostProcessor} support + * for injecting loggers. + * + * @author Andrew Phillips + */ +abstract class LoggingConfig implements BeanFactoryAware { + protected static final LoggerFactory LOGGER_FACTORY = firstOrJDKLoggingModule().createLoggerFactory(); + + private static final Logger LOGGER = LOGGER_FACTORY.getLogger(LoggingConfig.class.getName()); + + private AutowireCapableBeanFactory beanFactory; + + @PostConstruct + public void initLoggerSupport() { + CommonAnnotationBeanPostProcessor resourceProcessor = + (CommonAnnotationBeanPostProcessor) beanFactory.getBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME); + resourceProcessor.setResourceFactory(new LoggerResourceBeanFactory(beanFactory)); + } + + private static class LoggerResourceBeanFactory extends DelegatingAutowireCapableBeanFactory { + + LoggerResourceBeanFactory(AutowireCapableBeanFactory delegate) { + super(delegate); + } + + @Override + public Object resolveDependency(DependencyDescriptor descriptor, + String beanName, Set autowiredBeanNames, + TypeConverter typeConverter) throws BeansException { + Object bean; + if (descriptor.getDependencyType().equals(Logger.class)) { + Class requestingType = getType(beanName); + LOGGER.trace("About to create logger for bean '%s' of type '%s'", + beanName, requestingType); + bean = LOGGER_FACTORY.getLogger(requestingType.getName()); + LOGGER.trace("Successfully created logger."); + return bean; + } + return super.resolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter); + } + } + + @Override + public void setBeanFactory(BeanFactory beanFactory) throws BeansException { + checkArgument(beanFactory instanceof AutowireCapableBeanFactory, "expected an instance of '%s' but was '%s'", + AutowireCapableBeanFactory.class, beanFactory.getClass()); + this.beanFactory = (AutowireCapableBeanFactory) beanFactory; + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java new file mode 100644 index 0000000000..25bdbd80e6 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java @@ -0,0 +1,236 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Predicates.in; +import static com.google.common.collect.ImmutableSet.copyOf; +import static com.google.common.collect.Sets.filter; +import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_BLOBSTORES; +import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.servlet.Servlet; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.demo.paas.PlatformServices; +import org.jclouds.demo.paas.service.taskqueue.TaskQueue; +import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; +import org.jclouds.demo.tweetstore.controller.AddTweetsController; +import org.jclouds.demo.tweetstore.controller.EnqueueStoresController; +import org.jclouds.demo.tweetstore.controller.StoreTweetsController; +import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; +import org.jclouds.logging.Logger; +import org.springframework.beans.factory.BeanCreationException; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.context.ServletConfigAware; +import org.springframework.web.servlet.HandlerAdapter; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.servlet.handler.SimpleServletHandlerAdapter; +import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; + +import twitter4j.Twitter; +import twitter4j.TwitterFactory; +import twitter4j.conf.ConfigurationBuilder; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.io.Closeables; +import com.google.inject.Module; + +/** + * Creates servlets (using resources from the {@link SpringAppConfig}) and mappings. + * + * @author Andrew Phillips + * @see SpringAppConfig + */ +@Configuration +public class SpringServletConfig extends LoggingConfig implements ServletConfigAware { + public static final String PROPERTY_BLOBSTORE_CONTEXTS = "blobstore.contexts"; + + private static final Logger LOGGER = LOGGER_FACTORY.getLogger(SpringServletConfig.class.getName()); + + private ServletConfig servletConfig; + + private Map providerTypeToBlobStoreMap; + private Twitter twitterClient; + private String container; + private TaskQueue queue; + private String baseUrl; + + @PostConstruct + public void initialize() throws IOException { + BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory(); + + Properties props = loadJCloudsProperties(); + LOGGER.trace("About to initialize members."); + + Set modules = ImmutableSet.of(); + // shared across all blobstores and used to retrieve tweets + try { + twitter4j.conf.Configuration twitterConf = new ConfigurationBuilder() + .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY)) + .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET)) + .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN)) + .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) + .build(); + twitterClient = new TwitterFactory(twitterConf).getInstance(); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); + } + // common namespace for storing tweets + container = checkNotNull(props.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); + + // instantiate and store references to all blobstores by provider name + providerTypeToBlobStoreMap = Maps.newHashMap(); + for (String hint : getBlobstoreContexts(props)) { + providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); + } + + // get a queue for submitting store tweet requests and the application's base URL + PlatformServices platform = PlatformServices.get(servletConfig.getServletContext()); + queue = platform.getTaskQueue("twitter"); + baseUrl = platform.getBaseUrl(); + + LOGGER.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient, + container, providerTypeToBlobStoreMap.keySet()); + } + + private static Iterable getBlobstoreContexts(Properties props) { + Set contexts = new CredentialsCollector().apply(props).keySet(); + String explicitContexts = props.getProperty(PROPERTY_TWEETSTORE_BLOBSTORES); + if (explicitContexts != null) { + contexts = filter(contexts, in(copyOf(Splitter.on(',').split(explicitContexts)))); + } + checkState(!contexts.isEmpty(), "no credentials available for any requested context"); + return contexts; + } + + private Properties loadJCloudsProperties() { + LOGGER.trace("About to read properties from '%s'", "/WEB-INF/jclouds.properties"); + Properties props = new Properties(); + InputStream input = servletConfig.getServletContext().getResourceAsStream("/WEB-INF/jclouds.properties"); + try { + props.load(input); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + Closeables.closeQuietly(input); + } + LOGGER.trace("Properties successfully read."); + return props; + } + + @Bean + public StoreTweetsController storeTweetsController() { + StoreTweetsController controller = new StoreTweetsController(providerTypeToBlobStoreMap, container, twitterClient); + injectServletConfig(controller); + return controller; + } + + @Bean + public AddTweetsController addTweetsController() { + AddTweetsController controller = new AddTweetsController(providerTypeToBlobStoreMap, + serviceToStoredTweetStatuses()); + injectServletConfig(controller); + return controller; + } + + @Bean + public EnqueueStoresController enqueueStoresController() { + return new EnqueueStoresController(providerTypeToBlobStoreMap, queue, baseUrl); + } + + private void injectServletConfig(Servlet servlet) { + LOGGER.trace("About to inject servlet config '%s'", servletConfig); + try { + servlet.init(checkNotNull(servletConfig)); + } catch (ServletException exception) { + throw new BeanCreationException("Unable to instantiate " + servlet, exception); + } + LOGGER.trace("Successfully injected servlet config."); + } + + @Bean + ServiceToStoredTweetStatuses serviceToStoredTweetStatuses() { + return new ServiceToStoredTweetStatuses(providerTypeToBlobStoreMap, container); + } + + @Bean + public HandlerMapping handlerMapping() { + SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); + Map urlMap = Maps.newHashMapWithExpectedSize(2); + urlMap.put("/store/*", storeTweetsController()); + urlMap.put("/tweets/*", addTweetsController()); + urlMap.put("/stores/*", enqueueStoresController()); + mapping.setUrlMap(urlMap); + /* + * "/store", "/tweets" and "/stores" are part of the servlet mapping and thus + * stripped by the mapping if using default settings. + */ + mapping.setAlwaysUseFullPath(true); + return mapping; + } + + @Bean + public HandlerAdapter servletHandlerAdapter() { + return new SimpleServletHandlerAdapter(); + } + + @PreDestroy + public void destroy() throws Exception { + LOGGER.trace("About to close contexts."); + for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { + context.close(); + } + LOGGER.trace("Contexts closed."); + LOGGER.trace("About to purge request queue."); + queue.destroy(); + LOGGER.trace("Request queue purged."); + } + + /* + * (non-Javadoc) + * + * @see + * org.springframework.web.context.ServletConfigAware#setServletConfig(javax.servlet.ServletConfig + * ) + */ + @Override + public void setServletConfig(ServletConfig servletConfig) { + this.servletConfig = servletConfig; + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollector.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollector.java new file mode 100644 index 0000000000..ce3943376e --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollector.java @@ -0,0 +1,153 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.config.util; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Predicates.notNull; +import static com.google.common.collect.Collections2.filter; +import static com.google.common.collect.Collections2.transform; +import static com.google.common.collect.ImmutableSet.copyOf; +import static com.google.common.collect.Maps.filterValues; +import static org.jclouds.util.Maps2.fromKeys; + +import java.util.Collection; +import java.util.Map; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.jclouds.demo.tweetstore.config.util.CredentialsCollector.Credential; + +import com.google.common.annotations.GwtIncompatible; +import com.google.common.base.Function; +import com.google.common.base.Predicate; + +/** + * Reads provider credentials from a {@link Properties} bag. + * + * @author Andrew Phillips + * + */ +public class CredentialsCollector implements Function> { + private static final String IDENTITY_PROPERTY_SUFFIX = ".identity"; + private static final String CREDENTIAL_PROPERTY_SUFFIX = ".credential"; + + // using the identity for provider name extraction + private static final Pattern IDENTITY_PROPERTY_PATTERN = + Pattern.compile("([a-zA-Z0-9-]+)" + Pattern.quote(IDENTITY_PROPERTY_SUFFIX)); + + @Override + public Map apply(final Properties properties) { + Collection providerNames = transform( + filter(properties.stringPropertyNames(), MatchesPattern.matches(IDENTITY_PROPERTY_PATTERN)), + new Function() { + @Override + public String apply(String input) { + Matcher matcher = IDENTITY_PROPERTY_PATTERN.matcher(input); + // as a side-effect, sets the matching group! + checkState(matcher.matches(), "'%s' should match '%s'", input, IDENTITY_PROPERTY_PATTERN); + return matcher.group(1); + } + }); + /* + * Providers without a credential property result in null values, which are + * removed from the returned map. + */ + return filterValues(fromKeys(copyOf(providerNames), new Function() { + @Override + public Credential apply(String providerName) { + String identity = properties.getProperty(providerName + IDENTITY_PROPERTY_SUFFIX); + String credential = properties.getProperty(providerName + CREDENTIAL_PROPERTY_SUFFIX); + return (((identity != null) && (credential != null)) + ? new Credential(identity, credential) + : null); + } + }), notNull()); + } + + public static class Credential { + private final String identity; + private final String credential; + + public Credential(String identity, String credential) { + this.identity = checkNotNull(identity, "identity"); + this.credential = checkNotNull(credential, "credential"); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((credential == null) ? 0 : credential.hashCode()); + result = prime * result + + ((identity == null) ? 0 : identity.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Credential other = (Credential) obj; + if (credential == null) { + if (other.credential != null) + return false; + } else if (!credential.equals(other.credential)) + return false; + if (identity == null) { + if (other.identity != null) + return false; + } else if (!identity.equals(other.identity)) + return false; + return true; + } + + public String getIdentity() { + return identity; + } + + public String getCredential() { + return credential; + } + } + + @GwtIncompatible(value = "java.util.regex.Pattern") + private static class MatchesPattern implements Predicate { + private final Pattern pattern; + + private MatchesPattern(Pattern pattern) { + this.pattern = pattern; + } + + @Override + public boolean apply(String input) { + return pattern.matcher(input).matches(); + } + + private static MatchesPattern matches(Pattern pattern) { + return new MatchesPattern(pattern); + } + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/util/PropertiesLoader.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/util/PropertiesLoader.java new file mode 100644 index 0000000000..dafa5c311b --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/util/PropertiesLoader.java @@ -0,0 +1,59 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.config.util; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import javax.servlet.ServletContext; + +import com.google.common.io.Closeables; +import com.google.inject.Provider; + +/** + * @author Andrew Phillips + */ +public class PropertiesLoader implements Provider{ + private static final String PROPERTIES_FILE = "/WEB-INF/jclouds.properties"; + + private final Properties properties; + + public PropertiesLoader(ServletContext context) { + properties = loadJcloudsProperties(context); + } + + private static Properties loadJcloudsProperties(ServletContext context) { + InputStream input = context.getResourceAsStream(PROPERTIES_FILE); + Properties props = new Properties(); + try { + props.load(input); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + Closeables.closeQuietly(input); + } + return props; + } + + @Override + public Properties get() { + return properties; + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java new file mode 100644 index 0000000000..7254941332 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -0,0 +1,101 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.controller; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.cloudfoundry.runtime.env.ApplicationInstanceInfo; +import org.cloudfoundry.runtime.env.CloudEnvironment; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; + +/** + * Shows an example of how to use @{link BlobStoreContext} injected with Guice. + * + * @author Adrian Cole + */ +@Singleton +public class AddTweetsController extends HttpServlet implements + Function, List> { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3888348023150822683L; + private final Map contexts; + private final ServiceToStoredTweetStatuses blobStoreContextToContainerResult; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject + public AddTweetsController(Map contexts, + ServiceToStoredTweetStatuses blobStoreContextToContainerResult) { + this.contexts = contexts; + this.blobStoreContextToContainerResult = blobStoreContextToContainerResult; + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + try { + addMyTweetsToRequest(request); + RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/tweets.jsp"); + dispatcher.forward(request, response); + } catch (Exception e) { + logger.error(e, "Error listing containers"); + throw new ServletException(e); + } + } + + void addMyTweetsToRequest(HttpServletRequest request) throws InterruptedException, + ExecutionException, TimeoutException { + request.setAttribute("tweets", apply(contexts.keySet())); + // TODO: remove me! + ApplicationInstanceInfo instanceInfo = new CloudEnvironment().getInstanceInfo(); + request.setAttribute("instanceInfo", instanceInfo); + } + + public List apply(Set in) { + List statuses = Lists.newArrayList(); + for (Iterable list : Iterables.transform(in, + blobStoreContextToContainerResult)) { + Iterables.addAll(statuses, list); + } + return statuses; + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java new file mode 100644 index 0000000000..592eaaa8bd --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java @@ -0,0 +1,101 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.controller; + +import static com.google.common.base.Strings.nullToEmpty; +import static org.jclouds.demo.paas.RunnableHttpRequest.PLATFORM_REQUEST_ORIGINATOR_HEADER; + +import java.io.IOException; +import java.net.URI; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.MediaType; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.demo.paas.reference.PaasConstants; +import org.jclouds.demo.paas.service.taskqueue.TaskQueue; +import org.jclouds.http.HttpRequest; +import org.jclouds.logging.Logger; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.ImmutableMultimap; + +/** + * Adds tasks to retrieve and store tweets in all registered contexts to an async + * task queue. + * + * @author Andrew Phillips + * @see StoreTweetsController + */ +@Singleton +public class EnqueueStoresController extends HttpServlet { + /** The serialVersionUID */ + private static final long serialVersionUID = 7215420527854203714L; + + private final Set contextNames; + private final TaskQueue taskQueue; + private final String baseUrl; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject + public EnqueueStoresController(Map contexts, TaskQueue taskQueue, + @Named(PaasConstants.PROPERTY_PLATFORM_BASE_URL) String baseUrl) { + contextNames = contexts.keySet(); + this.taskQueue = taskQueue; + this.baseUrl = baseUrl; + } + + @VisibleForTesting + void enqueueStoreTweetTasks() { + for (String contextName : contextNames) { + logger.debug("enqueuing task to store tweets in blobstore '%s'", contextName); + taskQueue.add(taskQueue.getHttpRequestFactory().create(HttpRequest.builder() + .endpoint(URI.create(baseUrl + "/store/do")) + .headers(ImmutableMultimap.of("context", contextName)) + .method("GET").build())); + } + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if (!nullToEmpty(request.getHeader(PLATFORM_REQUEST_ORIGINATOR_HEADER)).equals("scheduler")) { + response.sendError(401); + } + + try { + enqueueStoreTweetTasks(); + response.setContentType(MediaType.TEXT_PLAIN); + response.getWriter().println("Done!"); + } catch (Exception e) { + logger.error(e, "Error storing tweets"); + throw new ServletException(e); + } + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java new file mode 100644 index 0000000000..725ba128f6 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -0,0 +1,130 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.controller; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Strings.nullToEmpty; +import static org.jclouds.demo.paas.RunnableHttpRequest.PLATFORM_REQUEST_ORIGINATOR_HEADER; + +import java.io.IOException; +import java.util.Map; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.MediaType; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.jclouds.logging.Logger; +import org.jclouds.rest.AuthorizationException; + +import twitter4j.Status; +import twitter4j.Twitter; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; + +/** + * Grab tweets related to me and store them into blobstores + * + * @author Adrian Cole + */ +@Singleton +public class StoreTweetsController extends HttpServlet { + + private static final class StatusToBlob implements Function { + private final BlobMap map; + + private StatusToBlob(BlobMap map) { + this.map = map; + } + + public Blob apply(Status from) { + Blob to = map.blobBuilder().name(from.getId() + "").build(); + to.setPayload(from.getText()); + to.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); + to.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, from.getUser().getScreenName()); + return to; + } + } + + /** The serialVersionUID */ + private static final long serialVersionUID = 7215420527854203714L; + + private final Map contexts; + private final Twitter client; + private final String container; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject + @VisibleForTesting + public StoreTweetsController(Map contexts, + @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container, Twitter client) { + this.container = container; + this.contexts = contexts; + this.client = client; + } + + @VisibleForTesting + public void addMyTweets(String contextName, Iterable responseList) { + BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + + contexts.keySet()); + BlobMap map = context.createBlobMap(container); + for (Status status : responseList) { + Blob blob = null; + try { + blob = new StatusToBlob(map).apply(status); + map.put(status.getId() + "", blob); + } catch (AuthorizationException e) { + throw e; + } catch (Exception e) { + logger.error(e, "Error storing tweet %s (blob[%s]) on map %s/%s", status.getId(), blob, context, container); + } + } + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if (nullToEmpty(request.getHeader(PLATFORM_REQUEST_ORIGINATOR_HEADER)).equals("taskqueue-twitter")) { + try { + String contextName = checkNotNull(request.getHeader("context"), "missing header context"); + logger.info("retrieving tweets"); + addMyTweets(contextName, client.getMentions()); + logger.debug("done storing tweets"); + response.setContentType(MediaType.TEXT_PLAIN); + response.getWriter().println("Done!"); + } catch (Exception e) { + logger.error(e, "Error storing tweets"); + throw new ServletException(e); + } + } else { + response.sendError(401); + } + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java new file mode 100644 index 0000000000..42ad65df01 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java @@ -0,0 +1,149 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.domain; + +import java.io.Serializable; + +/** + * + * @author Adrian Cole + */ +public class StoredTweetStatus implements Comparable, Serializable { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3257496189689220018L; + private final String service; + private final String host; + private final String container; + private final String id; + private final String from; + private final String tweet; + private final String status; + + @Override + public String toString() { + return "StoredTweetStatus [container=" + container + ", from=" + from + ", host=" + host + + ", id=" + id + ", service=" + service + ", status=" + status + ", tweet=" + tweet + + "]"; + } + + public StoredTweetStatus(String service, String host, String container, String id, String from, + String tweet, String status) { + this.service = service; + this.host = host; + this.container = container; + this.id = id; + this.from = from; + this.tweet = tweet; + this.status = status; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((container == null) ? 0 : container.hashCode()); + result = prime * result + ((from == null) ? 0 : from.hashCode()); + result = prime * result + ((host == null) ? 0 : host.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((service == null) ? 0 : service.hashCode()); + result = prime * result + ((tweet == null) ? 0 : tweet.hashCode()); + return result; + } + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + StoredTweetStatus other = (StoredTweetStatus) obj; + if (container == null) { + if (other.container != null) + return false; + } else if (!container.equals(other.container)) + return false; + if (from == null) { + if (other.from != null) + return false; + } else if (!from.equals(other.from)) + return false; + if (host == null) { + if (other.host != null) + return false; + } else if (!host.equals(other.host)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (service == null) { + if (other.service != null) + return false; + } else if (!service.equals(other.service)) + return false; + if (tweet == null) { + if (other.tweet != null) + return false; + } else if (!tweet.equals(other.tweet)) + return false; + return true; + } + + + public String getService() { + return service; + } + + public String getHost() { + return host; + } + + public String getContainer() { + return container; + } + + public String getFrom() { + return from; + } + + public String getTweet() { + return tweet; + } + + public String getStatus() { + return status; + } + + public int compareTo(StoredTweetStatus o) { + if (id == null) + return -1; + return (int) ((this == o) ? 0 : id.compareTo(o.id)); + } + + + public String getId() { + return id; + } + +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java new file mode 100644 index 0000000000..2a6ea0a69c --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java @@ -0,0 +1,71 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.functions; + +import static org.jclouds.util.Strings2.toStringAndClose; + +import javax.annotation.Resource; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; + +/** + * + * @author Adrian Cole + */ +public class KeyToStoredTweetStatus implements Function { + private final String host; + private final BlobMap map; + private final String service; + private final String container; + + @Resource + protected Logger logger = Logger.NULL; + + KeyToStoredTweetStatus(BlobMap map, String service, String host, String container) { + this.host = host; + this.map = map; + this.service = service; + this.container = container; + } + + public StoredTweetStatus apply(String id) { + String status; + String from; + String tweet; + try { + long start = System.currentTimeMillis(); + Blob blob = map.get(id); + status = ((System.currentTimeMillis() - start) + "ms"); + from = blob.getMetadata().getUserMetadata().get(TweetStoreConstants.SENDER_NAME); + tweet = toStringAndClose(blob.getPayload().getInput()); + } catch (Exception e) { + logger.error(e, "Error listing container %s//%s/%s", service, container, id); + status = (e.getMessage()); + tweet = ""; + from = ""; + } + return new StoredTweetStatus(service, host, container, id, from, tweet, status); + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java new file mode 100644 index 0000000000..0807c7bb46 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java @@ -0,0 +1,71 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.functions; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; +import com.google.common.collect.Iterables; + +@Singleton +public class ServiceToStoredTweetStatuses implements Function> { + + private final Map contexts; + private final String container; + + @Inject + public ServiceToStoredTweetStatuses(Map contexts, + @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container) { + this.contexts = contexts; + this.container = container; + } + + @Resource + protected Logger logger = Logger.NULL; + + public Iterable apply(String service) { + BlobStoreContext context = contexts.get(service); + String host = context.getProviderSpecificContext().getEndpoint().getHost(); + try { + BlobMap blobMap = context.createBlobMap(container); + Set blobs = blobMap.keySet(); + return Iterables.transform(blobs, new KeyToStoredTweetStatus(blobMap, service, host, + container)); + } catch (Exception e) { + StoredTweetStatus result = new StoredTweetStatus(service, host, container, null, null, + null, e.getMessage()); + logger.error(e, "Error listing service %s", service); + return Collections.singletonList(result); + } + + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TweetStoreConstants.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TweetStoreConstants.java new file mode 100644 index 0000000000..42ec480ae2 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TweetStoreConstants.java @@ -0,0 +1,34 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.reference; + +/** + * Configuration properties and constants used in TweetStore connections. + * + * @author Adrian Cole + */ +public interface TweetStoreConstants { + static final String PROPERTY_TWEETSTORE_BLOBSTORES = "jclouds.tweetstore.blobstores"; + static final String PROPERTY_TWEETSTORE_CONTAINER = "jclouds.tweetstore.container"; + /** + * Note that this has to conform to restrictions of all blobstores. for + * example, azure doesn't support periods. + */ + static final String SENDER_NAME = "sendername"; +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java new file mode 100644 index 0000000000..dc8b97915f --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java @@ -0,0 +1,31 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.reference; + +/** + * Configuration properties and constants used in Twitter connections. + * + * @author Andrew Phillips + */ +public interface TwitterConstants { + static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity"; + static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential"; + static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity"; + static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential"; +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/platform/.gitignore b/demos/tweetstore/cf-tweetstore-spring/src/main/platform/.gitignore new file mode 100644 index 0000000000..843dfe79c0 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/platform/.gitignore @@ -0,0 +1 @@ +# PaaS vendor specific files go in here \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/resources/jobs.xml b/demos/tweetstore/cf-tweetstore-spring/src/main/resources/jobs.xml new file mode 100644 index 0000000000..b740fdd52f --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/resources/jobs.xml @@ -0,0 +1,29 @@ + + + + + + enqueue-store-tweet-tasks + Enqueue 'store tweet' tasks for all contexts + org.jclouds.demo.paas.service.scheduler.HttpRequestJob + + + url + /stores/do + + + + + + + submit-recurring-job + enqueue-store-tweet-tasks + 10 + MINUTE + + + + \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/resources/quartz.properties b/demos/tweetstore/cf-tweetstore-spring/src/main/resources/quartz.properties new file mode 100644 index 0000000000..12a0fcfe91 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/resources/quartz.properties @@ -0,0 +1,28 @@ +#============================================================================ +# Configure Main Scheduler Properties +#============================================================================ + +org.quartz.scheduler.skipUpdateCheck: true + +#============================================================================ +# Configure ThreadPool +#============================================================================ + +org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool +org.quartz.threadPool.threadCount: 1 + +#============================================================================ +# Configure JobStore +#============================================================================ + +org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore + +#============================================================================ +# Configure the Job Initialization Plugin +#============================================================================ + +org.quartz.plugin.jobInitializer.class: org.jclouds.demo.paas.service.scheduler.quartz.plugins.TransactionlessXmlSchedulingDataProcessorPlugin +org.quartz.plugin.jobInitializer.fileNames: jobs.xml +org.quartz.plugin.jobInitializer.failOnFileNotFound: true +org.quartz.plugin.jobInitializer.scanInterval: 0 +#org.quartz.plugin.jobInitializer.wrapInUserTransaction: false \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/WEB-INF/web.xml b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..4ca14fb517 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,64 @@ + + + + jclouds-tweetstore + + + org.jclouds.demo.paas.config.PlatformServicesInitializer + + + + + dispatcher + org.springframework.web.servlet.DispatcherServlet + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.jclouds.demo.tweetstore.config.SpringServletConfig + + + + + + dispatcher + /store/* + + + dispatcher + /tweets/* + + + dispatcher + /stores/* + + + + index.jsp + + \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/images/cloudfoundry-logo.png b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/images/cloudfoundry-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..2df231c26c5ccc254d32fa18468c982beed2c984 GIT binary patch literal 6042 zcmV;L7iH*)P)X0ssI2-$8kU00001b5ch_0Itp) z=>Px#1ZP1_K>z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBU}7)eAyRA@u(T6cJqRk{acb!~tUq!-vR8mNt^hqH-naNBh(=&Z0)90I-{Y}0Qk`Q?A^LYJB zzvr9pIdjf?-u}L)E}fd1TJrt#-O&K-{p~$GqpezI78-5e9*OS`W{1Nel}cqY8J$k& za=9q?_4TRM>fYX7yU1>CX+^^86O{Ku~@ME6ce*J`ywp%C?e$6uXJ_aJ-Q z?e=;8aE~tS4hL6jp-POk0)30fz?d|fZT1CF@F~)*q=c<|(kds=>A_gPBPRPsVp=Q~ zxm*quuu*z?dUSL&4BXY#m5`8t5FZ&C2@4BjGMNH_ATBP>Xfy&65lO7}DWl60#+If}EKB07Or*bdgB{kdkejT|UXH0AzOjviSJ%PO z5f;)F9H448e;?)F$leI+j*bqXfF@H@Q!_I&8yg#&nwqk*vJlXS`@+IPo6UCf=1pH; z-_FiXKqB;!1MX|@VXf7jZmg0L_wv;)(!W~3TAIvzIF9j~>@nARfk&IKzb&= zjTXDoV6#lGn-Gpj4#*xTi*)8q34M=8_Lq%2jcs;JQB{^vtyQA6PN*$XlZ~afnWkrW z_!ZDp&&KvYajmNYXR4LN%-Tjd+>yK%yhJEkUV4t$bms)P|$ z+^{l*Hc1ic&G(t7HVX9#v`I`{;-=r&VI|6Z-OLncR7FG%Do(Xa{Cnh>z0Ptrq$E=5 zlhQd0QHjxp8c3wK*t41Hn;fT#W}iVNkxWyG4OXGv3NVr}a9GXPY41pFwL8kV`V_h* zWmKC?*Cf%@jUvK2t<8*4b){fNS0ql2bt;Ljrb-C(Y7!YbCB`1PsX=I1bUo&nvYM?X zC->(moaLcC+e*d+)2z$Q_LID+urXZ|Q&UTu$FZKUH#5|iDS{tdX?{AQ`)Ku8?uc~K zR?Pu4NC_getKoX08r<>9@{!+Tan4=jrq_+dn^4|M_(?YhZ+G_s$q zUO3|$k{e&oV=jvrghxIR)we8i=!Nu=CV_JWBG6ejCJz2@5p%9uKd9iWjUQB)Y^fuP zrE!d9(e!0e!^@&ZfZ>lhv=-sKr3=~d!*b5jL^haN7S`*0!~1>^)?35VqA8+Jx;nOh zS$IFV1>4KQ`VQCe)Mlrf2Xsl6Mh-U5LD(qJE{z=W>lE{~<~4Bx4@C_YFjcd>UG5Yw zjiw<-R&dk+TNX3TSo8?KFQgBbPG?qw#kMJVcxmh?)beO}??cymz}40p47$?vNi`S1 zH|`*W#y+WHFAYbOs!>iKRU;Atd*ufyq9vG2;UU*cMw^3Yv@6YawwB=PE&X!ibJyB_ z6y2H0(Q=J;Y@SF=_GYwj-u^p8xrQYh`D9tjRRiL&Y#1~zgfxJgOdwEFD?vl|VnL%Z;HuBVe&8K;{^1;}i zV)~kpc8+?U3ybyU-z4@t9z+f46i(>O61^pLPzur;!>Hpblhk1OaZK0Ff|0rQ{$ojmX!5-!^oRYMlLsU{5?!}Q*Co;d z2D6;p5!v#fu2(bq!RMsOIw&*jEg4-N(tGsQ7$}Bz3Ld%A+$L~NV9BS2uX)(N>1sP) zpe6n*s&jd0@4C?Te#s0u)PtWEfu@?RLg837tB$KKXQ}+#1>ow@fYx%R0@J3S#dQBX z?lw(sU{9L*rFze1-tw!R$7@(JgLzYQ7n-04(7HjBFAwZEN8ym9g?bCp2EvIkNjT#h z6aDFYJk_tZoZ?Sq@J+sB22U2TyO#U##o8@-bZ>?(n{RYu+G_4h-2=yT7e}>8JmZl8 zb+gb|&osi=ZX?=cuHo{C`c$vNr%(D$jpWII7MBoe33K5nGS>!VnJ&{l%oXSTi=-t?1T zico!*C2;$XjN6ZURnnx|Xe##!uZlLVau!u9NBQ`Lis0sPq1yCZK-~+WjcdGbZH{e` z>75n|X&(RKg^E_Ls)i|hR4mTnfi!(_Gd47MDRxm#m%@0Pt)%zP%e zY5A$rbIrV5k*QT-N#PN22&5~6%~2>cE=Aj~>GeakloS928lUtg~HXL9pggr8@$|IE7-in!jzdE$6pHF3@#e zbbaKwp-4n{GYseHx(hT-xtQ=D)xil8*oMnYgD*oLHm=9!`76n{f9O$qs8LX%um-aX z;h5kp#zzumWW|BR!mh>b{b_v7e}0|HQ#eOW^0C?N+XG5|c{)ov-#k{k{g0OlUh&Lh zN!7nOm$NtK)?8|?Ne#a^ou$;9vfCJ|TobDLxpQ0J3$NVdmc~=eOX&v^8&(`jaXFm) z^p`1XzesX9oRUPLwJ;`Dy2kmIbT1I4dXT^3U{XxoP$Fe`&B26DmSh%yIwoFyAR)A> zPpHyAe?0B8_!>01XSJ?4oSN25kFFg8!ZxP3Ziv6aH6fv4crIr5tQMC;iNNruO9g8V zCcSv}`tQ!>ymU5u{gITv_?I%pGouDqu6^l3?usK>KE+NCc#ypt<>o*(fk7I5e(F=c z`b^>BnBmNdVB0+mP06P;-@KNaPsGB}5R*6u{KO32LQ87*kg? zVe+BtkoiwAEN(-ZTXO4>TGkJa7d(5l=}7rV5M7fY!0dPtPFhBIPwfu!NUL3x%g@8g zo_CF$m=oUsb4#vq*&EzA#GBh?RH)dvFLYmMu~KLHy?fF--Z^ty-w!DG?Xh@+$&%AF zyn1&~Z6ABKb#y}UW7mkcFJ|kf=a{pPYvj$fdxMIpqXLDND^ueI07t5R-ZkQHJ~<0S z@yl&~YLAnpjD`V-Q`dhNKPsQveKo13cS5QC@qwt%u9bp>&PcrDox5@0wVi&s>pl)? zrwi-)Iji;rrPTJ%G5|sT=S0%WClcA>$v>P*es+KOSBW);Vk@88bM?iq<0X^x(wk=% zW$j17EYaO@WPv_s;v0Np+`@ACSWfq&C-VQE*Iy;K42euV0wYUKP`NsMJGi<&DRF#I z6E*G}&NFz%YAF#tuCJGwBU$=-Ig!9Ml#5|+jT^&yVw5;JsKr*DZ=d|{Db(lB6+Lt~ zeP4RVkVwyv5nVheZJw_5M)Tj!ByZT|Q$U#!)oit8*Y*@r`Z1omUd`XM=kmBnX|Z9^ zXvd4evXjQ&@Q+K|++t|lnJ^N_)VsYiU3Ofo>1IIA{egMwcV24hpUD|L48gPS`|S12 zMpJfO@7j00Dm&=FV**Shqcu3^n1sc8Jfg&9hgT0%$d#ym`fHDd6j>w?DgNbm5E zdNGmTC4MuscGdB`fXWeUuwyF*3*H5;*Eh<4<&!Jx-a7ry)3NR$dE37TS-<_v0l!R} z-Qnt!j`AxX`)%GIfcMqU{69JyZ#0<`ikjDLJGtrIGY5Usj|N=-)dv^XZ9g5DK9j@S z23XJUIQz`@lb?Ae?!T0}>D{x>{newb-#LHIs_0n1-2?Ei?f3uvCw@Qzx_*h}X3N4I zr~Q}G(AqvQzJOb~O1I-g%=)*_zIiYR-0ty+U$@o$cY81Q(4G0lWVRf;nvK>!AG~_h zKkKb8Lf36S^QHfFoJO(uGO)4FGierKdGo;fZSLsa+CNs?Nn5||)X#Qa0AqjLcX{J> z_w{d|I}&(ZgMhGDf4kfJ_xt=vCaqT6N9U8C-s)aMrOl%9j463~>q!Pzyl9$4<&wFZ zokp|uPhL5jPNZKK5Df|o7V~(qKZ@xbc1s4u<}sByS7>UK6FRFyV|B2U=B^1Nd(zw? zFw#_J_(6-pqOsc5RtH6Hf$hbFO>MEu^foNJ)7mFCe3`N{xXfs_A-ESkFyl_hFU1tS z{;A(@cb$9ZaBxg+9pnU;0f}W>_xo?&=lkkjZ@ho{*k{klXoJbQA>Y_d|CeXN%m4Iz z>4WnhorAY&~g7v z;8|2h{)wf3JsdR565QLW)*7O7>b4)c3U0T2df6+g5d6=AX>^8&teUN^{=eMef$z19 zTl(o(7l@S~o`~>`EuM=oGOPNXLxF=#{_SB7$Zgr@2QlB=?+@mS>u!^0mW0`YzXvWR zo6R#$$recee(c&;m(z8InX`$c0t&kG#rKbI?6P7#Hlu!r<8WB<)BD1|?2yL`<_%-m zP^)2@+J#tvX<|7ui<1$dv2H{?C^WS29L)m5p?*ygXJ(0<#4(&?<2=+E#CnsxlBTX4 znf&SDxHrzEAt&F@`^b8DuE99(aK&n~!Ktz7clX5}{T!EpE=tR&^p*{6c5`q%FAedBCur*M*QpBi^e0lm&Pr68uTSEF-GiSQR2t4LXn zDUNxnWzqo)Lssbn6r%6iCXbV;kQ0#h5zF+=H$Dee1WOfqCP1 zuf}?gKeg32cje|ITmBXJZb<2SakUpy>pU~sPAAlzNo)wtYRD{YNiA+Zn^KZ z!_K(6kb>s4(w4-cro_COg#5bX($?tQ+O*>4%#!AFnGGLiba>`8CKWcmelT$Dwv*M= zc^h7{B4NiKXL;D^Lk-S+P=+JovJUET{72T~ncf(9l4oQj?RDamtGa$9$0C)~#DO>uqjs1~5+Yi;Ih4HW)ZNI~yneKnO4Z z01O92XhlaDthKfE#*G^Q19GSm7Xgxzl7IvVahglcokmCXgIzpScXn=aKhifEg1qPBjj-qkf1l>`ILn_=Ii;s^717IT}A_9lg z6bhxiy&Zia9Vmh;zO3)nzh_?9o_X6$XuSll4S>IJq)p7l1Yj$~SPDNWzd0W=a z*23EE^dgG0ro1h?yp62KUzBISDy9o}Dgl5dAfa>&8x4AR=DoB~gHw8(;Nt!Uq{4%X zS`ZA1fO2th2lj(4p&-bQFMJ|2G?dgbR2Cc@3<+UTNDdXiqOdX93ipE300X)M8){lw zS^$Ileq>mn5_d(QrrWn~;}#fn1Z^T53knLLN*D&fKnq}y2n-B_LjVBgK`SuBTId2r z0{|WXRIn?`2v%6v&(9Ah(6Bx5;~F9S0KgzxR#t`rZlRFZ7Vw}Knap5p{6!N?h|_L3 zC17AS-~l<@LIi2lg9I3Zi=YP10S!b&MWF_*&=tH2!2=PXC^GbCp9kGnT=bs8H@S%h zUqdch)ZWl0Tpp~$oFO40unKI30KzpqXcplJ|3w_bsi6*pby`{)qy;M26{12xxCMZE zK;kdl9|&=o3j&k6K-|EMfCQ?KjEsa&keLQ%##In#4VG(bYr_{>gT6oobP=HN6{rjs z$8b9g`~V5Q0DyA@1qGoy;vPxB>v#se)fm%xhGu3ZBF zm;@xr5@3J?+zjEjgs0uO_vzynW0M}L2Re8C%}fCGUa z@JuGB|C7BJHO#kE2}8m{kPz;PSO?SaXlM%LpdbhdeZlq+j|@#zl7kcC8<7Mv!`OHr zJj{jx4+#wdBS}CtfIB(1JR$AcTdb;ex0^0X(A%*nm)AiOl)H43;p&EQs%a1M;-& U<8G{SYybcN07*qoM6N<$f|B;iGXMYp literal 0 HcmV?d00001 diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/index.jsp b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/index.jsp new file mode 100644 index 0000000000..6365c49c09 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/index.jsp @@ -0,0 +1,30 @@ +<%-- + + Licensed to jclouds, Inc. (jclouds) under one or more + contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. jclouds licenses this file + to you 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. + +--%> + + +jclouds: anyweight cloudware for java + + +

    Welcome!

    +

    Click here to see tweets about jclouds.

    +

    Powered by Cloud Foundry

    + + diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/tweets.jsp b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/tweets.jsp new file mode 100644 index 0000000000..b066bd9167 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/tweets.jsp @@ -0,0 +1,108 @@ +<%-- + + Licensed to jclouds, Inc. (jclouds) under one or more + contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. jclouds licenses this file + to you 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. + +--%> +<%@ page buffer="20kb"%> +<%@ taglib uri="http://displaytag.sf.net" prefix="display"%> + + +jclouds: anyweight cloudware for java + + + +

    Tweets in Clouds

    + + + + + + + +
    +
    + + + + + + + + +
    +
    Powered by Cloud Foundry
    + + diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollectorTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollectorTest.java new file mode 100644 index 0000000000..031bb199fc --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollectorTest.java @@ -0,0 +1,82 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.config.util; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.Map; +import java.util.Properties; + +import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; +import org.jclouds.demo.tweetstore.config.util.CredentialsCollector.Credential; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; + +/** + * Tests behavior of {@code CredentialsCollector} + * + * @author Andrew Phillips + */ +@Test(groups = "unit") +public class CredentialsCollectorTest { + private CredentialsCollector collector = new CredentialsCollector(); + + public void testEmptyProperties() { + assertTrue(collector.apply(new Properties()).isEmpty(), + "Expected returned map to be empty"); + } + + public void testNoCredentials() { + Properties properties = propertiesOf(ImmutableMap.of("not-an-identity", + "v1", "not-a-credential", "v2")); + assertTrue(collector.apply(properties).isEmpty(), + "Expected returned map to be empty"); + } + + private static Properties propertiesOf(Map entries) { + Properties properties = new Properties(); + properties.putAll(entries); + return properties; + } + + public void testNonMatchingCredentials() { + Properties properties = propertiesOf(ImmutableMap.of("non_matching.identity", "v1", + "non_matching.credential", "v2")); + assertTrue(collector.apply(properties).isEmpty(), + "Expected returned map to be empty"); + } + + public void testIncompleteCredentials() { + Properties properties = propertiesOf(ImmutableMap.of("acme.identity", "v1", + "acme-2.credential", "v2")); + assertTrue(collector.apply(properties).isEmpty(), + "Expected returned map to be empty"); + } + + public void testCredentials() { + Properties properties = propertiesOf(ImmutableMap.of("acme.identity", "v1", + "acme.credential", "v2", "acme-2.identity", "v3", + "acme-2.credential", "v4")); + assertEquals(collector.apply(properties), + ImmutableMap.of("acme", new Credential("v1", "v2"), + "acme-2", new Credential("v3", "v4"))); + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java new file mode 100644 index 0000000000..c8e1241e4a --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -0,0 +1,77 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.controller; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.testng.annotations.Test; +import org.testng.collections.Maps; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; + +/** + * Tests behavior of {@code AddTweetsController} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class AddTweetsControllerTest { + + Map createServices(String container) throws InterruptedException, + ExecutionException { + Map services = Maps.newHashMap(); + for (String name : new String[] { "1", "2" }) { + BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", + "dummy", "dummy"); + context.getAsyncBlobStore().createContainerInLocation(null, container).get(); + Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); + blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); + blob.setPayload("I love beans!"); + context.getAsyncBlobStore().putBlob(container, blob).get(); + services.put(name, context); + } + return services; + } + + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { + String container = "container"; + Map contexts = createServices(container); + + ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); + AddTweetsController controller = new AddTweetsController(contexts, function); + List list = controller.apply(ImmutableSet.of("1", "2")); + assertEquals(list.size(), 2); + assertEquals(list, ImmutableList.of(new StoredTweetStatus("1", "localhost", container, "1", + "frank", "I love beans!", null), new StoredTweetStatus("2", "localhost", container, + "1", "frank", "I love beans!", null))); + + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java new file mode 100644 index 0000000000..ff3b651175 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java @@ -0,0 +1,83 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.controller; + +import static org.easymock.EasyMock.*; + +import java.net.URI; +import java.util.Map; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.demo.paas.RunnableHttpRequest; +import org.jclouds.demo.paas.RunnableHttpRequest.Factory; +import org.jclouds.demo.paas.service.taskqueue.TaskQueue; +import org.jclouds.http.HttpRequest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; + +/** + * Tests behavior of {@code EnqueueStoresController} + * + * @author Andrew Phillips + */ +@Test(groups = "unit") +public class EnqueueStoresControllerTest { + + Map createBlobStores() { + Map contexts = ImmutableMap.of( + "test1", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), + "test2", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); + return contexts; + } + + public void testEnqueueStores() { + Map stores = createBlobStores(); + TaskQueue taskQueue = createMock(TaskQueue.class); + Factory httpRequestFactory = createMock(Factory.class); + EnqueueStoresController function = new EnqueueStoresController(stores, + taskQueue, "http://localhost:8080"); + + expect(taskQueue.getHttpRequestFactory()).andStubReturn(httpRequestFactory); + + HttpRequest storeInTest1Request = HttpRequest.builder().endpoint( + URI.create("http://localhost:8080/store/do")) + .headers(ImmutableMultimap.of("context", "test1")).method("GET").build(); + RunnableHttpRequest storeInTest1Task = null; + expect(httpRequestFactory.create(eq(storeInTest1Request))).andReturn(storeInTest1Task); + + HttpRequest storeInTest2Request = HttpRequest.builder().endpoint( + URI.create("http://localhost:8080/store/do")) + .headers(ImmutableMultimap.of("context", "test2")).method("GET").build(); + RunnableHttpRequest storeInTest2Task = null; + expect(httpRequestFactory.create(eq(storeInTest2Request))).andReturn(storeInTest2Task); + + taskQueue.add(storeInTest1Task); + expectLastCall(); + taskQueue.add(storeInTest2Task); + expectLastCall(); + replay(httpRequestFactory, taskQueue); + + function.enqueueStoreTweetTasks(); + + verify(taskQueue); + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java new file mode 100644 index 0000000000..0e82a13f25 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -0,0 +1,118 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.controller; + +import static org.easymock.EasyMock.expect; +import static org.easymock.classextension.EasyMock.createMock; +import static org.easymock.classextension.EasyMock.replay; +import static org.easymock.classextension.EasyMock.verify; +import static org.jclouds.util.Strings2.toStringAndClose; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ExecutionException; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.testng.annotations.Test; + +import twitter4j.Status; +import twitter4j.Twitter; +import twitter4j.User; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +/** + * Tests behavior of {@code StoreTweetsController} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class StoreTweetsControllerTest { + + Twitter createTwitter() { + return createMock(Twitter.class); + } + + Map createBlobStores() throws InterruptedException, ExecutionException { + Map contexts = ImmutableMap. of("test1", + new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), "test2", + new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); + for (BlobStoreContext blobstore : contexts.values()) { + blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); + } + return contexts; + } + + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { + Map stores = createBlobStores(); + StoreTweetsController function = new StoreTweetsController(stores, "favo", createTwitter()); + + User frank = createMock(User.class); + expect(frank.getScreenName()).andReturn("frank").atLeastOnce(); + + Status frankStatus = createMock(Status.class); + expect(frankStatus.getId()).andReturn(1l).atLeastOnce(); + expect(frankStatus.getUser()).andReturn(frank).atLeastOnce(); + expect(frankStatus.getText()).andReturn("I love beans!").atLeastOnce(); + + User jimmy = createMock(User.class); + expect(jimmy.getScreenName()).andReturn("jimmy").atLeastOnce(); + + Status jimmyStatus = createMock(Status.class); + expect(jimmyStatus.getId()).andReturn(2l).atLeastOnce(); + expect(jimmyStatus.getUser()).andReturn(jimmy).atLeastOnce(); + expect(jimmyStatus.getText()).andReturn("cloud is king").atLeastOnce(); + + replay(frank); + replay(frankStatus); + replay(jimmy); + replay(jimmyStatus); + + function.addMyTweets("test1", ImmutableList.of(frankStatus, jimmyStatus)); + function.addMyTweets("test2", ImmutableList.of(frankStatus, jimmyStatus)); + + verify(frank); + verify(frankStatus); + verify(jimmy); + verify(jimmyStatus); + + for (Entry entry : stores.entrySet()) { + BlobMap map = entry.getValue().createBlobMap("favo"); + Blob frankBlob = map.get("1"); + assertEquals(frankBlob.getMetadata().getName(), "1"); + assertEquals(frankBlob.getMetadata().getUserMetadata().get(TweetStoreConstants.SENDER_NAME), "frank"); + assertEquals(frankBlob.getMetadata().getContentMetadata().getContentType(), "text/plain"); + assertEquals(toStringAndClose(frankBlob.getPayload().getInput()), "I love beans!"); + + Blob jimmyBlob = map.get("2"); + assertEquals(jimmyBlob.getMetadata().getName(), "2"); + assertEquals(jimmyBlob.getMetadata().getUserMetadata().get(TweetStoreConstants.SENDER_NAME), "jimmy"); + assertEquals(jimmyBlob.getMetadata().getContentMetadata().getContentType(), "text/plain"); + assertEquals(toStringAndClose(jimmyBlob.getPayload().getInput()), "cloud is king"); + } + + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java new file mode 100644 index 0000000000..58153eb3ed --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.functions; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code KeyToStoredTweetStatus} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class KeyToStoredTweetStatusTest { + + BlobMap createMap() throws InterruptedException, ExecutionException { + BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", + "dummy"); + context.getBlobStore().createContainerInLocation(null, "test1"); + return context.createBlobMap("test1"); + } + + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { + BlobMap map = createMap(); + Blob blob = map.blobBuilder().name("1").build(); + blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); + blob.setPayload("I love beans!"); + map.put("1", blob); + String host = "localhost"; + String service = "stub"; + String container = "tweetstore"; + + KeyToStoredTweetStatus function = new KeyToStoredTweetStatus(map, service, host, container); + StoredTweetStatus result = function.apply("1"); + + StoredTweetStatus expected = new StoredTweetStatus(service, host, container, "1", "frank", + "I love beans!", null); + + assertEquals(result, expected); + + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java new file mode 100644 index 0000000000..51df008762 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -0,0 +1,74 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.functions; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.testng.annotations.Test; +import org.testng.collections.Maps; + +import com.google.common.collect.Iterables; + +/** + * Tests behavior of {@code ServiceToStoredTweetStatuses} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class ServiceToStoredTweetStatusesTest { + + Map createServices(String container) throws InterruptedException, + ExecutionException { + Map services = Maps.newHashMap(); + for (String name : new String[] { "1", "2" }) { + BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", + "dummy", "dummy"); + context.getAsyncBlobStore().createContainerInLocation(null, container).get(); + Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); + blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); + blob.setPayload("I love beans!"); + context.getAsyncBlobStore().putBlob(container, blob).get(); + services.put(name, context); + } + return services; + } + + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { + String container = "container"; + Map contexts = createServices(container); + + ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); + + assertEquals(Iterables.getLast(function.apply("1")), new StoredTweetStatus("1", "localhost", + container, "1", "frank", "I love beans!", null)); + + assertEquals(Iterables.getLast(function.apply("2")), new StoredTweetStatus("2", "localhost", + container, "1", "frank", "I love beans!", null)); + + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/CloudFoundryServer.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/CloudFoundryServer.java new file mode 100644 index 0000000000..6ecebbdfab --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/CloudFoundryServer.java @@ -0,0 +1,106 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.integration; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.io.Closeables.closeQuietly; +import static java.lang.String.format; +import static org.jclouds.demo.tweetstore.integration.util.Zips.zipDir; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import org.cloudfoundry.client.lib.CloudApplication.AppState; +import org.cloudfoundry.client.lib.CloudFoundryClient; + +/** + * Basic "server facade" functionality to deploy a WAR to Cloud Foundry. + * + * @author Andrew Phillips + */ +public class CloudFoundryServer { + private static final String CLOUD_FOUNDRY_APPLICATION_URL_SUFFIX = ".cloudfoundry.com"; + + protected CloudFoundryClient client; + protected String appName; + + public void writePropertiesAndStartServer(final String address, final String warfile, + String target, String username, String password, Properties props) throws IOException, InterruptedException, ExecutionException { + String propsfile = String.format("%1$s/WEB-INF/jclouds.properties", warfile); + System.err.println("file: " + propsfile); + storeProperties(propsfile, props); + assert new File(propsfile).exists(); + + client = new CloudFoundryClient(username, password, target); + client.login(); + appName = getAppName(address); + deploy(warfile); + client.logout(); + TimeUnit.SECONDS.sleep(10); + } + + private void deploy(String explodedWar) throws IOException { + File war = zipDir(explodedWar, format("%s-cloudfoundry.war", explodedWar)); + client.uploadApplication(appName, war); + + // adapted from https://github.com/cloudfoundry/vcap-java-client/blob/master/cloudfoundry-maven-plugin/src/main/java/org/cloudfoundry/maven/Update.java + AppState appState = client.getApplication(appName).getState(); + switch (appState) { + case STOPPED: + client.startApplication(appName); + break; + case STARTED: + client.restartApplication(appName); + break; + default: + throw new IllegalStateException(format("Unexpected application state '%s'", appState)); + } + } + + private static void storeProperties(String filename, Properties props) + throws IOException { + FileOutputStream targetFile = new FileOutputStream(filename); + try { + props.store(targetFile, "test"); + } finally { + closeQuietly(targetFile); + } + } + + private static String getAppName(String applicationUrl) { + checkArgument(applicationUrl.endsWith(CLOUD_FOUNDRY_APPLICATION_URL_SUFFIX), + "Application URL '%s' does not end in '%s'", applicationUrl, + CLOUD_FOUNDRY_APPLICATION_URL_SUFFIX); + + return applicationUrl.substring(0, + applicationUrl.length() - CLOUD_FOUNDRY_APPLICATION_URL_SUFFIX.length()); + } + + public void stop() throws Exception { + checkState(client != null, "'stop' called before 'writePropertiesAndStartServer'"); + client.login(); + client.stopApplication(appName); + client.logout(); + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java new file mode 100644 index 0000000000..18bdfe395f --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -0,0 +1,233 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.integration; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_BLOBSTORES; +import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.demo.tweetstore.config.SpringServletConfig; +import org.jclouds.demo.tweetstore.controller.StoreTweetsController; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.util.Strings2; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import twitter4j.ResponseList; +import twitter4j.Status; +import twitter4j.Twitter; +import twitter4j.TwitterException; +import twitter4j.TwitterFactory; +import twitter4j.conf.Configuration; +import twitter4j.conf.ConfigurationBuilder; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.inject.Module; + +/** + * Starts up the Google App Engine for Java Development environment and deploys an application which + * tests accesses twitter and blobstores. + * + * @author Adrian Cole + */ +@Test(groups = "live", singleThreaded = true) +public class TweetStoreLiveTest { + + CloudFoundryServer server; + private URL url; + private Map contexts; + private String container; + + private static final Iterable blobstores = + Splitter.on(',').split(System.getProperty(PROPERTY_TWEETSTORE_BLOBSTORES, + "cloudfiles-us,aws-s3,azureblob")); + private static final Properties props = new Properties(); + + @BeforeTest + void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, + TwitterException { + container = getRequiredSystemProperty(PROPERTY_TWEETSTORE_CONTAINER); + + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container); + props.setProperty(SpringServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); + + // put all identity/credential pairs into the client + addCredentialsForBlobStores(props); + + // example of an ad-hoc client configuration + addConfigurationForTwitter(props); + + final BlobStoreContextFactory factory = new BlobStoreContextFactory(); + // for testing, capture logs. + final Set wiring = ImmutableSet. of(new Log4JLoggingModule()); + this.contexts = Maps.newConcurrentMap(); + + for (String provider : blobstores) { + contexts.put(provider, factory.createContext(provider, wiring, props)); + } + + Configuration conf = new ConfigurationBuilder() + .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY)) + .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET)) + .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN)) + .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) + .build(); + Twitter client = new TwitterFactory(conf).getInstance(); + StoreTweetsController controller = new StoreTweetsController(contexts, container, client); + + ResponseList statuses = client.getMentions(); + + boolean deleted = false; + for (BlobStoreContext context : contexts.values()) { + if (context.getBlobStore().containerExists(container)) { + System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() + .getEndpoint()); + context.getBlobStore().deleteContainer(container); + deleted = true; + } + } + if (deleted) { + System.err.println("sleeping 60 seconds to allow containers to clear"); + Thread.sleep(60000); + } + for (BlobStoreContext context : contexts.values()) { + System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() + .getEndpoint()); + context.getBlobStore().createContainerInLocation(null, container); + } + if (deleted) { + System.err.println("sleeping 5 seconds to allow containers to create"); + Thread.sleep(5000); + } + + for (Entry entry : contexts.entrySet()) { + System.err.printf("filling container %s at %s%n", container, entry.getKey()); + controller.addMyTweets(entry.getKey(), statuses); + } + } + + private static String getRequiredSystemProperty(String key) { + return checkNotNull(System.getProperty(key), key); + } + + private void addConfigurationForTwitter(Properties props) { + props.setProperty(PROPERTY_TWITTER_CONSUMER_KEY, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_CONSUMER_KEY)); + props.setProperty(PROPERTY_TWITTER_CONSUMER_SECRET, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_CONSUMER_SECRET)); + props.setProperty(PROPERTY_TWITTER_ACCESSTOKEN, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_ACCESSTOKEN)); + props.setProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_ACCESSTOKEN_SECRET)); + } + + private void addCredentialsForBlobStores(Properties props) { + for (String provider : blobstores) { + props.setProperty(provider + ".identity", + getRequiredSystemProperty("test." + provider + ".identity")); + props.setProperty(provider + ".credential", + getRequiredSystemProperty("test." + provider + ".credential")); + } + } + + @BeforeTest + @Parameters({ "warfile", "cloudfoundry.address", "cloudfoundry.port", "cloudfoundry.target", "cloudfoundry.username", "cloudfoundry.password" }) + public void startDevAppServer(final String warfile, final String address, final String port, + String target, String username, String password) throws Exception { + url = new URL(String.format("http://%s:%s", address, port)); + server = new CloudFoundryServer(); + server.writePropertiesAndStartServer(address, warfile, target, username, password, props); + } + + @Test + public void shouldPass() throws InterruptedException, IOException { + InputStream i = url.openStream(); + String string = Strings2.toStringAndClose(i); + assert string.indexOf("Welcome") >= 0 : string; + } + + @Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class) + public void shouldFail() throws InterruptedException, IOException { + new URL(url, "/store/do").openStream(); + } + + @Test(dependsOnMethods = "shouldFail") + public void testPrimeContainers() throws IOException, InterruptedException { + URL gurl = new URL(url, "/store/do"); + for (String context : blobstores) { + System.out.println("storing at context: " + context); + HttpURLConnection connection = (HttpURLConnection) gurl.openConnection(); + connection.addRequestProperty("X-Platform-Originator", "taskqueue-twitter"); + connection.addRequestProperty("context", context); + InputStream i = connection.getInputStream(); + String string = Strings2.toStringAndClose(i); + assert string.indexOf("Done!") >= 0 : string; + connection.disconnect(); + } + + System.err.println("sleeping 20 seconds to allow for eventual consistency delay"); + Thread.sleep(20000); + for (BlobStoreContext context : contexts.values()) { + assert context.createInputStreamMap(container).size() > 0 : context.getProviderSpecificContext().getEndpoint(); + } + } + + @Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers") + public void testSerial() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Strings2.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } + + @Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3) + public void testParallel() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Strings2.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } + + @AfterTest + public void stopDevAppServer() throws Exception { + server.stop(); + } +} diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/util/Zips.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/util/Zips.java new file mode 100644 index 0000000000..571c9083a3 --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/util/Zips.java @@ -0,0 +1,36 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.demo.tweetstore.integration.util; + +import java.io.File; +import java.io.IOException; + +import org.codehaus.plexus.archiver.zip.ZipArchiver; + +public class Zips { + + public static File zipDir(String dirToZip, String zipFile) throws IOException { + ZipArchiver archiver = new ZipArchiver(); + archiver.addDirectory(new File(dirToZip)); + File zip = new File(zipFile); + archiver.setDestFile(zip); + archiver.createArchive(); + return zip; + } +} \ No newline at end of file diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/resources/log4j.xml b/demos/tweetstore/cf-tweetstore-spring/src/test/resources/log4j.xml new file mode 100644 index 0000000000..2e5d01fb9e --- /dev/null +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/resources/log4j.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 98a89aa68d5d55b0780c027855c2a03abf02d2f4 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 12:11:36 +0100 Subject: [PATCH 33/69] Fix DMTF section types --- .../java/org/jclouds/dmtf/ovf/OperatingSystemSection.java | 2 -- .../java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java | 2 -- .../vcloud/director/v1_5/domain/OperatingSystemSection.java | 2 ++ .../vcloud/director/v1_5/domain/VirtualHardwareSection.java | 4 +++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java index 724eb9fa21..b51014cbf2 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java @@ -23,7 +23,6 @@ import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; @@ -33,7 +32,6 @@ import com.google.common.base.Objects; * @author Adrian Cole * @author Adam Lowe */ -@XmlType(name = "OperatingSystemSection_Type") public class OperatingSystemSection extends SectionType { public static Builder builder() { diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java index 3b5dbadeec..8d6db5eb47 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java @@ -25,7 +25,6 @@ import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.cim.ResourceAllocationSettingData; import org.jclouds.dmtf.cim.VirtualSystemSettingData; @@ -46,7 +45,6 @@ import com.google.common.collect.Sets; * @author Adam Lowe * @author grkvlt@apache.org */ -@XmlType(name = "VirtualHardwareSection_Type") public class VirtualHardwareSection extends SectionType { public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java index 50fab311ce..2fe2a5649e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -44,6 +45,7 @@ import com.google.common.collect.Sets; * @author grkvlt@apache.org */ @XmlRootElement(name = "OperatingSystemSection") +@XmlType(name = "OperatingSystemSection_Type") @XmlSeeAlso({ org.jclouds.dmtf.ovf.OperatingSystemSection.class }) public class OperatingSystemSection extends org.jclouds.dmtf.ovf.OperatingSystemSection { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java index a5c216a7df..340e333caf 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -41,7 +42,8 @@ import com.google.common.collect.Sets; * * @author grkvlt@apache.org */ -@XmlRootElement(name = "VirtualHardwareSection", namespace = VCLOUD_1_5_NS) +@XmlRootElement(name = "VirtualHardwareSection") +@XmlType(name = "VirtualHardwareSection_Type") @XmlSeeAlso({ org.jclouds.dmtf.ovf.VirtualHardwareSection.class }) public class VirtualHardwareSection extends org.jclouds.dmtf.ovf.VirtualHardwareSection { From b786178a909bf5d471def602ca86ed4888359b44 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 12:12:01 +0100 Subject: [PATCH 34/69] Better error checking and logging in test tear down/clean up methods --- .../v1_5/predicates/TaskStatusEquals.java | 5 +- .../director/v1_5/predicates/TaskSuccess.java | 20 +++-- .../vcloud/director/v1_5/domain/Checks.java | 2 + .../v1_5/features/CatalogClientLiveTest.java | 36 ++++---- .../v1_5/features/MediaClientLiveTest.java | 17 ++-- .../v1_5/features/NetworkClientLiveTest.java | 11 ++- .../v1_5/features/OrgClientLiveTest.java | 17 ++-- .../v1_5/features/QueryClientLiveTest.java | 4 +- .../v1_5/features/VAppClientLiveTest.java | 84 +++++++++++-------- .../features/VAppTemplateClientLiveTest.java | 7 +- .../v1_5/features/VdcClientLiveTest.java | 8 +- .../admin/AdminCatalogClientLiveTest.java | 11 +-- .../admin/AdminVdcClientLiveTest.java | 2 +- .../features/admin/UserClientLiveTest.java | 15 ++-- .../BaseVCloudDirectorClientLiveTest.java | 41 ++++++--- 15 files changed, 172 insertions(+), 108 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java index 4ba0faca7e..73a505d891 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java @@ -18,6 +18,8 @@ */ package org.jclouds.vcloud.director.v1_5.predicates; +import static com.google.common.base.Preconditions.checkNotNull; + import java.util.Collection; import java.util.Collections; import java.util.Set; @@ -34,7 +36,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; /** - * Test a {@link Task} to see if it has succeeded. + * Test a {@link Task} status is in a particular set of {@link Task.Status statuses}. * * @author grkvlt@apache.org */ @@ -61,6 +63,7 @@ public class TaskStatusEquals implements Predicate { /** @see Predicate#apply(Object) */ @Override public boolean apply(Task task) { + checkNotNull(task, "task"); logger.trace("looking for status on task %s", task); // TODO shouldn't we see if it's already done before getting it from API server? diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java index 0380138d08..82d278a55f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java @@ -18,6 +18,10 @@ */ package org.jclouds.vcloud.director.v1_5.predicates; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.EnumSet; + import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; @@ -30,7 +34,7 @@ import org.jclouds.vcloud.director.v1_5.features.TaskClient; import com.google.common.base.Predicate; /** - * Test a {@link Task} to see if it has succeeded. + * Test a {@link Task} to see if it has {@link Task.Status#SUCCESS succeeded}. * * @author grkvlt@apache.org */ @@ -50,21 +54,19 @@ public class TaskSuccess implements Predicate { /** @see Predicate#apply(Object) */ @Override public boolean apply(Task task) { - logger.trace("looking for status on task %s", task); + checkNotNull(task, "task"); + logger.trace("looking for status on task %s", task.getOperationName()); // TODO shouldn't we see if it's already done before getting it from API server? task = taskClient.getTask(task.getHref()); // perhaps task isn't available, yet if (task == null) return false; - logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus()); - if (task.getStatus().equals(Task.Status.ERROR)) + + logger.trace("%s: looking for status %s: currently: %s", task.getOperationName(), Task.Status.SUCCESS, task.getStatus()); + if (EnumSet.of(Task.Status.ERROR, Task.Status.CANCELED, Task.Status.ABORTED).contains(task.getStatus())) { throw new VCloudDirectorException(task); - if (task.getStatus().equals(Task.Status.CANCELED)) - throw new VCloudDirectorException(task); - if (task.getStatus().equals(Task.Status.ABORTED)) - throw new VCloudDirectorException(task); - return task.getStatus().equals(Task.Status.SUCCESS); + } else return task.getStatus().equals(Task.Status.SUCCESS); } @Override diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 512173b720..8c95489a10 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -582,6 +582,8 @@ public class Checks { } public static void checkVmPendingQuestion(VmPendingQuestion question) { + assertNotNull(question, String.format(NOT_NULL_OBJ_FMT, "VmPendingQuestion")); + // Check required fields assertNotNull(question.getQuestion(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "Question")); assertNotNull(question.getQuestionId(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "QuestionId")); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index bf0284a2fc..9ee89bc11b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -25,7 +25,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCatalogItem; -import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkError; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValue; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkTask; @@ -35,9 +34,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; @@ -112,22 +109,29 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { @AfterClass(alwaysRun = true) public void tearDown() { - if (catalogItem != null) - catalogClient.deleteCatalogItem(catalogItem.getHref()); - - if (media != null) - context.getApi().getMediaClient().deleteMedia(media.getHref()); - - if (adminCatalog != null) { - adminContext.getApi().getCatalogClient().deleteCatalog(adminCatalog.getHref()); + if (catalogItem != null) { try { - catalogClient.getCatalog(catalogRef.getHref()); - fail("The Catalog should have been deleted"); - } catch (VCloudDirectorException vcde) { - checkError(vcde.getError()); - assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted"); + catalogClient.deleteCatalogItem(catalogItem.getHref()); + } catch (Exception e) { + logger.warn(e, "Error when deleting catalog item '%s'", catalogItem.getName()); } } + if (media != null) { + try { + Task delete = context.getApi().getMediaClient().deleteMedia(media.getHref()); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting media '%s'", media.getName()); + } + } + if (adminContext != null && adminCatalog != null) { + try { + adminContext.getApi().getCatalogClient().deleteCatalog(adminCatalog.getHref()); + } catch (Exception e) { + logger.warn(e, "Error when deleting catalog '%s'", adminCatalog.getName()); + } + } + // TODO wait for tasks } @Test(description = "GET /catalog/{id}") diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index 1759f04f94..de8bab0473 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -42,18 +42,15 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; import java.net.URISyntaxException; import java.util.Collections; import java.util.Set; import org.jclouds.io.Payloads; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; -import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.File; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; @@ -108,10 +105,20 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { @AfterClass(alwaysRun = true) protected void tidyUp() { if (media != null) { - assertTaskSucceeds(mediaClient.deleteMedia(media.getHref())); + try { + Task delete = mediaClient.deleteMedia(media.getHref()); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting media '%s': %s", media.getName()); + } } if (oldMedia != null) { - assertTaskSucceeds(mediaClient.deleteMedia(oldMedia.getHref())); + try { + Task delete = mediaClient.deleteMedia(oldMedia.getHref()); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting media '%s': %s", oldMedia.getName()); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 3b39a37493..2a4375bffd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -36,6 +36,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Network; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; +import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -67,10 +68,14 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @AfterClass(alwaysRun = true) - public void cleanUp() throws Exception { + public void cleanUp() { if (metadataSet) { - adminContext.getApi().getNetworkClient().getMetadataClient() - .deleteMetadataEntry(toAdminUri(networkURI), "key"); + try { + Task delete = adminContext.getApi().getNetworkClient().getMetadataClient().deleteMetadataEntry(toAdminUri(networkURI), "key"); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting metadata"); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index b40961672f..9f18039da7 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -40,6 +40,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -73,11 +74,17 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { @AfterClass(alwaysRun = true) public void cleanUp() throws Exception { if (adminMembersSet) { - adminContext.getApi().getOrgClient().getMetadataClient() - .deleteMetadataEntry(toAdminUri(orgURI), "KEY"); - - adminContext.getApi().getCatalogClient() - .deleteCatalog(catalogRef); + try { + Task delete = adminContext.getApi().getOrgClient().getMetadataClient().deleteMetadataEntry(toAdminUri(orgURI), "KEY"); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting metadata entry"); + } + try { + adminContext.getApi().getCatalogClient().deleteCatalog(catalogRef); + } catch (Exception e) { + logger.warn(e, "Error when deleting catalog'%s': %s", catalogRef); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java index fb8b0c7894..d0bb44abff 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java @@ -76,9 +76,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { @AfterClass(alwaysRun = true) public void cleanUp() throws Exception { - if (vApp != null) { - cleanUpVApp(vApp); - } + if (vApp != null) cleanUpVApp(vApp); } @Override diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java index 773d292aac..8b82c17a63 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java @@ -134,46 +134,46 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { private MetadataValue metadataValue; private String key; - private URI mediaURI; private URI testUserURI; + private boolean mediaCreated = false; + private boolean testUserCreated = false; - @Override - @BeforeClass(alwaysRun = true) - protected void setupRequiredClients() { - super.setupRequiredClients(); - + @BeforeClass(alwaysRun = true, dependsOnMethods = { "setupRequiredClients" }) + protected void setupRequiredEntities() { Set links = vdcClient.getVdc(vdcURI).getLinks(); - Predicate addMediaLink = and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA)); - - if (contains(links, addMediaLink)) { - Link addMedia = find(links, addMediaLink); - byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + + if (mediaURI == null) { + Predicate addMediaLink = and(relEquals(Link.Rel.ADD), typeEquals(VCloudDirectorMediaType.MEDIA)); - Media sourceMedia = Media.builder() - .type(VCloudDirectorMediaType.MEDIA) - .name("Test media "+random.nextInt()) - .size(iso.length) - .imageType(Media.ImageType.ISO) - .description("Test media generated by vAppClientLiveTest") - .build(); - Media media = context.getApi().getMediaClient().createMedia(addMedia.getHref(), sourceMedia); - - Link uploadLink = getFirst(getFirst(media.getFiles(), null).getLinks(), null); - context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso)); - - media = context.getApi().getMediaClient().getMedia(media.getHref()); - - if (media.getTasks().size() == 1) { - Task uploadTask = Iterables.getOnlyElement(media.getTasks()); - Checks.checkTask(uploadTask); - assertEquals(uploadTask.getStatus(), Task.Status.RUNNING); - assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask")); + if (contains(links, addMediaLink)) { + Link addMedia = find(links, addMediaLink); + byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + + Media sourceMedia = Media.builder() + .type(VCloudDirectorMediaType.MEDIA) + .name("Test media "+random.nextInt()) + .size(iso.length) + .imageType(Media.ImageType.ISO) + .description("Test media generated by vAppClientLiveTest") + .build(); + Media media = context.getApi().getMediaClient().createMedia(addMedia.getHref(), sourceMedia); + + Link uploadLink = getFirst(getFirst(media.getFiles(), null).getLinks(), null); + context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso)); + media = context.getApi().getMediaClient().getMedia(media.getHref()); + + if (media.getTasks().size() == 1) { + Task uploadTask = Iterables.getOnlyElement(media.getTasks()); + Checks.checkTask(uploadTask); + assertEquals(uploadTask.getStatus(), Task.Status.RUNNING); + assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask")); + media = context.getApi().getMediaClient().getMedia(media.getHref()); + } + + mediaURI = media.getHref(); + mediaCreated = true; } - - mediaURI = media.getHref(); - } else { - mediaURI = super.mediaURI; } if (adminContext != null) { @@ -187,8 +187,20 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest { @Override @AfterClass(alwaysRun = true) public void cleanUp() { - if (adminContext != null && mediaURI != null) { - assertTaskDoneEventually(context.getApi().getMediaClient().deleteMedia(mediaURI)); + if (adminContext != null && mediaCreated && mediaURI != null) { + try { + Task delete = context.getApi().getMediaClient().deleteMedia(mediaURI); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn("Error when deleting media: %s", e.getMessage()); + } + } + if (adminContext != null && testUserCreated && testUserURI != null) { + try { + adminContext.getApi().getUserClient().deleteUser(testUserURI); + } catch (Exception e) { + logger.warn("Error when deleting user: %s", e.getMessage()); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java index 15d43555de..5a3da1cdbe 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java @@ -93,7 +93,12 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { @AfterClass(alwaysRun = true) protected void tidyUp() { if (key != null) { - assertTaskSucceeds(vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key)); + try { + Task delete = vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error when deleting metadata entry '%s'", key); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 7ae512dc31..bf1a1cd3b7 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -118,8 +118,12 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } if (metadataSet) { - adminContext.getApi().getVdcClient().getMetadataClient() - .deleteMetadataEntry(toAdminUri(vdcURI), "key"); + try { + Task delete = adminContext.getApi().getVdcClient().getMetadataClient().deleteMetadataEntry(toAdminUri(vdcURI), "key"); + taskDoneEventually(delete); + } catch (Exception e) { + logger.warn(e, "Error deleting metadata entry"); + } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java index e8c73cc02a..c6c2d68751 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java @@ -83,13 +83,10 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest @AfterClass(alwaysRun = true) protected void tidyUp() { if (catalog != null) { - catalogClient.deleteCatalog(catalog.getHref()); - try { //TODO: predicate to retry for a short while? - catalogClient.getCatalog(catalog.getHref()); - fail("The Catalog should have been deleted"); - } catch (VCloudDirectorException vcde) { - checkError(vcde.getError()); - assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted"); + try { + catalogClient.deleteCatalog(catalog.getHref()); + } catch (Exception e) { + logger.warn(e, "Error deleting admin catalog '%s'", catalog.getName()); } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java index 6ef70f5087..205d470c85 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java @@ -75,7 +75,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { if (metadataKey != null) { try { Task task = metadataClient.deleteMetadataEntry(adminVdcUri, metadataKey); - assertTaskSucceeds(task); + taskDoneEventually(task); } catch (VCloudDirectorException e) { logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing..."); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java index 9ca09a523f..80bd1c94e0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java @@ -30,7 +30,6 @@ import static org.testng.AssertJUnit.assertFalse; import java.net.URI; import org.jclouds.rest.AuthorizationException; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; @@ -77,8 +76,8 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { if (user != null) { try { userClient.deleteUser(user.getHref()); - } catch (VCloudDirectorException e) { - // ignore; user probably already deleted + } catch (Exception e) { + logger.warn(e, "Error deleting user '%s'", user.getName()); } } } @@ -177,11 +176,13 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { assertTrue(settings.isAccountLockoutEnabled()); - for (int i=0; i immutableSet) { + protected boolean taskStatusEventually(Task task, Task.Status running, ImmutableSet immutableSet) { TaskClient taskClient = context.getApi().getTaskClient(); TaskStatusEquals predicate = new TaskStatusEquals(taskClient, running, immutableSet); RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, TASK_TIMEOUT_SECONDS * 1000L); - assertTrue(retryablePredicate.apply(task), "Task must enter status "+running); + return retryablePredicate.apply(task); } - protected void assertTaskDoneEventually(Task task) { + protected void assertTaskStatusEventually(Task task, Task.Status running, ImmutableSet immutableSet) { + assertTrue(taskStatusEventually(task, running, immutableSet), + String.format("Task '%s' must reach status %s", task.getOperationName(), running)); + } + + protected boolean taskDoneEventually(Task task) { TaskClient taskClient = context.getApi().getTaskClient(); TaskStatusEquals predicate = new TaskStatusEquals( taskClient, ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), Collections.emptySet()); RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L); - assertTrue(retryablePredicate.apply(task), "Task must be done"); + return retryablePredicate.apply(task); + } + + protected void assertTaskDoneEventually(Task task) { + assertTrue(taskDoneEventually(task), + String.format("Task '%s' must complete", task.getOperationName())); } /** @@ -407,10 +417,13 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ protected void cleanUpVAppTemplate(VAppTemplate vAppTemplate) { VAppTemplateClient vappTemplateClient = context.getApi().getVAppTemplateClient(); - - Task task = vappTemplateClient.deleteVappTemplate(vAppTemplate.getHref()); - assertTaskSucceeds(task); - } + try { + Task task = vappTemplateClient.deleteVappTemplate(vAppTemplate.getHref()); + taskDoneEventually(task); + } catch (Exception e) { + logger.warn(e, "Error deleting template '%s'", vAppTemplate.getName()); + } + } protected void cleanUpVApp(VApp vApp) { cleanUpVApp(vApp.getHref()); @@ -434,7 +447,9 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ // Otherwise, get error on delete "entity is busy completing an operation. if (vApp.getTasks() != null) { for (Task task : vApp.getTasks()) { - assertTaskDoneEventually(task); + if (!taskDoneEventually(task)) { + logger.warn("Task '%s' did not complete", task.getOperationName()); + } } } @@ -442,7 +457,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ if (vApp.getStatus().equals(Status.POWERED_ON.getValue())) { try { Task shutdownTask = vAppClient.shutdown(vAppURI); - retryTaskSuccess.apply(shutdownTask); + taskDoneEventually(shutdownTask); } catch (Exception e) { // keep going; cleanup as much as possible logger.warn(e, "Continuing cleanup after error shutting down VApp %s", vApp.getName()); @@ -454,7 +469,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ try { UndeployVAppParams params = UndeployVAppParams.builder().build(); Task undeployTask = vAppClient.undeploy(vAppURI, params); - retryTaskSuccess.apply(undeployTask); + taskDoneEventually(undeployTask); } catch (Exception e) { // keep going; cleanup as much as possible logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp.getName()); @@ -463,7 +478,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ try { Task task = vAppClient.deleteVApp(vAppURI); - assertTaskSucceeds(task); + taskDoneEventually(task); vAppNames.remove(vApp.getName()); logger.info("Deleted VApp %s", vApp.getName()); } catch (Exception e) { @@ -480,4 +495,4 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ public static String name(String prefix) { return prefix + Integer.toString(random.nextInt(Integer.MAX_VALUE)); } -} +} \ No newline at end of file From fd616ddbed040e55e02804375b229a9ff10b3839 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 13:05:04 +0100 Subject: [PATCH 35/69] Error handler check for empty payload --- .../director/v1_5/handlers/VCloudDirectorErrorHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java index 5d209865c7..49c936c914 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/handlers/VCloudDirectorErrorHandler.java @@ -55,11 +55,12 @@ public class VCloudDirectorErrorHandler implements HttpErrorHandler { : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); Exception exception = new HttpResponseException(command, response, message); - // Try to create a VCloudDirectorException from XML payload - if (response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) { + // Try to create a VCloudDirectorException from XML payload, if it exists + if (response.getPayload() != null && response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) { try { Error error = JAXB.unmarshal(InputSuppliers.of(data).getInput(), Error.class); exception = new VCloudDirectorException(error); + message = error.getMessage(); } catch (Exception e) { Throwables.propagate(e); } From 2e67af207557eb3dea0d275c379967f3c45bd627 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 14:03:34 +0100 Subject: [PATCH 36/69] Minor fixups --- .../java/org/jclouds/vcloud/director/v1_5/domain/Link.java | 3 ++- .../vcloud/director/v1_5/domain/OperatingSystemSection.java | 3 ++- .../vcloud/director/v1_5/domain/VirtualHardwareSection.java | 3 ++- .../vcloud/director/v1_5/features/VAppTemplateAsyncClient.java | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index 6aad1d69ae..447ea1f7b3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -95,6 +95,7 @@ public class Link extends Reference { @XmlEnumValue("remove") REMOVE("remove"), @XmlEnumValue("screen:acquireTicket") SCREEN_ACQUIRE_TICKET("screen:acquireTicket"), @XmlEnumValue("screen:thumbnail") SCREEN_THUMBNAIL("screen:thumbnail"), + @XmlEnumValue("syncSyslogSettings") SYNC_SYSLOG_SETTINGS("syncSyslogSettings"), @XmlEnumValue("task:cancel") TASK_CANCEL("task:cancel"), @XmlEnumValue("blockingTask") BLOCKING_TASK("blockingTask"), @XmlEnumValue("taskOwner") TASK_OWNER("taskOwner"), @@ -121,7 +122,7 @@ public class Link extends Reference { NEXT_PAGE, OVA, OVF, POWER_OFF, POWER_ON, REBOOT, RESET, SHUTDOWN, SUSPEND, PREVIOUS_PAGE, PUBLISH, RECOMPOSE, RECONNECT, REGISTER, REJECT, RELOCATE, REMOVE, REPAIR, SCREEN_ACQUIRE_TICKET, - SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER, + SCREEN_THUMBNAIL, SYNC_SYSLOG_SETTINGS, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER, TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP, UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT, UPLOAD_DEFAULT); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java index 2fe2a5649e..654fc6d0fe 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java @@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS; @@ -44,7 +45,7 @@ import com.google.common.collect.Sets; * @author Adam Lowe * @author grkvlt@apache.org */ -@XmlRootElement(name = "OperatingSystemSection") +@XmlRootElement(name = "OperatingSystemSection", namespace = OVF_NS) @XmlType(name = "OperatingSystemSection_Type") @XmlSeeAlso({ org.jclouds.dmtf.ovf.OperatingSystemSection.class }) public class OperatingSystemSection extends org.jclouds.dmtf.ovf.OperatingSystemSection { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java index 340e333caf..34961da6c0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java @@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; @@ -42,7 +43,7 @@ import com.google.common.collect.Sets; * * @author grkvlt@apache.org */ -@XmlRootElement(name = "VirtualHardwareSection") +@XmlRootElement(name = "VirtualHardwareSection", namespace = OVF_NS) @XmlType(name = "VirtualHardwareSection_Type") @XmlSeeAlso({ org.jclouds.dmtf.ovf.VirtualHardwareSection.class }) public class VirtualHardwareSection extends org.jclouds.dmtf.ovf.VirtualHardwareSection { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java index e49e85d604..1a60ee16b8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java @@ -204,7 +204,7 @@ public interface VAppTemplateAsyncClient { * @see VAppTemplateClient#getNetworkConnectionSection(URI) */ @GET - @Consumes(NETWORK_CONFIG_SECTION) + @Consumes(NETWORK_CONNECTION_SECTION) @Path("/networkConnectionSection") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) From b161fcc48e977194bbb9da6d174ef26abdabe8ad Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 10:36:47 -0400 Subject: [PATCH 37/69] Returning one logger per class in Spring JavaConfig's logger @Resource injection support --- .../demo/tweetstore/config/LoggingConfig.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java index fc3a28dc1b..e322b0551b 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/LoggingConfig.java @@ -19,6 +19,7 @@ package org.jclouds.demo.tweetstore.config; import static com.google.common.base.Preconditions.checkArgument; +import static java.lang.String.format; import static org.jclouds.logging.LoggingModules.firstOrJDKLoggingModule; import java.util.Set; @@ -66,17 +67,29 @@ abstract class LoggingConfig implements BeanFactoryAware { public Object resolveDependency(DependencyDescriptor descriptor, String beanName, Set autowiredBeanNames, TypeConverter typeConverter) throws BeansException { - Object bean; if (descriptor.getDependencyType().equals(Logger.class)) { Class requestingType = getType(beanName); - LOGGER.trace("About to create logger for bean '%s' of type '%s'", + LOGGER.trace("About to resolve logger for bean '%s' of type '%s'", beanName, requestingType); - bean = LOGGER_FACTORY.getLogger(requestingType.getName()); - LOGGER.trace("Successfully created logger."); - return bean; + Logger logger = resolveLogger(requestingType, autowiredBeanNames); + LOGGER.trace("Successfully resolved logger."); + return logger; } return super.resolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter); } + + private Logger resolveLogger(Class type, Set autowiredBeanNames) { + String loggerBeanName = format("%s#logger", type); + if (autowiredBeanNames.contains(loggerBeanName)) { + LOGGER.trace("Returning existing bean '%s'", loggerBeanName); + return (Logger) getBean(loggerBeanName); + } + + LOGGER.trace("About to create logger for type '%s'", type); + Logger logger = LOGGER_FACTORY.getLogger(type.getName()); + LOGGER.trace("Successfully created logger."); + return logger; + } } @Override From e24e8cd98c68a82727c24f6d3b1aab799e2dc48f Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 10:49:48 -0400 Subject: [PATCH 38/69] Removed an unused request attribute (originally included for testing) --- .../demo/tweetstore/controller/AddTweetsController.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java index 7254941332..5a8e6baf4b 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -34,8 +34,6 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.cloudfoundry.runtime.env.ApplicationInstanceInfo; -import org.cloudfoundry.runtime.env.CloudEnvironment; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; @@ -85,9 +83,6 @@ public class AddTweetsController extends HttpServlet implements void addMyTweetsToRequest(HttpServletRequest request) throws InterruptedException, ExecutionException, TimeoutException { request.setAttribute("tweets", apply(contexts.keySet())); - // TODO: remove me! - ApplicationInstanceInfo instanceInfo = new CloudEnvironment().getInstanceInfo(); - request.setAttribute("instanceInfo", instanceInfo); } public List apply(Set in) { From 6f6790d9d3d07d390dd9f2475cbdf4037b5dd8f3 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 11 Apr 2012 17:29:13 -0400 Subject: [PATCH 39/69] Added the Quartz listener to cf-tweetstore-spring for CRON functionality --- .../src/main/webapp/WEB-INF/web.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/WEB-INF/web.xml b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/WEB-INF/web.xml index 4ca14fb517..4b760f2a4e 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/WEB-INF/web.xml +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/webapp/WEB-INF/web.xml @@ -24,10 +24,20 @@ version="2.5"> jclouds-tweetstore + + quartz:scheduler-context-servlet-context-key + servlet-context + + + org.jclouds.demo.paas.config.PlatformServicesInitializer - + + + org.quartz.ee.servlet.QuartzInitializerListener + + dispatcher From 19c88aa1fe90f69829f5a9000f273fa79a1be2c4 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 22:48:48 +0100 Subject: [PATCH 40/69] Updated test annotations for command-line test tool --- .../director/v1_5/HttpClientLiveTest.java | 114 +++++++++++++++ .../v1_5/NonClientOperationsLiveTest.java | 136 ------------------ .../features/CatalogClientExpectTest.java | 2 +- .../v1_5/features/CatalogClientLiveTest.java | 2 +- .../v1_5/features/MediaClientExpectTest.java | 2 +- .../v1_5/features/MediaClientLiveTest.java | 2 +- .../features/NetworkClientExpectTest.java | 2 +- .../v1_5/features/NetworkClientLiveTest.java | 2 +- .../v1_5/features/OrgClientExpectTest.java | 2 +- .../v1_5/features/OrgClientLiveTest.java | 2 +- .../v1_5/features/QueryClientExpectTest.java | 2 +- .../v1_5/features/QueryClientLiveTest.java | 2 +- .../v1_5/features/TaskClientExpectTest.java | 2 +- .../v1_5/features/TaskClientLiveTest.java | 2 +- .../v1_5/features/UploadClientLiveTest.java | 2 +- .../v1_5/features/VAppClientExpectTest.java | 2 +- .../v1_5/features/VAppClientLiveTest.java | 2 +- .../VAppTemplateClientExpectTest.java | 2 +- .../features/VAppTemplateClientLiveTest.java | 2 +- .../v1_5/features/VdcClientExpectTest.java | 2 +- .../v1_5/features/VdcClientLiveTest.java | 2 +- .../admin/AdminCatalogClientExpectTest.java | 2 +- .../admin/AdminCatalogClientLiveTest.java | 2 +- .../admin/AdminNetworkClientExpectTest.java | 2 +- .../admin/AdminNetworkClientLiveTest.java | 2 +- .../admin/AdminOrgClientExpectTest.java | 2 +- .../admin/AdminOrgClientLiveTest.java | 2 +- .../admin/AdminQueryClientExpectTest.java | 2 +- .../admin/AdminQueryClientLiveTest.java | 2 +- .../admin/AdminVdcClientExpectTest.java | 2 +- .../admin/AdminVdcClientLiveTest.java | 2 +- .../features/admin/GroupClientExpectTest.java | 2 +- .../features/admin/GroupClientLiveTest.java | 2 +- .../features/admin/UserClientExpectTest.java | 2 +- .../features/admin/UserClientLiveTest.java | 8 +- .../v1_5/login/SessionClientExpectTest.java | 2 +- .../v1_5/login/SessionClientLiveTest.java | 8 +- 37 files changed, 154 insertions(+), 178 deletions(-) create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java delete mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java new file mode 100644 index 0000000000..550c337e72 --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java @@ -0,0 +1,114 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.director.v1_5; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.net.URI; + +import org.jclouds.crypto.CryptoStreams; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.util.Strings2; +import org.jclouds.vcloud.director.v1_5.domain.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; +import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; +import org.jclouds.xml.internal.JAXBParser; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Iterables; + +/** + * Tests live behavior of {@link AdminCatalogClient}. + * + * @author danikov + */ +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "HttpClientLiveTest") +public class HttpClientLiveTest extends BaseVCloudDirectorClientLiveTest { + + private JAXBParser parser = new JAXBParser("true"); + private SessionWithToken sessionWithToken; + + @Override + protected void setupRequiredClients() throws Exception { + setupCredentials(); + } + + @Test(description = "POST /login") + public void testPostLogin() throws IOException { + testLoginWithMethod("POST"); + } + + @Test(description = "GET /login") + public void testGetLogin() throws IOException { + testLoginWithMethod("GET"); + } + + private void testLoginWithMethod(final String method) throws IOException { + String user = identity.substring(0, identity.lastIndexOf('@')); + String org = identity.substring(identity.lastIndexOf('@') + 1); + String password = credential; + + String authHeader = "Basic " + CryptoStreams.base64(String.format("%s@%s:%s", checkNotNull(user), checkNotNull(org), checkNotNull(password)).getBytes("UTF-8")); + + HttpResponse response = context.getUtils().getHttpClient().invoke(HttpRequest.builder() + .method(method) + .endpoint(URI.create(endpoint + "/login")) + .headers(ImmutableMultimap.builder() + .put("Authorization", authHeader) + .put("Accept", "*/*") + .build()) + .build()); + + sessionWithToken = SessionWithToken.builder().session(session).token(response.getFirstHeaderOrNull("x-vcloud-authorization")).build(); + + assertEquals(sessionWithToken.getSession().getUser(), user); + assertEquals(sessionWithToken.getSession().getOrg(), org); + assertTrue(sessionWithToken.getSession().getLinks().size() > 0); + assertNotNull(sessionWithToken.getToken()); + + OrgList orgList = parser.fromXML(Strings2.toStringAndClose(response.getPayload().getInput()), OrgList.class); + + assertTrue(orgList.getOrgs().size() > 0, "must have orgs"); + + context.getApi().getOrgClient().getOrg(Iterables.getLast(orgList.getOrgs()).getHref()); + } + + @Test(description = "GET /schema/{schemaFileName}", dependsOnMethods = { "testPostLogin", "testGetLogin" }) + public void testGetSchema() throws IOException { + String schemafileName = "master.xsd"; + HttpResponse response = context.getUtils().getHttpClient().invoke(HttpRequest.builder() + .method("GET") + .endpoint(URI.create(endpoint + "/v1.5/schema/" + schemafileName)) + .headers(ImmutableMultimap.builder() + .put("x-vcloud-authorization", sessionWithToken.getToken()) + .put("Accept", "*/*") + .build()) + .build()); + + String schema = Strings2.toStringAndClose(response.getPayload().getInput()); + + // TODO: asserting something about the schema + } +} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java deleted file mode 100644 index 65f4aa31e5..0000000000 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/NonClientOperationsLiveTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.crypto.CryptoStreams; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; -import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; -import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Iterables; - -/** - * Tests live behavior of {@link AdminCatalogClient}. - * - * @author danikov - */ -@Test(groups = {"live", "user", "nonClient"}, singleThreaded = true, testName = "NonClientOperationsLiveTest") -public class NonClientOperationsLiveTest extends BaseVCloudDirectorClientLiveTest -{ - - private JAXBParser parser = new JAXBParser("true"); - - private SessionWithToken sessionWithToken; - - @Override - protected void setupRequiredClients() throws Exception - { - setupCredentials(); - } - - @Test(testName = "POST /login") - public void testPostLogin() throws IOException - { - testLoginWithMethod("POST"); - } - - @Test(testName = "GET /login") - public void testGetLogin() throws IOException - { - testLoginWithMethod("GET"); - } - - private void testLoginWithMethod(final String method) throws IOException - { - String user = identity.substring(0, identity.lastIndexOf('@')); - String org = identity.substring(identity.lastIndexOf('@') + 1); - String password = credential; - - String authHeader = - "Basic " - + CryptoStreams.base64(String.format("%s@%s:%s", checkNotNull(user), - checkNotNull(org), checkNotNull(password)).getBytes("UTF-8")); - - HttpResponse response = - context - .getUtils() - .getHttpClient() - .invoke( - HttpRequest - .builder() - .method(method) - .endpoint(URI.create(endpoint + "/login")) - .headers(ImmutableMultimap.of("Authorization", authHeader, "Accept", "*/*")) - .build()); - - sessionWithToken = - SessionWithToken.builder().session(session) - .token(response.getFirstHeaderOrNull("x-vcloud-authorization")).build(); - - assertEquals(sessionWithToken.getSession().getUser(), user); - assertEquals(sessionWithToken.getSession().getOrg(), org); - assertTrue(sessionWithToken.getSession().getLinks().size() > 0); - assertNotNull(sessionWithToken.getToken()); - - OrgList orgList = - parser.fromXML(Strings2.toStringAndClose(response.getPayload().getInput()), - OrgList.class); - - assertTrue(orgList.getOrgs().size() > 0, "must have orgs"); - - context.getApi().getOrgClient().getOrg(Iterables.getLast(orgList.getOrgs()).getHref()); - } - - @Test(testName = "GET /schema/{schemaFileName}", dependsOnMethods = {"testPostLogin", - "testGetLogin"}) - public void testGetSchema() throws IOException - { - String schemafileName = "master.xsd"; - HttpResponse response = - context - .getUtils() - .getHttpClient() - .invoke( - HttpRequest - .builder() - .method("GET") - .endpoint(URI.create(endpoint + "/v1.5/schema/" + schemafileName)) - .headers( - ImmutableMultimap.of("x-vcloud-authorization", - sessionWithToken.getToken(), "Accept", "*/*")).build()); - - String schema = Strings2.toStringAndClose(response.getPayload().getInput()); - - // TODO: asserting something about the schema - } -} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java index 0c5a194843..0335daf5ad 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java @@ -45,7 +45,7 @@ import com.google.common.collect.ImmutableSet; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "CatalogClientExpectTest") public class CatalogClientExpectTest extends VCloudDirectorClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index 9ee89bc11b..81c6df43e3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -61,7 +61,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CatalogClientLiveTest") public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java index 1350c0d714..be405a174c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java @@ -49,7 +49,7 @@ import com.google.common.collect.ImmutableSet; * * @author danikov */ -@Test(groups = { "unit", "user", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "MediaClientExpectTest") public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index de8bab0473..d9c461b206 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -74,7 +74,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "user", "media" }, singleThreaded = true, testName = "MediaClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "MediaClientLiveTest") public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String MEDIA = "media"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index 4fdb7fd8cb..64842221e4 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -53,7 +53,7 @@ import com.google.common.collect.ImmutableSet; * * @author danikov */ -@Test(groups = { "unit", "user", "network" }, singleThreaded = true, testName = "NetworkClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "NetworkClientExpectTest") public class NetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 2a4375bffd..7f98d5df26 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -49,7 +49,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "user", "network" }, singleThreaded = true, testName = "NetworkClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "NetworkClientLiveTest") public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String NETWORK = "network"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 2c5ddd9c24..2bcf6eb09e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -46,7 +46,7 @@ import com.google.common.collect.Iterables; * * @author Adrian Cole */ -@Test(groups = { "unit", "user", "org" }, singleThreaded = true, testName = "OrgClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "OrgClientExpectTest") public class OrgClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index 9f18039da7..6630bd1cdd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -53,7 +53,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "org" }, singleThreaded = true, testName = "OrgClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "OrgClientLiveTest") public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java index 287598d308..3aa66882be 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java @@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user", "query" }, singleThreaded = true, testName = "QueryClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "QueryClientExpectTest") public class QueryClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java index d0bb44abff..ceff2b4b55 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java @@ -61,7 +61,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "query" }, singleThreaded = true, testName = "QueryClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "QueryClientLiveTest") public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java index f62745bf1e..43c5cd0ad9 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientExpectTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user", "task" }, singleThreaded = true, testName = "TaskClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "TaskClientExpectTest") public class TaskClientExpectTest extends VCloudDirectorAdminClientExpectTest { @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java index 9b1bac8b03..3db51c5ee8 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.Iterables; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "task" }, singleThreaded = true, testName = "TaskClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "TaskClientLiveTest") public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java index 0d9e8b9050..bc05002fc0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UploadClientLiveTest.java @@ -27,7 +27,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "user", "upload" }, singleThreaded = true, testName = "UploadClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "UploadClientLiveTest") public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String UPLOAD = "upload"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java index ebf622b700..b54e0626cb 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java @@ -64,7 +64,7 @@ import com.google.common.collect.Multimaps; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "user", "vapp" }, singleThreaded = true, testName = "VAppClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "VAppClientExpectTest") public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest { private String vAppId = "vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java index 8b82c17a63..e5051647ba 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java @@ -129,7 +129,7 @@ import com.google.common.collect.Sets; * * @author grkvlt@apache.org */ -@Test(groups = { "live", "user", "vapp" }, singleThreaded = true, testName = "VAppClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VAppClientLiveTest") public class VAppClientLiveTest extends AbstractVAppClientLiveTest { private MetadataValue metadataValue; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java index 21a63f50d6..e42ea30c9e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java @@ -77,7 +77,7 @@ import com.google.common.collect.ImmutableSet; * * @author Adam Lowe */ -@Test(groups = { "unit", "user", "vapptemplate" }, testName = "VAppTemplateClientExpectTest") +@Test(groups = { "unit", "user" }, testName = "VAppTemplateClientExpectTest") public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpectTest { public VAppTemplateClientExpectTest() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java index 5a3da1cdbe..674084686f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java @@ -84,7 +84,7 @@ import com.google.common.collect.Iterables; * * @author Aled Sage */ -@Test(groups = { "live", "user", "vapptemplate" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest") public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { private String key; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index 69a9aff4db..37872d3518 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -56,7 +56,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "user", "vdc" }, singleThreaded = true, testName = "VdcClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "VdcClientExpectTest") public class VdcClientExpectTest extends VCloudDirectorAdminClientExpectTest { private URI vdcURI; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index bf1a1cd3b7..4db5a17c49 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -66,7 +66,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "user", "vdc" }, singleThreaded = true, testName = "VdcClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VdcClientLiveTest") public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String VDC = "vdc"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java index 5f2c3a71ff..4d2b5433a0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java @@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableSet; * * @author grkvlt@apache.org */ -@Test(groups = { "unit", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "CatalogClientExpectTest") public class AdminCatalogClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference catalogRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java index c6c2d68751..957f6b331d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java @@ -54,7 +54,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CatalogClientLiveTest") public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String CATALOG = "admin catalog"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java index 380f14c061..7ff0c808d3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java @@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet; * * @author danikov */ -@Test(groups = { "unit", "admin", "network"}, singleThreaded = true, testName = "AdminNetworkClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminNetworkClientExpectTest") public class AdminNetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest { Reference networkRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java index 8534ade8e1..0ecbd05541 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java @@ -51,7 +51,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "admin", "network" }, singleThreaded = true, testName = "AdminNetworkLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminNetworkLiveTest") public class AdminNetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String NETWORK = "AdminNetwork"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java index 2539fce13d..4c57f0fb25 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java @@ -43,7 +43,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "user", "org"}, singleThreaded = true, testName = "AdminOrgClientExpectTest") +@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "AdminOrgClientExpectTest") public class AdminOrgClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference orgRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java index 9224390c6b..cb8ee41e50 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java @@ -47,7 +47,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "admin", "org" }, singleThreaded = true, testName = "AdminOrgClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminOrgClientLiveTest") public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String ORG = "admin org"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java index aac0747ce1..d75ac6291a 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientExpectTest.java @@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author Aled Sage */ -@Test(groups = { "unit", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminQueryClientExpectTest") public class AdminQueryClientExpectTest extends VCloudDirectorAdminClientExpectTest { // TODO Write expect tests for all other admin-query operations diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientLiveTest.java index f6f85594bb..4813a72132 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminQueryClientLiveTest.java @@ -40,7 +40,7 @@ import org.testng.annotations.Test; * * @author Aled Sage */ -@Test(groups = { "live", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminQueryClientLiveTest") public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { /* diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java index b34dad2d43..fa19328b73 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientExpectTest.java @@ -35,7 +35,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminVdcClientExpectTest") public class AdminVdcClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference vdcRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java index 205d470c85..577a7b0f21 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcClientLiveTest.java @@ -45,7 +45,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminVdcClientLiveTest") public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String VDC = "admin vdc"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java index 96e49a777b..ec8c6cdc4d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientExpectTest.java @@ -34,7 +34,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "admin", "group"}, singleThreaded = true, testName = "GroupClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "GroupClientExpectTest") public class GroupClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference groupRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java index 8617396c83..3490762c10 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java @@ -38,7 +38,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "live", "admin", "group" }, singleThreaded = true, testName = "GroupClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "GroupClientLiveTest") public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String GROUP = "admin group"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java index 6fae492e4c..2e56895584 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientExpectTest.java @@ -37,7 +37,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "admin", "adminUser"}, singleThreaded = true, testName = "UserClientExpectTest") +@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "UserClientExpectTest") public class UserClientExpectTest extends VCloudDirectorAdminClientExpectTest { private Reference orgRef = Reference.builder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java index 80bd1c94e0..81ac32bcb0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java @@ -48,7 +48,7 @@ import com.google.common.collect.Iterables; * * @author danikov */ -@Test(groups = { "live", "admin", "adminUser" }, singleThreaded = true, testName = "UserClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "UserClientLiveTest") public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String USER = "admin user"; @@ -89,16 +89,14 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { checkUser(newUser); } - @Test(description = "GET /admin/user/{id}", - dependsOnMethods = { "testCreateUser" }) + @Test(description = "GET /admin/user/{id}", dependsOnMethods = { "testCreateUser" }) public void testGetUser() { user = userClient.getUser(user.getHref()); checkUser(user); } - @Test(description = "PUT /admin/user/{id}", - dependsOnMethods = { "testGetUser" }) + @Test(description = "PUT /admin/user/{id}", dependsOnMethods = { "testGetUser" }) public void testUpdateUser() { User oldUser = user.toBuilder().build(); User newUser = user.toBuilder() diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java index 0c31ba2885..d905f77b5b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java @@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author Adrian Cole */ -@Test(groups = "unit", testName = "SessionClientExpectTest") +@Test(groups = { "unit", "user" }, testName = "SessionClientExpectTest") // only needed as SessionClient is not registered in rest.properties @RegisterContext(sync = SessionClient.class, async = SessionAsyncClient.class) public class SessionClientExpectTest extends BaseRestClientExpectTest { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java index 31662c7269..c4c5c7f2ee 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java @@ -48,7 +48,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Listeners(FormatApiResultsListener.class) -@Test(groups = { "live", "user", "login" }, testName = "SessionClientLiveTest") +@Test(groups = { "live", "user" }, testName = "SessionClientLiveTest") public class SessionClientLiveTest extends BaseVersionedServiceLiveTest { public SessionClientLiveTest() { provider = "vcloud-director"; @@ -73,7 +73,7 @@ public class SessionClientLiveTest extends BaseVersionedServiceLiveTest { private SessionClient client; private SessionWithToken sessionWithToken; - @Test(testName = "POST /sessions") + @Test(description = "POST /sessions") public void testLogin() { String user = identity.substring(0, identity.lastIndexOf('@')); String org = identity.substring(identity.lastIndexOf('@') + 1); @@ -86,13 +86,13 @@ public class SessionClientLiveTest extends BaseVersionedServiceLiveTest { assertNotNull(sessionWithToken.getToken()); } - @Test(testName = "GET /session", dependsOnMethods = "testLogin") + @Test(description = "GET /session", dependsOnMethods = "testLogin") public void testGetSession() { assertEquals(client.getSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken()), sessionWithToken.getSession()); } - @Test(testName = "DELETE /session", dependsOnMethods = "testGetSession") + @Test(description = "DELETE /session", dependsOnMethods = "testGetSession") public void testLogout() { client.logoutSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken()); } From 5de8e7bad6222a3fe93d276900a3d191a05ac249 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 11 Apr 2012 22:49:16 +0100 Subject: [PATCH 41/69] Various minor changes to fix live tests --- .../v1_5/VCloudDirectorLiveTestConstants.java | 8 +++++++ .../vcloud/director/v1_5/domain/Checks.java | 4 ++-- .../v1_5/features/MediaClientLiveTest.java | 22 ++++++++++--------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java index a7e7236134..c1ee58df0e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java @@ -51,6 +51,8 @@ public class VCloudDirectorLiveTestConstants { public static final String OBJ_FIELD_GTE_1 = "ERR-108: %s field %s must be greater than to equal to 0 (%d)"; + public static final String OBJ_FIELD_GTE = "ERR-108: %s field %s must be greater than to equal to %d (%d)"; + public static final String GETTER_RETURNS_SAME_OBJ = "ERR-109: %s should return the same %s as %s (%s, %s)"; public static final String OBJ_FIELD_UPDATABLE = "ERR-110: %s field %s should be updatable"; @@ -88,7 +90,13 @@ public class VCloudDirectorLiveTestConstants { public static final String NOT_EMPTY_STRING_FMT = "ERR-126: The %s field must not be an empty string"; public static final String MATCHES_STRING_FMT = "ERR-127: The %s field must match the pattern \"%s\" (%s)"; + + public static final String OBJ_FIELD_LIST_EMPTY = "ERR-128: %s %s must be empty (%d members)"; + public static final String OBJ_FIELD_LIST_SIZE_EQ = "ERR-129: %s %s must have %d members (%d members)"; + + public static final String OBJ_FIELD_LIST_SIZE_GE = "ERR-130: %s %s must have at least %d members (%d members)"; + /* Error codes from 300 to 399 reflect entities and their links and relationship errors. */ public static final String ENTITY_NON_NULL = "ERR-301: The %s entity must not be null"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 8c95489a10..b637c229ef 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -729,7 +729,7 @@ public class Checks { // NOTE transport cannot be checked if (hardware.getItems() != null) { for (ResourceAllocationSettingData item : hardware.getItems()) { - checkResourceAllocationSettingData((RasdItem) item); + checkResourceAllocationSettingData(item); } } @@ -760,7 +760,7 @@ public class Checks { // assertNotNull(virtualSystem.getVirtualSystemType(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "virtualSystemType")); } - public static void checkResourceAllocationSettingData(RasdItem item) { + public static void checkResourceAllocationSettingData(ResourceAllocationSettingData item) { // TODO } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index d9c461b206..4776eb7557 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -32,6 +32,8 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_LIST_SIZE_EQ; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_LIST_SIZE_GE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY; @@ -62,10 +64,12 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; +import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -144,29 +148,27 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMediaFor(MEDIA, media); assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files")); - assertTrue(media.getFiles().size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "files.size()", "1", - media.getFiles().size())); + assertTrue(media.getFiles().size() == 1, String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size())); File uploadFile = getFirst(media.getFiles(), null); assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first")); assertEquals(uploadFile.getSize(), new Long(iso.length)); - assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", - sourceMedia.getSize(), uploadFile.getSize())); + assertEquals(uploadFile.getSize().longValue(), sourceMedia.getSize(), + String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", sourceMedia.getSize(), uploadFile.getSize())); Set links = uploadFile.getLinks(); assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links")); - assertTrue(links.size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "uploadfile.links.size()", "1", - links.size())); - Link uploadLink = getFirst(links, null); - assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); + assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size())); + assertTrue(Iterables.all(links, Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT), LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))), + String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); + Link uploadLink = Iterables.find(links, LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT)); context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso)); media = mediaClient.getMedia(media.getHref()); - if (media.getTasks().size() == 1) { Task uploadTask = Iterables.getOnlyElement(media.getTasks()); Checks.checkTask(uploadTask); - assertEquals(uploadTask.getStatus(), "running"); + assertEquals(uploadTask.getStatus(), Task.Status.RUNNING); assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask")); media = mediaClient.getMedia(media.getHref()); } From 23cb01f9777f21befc37b3c053bd7bfe6f637e4d Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 4 Apr 2012 22:32:48 -0700 Subject: [PATCH 42/69] refactor PropertiesBuilder and related types into ApiMetadata and ProviderMetadata, and update all usage --- .../taskdefs/compute/ComputeTaskUtils.java | 6 +- apis/atmos/pom.xml | 3 +- .../org/jclouds/atmos/AtmosApiMetadata.java | 77 ++- .../jclouds/atmos/AtmosContextBuilder.java | 32 +- .../atmos/blobstore/AtmosAsyncBlobStore.java | 2 +- .../atmos/blobstore/AtmosBlobStore.java | 2 +- .../jclouds/atmos/AtmosApiMetadataTest.java | 7 +- .../jclouds/atmos/AtmosAsyncClientTest.java | 14 +- .../blobstore/AtmosBlobRequestSignerTest.java | 13 +- .../config/AtmosBlobStoreModuleTest.java | 15 +- .../integration/AtmosBlobSignerLiveTest.java | 4 +- .../AtmosContainerIntegrationLiveTest.java | 4 +- .../integration/AtmosContainerLiveTest.java | 4 +- ...tmosInputStreamMapIntegrationLiveTest.java | 5 +- .../integration/AtmosIntegrationLiveTest.java | 4 +- .../blobstore/integration/AtmosLiveTest.java | 3 + .../AtmosMapIntegrationLiveTest.java | 4 +- .../AtmosServiceIntegrationLiveTest.java | 4 +- .../integration/AtmosTestInitializer.java | 47 -- .../atmos/filters/SignRequestTest.java | 18 +- .../org/jclouds/byon/BYONApiMetadata.java | 69 ++- .../BYONComputeServiceContextBuilder.java | 16 +- .../jclouds/byon/BYONPropertiesBuilder.java | 48 -- .../org/jclouds/byon/BYONApiMetadataTest.java | 7 +- .../byon/BYONComputeServiceLiveTest.java | 9 +- .../jclouds/byon/BYONComputeServiceTest.java | 20 +- apis/cloudfiles/pom.xml | 2 - .../cloudfiles/CloudFilesApiMetadata.java | 78 ++- .../cloudfiles/CloudFilesContextBuilder.java | 31 +- .../blobstore/CloudFilesAsyncBlobStore.java | 2 +- .../blobstore/CloudFilesBlobStore.java | 2 +- .../cloudfiles/CloudFilesApiMetadataTest.java | 7 +- .../cloudfiles/CloudFilesClientLiveTest.java | 4 + .../CloudFilesBlobIntegrationLiveTest.java | 4 + .../integration/CloudFilesBlobLiveTest.java | 4 +- .../CloudFilesBlobMapIntegrationLiveTest.java | 4 +- .../CloudFilesBlobSignerLiveTest.java | 4 +- ...loudFilesContainerIntegrationLiveTest.java | 4 +- .../CloudFilesContainerLiveTest.java | 4 +- ...ilesInputStreamMapIntegrationLiveTest.java | 4 +- .../CloudFilesServiceIntegrationLiveTest.java | 4 +- .../CloudLoadBalancersApiMetadata.java | 69 ++- .../CloudLoadBalancersContextBuilder.java | 19 +- .../CloudLoadBalancersPropertiesBuilder.java | 44 -- .../CloudLoadBalancersApiMetadataTest.java | 7 +- .../features/LoadBalancerClientLiveTest.java | 4 +- ...BaseCloudLoadBalancersAsyncClientTest.java | 25 +- .../BaseCloudLoadBalancersClientLiveTest.java | 32 +- .../cloudservers/CloudServersApiMetadata.java | 68 ++- .../CloudServersContextBuilder.java | 32 +- .../CloudServersPropertiesBuilder.java | 45 -- .../CloudServersApiMetadataTest.java | 7 +- .../CloudServersAsyncClientTest.java | 11 +- .../CloudServersClientLiveTest.java | 28 +- .../CloudServersComputeServiceLiveTest.java | 16 +- .../BaseCloudServersRestClientExpectTest.java | 14 +- .../cloudsigma/CloudSigmaApiMetadata.java | 72 ++- .../cloudsigma/CloudSigmaContextBuilder.java | 16 +- .../CloudSigmaPropertiesBuilder.java | 50 -- .../cloudsigma/CloudSigmaApiMetadataTest.java | 7 +- .../cloudsigma/CloudSigmaAsyncClientTest.java | 23 +- .../cloudsigma/CloudSigmaClientLiveTest.java | 52 +- .../CloudSigmaComputeServiceLiveTest.java | 10 +- .../cloudstack/CloudStackApiMetadata.java | 81 ++- .../jclouds/cloudstack/CloudStackContext.java | 3 +- .../cloudstack/CloudStackContextBuilder.java | 26 +- .../CloudStackPropertiesBuilder.java | 48 -- .../config/CloudStackProperties.java | 4 +- .../internal/CloudStackContextImpl.java | 1 - .../jclouds/cloudstack/util/ApiKeyPairs.java | 43 +- .../cloudstack/CloudStackApiMetadataTest.java | 7 +- ...oudStackComputeServiceAdapterLiveTest.java | 23 +- .../CloudStackComputeServiceLiveTest.java | 12 +- .../compute/CloudStackExperimentLiveTest.java | 16 +- .../BaseCloudStackAsyncClientTest.java | 20 +- .../BaseCloudStackClientLiveTest.java | 62 +-- .../BaseCloudStackRestClientExpectTest.java | 17 +- .../features/FirewallClientLiveTest.java | 4 +- .../features/GlobalUserClientLiveTest.java | 10 +- .../features/LoadBalancerClientLiveTest.java | 4 +- .../features/NetworkClientLiveTest.java | 6 +- .../features/OfferingClientLiveTest.java | 4 +- .../features/SessionClientLiveTest.java | 2 + .../features/TemplateClientLiveTest.java | 2 +- .../features/ZoneAsyncClientTest.java | 2 +- .../cloudstack/filters/QuerySignerTest.java | 37 +- ...ticNATVirtualMachineInNetworkLiveTest.java | 2 +- .../cloudwatch/CloudWatchApiMetadata.java | 83 ++- .../cloudwatch/CloudWatchContextBuilder.java | 27 +- .../CloudWatchPropertiesBuilder.java | 53 -- .../cloudwatch/CloudWatchApiMetadataTest.java | 5 +- .../cloudwatch/CloudWatchAsyncClientTest.java | 15 +- .../cloudwatch/CloudWatchClientLiveTest.java | 35 +- .../deltacloud/DeltacloudApiMetadata.java | 73 +-- .../deltacloud/DeltacloudContextBuilder.java | 16 +- .../DeltacloudPropertiesBuilder.java | 46 -- .../deltacloud/DeltacloudApiMetadataTest.java | 7 +- .../deltacloud/DeltacloudAsyncClientTest.java | 36 +- .../deltacloud/DeltacloudClientLiveTest.java | 7 +- .../ReadOnlyDeltacloudClientLiveTest.java | 39 +- .../DeltacloudComputeServiceLiveTest.java | 12 +- .../DeltacloudTemplateBuilderLiveTest.java | 9 +- ...DeltacloudRedirectionRetryHandlerTest.java | 25 +- .../java/org/jclouds/ec2/EC2ApiMetadata.java | 119 ++-- .../org/jclouds/ec2/EC2ContextBuilder.java | 31 +- .../org/jclouds/ec2/EC2PropertiesBuilder.java | 59 -- .../ec2/compute/EC2ComputeService.java | 2 +- .../compute/EC2ComputeServiceContext.java} | 23 +- .../EC2ComputeServiceDependenciesModule.java | 1 + .../EC2ComputeServiceContextImpl.java | 52 ++ .../ec2/config/EC2RestClientModule.java | 4 - ...icationArchitecturesEC2ClientLiveTest.java | 22 +- .../jclouds/ec2/EBSBootEC2ClientLiveTest.java | 23 +- .../org/jclouds/ec2/EC2ApiMetadataTest.java | 8 +- .../compute/EC2ComputeServiceLiveTest.java | 13 +- .../compute/EC2TemplateBuilderLiveTest.java | 17 +- .../compute/TestCanRecreateGroupLiveTest.java | 27 +- ...ailabilityZoneAndRegionClientLiveTest.java | 31 +- .../ec2/services/BaseEC2AsyncClientTest.java | 29 +- .../ElasticBlockStoreClientLiveTest.java | 33 +- .../ElasticIPAddressClientLiveTest.java | 31 +- .../ec2/services/InstanceClientLiveTest.java | 34 +- .../ec2/services/KeyPairClientLiveTest.java | 34 +- .../services/SecurityGroupClientLiveTest.java | 25 +- .../ec2/services/WindowsClientLiveTest.java | 49 +- .../elasticstack/ElasticStackApiMetadata.java | 78 ++- .../ElasticStackContextBuilder.java | 18 +- .../ElasticStackPropertiesBuilder.java | 50 -- .../ElasticStackApiMetadataTest.java | 7 +- .../ElasticStackAsyncClientTest.java | 67 ++- .../ElasticStackClientLiveTest.java | 35 +- .../ElasticStackComputeServiceLiveTest.java | 10 +- .../eucalyptus/EucalyptusApiMetadata.java | 61 ++- .../EucalyptusPropertiesBuilder.java | 50 -- .../eucalyptus/EucalyptusApiMetadataTest.java | 7 +- .../EucalyptusComputeServiceLiveTest.java | 6 +- apis/filesystem/pom.xml | 6 +- .../filesystem/FilesystemApiMetadata.java | 66 ++- .../filesystem/FilesystemAsyncBlobStore.java | 2 +- .../FilesystemBlobStoreContextBuilder.java | 24 +- .../FilesystemBlobStorePropertiesBuilder.java | 56 -- .../FilesystemBlobStoreContextModule.java | 1 + .../config/FilesystemBlobStoreModule.java | 12 +- .../filesystem/FilesystemApiMetadataTest.java | 7 +- .../FilesystemAsyncBlobStoreTest.java | 14 +- ...ilesystemBlobIntegrationTestDisabled.java} | 20 +- ...systemBlobMapIntegrationTestDisabled.java} | 17 +- ...stemContainerIntegrationTestDisabled.java} | 17 +- ...nputStreamMapIntegrationTestDisabled.java} | 17 +- ...systemServiceIntegrationTestDisabled.java} | 17 +- .../FilesystemTestInitializer.java | 61 --- .../openstack/nova/NovaApiMetadata.java | 70 ++- .../openstack/nova/NovaContextBuilder.java | 32 +- .../openstack/nova/NovaApiMetadataTest.java | 7 +- .../openstack/nova/NovaAsyncClientTest.java | 28 +- .../openstack/nova/NovaClientLiveTest.java | 28 +- .../compute/NovaComputeServiceLiveTest.java | 17 +- .../nova/ec2/NovaEC2ApiMetadata.java | 79 ++- .../nova/ec2/NovaEC2ContextBuilder.java | 17 +- .../nova/ec2/NovaEC2PropertiesBuilder.java | 64 --- .../nova/ec2/NovaEC2ApiMetadataTest.java | 7 +- .../NovaEC2ComputeServiceLiveTest.java | 5 +- .../openstack/nova/v1_1/NovaApiMetadata.java | 107 ++-- .../nova/v1_1/NovaContextBuilder.java | 25 +- .../nova/v1_1/NovaPropertiesBuilder.java | 63 --- .../nova/v1_1/compute/NovaComputeService.java | 2 +- .../nova/v1_1/NovaApiMetadataTest.java | 7 +- .../NovaComputeServiceAdapterExpectTest.java | 1 + .../compute/NovaComputeServiceLiveTest.java | 8 +- .../extensions/FloatingIPClientLiveTest.java | 18 +- .../extensions/KeyPairClientLiveTest.java | 12 +- .../SecurityGroupClientLiveTest.java | 12 +- .../features/ExtensionClientLiveTest.java | 4 +- .../v1_1/features/FlavorClientLiveTest.java | 8 +- .../v1_1/features/ImageClientLiveTest.java | 8 +- .../v1_1/features/ServerClientLiveTest.java | 4 +- .../BaseNovaAsyncClientExpectTest.java | 12 +- .../v1_1/internal/BaseNovaClientLiveTest.java | 32 +- ...seNovaComputeServiceContextExpectTest.java | 24 +- .../BaseNovaComputeServiceExpectTest.java | 2 +- .../v1_1/internal/BaseNovaExpectTest.java | 2 +- apis/s3/pom.xml | 2 - .../java/org/jclouds/s3/S3ApiMetadata.java | 125 +++-- .../java/org/jclouds/s3/S3ContextBuilder.java | 14 +- .../org/jclouds/s3/S3PropertiesBuilder.java | 64 --- .../s3/blobstore/S3AsyncBlobStore.java | 2 +- .../org/jclouds/s3/blobstore/S3BlobStore.java | 2 +- .../s3/blobstore/S3BlobStoreContext.java | 22 +- .../internal/S3BlobStoreContextImpl.java | 61 +++ .../org/jclouds/s3/S3ApiMetadataTest.java | 8 +- .../java/org/jclouds/s3/S3ClientLiveTest.java | 4 + .../BindAsHostPrefixIfConfiguredTest.java | 4 +- .../S3BlobIntegrationLiveTest.java | 8 +- .../blobstore/integration/S3BlobLiveTest.java | 7 +- .../S3BlobMapIntegrationLiveTest.java | 7 +- .../integration/S3BlobSignerLiveTest.java | 7 +- .../S3ContainerIntegrationLiveTest.java | 7 +- .../integration/S3ContainerLiveTest.java | 7 +- .../S3InputStreamMapIntegrationLiveTest.java | 7 +- .../S3ServiceIntegrationLiveTest.java | 7 +- .../integration/S3TestInitializer.java | 50 -- .../s3/internal/BaseS3AsyncClientTest.java | 27 +- .../s3/internal/BaseS3ClientExpectTest.java | 27 +- .../jclouds/s3/services/BucketsLiveTest.java | 5 + apis/swift/pom.xml | 2 - .../openstack/swift/SwiftApiMetadata.java | 95 +++- .../openstack/swift/SwiftContextBuilder.java | 33 +- .../swift/SwiftPropertiesBuilder.java | 53 -- .../swift/blobstore/SwiftAsyncBlobStore.java | 2 +- .../swift/blobstore/SwiftBlobStore.java | 2 +- .../swift/CommonSwiftClientLiveTest.java | 2 +- .../swift/CommonSwiftClientTest.java | 14 +- .../openstack/swift/SwiftApiMetadataTest.java | 7 +- .../openstack/swift/SwiftClientLiveTest.java | 6 +- .../SwiftBlobIntegrationLiveTest.java | 4 +- .../integration/SwiftBlobLiveTest.java | 4 +- .../SwiftBlobMapIntegrationLiveTest.java | 4 +- .../integration/SwiftBlobSignerLiveTest.java | 4 +- .../SwiftContainerIntegrationLiveTest.java | 4 +- .../integration/SwiftContainerLiveTest.java | 4 +- ...wiftInputStreamMapIntegrationLiveTest.java | 4 +- .../SwiftServiceIntegrationLiveTest.java | 4 +- .../integration/SwiftTestInitializer.java | 48 -- .../org/jclouds/vcloud/VCloudApiMetadata.java | 90 +++- .../jclouds/vcloud/VCloudContextBuilder.java | 38 +- .../vcloud/VCloudPropertiesBuilder.java | 63 --- .../jclouds/vcloud/VCloudApiMetadataTest.java | 2 +- .../vcloud/VCloudVersionsAsyncClientTest.java | 15 +- .../BindCatalogItemToXmlPayloadTest.java | 5 +- .../BindDeployVAppParamsToXmlPayloadTest.java | 5 +- ...ateVAppTemplateParamsToXmlPayloadTest.java | 5 +- ...workConnectionSectionToXmlPayloadTest.java | 5 +- ...indUndeployVAppParamsToXmlPayloadTest.java | 5 +- .../BaseVCloudComputeServiceExpectTest.java | 21 +- .../compute/VCloudComputeServiceLiveTest.java | 9 +- .../functions/VAppToNodeMetadataTest.java | 7 +- .../features/CatalogClientLiveTest.java | 2 +- .../internal/BaseVCloudAsyncClientTest.java | 21 +- .../internal/BaseVCloudClientLiveTest.java | 45 +- .../internal/VCloudLoginAsyncClientTest.java | 16 +- apis/walrus/pom.xml | 2 - .../org/jclouds/walrus/WalrusApiMetadata.java | 66 ++- .../jclouds/walrus/WalrusContextBuilder.java | 20 +- .../walrus/WalrusPropertiesBuilder.java | 48 -- .../jclouds/walrus/WalrusApiMetadataTest.java | 7 +- .../walrus/WalrusAsyncClientTestDisabled.java | 47 -- .../WalrusBlobIntegrationLiveTest.java | 6 +- .../walrus/blobstore/WalrusBlobLiveTest.java | 6 +- .../WalrusBlobMapIntegrationLiveTest.java | 6 +- .../blobstore/WalrusBlobSignerLiveTest.java | 6 +- .../WalrusContainerIntegrationLiveTest.java | 6 +- .../blobstore/WalrusContainerLiveTest.java | 6 +- ...lrusInputStreamMapIntegrationLiveTest.java | 6 +- .../WalrusServiceIntegrationLiveTest.java | 6 +- .../java/__providerName__AsyncClientTest.java | 4 +- blobstore/pom.xml | 5 - .../org/jclouds/blobstore/AsyncBlobStore.java | 2 +- .../java/org/jclouds/blobstore/BlobStore.java | 2 +- .../blobstore/BlobStoreApiMetadata.java | 20 + .../jclouds/blobstore/BlobStoreContext.java | 13 +- .../blobstore/BlobStoreContextBuilder.java | 49 +- .../blobstore/BlobStoreContextFactory.java | 172 +++--- .../blobstore/TransientApiMetadata.java | 64 ++- .../blobstore/TransientAsyncBlobStore.java | 2 +- .../TransientBlobStoreContextBuilder.java | 20 +- .../TransientBlobStorePropertiesBuilder.java | 52 -- .../blobstore/config/TransientBlobStore.java | 3 +- .../TransientBlobStoreContextModule.java | 1 + .../internal/BaseAsyncBlobStore.java | 6 +- .../blobstore/internal/BaseBlobStore.java | 6 +- .../internal/BaseBlobStoreApiMetadata.java | 65 +++ .../internal/BlobStoreContextImpl.java | 5 +- .../blobstore/util/BlobStoreUtils.java | 7 +- .../org/jclouds/blobstore/BlobStoresTest.java | 10 +- .../blobstore/TransientApiMetadataTest.java | 7 +- .../TransientBlobRequestSignerTest.java | 24 +- .../binders/BindBlobToMultipartFormTest.java | 5 +- ...ndUserMetadataToHeadersWithPrefixTest.java | 6 +- .../blobstore/functions/BlobNameTest.java | 6 +- .../TransientBlobIntegrationTest.java | 4 +- .../TransientBlobMapIntegrationTest.java | 4 +- .../TransientContainerIntegrationTest.java | 5 +- ...ransientInputStreamMapIntegrationTest.java | 4 +- .../TransientServiceIntegrationTest.java | 4 +- .../internal/BaseBlobIntegrationTest.java | 2 +- .../internal/BaseBlobMapIntegrationTest.java | 8 +- .../BaseBlobStoreIntegrationTest.java | 42 +- .../BaseInputStreamMapIntegrationTest.java | 4 +- .../internal/BaseMapIntegrationTest.java | 4 +- .../internal/BaseTestInitializer.java | 93 ---- .../blobstore/internal/BaseBlobMapTest.java | 6 +- .../BaseBlobStoreApiMetadataTest.java | 34 ++ .../internal/BiggerThanPageSizeTest.java | 4 +- .../jclouds/aws/filters/FormSignerTest.java | 30 +- .../org/jclouds/aws/util/AWSUtilsTest.java | 8 +- .../storage/AzureStorageContextBuilder.java | 32 +- .../SharedKeyLiteAuthenticationTest.java | 54 +- .../OpenStackAuthAsyncClientTest.java | 17 +- .../BaseKeystoneRestClientExpectTest.java | 2 +- .../v2_0/internal/KeystoneFixture.java | 2 +- .../TerremarkVCloudContextBuilder.java | 18 +- .../TerremarkVCloudComputeService.java | 1 + ...markVCloudComputeServiceContextModule.java | 1 + .../internal/TerremarkVCloudApiMetadata.java | 83 +++ .../vcloud_0_8/TerremarkClientLiveTest.java | 98 ++-- .../VAppTemplatesInOrgsLiveTest.java | 38 +- .../internal/BaseTerremarkClientLiveTest.java | 48 +- .../TerremarkVCloudLoginAsyncClientTest.java | 19 +- ...erremarkVCloudVersionsAsyncClientTest.java | 14 +- .../org/jclouds/compute/ComputeService.java | 2 +- .../compute/ComputeServiceApiMetadata.java | 17 +- .../compute/ComputeServiceContext.java | 8 +- .../compute/ComputeServiceContextBuilder.java | 76 +-- .../compute/ComputeServiceContextFactory.java | 173 +++--- ...tandaloneComputeServiceContextBuilder.java | 34 +- .../StandaloneComputeServiceContextSpec.java | 53 -- .../compute/internal/BaseComputeService.java | 6 +- .../BaseComputeServiceApiMetadata.java | 63 +++ .../internal/ComputeServiceContextImpl.java | 5 +- .../jclouds/compute/stub/StubApiMetadata.java | 61 ++- .../StubComputeServiceContextBuilder.java | 20 +- .../compute/util/ComputeServiceUtils.java | 7 +- .../org/jclouds/compute/ComputeTestUtils.java | 20 +- .../StubComputeServiceIntegrationTest.java | 21 +- .../StubTemplateBuilderIntegrationTest.java | 12 +- .../config/ComputeServicePropertiesTest.java | 10 +- .../BaseComputeServiceApiMetadataTest.java | 34 ++ .../BaseComputeServiceContextLiveTest.java} | 59 +- .../BaseComputeServiceLiveTest.java | 101 ++-- .../BaseTemplateBuilderLiveTest.java | 53 +- .../predicates/ImagePredicatesTest.java | 5 +- .../compute/stub/StubApiMetadataTest.java | 7 +- .../java/org/jclouds/apis/ApiMetadata.java | 195 ++++++- .../java/org/jclouds/apis/ApiPredicates.java | 74 ++- core/src/main/java/org/jclouds/apis/Apis.java | 55 +- .../org/jclouds/apis/BaseApiMetadata.java | 211 -------- .../apis/internal/BaseApiMetadata.java | 509 ++++++++++++++++++ .../jclouds/providers/ProviderMetadata.java | 153 +++--- .../jclouds/providers/ProviderPredicates.java | 93 +++- .../java/org/jclouds/providers/Providers.java | 96 ++-- .../{ => internal}/BaseProviderMetadata.java | 198 ++++--- .../rest/AnonymousProviderMetadata.java | 79 +++ .../rest/AnonymousRestApiMetadata.java | 78 +++ .../org/jclouds/rest/BackedByRestContext.java | 15 +- .../main/java/org/jclouds/rest/Providers.java | 135 +---- .../org/jclouds/rest/RestApiMetadata.java | 17 +- .../java/org/jclouds/rest/RestContext.java | 4 +- .../org/jclouds/rest/RestContextBuilder.java | 293 +--------- .../org/jclouds/rest/RestContextFactory.java | 470 +++------------- .../org/jclouds/rest/RestContextSpec.java | 99 ---- .../rest/internal/BaseRestApiMetadata.java | 74 +++ .../jclouds/rest/internal/ContextBuilder.java | 465 ++++++++++++++++ core/src/main/resources/rest.properties | 9 - .../test/java/org/jclouds/apis/ApisTest.java | 18 +- .../apis/JcloudsTestBlobStoreApiMetadata.java | 58 +- .../apis/JcloudsTestComputeApiMetadata.java | 56 +- ...loudsTestYetAnotherComputeApiMetadata.java | 55 +- .../{ => internal}/BaseApiMetadataTest.java | 18 +- .../internal/BaseRestApiMetadataTest.java | 38 +- .../java/org/jclouds/http/BaseJettyTest.java | 22 +- .../http/IntegrationTestClientExpectTest.java | 11 +- .../handlers/RedirectionRetryHandlerTest.java | 2 +- .../JcloudsTestBlobStoreProviderMetadata.java | 54 +- .../JcloudsTestComputeProviderMetadata.java | 56 +- ...TestYetAnotherComputeProviderMetadata.java | 56 +- .../org/jclouds/providers/ProvidersTest.java | 86 +-- .../BaseProviderMetadataTest.java | 17 +- .../jclouds/rest/BaseRestClientLiveTest.java | 81 --- .../jclouds/rest/InputParamValidatorTest.java | 14 +- .../jclouds/rest/RestContextFactoryTest.java | 292 ---------- .../BaseAsyncClientTest.java} | 51 +- .../rest/internal/BaseContextLiveTest.java | 143 +++++ .../BaseRestClientExpectTest.java | 87 +-- .../{ => internal}/BaseRestClientTest.java | 2 +- .../ContextBuilderTest.java} | 56 +- .../internal/RestAnnotationProcessorTest.java | 39 +- .../java/org/jclouds/util/ProvidersTest.java | 6 +- .../aws/elb/AWSELBPropertiesBuilder.java | 76 --- .../aws/elb/AWSELBProviderMetadata.java | 99 +++- .../aws/elb/AWSELBAsyncClientTest.java | 10 +- .../jclouds/aws/elb/AWSELBClientLiveTest.java | 4 +- .../jclouds/aws/elb/AWSELBProviderTest.java | 6 +- .../AWSELBLoadBalancerServiceLiveTest.java | 6 +- .../CarrenzaVCloudDirectorContextBuilder.java | 16 +- ...rrenzaVCloudDirectorPropertiesBuilder.java | 47 -- ...arrenzaVCloudDirectorProviderMetadata.java | 85 ++- ...udDirectorNonClientOperationsLiveTest.java | 4 +- .../CarrenzaVCloudDirectorProviderTest.java | 2 +- ...VCloudDirectorTemplateBuilderLiveTest.java | 86 ++- .../java/org/jclouds/elb/ELBApiMetadata.java | 84 ++- .../org/jclouds/elb/ELBContextBuilder.java | 18 +- .../org/jclouds/elb/ELBApiMetadataTest.java | 8 +- .../org/jclouds/elb/ELBAsyncClientTest.java | 18 +- .../org/jclouds/elb/ELBClientLiveTest.java | 28 +- .../ELBLoadBalancerServiceLiveTest.java | 5 +- .../org/jclouds/glesys/GleSYSApiMetadata.java | 75 ++- .../jclouds/glesys/GleSYSContextBuilder.java | 17 +- .../glesys/GleSYSPropertiesBuilder.java | 61 --- .../glesys/GleSYSProviderMetadata.java | 82 ++- .../jclouds/glesys/GleSYSProviderTest.java | 2 +- .../compute/GleSYSComputeServiceLiveTest.java | 16 +- .../compute/GleSYSExperimentExpectTest.java | 2 +- .../compute/GleSYSExperimentLiveTest.java | 28 +- .../GleSYSTemplateBuilderLiveTest.java | 9 +- .../BaseGleSYSComputeServiceExpectTest.java | 19 +- .../features/ArchiveClientExpectTest.java | 2 +- .../features/ArchiveClientLiveTest.java | 16 +- .../features/DomainClientExpectTest.java | 2 +- .../glesys/features/DomainClientLiveTest.java | 10 +- .../features/EmailClientExpectTest.java | 2 +- .../glesys/features/EmailClientLiveTest.java | 14 +- .../glesys/features/IpClientExpectTest.java | 2 +- .../glesys/features/IpClientLiveTest.java | 6 +- .../features/ServerClientExpectTest.java | 2 +- .../glesys/features/ServerClientLiveTest.java | 10 +- .../internal/BaseGleSYSAsyncClientTest.java | 17 +- .../internal/BaseGleSYSClientLiveTest.java | 40 +- .../servers/OpSourceServersApiMetadata.java | 88 +++ .../OpSourceServersContextBuilder.java | 23 +- .../OpSourceServersPropertiesBuilder.java | 47 -- .../services/org.jclouds.apis.ApiMetadata | 1 + ...SourceServersClientExperimentLiveTest.java | 2 +- .../features/AccountClientLiveTest.java | 6 +- .../features/ServerClientLiveTest.java | 8 +- .../features/ServerImageClientLiveTest.java | 2 +- .../BaseOpSourceServersClientLiveTest.java | 33 +- ...seOpSourceServersRestClientExpectTest.java | 8 +- .../vpdc/SavvisSymphonyVPDCApiMetadata.java | 50 -- .../SavvisSymphonyVPDCProviderMetadata.java | 99 ---- .../jclouds/savvis/vpdc/VPDCApiMetadata.java | 92 ++++ .../savvis/vpdc/VPDCContextBuilder.java | 20 +- .../savvis/vpdc/VPDCProviderMetadata.java | 123 +++++ .../org.jclouds.providers.ProviderMetadata | 2 +- ...roviderTest.java => VPDCProviderTest.java} | 14 +- .../VPDCComputeServiceLiveTestDisabled.java | 9 +- .../compute/VPDCTemplateBuilderLiveTest.java | 8 +- .../features/BaseVPDCAsyncClientTest.java | 15 +- .../vpdc/features/BaseVPDCClientLiveTest.java | 41 +- .../vpdc/features/BrowsingClientLiveTest.java | 4 +- .../vpdc/features/FirewallClientLiveTest.java | 11 +- .../ServiceManagementClientLiveTest.java | 4 +- .../vpdc/features/VMClientLiveTest.java | 8 +- .../v1_5/VCloudDirectorApiMetadata.java | 95 +++- .../v1_5/VCloudDirectorContextBuilder.java | 34 +- .../director/v1_5/HttpClientLiveTest.java | 3 +- .../v1_5/VCloudDirectorApiMetadataTest.java | 2 +- .../v1_5/features/CatalogClientLiveTest.java | 2 +- .../BaseVCloudDirectorClientLiveTest.java | 45 +- .../BaseVCloudDirectorExpectTest.java | 10 +- .../VCloudDirectorAdminClientExpectTest.java | 8 +- .../v1_5/login/SessionClientExpectTest.java | 15 +- .../v1_5/login/SessionClientLiveTest.java | 63 +-- .../virtualbox/VirtualBoxApiMetadata.java | 107 +++- .../virtualbox/VirtualBoxContextBuilder.java | 14 +- .../VirtualBoxPropertiesBuilder.java | 85 --- ...VirtualBoxComputeServiceContextModule.java | 12 +- .../BaseVirtualBoxClientLiveTest.java | 41 +- .../virtualbox/PreseedCfgServerTest.java | 2 +- .../virtualbox/VirtualBoxApiMetadataTest.java | 2 +- ...romIMachineIfNotAlreadyExistsLiveTest.java | 4 +- .../functions/CreateAndInstallVmLiveTest.java | 4 +- ...hineFromIsoIfNotAlreadyExistsLiveTest.java | 4 +- .../GuestAdditionsInstallerLiveTest.java | 4 +- .../IMachinePredicatesLiveTest.java | 4 +- .../util/MachineControllerLiveTest.java | 4 +- .../virtualbox/util/MachineUtilsLiveTest.java | 4 +- .../loadbalancer/LoadBalancerService.java | 2 +- .../LoadBalancerServiceApiMetadata.java | 20 + .../LoadBalancerServiceContext.java | 10 +- .../LoadBalancerServiceContextBuilder.java | 53 +- .../LoadBalancerServiceContextFactory.java | 173 +++--- .../internal/BaseLoadBalancerService.java | 6 +- .../BaseLoadBalancerServiceApiMetadata.java | 63 +++ ...BaseLoadBalancerServiceContextBuilder.java | 31 +- .../LoadBalancerServiceContextImpl.java | 7 +- .../BaseLoadBalancerServiceLiveTest.java | 101 ++-- ...aseLoadBalancerServiceApiMetadataTest.java | 34 ++ .../AWSCloudWatchPropertiesBuilder.java | 73 --- .../AWSCloudWatchProviderMetadata.java | 100 ++-- .../cloudwatch/AWSCloudWatchProviderTest.java | 6 +- .../jclouds/aws/ec2/AWSEC2ApiMetadata.java | 63 ++- .../jclouds/aws/ec2/AWSEC2ContextBuilder.java | 40 +- .../aws/ec2/AWSEC2PropertiesBuilder.java | 77 --- .../aws/ec2/AWSEC2ProviderMetadata.java | 92 +++- .../aws/ec2/compute/AWSEC2ComputeService.java | 2 +- .../compute/AWSEC2ComputeServiceContext.java} | 28 +- .../AWSEC2ComputeServiceContextModule.java | 1 - ...WSEC2ComputeServiceDependenciesModule.java | 1 + .../AWSEC2ComputeServiceContextImpl.java | 51 ++ .../aws/ec2/AWSEC2ContextBuilderTest.java | 6 +- .../jclouds/aws/ec2/AWSEC2ProviderTest.java | 2 +- .../compute/AWSEC2ComputeServiceLiveTest.java | 12 +- .../AWSEC2TemplateBuilderLiveTest.java | 48 +- .../aws/ec2/services/AMIClientLiveTest.java | 43 +- .../ec2/services/AWSAMIClientLiveTest.java | 28 +- .../services/AWSInstanceClientLiveTest.java | 35 +- .../services/AWSKeyPairClientLiveTest.java | 51 +- .../AWSSecurityGroupClientLiveTest.java | 5 +- .../services/BaseAWSEC2AsyncClientTest.java | 12 +- .../services/MonitoringClientLiveTest.java | 29 +- .../PlacementGroupClientLiveTest.java | 34 +- .../services/SpotInstanceClientLiveTest.java | 31 +- .../aws/ec2/services/TagClientLiveTest.java | 45 +- .../org/jclouds/aws/s3/AWSS3ApiMetadata.java | 55 +- .../jclouds/aws/s3/AWSS3ContextBuilder.java | 18 +- .../aws/s3/AWSS3PropertiesBuilder.java | 67 --- .../jclouds/aws/s3/AWSS3ProviderMetadata.java | 92 +++- .../aws/s3/blobstore/AWSS3AsyncBlobStore.java | 2 +- .../aws/s3/blobstore/AWSS3BlobStore.java | 2 +- .../s3/blobstore/AWSS3BlobStoreContext.java | 21 +- .../internal/AWSS3BlobStoreContextImpl.java | 62 +++ .../aws/s3/config/AWSS3RestClientModule.java | 5 +- .../jclouds/aws/s3/AWSS3AsyncClientTest.java | 14 +- .../jclouds/aws/s3/AWSS3ClientExpectTest.java | 16 +- .../jclouds/aws/s3/AWSS3ClientLiveTest.java | 5 +- .../org/jclouds/aws/s3/AWSS3ProviderTest.java | 2 +- .../AWSS3BlobIntegrationLiveTest.java | 4 +- .../integration/AWSS3BlobLiveTest.java | 4 +- .../AWSS3BlobMapIntegrationLiveTest.java | 4 +- .../integration/AWSS3BlobSignerLiveTest.java | 4 +- .../AWSS3ContainerIntegrationLiveTest.java | 4 +- .../integration/AWSS3ContainerLiveTest.java | 4 +- ...WSS3InputStreamMapIntegrationLiveTest.java | 4 +- .../AWSS3ServiceIntegrationLiveTest.java | 4 + .../integration/AWSS3TestInitializer.java | 52 -- ...SequentialMultipartUploadStrategyTest.java | 6 +- .../internal/BaseAWSS3ClientExpectTest.java | 36 +- providers/azureblob/pom.xml | 2 - .../azureblob/AzureBlobApiMetadata.java | 77 ++- .../azureblob/AzureBlobContextBuilder.java | 34 +- .../azureblob/AzureBlobPropertiesBuilder.java | 50 -- .../azureblob/AzureBlobProviderMetadata.java | 66 ++- .../blobstore/AzureAsyncBlobStore.java | 2 +- .../azureblob/blobstore/AzureBlobStore.java | 2 +- .../azureblob/AzureBlobAsyncClientTest.java | 11 +- .../azureblob/AzureBlobClientLiveTest.java | 159 +++--- .../azureblob/AzureBlobProviderTest.java | 2 +- .../BindAzureBlobMetadataToRequestTest.java | 12 +- .../blobstore/AzureBlobRequestSignerTest.java | 13 +- .../config/AzureBlobStoreModuleTest.java | 23 +- ...AzureBlobContainerIntegrationLiveTest.java | 4 +- .../AzureBlobContainerLiveTest.java | 4 +- ...BlobInputStreamMapIntegrationLiveTest.java | 4 +- .../AzureBlobIntegrationLiveTest.java | 4 +- .../integration/AzureBlobLiveTest.java | 4 +- .../AzureBlobMapIntegrationLiveTest.java | 4 +- .../AzureBlobServiceIntegrationLiveTest.java | 3 + .../integration/AzureBlobSignerLiveTest.java | 4 +- .../integration/AzureBlobTestInitializer.java | 48 -- .../BluelockVCloudZone01ContextBuilder.java | 27 +- ...BluelockVCloudZone01PropertiesBuilder.java | 49 -- .../BluelockVCloudZone01ProviderMetadata.java | 81 ++- .../BluelockVCloudZone01ProviderTest.java | 2 +- ...ckVCloudZone01TemplateBuilderLiveTest.java | 25 +- providers/cloudfiles-uk/pom.xml | 2 - .../CloudFilesUKPropertiesBuilder.java | 48 -- .../CloudFilesUKProviderMetadata.java | 76 ++- .../CloudFilesUKClientLiveTest.java | 8 +- .../cloudfiles/CloudFilesUKProviderTest.java | 2 +- .../CloudFilesUKBlobIntegrationLiveTest.java | 4 +- .../integration/CloudFilesUKBlobLiveTest.java | 3 + ...loudFilesUKBlobMapIntegrationLiveTest.java | 3 + .../CloudFilesUKBlobSignerLiveTest.java | 3 + ...udFilesUKContainerIntegrationLiveTest.java | 3 + .../CloudFilesUKContainerLiveTest.java | 3 + ...esUKInputStreamMapIntegrationLiveTest.java | 3 + ...loudFilesUKServiceIntegrationLiveTest.java | 4 + .../CloudFilesUKTestInitializer.java | 32 -- .../CloudFilesUSPropertiesBuilder.java | 48 -- .../CloudFilesUSProviderMetadata.java | 75 ++- .../CloudFilesUSClientLiveTest.java | 4 +- .../cloudfiles/CloudFilesUSProviderTest.java | 2 +- .../CloudFilesUSBlobIntegrationLiveTest.java | 5 +- .../integration/CloudFilesUSBlobLiveTest.java | 4 +- ...loudFilesUSBlobMapIntegrationLiveTest.java | 4 +- .../CloudFilesUSBlobSignerLiveTest.java | 4 +- ...udFilesUSContainerIntegrationLiveTest.java | 4 +- .../CloudFilesUSContainerLiveTest.java | 4 +- ...esUSInputStreamMapIntegrationLiveTest.java | 4 +- ...loudFilesUSServiceIntegrationLiveTest.java | 3 + .../CloudFilesUSTestInitializer.java | 32 -- ...CloudLoadBalancersUKPropertiesBuilder.java | 62 --- .../CloudLoadBalancersUKProviderMetadata.java | 87 ++- ...BalancersUKLoadBalancerClientLiveTest.java | 2 +- .../CloudLoadBalancersUKProviderTest.java | 2 +- ...CloudLoadBalancersUSPropertiesBuilder.java | 66 --- .../CloudLoadBalancersUSProviderMetadata.java | 95 +++- ...BalancersUSLoadBalancerClientLiveTest.java | 2 +- .../CloudLoadBalancersUSProviderTest.java | 2 +- providers/cloudonestorage/pom.xml | 2 - .../CloudOneStoragePropertiesBuilder.java | 53 -- .../CloudOneStorageProviderMetadata.java | 70 ++- .../CloudOneStorageProviderTest.java | 2 +- ...loudOneStorageBlobIntegrationLiveTest.java | 3 + .../CloudOneStorageBlobLiveTest.java | 3 + ...dOneStorageBlobMapIntegrationLiveTest.java | 3 + .../CloudOneStorageBlobSignerLiveTest.java | 3 + ...neStorageContainerIntegrationLiveTest.java | 3 + .../CloudOneStorageContainerLiveTest.java | 3 + ...rageInputStreamMapIntegrationLiveTest.java | 3 + ...dOneStorageServiceIntegrationLiveTest.java | 4 + .../CloudServersUKPropertiesBuilder.java | 46 -- .../CloudServersUKProviderMetadata.java | 73 ++- .../CloudServersUKProviderTest.java | 2 +- ...CloudServersUKTemplateBuilderLiveTest.java | 9 +- .../CloudServersUSPropertiesBuilder.java | 46 -- .../CloudServersUSProviderMetadata.java | 74 ++- .../CloudServersUSProviderTest.java | 2 +- ...CloudServersUSTemplateBuilderLiveTest.java | 9 +- .../CloudSigmaLasVegasPropertiesBuilder.java | 44 -- .../CloudSigmaLasVegasProviderMetadata.java | 70 ++- .../CloudSigmaLasVegasProviderTest.java | 2 +- ...dSigmaLasVegasTemplateBuilderLiveTest.java | 9 +- .../CloudSigmaZurichPropertiesBuilder.java | 44 -- .../CloudSigmaZurichProviderMetadata.java | 70 ++- .../CloudSigmaZurichProviderTest.java | 2 +- ...oudSigmaZurichTemplateBuilderLiveTest.java | 9 +- ...HostsPeer1LosAngelesPropertiesBuilder.java | 48 -- ...cHostsPeer1LosAngelesProviderMetadata.java | 74 ++- ...asticHostsPeer1LosAngelesProviderTest.java | 2 +- ...eer1LosAngelesTemplateBuilderLiveTest.java | 9 +- ...ostsBlueSquareLondonPropertiesBuilder.java | 48 -- ...HostsBlueSquareLondonProviderMetadata.java | 71 ++- ...sticHostsBlueSquareLondonProviderTest.java | 2 +- ...ueSquareLondonTemplateBuilderLiveTest.java | 9 +- ...sticHostsPeer1LondonPropertiesBuilder.java | 48 -- ...asticHostsPeer1LondonProviderMetadata.java | 72 ++- .../ElasticHostsPeer1LondonProviderTest.java | 2 +- ...stsPeer1LondonTemplateBuilderLiveTest.java | 9 +- ...HostsPeer1SanAntonioPropertiesBuilder.java | 48 -- ...cHostsPeer1SanAntonioProviderMetadata.java | 71 ++- ...asticHostsPeer1SanAntonioProviderTest.java | 2 +- ...eer1SanAntonioTemplateBuilderLiveTest.java | 9 +- ...ticHostsPeer1TorontoPropertiesBuilder.java | 48 -- ...sticHostsPeer1TorontoProviderMetadata.java | 69 ++- .../ElasticHostsPeer1TorontoProviderTest.java | 2 +- ...tsPeer1TorontoTemplateBuilderLiveTest.java | 9 +- .../EucalyptusPartnerCloudContextBuilder.java | 16 +- ...lyptusPartnerCloudEC2ProviderMetadata.java | 91 ++-- ...calyptusPartnerCloudPropertiesBuilder.java | 53 -- ...EucalyptusPartnerCloudEC2ProviderTest.java | 2 +- ...loudEucalyptusTemplateBuilderLiveTest.java | 8 +- providers/eucalyptus-partnercloud-s3/pom.xml | 2 - ...alyptusPartnerCloudS3ProviderMetadata.java | 90 ++-- ...usPartnerCloudWalrusPropertiesBuilder.java | 53 -- .../EucalyptusPartnerCloudS3ProviderTest.java | 2 +- ...nerCloudWalrusAsyncClientTestDisabled.java | 36 -- ...nerCloudWalrusBlobIntegrationLiveTest.java | 3 + ...alyptusPartnerCloudWalrusBlobLiveTest.java | 5 +- ...CloudWalrusBlobMapIntegrationLiveTest.java | 6 +- ...sPartnerCloudWalrusBlobSignerLiveTest.java | 5 +- ...oudWalrusContainerIntegrationLiveTest.java | 5 +- ...usPartnerCloudWalrusContainerLiveTest.java | 3 + ...lrusInputStreamMapIntegrationLiveTest.java | 8 +- ...CloudWalrusServiceIntegrationLiveTest.java | 5 + ...ptusPartnerCloudWalrusTestInitializer.java | 35 -- ...o2CloudJohannesburg1PropertiesBuilder.java | 48 -- ...Go2CloudJohannesburg1ProviderMetadata.java | 72 ++- ...annesburg1ComputeServiceContextModule.java | 38 -- .../Go2CloudJohannesburg1ProviderTest.java | 2 +- ...dJohannesburg1TemplateBuilderLiveTest.java | 25 +- .../org/jclouds/gogrid/GoGridApiMetadata.java | 74 ++- .../jclouds/gogrid/GoGridContextBuilder.java | 30 +- .../gogrid/GoGridPropertiesBuilder.java | 59 -- .../gogrid/GoGridProviderMetadata.java | 82 ++- .../gogrid/compute/GoGridComputeService.java | 2 +- .../gogrid/GoGridLiveTestDisabled.java | 30 +- .../jclouds/gogrid/GoGridProviderTest.java | 2 +- .../compute/GoGridComputeServiceLiveTest.java | 10 +- .../GoGridTemplateBuilderLiveTest.java | 9 +- .../services/BaseGoGridAsyncClientTest.java | 14 +- .../services/BaseGoGridClientLiveTest.java | 32 +- .../BaseGoGridRestClientExpectTest.java | 2 +- .../services/GridImageAsyncClientTest.java | 8 +- .../services/GridIpAsyncClientTest.java | 4 +- .../services/GridJobAsyncClientTest.java | 6 +- .../GridLoadBalancerAsyncClientTest.java | 12 +- .../services/GridServerAsyncClientTest.java | 18 +- ...nHouseDataElementVCloudContextBuilder.java | 20 +- ...useDataElementVCloudPropertiesBuilder.java | 48 -- ...ouseDataElementVCloudProviderMetadata.java | 81 ++- ...eenHouseDataElementVCloudProviderTest.java | 2 +- ...aElementVCloudTemplateBuilderLiveTest.java | 9 +- .../compute/HPCloudComputeApiMetadata.java | 60 --- .../compute/HPCloudComputeContextBuilder.java | 16 +- .../HPCloudComputePropertiesBuilder.java | 57 -- .../HPCloudComputeProviderMetadata.java | 89 ++- .../compute/HPCloudComputeProviderTest.java | 5 +- ...HPCloudComputeTemplateBuilderLiveTest.java | 8 +- providers/hpcloud-objectstorage/pom.xml | 5 - .../HPCloudObjectStorageApiMetadata.java | 102 +++- .../HPCloudObjectStorageContextBuilder.java | 34 +- ...HPCloudObjectStoragePropertiesBuilder.java | 58 -- .../HPCloudObjectStorageProviderMetadata.java | 79 ++- .../HPCloudObjectStorageAsyncBlobStore.java | 2 +- .../HPCloudObjectStorageBlobStore.java | 2 +- .../HPCloudObjectStorageClientLiveTest.java | 6 +- .../HPCloudObjectStorageProviderTest.java | 2 +- ...dObjectStorageBlobIntegrationLiveTest.java | 4 + .../HPCloudObjectStorageBlobLiveTest.java | 3 + ...jectStorageBlobMapIntegrationLiveTest.java | 3 + ...PCloudObjectStorageBlobSignerLiveTest.java | 3 + ...ctStorageContainerIntegrationLiveTest.java | 3 + ...HPCloudObjectStorageContainerLiveTest.java | 3 + ...rageInputStreamMapIntegrationLiveTest.java | 3 + ...jectStorageServiceIntegrationLiveTest.java | 4 + .../HPCloudObjectStorageTestInitializer.java | 32 -- .../HPCloudObjectStorageExpectTest.java | 22 +- .../internal/KeystoneFixture.java | 2 +- .../NinefoldComputeContextBuilder.java | 44 -- .../NinefoldComputePropertiesBuilder.java | 51 -- .../NinefoldComputeProviderMetadata.java | 93 ++-- .../NinefoldComputeServiceContextModule.java | 29 - .../compute/NinefoldComputeProviderTest.java | 2 +- ...inefoldComputeTemplateBuilderLiveTest.java | 9 +- providers/ninefold-storage/pom.xml | 2 - .../NinefoldStoragePropertiesBuilder.java | 53 -- .../NinefoldStorageProviderMetadata.java | 70 ++- .../storage/NinefoldStorageProviderTest.java | 2 +- ...inefoldStorageBlobIntegrationLiveTest.java | 3 + .../NinefoldStorageBlobLiveTest.java | 3 + ...foldStorageBlobMapIntegrationLiveTest.java | 3 + .../NinefoldStorageBlobSignerLiveTest.java | 3 + ...ldStorageContainerIntegrationLiveTest.java | 3 + .../NinefoldStorageContainerLiveTest.java | 3 + ...rageInputStreamMapIntegrationLiveTest.java | 3 + ...foldStorageServiceIntegrationLiveTest.java | 5 + .../NinefoldStorageTestInitializer.java | 33 -- .../OpenHostingEast1ContextBuilder.java | 44 -- .../OpenHostingEast1PropertiesBuilder.java | 48 -- .../OpenHostingEast1ProviderMetadata.java | 74 ++- .../OpenHostingEast1ProviderTest.java | 2 +- ...enHostingEast1TemplateBuilderLiveTest.java | 29 +- .../miro/RimuHostingApiMetadata.java | 78 ++- .../miro/RimuHostingContextBuilder.java | 40 +- .../miro/RimuHostingPropertiesBuilder.java | 66 --- .../miro/RimuHostingProviderMetadata.java | 83 ++- .../miro/RimuHostingAsyncClientTest.java | 12 +- .../miro/RimuHostingClientLiveTest.java | 30 +- .../miro/RimuHostingProviderTest.java | 2 +- .../RimuHostingComputeServiceLiveTest.java | 10 +- .../RimuHostingTemplateBuilderLiveTest.java | 9 +- .../ServerloveManchesterContextBuilder.java | 44 -- ...ServerloveManchesterPropertiesBuilder.java | 48 -- .../ServerloveManchesterProviderMetadata.java | 71 ++- ...ManchesterComputeServiceContextModule.java | 29 - .../ServerloveManchesterProviderTest.java | 2 +- ...loveManchesterTemplateBuilderLiveTest.java | 29 +- .../SkaliCloudMalaysiaContextBuilder.java | 44 -- .../SkaliCloudMalaysiaPropertiesBuilder.java | 48 -- .../SkaliCloudMalaysiaProviderMetadata.java | 72 ++- ...udMalaysiaComputeServiceContextModule.java | 29 - .../SkaliCloudMalaysiaProviderTest.java | 2 +- ...iCloudMalaysiaTemplateBuilderLiveTest.java | 9 +- .../slicehost/SlicehostApiMetadata.java | 66 ++- .../slicehost/SlicehostContextBuilder.java | 32 +- .../slicehost/SlicehostPropertiesBuilder.java | 49 -- .../slicehost/SlicehostProviderMetadata.java | 81 ++- .../slicehost/SlicehostAsyncClientTest.java | 12 +- .../slicehost/SlicehostClientLiveTest.java | 28 +- .../slicehost/SlicehostProviderTest.java | 2 +- .../SlicehostComputeServiceLiveTest.java | 10 +- .../SlicehostTemplateBuilderLiveTest.java | 9 +- .../softlayer/SoftLayerApiMetadata.java | 75 ++- .../softlayer/SoftLayerContextBuilder.java | 17 +- .../softlayer/SoftLayerPropertiesBuilder.java | 79 --- .../softlayer/SoftLayerProviderMetadata.java | 103 +++- .../softlayer/SoftLayerProviderTest.java | 2 +- ...oftLayerComputeServiceAdapterLiveTest.java | 17 +- .../SoftLayerComputeServiceLiveTest.java | 12 +- .../compute/SoftLayerExperimentLiveTest.java | 30 +- .../SoftLayerTemplateBuilderLiveTest.java | 69 ++- .../functions/ProductItemsToHardwareTest.java | 5 +- .../features/AccountClientLiveTest.java | 6 +- .../BaseSoftLayerAsyncClientTest.java | 17 +- .../features/BaseSoftLayerClientLiveTest.java | 82 +-- .../features/DatacenterAsyncClientTest.java | 2 +- .../features/DatacenterClientLiveTest.java | 6 +- .../ProductPackageClientLiveTest.java | 8 +- .../features/VirtualGuestAsyncClientTest.java | 2 +- .../VirtualGuestClientExpectTest.java | 2 +- .../features/VirtualGuestClientLiveTest.java | 17 +- .../predicates/ProductItemPredicatesTest.java | 2 +- .../StratoGenVCloudMyCloudContextBuilder.java | 20 +- ...ratoGenVCloudMyCloudPropertiesBuilder.java | 49 -- ...tratoGenVCloudMyCloudProviderMetadata.java | 81 ++- .../StratoGenVCloudMyCloudProviderTest.java | 2 +- ...nVCloudMyCloudTemplateBuilderLiveTest.java | 9 +- providers/synaptic-storage/pom.xml | 2 - .../SynapticStoragePropertiesBuilder.java | 53 -- .../SynapticStorageProviderMetadata.java | 87 +-- .../storage/SynapticStorageProviderTest.java | 2 +- ...ynapticStorageBlobIntegrationLiveTest.java | 3 + .../SynapticStorageBlobLiveTest.java | 3 + ...pticStorageBlobMapIntegrationLiveTest.java | 3 + .../SynapticStorageBlobSignerLiveTest.java | 3 + ...icStorageContainerIntegrationLiveTest.java | 3 + .../SynapticStorageContainerLiveTest.java | 3 + ...rageInputStreamMapIntegrationLiveTest.java | 3 + ...pticStorageServiceIntegrationLiveTest.java | 5 + .../SynapticStorageTestInitializer.java | 33 -- .../ecloud/TerremarkECloudApiMetadata.java | 67 ++- .../ecloud/TerremarkECloudContextBuilder.java | 20 +- .../TerremarkECloudPropertiesBuilder.java | 52 -- .../TerremarkECloudProviderMetadata.java | 61 ++- .../BaseTerremarkECloudAsyncClientTest.java | 12 +- .../BaseTerremarkECloudClientLiveTest.java | 2 +- .../ecloud/TerremarkECloudClientLiveTest.java | 2 +- .../ecloud/TerremarkECloudProviderTest.java | 2 +- ...TerremarkECloudComputeServiceLiveTest.java | 16 +- ...erremarkECloudTemplateBuilderLiveTest.java | 9 +- .../TerremarkVCloudExpressApiMetadata.java | 87 ++- .../TerremarkVCloudExpressContextBuilder.java | 20 +- ...erremarkVCloudExpressProviderMetadata.java | 65 ++- .../InternetServiceLiveTest.java | 36 +- ...TerremarkVCloudExpressAsyncClientTest.java | 15 +- .../TerremarkVCloudExpressClientLiveTest.java | 2 +- .../TerremarkVCloudExpressProviderTest.java | 2 +- ...rkVCloudExpressComputeServiceLiveTest.java | 17 +- ...kVCloudExpressTemplateBuilderLiveTest.java | 9 +- .../nova/TryStackNovaContextBuilder.java | 16 +- .../nova/TryStackNovaPropertiesBuilder.java | 53 -- .../nova/TryStackNovaProviderMetadata.java | 82 ++- .../nova/TryStackNovaProviderTest.java | 2 +- .../TryStackNovaTemplateBuilderLiveTest.java | 8 +- .../ServerManagerApiMetadata.java | 58 ++ ...erManagerComputeServiceContextBuilder.java | 21 +- .../services/org.jclouds.apis.ApiMetadata | 1 + ...nagerComputeServiceContextBuilderTest.java | 51 +- .../ServerManagerComputeServiceLiveTest.java | 26 +- .../ServerManagerExperimentLiveTest.java | 27 +- 831 files changed, 11752 insertions(+), 12753 deletions(-) delete mode 100644 apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosTestInitializer.java delete mode 100644 apis/byon/src/main/java/org/jclouds/byon/BYONPropertiesBuilder.java delete mode 100644 apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersPropertiesBuilder.java delete mode 100644 apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersPropertiesBuilder.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java delete mode 100644 apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java delete mode 100644 apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchPropertiesBuilder.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudPropertiesBuilder.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/EC2PropertiesBuilder.java rename apis/{cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesPropertiesBuilder.java => ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java} (63%) create mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java delete mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackPropertiesBuilder.java delete mode 100644 apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusPropertiesBuilder.java delete mode 100644 apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStorePropertiesBuilder.java rename apis/filesystem/src/test/java/org/jclouds/filesystem/integration/{FilesystemBlobIntegrationTest.java => FilesystemBlobIntegrationTestDisabled.java} (55%) rename apis/filesystem/src/test/java/org/jclouds/filesystem/integration/{FilesystemBlobMapIntegrationTest.java => FilesystemBlobMapIntegrationTestDisabled.java} (60%) rename apis/filesystem/src/test/java/org/jclouds/filesystem/integration/{FilesystemContainerIntegrationTest.java => FilesystemContainerIntegrationTestDisabled.java} (78%) rename apis/filesystem/src/test/java/org/jclouds/filesystem/integration/{FilesystemInputStreamMapIntegrationTest.java => FilesystemInputStreamMapIntegrationTestDisabled.java} (60%) rename apis/filesystem/src/test/java/org/jclouds/filesystem/integration/{FilesystemServiceIntegrationTest.java => FilesystemServiceIntegrationTestDisabled.java} (60%) delete mode 100644 apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemTestInitializer.java delete mode 100644 apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2PropertiesBuilder.java delete mode 100644 apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaPropertiesBuilder.java delete mode 100644 apis/s3/src/main/java/org/jclouds/s3/S3PropertiesBuilder.java rename blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobStoreTestInitializer.java => apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java (64%) create mode 100644 apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java delete mode 100644 apis/s3/src/test/java/org/jclouds/s3/blobstore/integration/S3TestInitializer.java delete mode 100644 apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftPropertiesBuilder.java delete mode 100644 apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftTestInitializer.java delete mode 100644 apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudPropertiesBuilder.java delete mode 100644 apis/walrus/src/main/java/org/jclouds/walrus/WalrusPropertiesBuilder.java delete mode 100644 apis/walrus/src/test/java/org/jclouds/walrus/WalrusAsyncClientTestDisabled.java create mode 100644 blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStorePropertiesBuilder.java create mode 100644 blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java delete mode 100644 blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseTestInitializer.java create mode 100644 blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java create mode 100644 common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java rename apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusTestInitializer.java => compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java (63%) delete mode 100644 compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextSpec.java create mode 100644 compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java rename compute/src/main/java/org/jclouds/compute/stub/{ => internal}/StubComputeServiceContextBuilder.java (63%) create mode 100644 compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java rename compute/src/test/java/org/jclouds/compute/{BaseVersionedServiceLiveTest.java => internal/BaseComputeServiceContextLiveTest.java} (55%) rename compute/src/test/java/org/jclouds/compute/{ => internal}/BaseComputeServiceLiveTest.java (92%) rename compute/src/test/java/org/jclouds/compute/{ => internal}/BaseTemplateBuilderLiveTest.java (86%) delete mode 100644 core/src/main/java/org/jclouds/apis/BaseApiMetadata.java create mode 100644 core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java rename core/src/main/java/org/jclouds/providers/{ => internal}/BaseProviderMetadata.java (50%) create mode 100644 core/src/main/java/org/jclouds/rest/AnonymousProviderMetadata.java create mode 100644 core/src/main/java/org/jclouds/rest/AnonymousRestApiMetadata.java rename providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaZurichComputeServiceContextModule.java => core/src/main/java/org/jclouds/rest/BackedByRestContext.java (72%) rename providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageTestInitializer.java => core/src/main/java/org/jclouds/rest/RestApiMetadata.java (65%) delete mode 100644 core/src/main/java/org/jclouds/rest/RestContextSpec.java create mode 100644 core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java create mode 100644 core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java rename core/src/test/java/org/jclouds/apis/{ => internal}/BaseApiMetadataTest.java (75%) rename compute/src/test/java/org/jclouds/compute/ComputeServiceContextFactoryTest.java => core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java (51%) rename core/src/test/java/org/jclouds/providers/{ => internal}/BaseProviderMetadataTest.java (80%) delete mode 100644 core/src/test/java/org/jclouds/rest/BaseRestClientLiveTest.java delete mode 100644 core/src/test/java/org/jclouds/rest/RestContextFactoryTest.java rename core/src/test/java/org/jclouds/rest/{RestClientTest.java => internal/BaseAsyncClientTest.java} (60%) create mode 100644 core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java rename core/src/test/java/org/jclouds/rest/{ => internal}/BaseRestClientExpectTest.java (90%) rename core/src/test/java/org/jclouds/rest/{ => internal}/BaseRestClientTest.java (99%) rename core/src/test/java/org/jclouds/rest/{RestContextBuilderTest.java => internal/ContextBuilderTest.java} (74%) delete mode 100644 labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java delete mode 100644 labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorPropertiesBuilder.java delete mode 100644 labs/glesys/src/main/java/org/jclouds/glesys/GleSYSPropertiesBuilder.java create mode 100644 labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java delete mode 100644 labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersPropertiesBuilder.java create mode 100644 labs/opsource-servers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata delete mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCApiMetadata.java delete mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java create mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java create mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java rename labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/{SavvisSymphonyVPDCProviderTest.java => VPDCProviderTest.java} (66%) delete mode 100644 labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxPropertiesBuilder.java create mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java create mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java rename providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ContextBuilder.java => loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java (54%) create mode 100644 loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java delete mode 100644 providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchPropertiesBuilder.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java rename providers/{cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichContextBuilder.java => aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java} (61%) create mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java delete mode 100644 providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3PropertiesBuilder.java rename apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java => providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java (60%) create mode 100644 providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java delete mode 100644 providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3TestInitializer.java delete mode 100644 providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobPropertiesBuilder.java delete mode 100644 providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobTestInitializer.java delete mode 100644 providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01PropertiesBuilder.java delete mode 100644 providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKPropertiesBuilder.java delete mode 100644 providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKTestInitializer.java delete mode 100644 providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSPropertiesBuilder.java delete mode 100644 providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSTestInitializer.java delete mode 100644 providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java delete mode 100644 providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java delete mode 100644 providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStoragePropertiesBuilder.java delete mode 100644 providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKPropertiesBuilder.java delete mode 100644 providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSPropertiesBuilder.java delete mode 100644 providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasPropertiesBuilder.java delete mode 100644 providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichPropertiesBuilder.java delete mode 100644 providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesPropertiesBuilder.java delete mode 100644 providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java delete mode 100644 providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonPropertiesBuilder.java delete mode 100644 providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioPropertiesBuilder.java delete mode 100644 providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoPropertiesBuilder.java delete mode 100644 providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudPropertiesBuilder.java delete mode 100644 providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudWalrusPropertiesBuilder.java delete mode 100644 providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudWalrusAsyncClientTestDisabled.java delete mode 100644 providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusTestInitializer.java delete mode 100644 providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1PropertiesBuilder.java delete mode 100644 providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/config/Go2CloudJohannesburg1ComputeServiceContextModule.java delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridPropertiesBuilder.java delete mode 100644 providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java delete mode 100644 providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeApiMetadata.java delete mode 100644 providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputePropertiesBuilder.java delete mode 100644 providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStoragePropertiesBuilder.java delete mode 100644 providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageTestInitializer.java delete mode 100644 providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeContextBuilder.java delete mode 100644 providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputePropertiesBuilder.java delete mode 100644 providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/config/NinefoldComputeServiceContextModule.java delete mode 100644 providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStoragePropertiesBuilder.java delete mode 100644 providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageTestInitializer.java delete mode 100644 providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ContextBuilder.java delete mode 100644 providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1PropertiesBuilder.java delete mode 100644 providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java delete mode 100644 providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterContextBuilder.java delete mode 100644 providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterPropertiesBuilder.java delete mode 100644 providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/config/ServerloveManchesterComputeServiceContextModule.java delete mode 100644 providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaContextBuilder.java delete mode 100644 providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaPropertiesBuilder.java delete mode 100644 providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/config/SkaliCloudMalaysiaComputeServiceContextModule.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostPropertiesBuilder.java delete mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerPropertiesBuilder.java delete mode 100644 providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudPropertiesBuilder.java delete mode 100644 providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStoragePropertiesBuilder.java delete mode 100644 providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageTestInitializer.java delete mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudPropertiesBuilder.java delete mode 100644 providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaPropertiesBuilder.java create mode 100644 skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java create mode 100644 skeletons/standalone-compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java index 9e67de8d7f..0c4b3c2a3b 100644 --- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java +++ b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java @@ -18,8 +18,6 @@ */ package org.jclouds.tools.ant.taskdefs.compute; -import static org.jclouds.rest.RestContextFactory.getPropertiesFromResource; - import java.io.IOException; import java.net.URI; import java.util.NoSuchElementException; @@ -73,13 +71,13 @@ public class ComputeTaskUtils { @SuppressWarnings("unchecked") @Override public ComputeServiceContext load(URI from) { - Properties props = getPropertiesFromResource("/rest.properties"); + Properties props = new Properties(); props.putAll(projectProvider.get().getProperties()); // adding the properties to the factory will allow us to pass // alternate endpoints String provider = from.getHost(); Credentials creds = Credentials.parse(from); - return new ComputeServiceContextFactory(props).createContext(provider, creds.identity, creds.credential, + return new ComputeServiceContextFactory().createContext(provider, creds.identity, creds.credential, ImmutableSet.of((Module) new AntLoggingModule(projectProvider.get(), ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule()), props); diff --git a/apis/atmos/pom.xml b/apis/atmos/pom.xml index 5a794c889f..eac3f8804e 100644 --- a/apis/atmos/pom.xml +++ b/apis/atmos/pom.xml @@ -34,8 +34,7 @@ bundle - org.jclouds.atmos.blobstore.integration.AtmosStorageTestInitializer - https://accesspoint.atmos.com + https://accesspoint.atmosonline.com 1.3.0 FIXME diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java index 20fe7cd5e3..1dd282eff9 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java @@ -18,50 +18,75 @@ */ package org.jclouds.atmos; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for EMC's Atmos API. + * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * * @author Adrian Cole */ -public class AtmosApiMetadata extends BaseApiMetadata { - - public AtmosApiMetadata() { - this(builder() - .id("atmos") - .type(ApiType.BLOBSTORE) - .name("EMC's Atmos API") - .identityName("Subtenant ID (UID)") - .credentialName("Shared Secret") - .documentation(URI.create("https://community.emc.com/docs/DOC-10508"))); +public class AtmosApiMetadata + extends + BaseBlobStoreApiMetadata, AtmosApiMetadata> { + private static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AtmosApiMetadata(Builder builder) { + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } + + public AtmosApiMetadata() { + this(builder()); + } + + protected AtmosApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); + properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); + return properties; + } + + public static class Builder + extends + BaseBlobStoreApiMetadata.Builder, AtmosApiMetadata> { + protected Builder() { + id("atmos") + .name("EMC's Atmos API") + .identityName("Subtenant ID (UID)") + .credentialName("Shared Secret") + .documentation(URI.create("https://community.emc.com/docs/DOC-10508")) + .version("1.4.0") + .defaultEndpoint("https://accesspoint.atmosonline.com") + .contextBuilder(TypeToken.of(AtmosContextBuilder.class)) + .defaultProperties(AtmosApiMetadata.defaultProperties()) + .javaApi(AtmosClient.class, AtmosAsyncClient.class); + } @Override public AtmosApiMetadata build() { return new AtmosApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); + @Override + public Builder fromApiMetadata(AtmosApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java index 19c7a16d7a..6856023dee 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java @@ -19,35 +19,45 @@ package org.jclouds.atmos; import java.util.List; -import java.util.Properties; import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule; import org.jclouds.atmos.config.AtmosRestClientModule; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link AtmosBlobStoreContext} or {@link Injector} instances based on the most commonly - * requested arguments. + * Creates {@link AtmosStoreContext} or {@link Injector} instances based on + * the most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole, Andrew Newdigate - * @see AtmosBlobStoreContext + * @see AtmosStoreContext */ -public class AtmosContextBuilder extends - BlobStoreContextBuilder { +public class AtmosContextBuilder + extends + BlobStoreContextBuilder, AtmosApiMetadata> { - public AtmosContextBuilder(Properties props) { - super(AtmosClient.class, AtmosAsyncClient.class, props); + public AtmosContextBuilder( + ProviderMetadata, AtmosApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public AtmosContextBuilder(AtmosApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java index 18c1b084be..7c5db767a6 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java @@ -85,7 +85,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { private final LoadingCache isPublic; @Inject - AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + AtmosAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AtmosAsyncClient async, AtmosClient sync, ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java index 4ba8c4b63b..5dafd49b28 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java @@ -73,7 +73,7 @@ public class AtmosBlobStore extends BaseBlobStore { private final LoadingCache isPublic; @Inject - AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AtmosBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AtmosClient sync, ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, BlobStoreListOptionsToListOptions container2ContainerListOptions, diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java index 9f5f407922..c9fedebe65 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.atmos; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "AtmosApiMetadataTest") -public class AtmosApiMetadataTest extends BaseApiMetadataTest { +public class AtmosApiMetadataTest extends BaseBlobStoreApiMetadataTest { public AtmosApiMetadataTest() { - super(new AtmosApiMetadata(), ApiType.BLOBSTORE); + super(new AtmosApiMetadata()); } } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java index 7f41fe9b34..6722aeffc4 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java @@ -22,10 +22,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; -import java.util.Properties; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.apis.ApiMetadata; import org.jclouds.atmos.blobstore.functions.BlobToObject; import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.atmos.domain.AtmosObject; @@ -47,12 +47,10 @@ import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.options.GetOptions; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -68,7 +66,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AtmosAsyncClientTest") -public class AtmosAsyncClientTest extends RestClientTest { +public class AtmosAsyncClientTest extends BaseAsyncClientTest { private BlobToObject blobToObject; @@ -339,10 +337,8 @@ public class AtmosAsyncClientTest extends RestClientTest { protected String provider = "atmos"; @Override - public RestContextSpec createContextSpec() { - Properties props = new Properties(); - props.setProperty(provider + ".endpoint", "https://accesspoint.atmosonline.com"); - return new RestContextFactory().createContextSpec(provider, "identity", "credential", props); + public ApiMetadata createApiMetadata() { + return new AtmosApiMetadata(); } } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java index 44c1a03591..c4f2d593be 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java @@ -21,8 +21,9 @@ package org.jclouds.atmos.blobstore; import static org.testng.Assert.assertEquals; import java.io.IOException; -import java.util.Properties; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.atmos.AtmosAsyncClient; import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.atmos.filters.SignRequest; @@ -33,9 +34,7 @@ import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -51,7 +50,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AtmosBlobRequestSignerTest") -public class AtmosBlobRequestSignerTest extends RestClientTest { +public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest { private BlobRequestSigner signer; private Factory blobFactory; @@ -144,8 +143,8 @@ public class AtmosBlobRequestSignerTest extends RestClientTest } @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec("atmos", "identity", "credential", new Properties()); + public ApiMetadata createApiMetadata() { + return new AtmosApiMetadata(); } } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java index 7c87d6eeb9..ccf9a5c840 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java @@ -20,13 +20,14 @@ package org.jclouds.atmos.blobstore.config; import static org.testng.Assert.assertEquals; +import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata; import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientTest.MockModule; -import org.jclouds.rest.RestContextFactory; +import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -40,15 +41,19 @@ import com.google.inject.Module; public class AtmosBlobStoreModuleTest { Injector createInjector() { - return new RestContextFactory().createContextBuilder("atmos", "uid", "key", - ImmutableSet. of(new MockModule(), new NullLoggingModule())).buildInjector(); + return BlobStoreContextBuilder + .newBuilder(new AtmosApiMetadata()) + .credentials("uid", "key") + .modules( + ImmutableSet. of(new MockModule(),new NullLoggingModule())) + .buildInjector(); } @Test void testContextImpl() { Injector injector = createInjector(); - BlobStoreContext handler = injector.getInstance(BlobStoreContext.class); + BlobStoreContext handler = injector.getInstance(BlobStoreContext.class); assertEquals(handler.getClass(), BlobStoreContextImpl.class); ContainsValueInListStrategy valueList = injector .getInstance(ContainsValueInListStrategy.class); diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosBlobSignerLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosBlobSignerLiveTest.java index df8da0418c..8521358067 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosBlobSignerLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosBlobSignerLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class AtmosBlobSignerLiveTest extends BaseBlobSignerLiveTest { - + public AtmosBlobSignerLiveTest() { + provider = "atmos"; + } } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java index a2f31c766b..a134e0fab6 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java @@ -31,7 +31,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class AtmosContainerIntegrationLiveTest extends BaseContainerIntegrationTest { - + public AtmosContainerIntegrationLiveTest() { + provider = "atmos"; + } @Override public void testListContainerMaxResults() throws InterruptedException { // Not currently working diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java index 57a690d067..90c28d9b7a 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class AtmosContainerLiveTest extends BaseContainerLiveTest { - + public AtmosContainerLiveTest() { + provider = "atmos"; + } } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosInputStreamMapIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosInputStreamMapIntegrationLiveTest.java index 5e8cfd49ea..ec4fcf4e57 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosInputStreamMapIntegrationLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosInputStreamMapIntegrationLiveTest.java @@ -29,7 +29,10 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class AtmosInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest { - + public AtmosInputStreamMapIntegrationLiveTest() { + provider = "atmos"; + } + @Override @Test(enabled = false) public void testContainsBytesValue() throws InterruptedException, ExecutionException, diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosIntegrationLiveTest.java index aad3085662..56246296de 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosIntegrationLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosIntegrationLiveTest.java @@ -35,7 +35,9 @@ import org.testng.annotations.Test; */ @Test(groups = { "integration", "live" }) public class AtmosIntegrationLiveTest extends BaseBlobIntegrationTest { - + public AtmosIntegrationLiveTest() { + provider = "atmos"; + } @DataProvider(name = "delete") // no unicode support @Override diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java index 06cf5c12c6..4c17e48f31 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java @@ -29,6 +29,9 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class AtmosLiveTest extends BaseBlobLiveTest { + public AtmosLiveTest() { + provider = "atmos"; + } protected void checkMD5(String container, String name, byte[] md5) { // atmos does not support content-md5 yet assertEquals(context.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null); diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosMapIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosMapIntegrationLiveTest.java index ada6ffb7b3..86d9dc5680 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosMapIntegrationLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosMapIntegrationLiveTest.java @@ -30,7 +30,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class AtmosMapIntegrationLiveTest extends BaseBlobMapIntegrationTest { - + public AtmosMapIntegrationLiveTest() { + provider = "atmos"; + } @Override // NO support for Content-MD5, so contains cannot work public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException { diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosServiceIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosServiceIntegrationLiveTest.java index 47e58e83cc..a36d98e76e 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosServiceIntegrationLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosServiceIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class AtmosServiceIntegrationLiveTest extends BaseServiceIntegrationTest { - + public AtmosServiceIntegrationLiveTest() { + provider = "atmos"; + } } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosTestInitializer.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosTestInitializer.java deleted file mode 100644 index 1cc02f150e..0000000000 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosTestInitializer.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.atmos.blobstore.integration; - -import java.io.IOException; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class AtmosTestInitializer extends TransientBlobStoreTestInitializer { - public AtmosTestInitializer() { - provider = "synaptic"; - } - - @Override - protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiVersion, - String buildVersion, String app, String identity, String credential) throws IOException { - return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule, - new Log4JLoggingModule()), setupProperties(endpoint, apiVersion, buildVersion, identity, credential)); - } - -} diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java index 8e4caeb019..dc07a557d8 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java @@ -24,20 +24,19 @@ import java.io.IOException; import java.net.URI; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.util.Properties; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.atmos.reference.AtmosHeaders; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientTest.MockModule; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestContextFactory; +import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.jclouds.util.Strings2; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -98,13 +97,12 @@ public class SignRequestTest { @BeforeClass protected void createFilter() { - Injector injector = new RestContextFactory() - .createContextBuilder( - "atmos", - UID, - KEY, - ImmutableSet. of(new MockModule(), new TestAtmosRestClientModule(), - new NullLoggingModule()), new Properties()).buildInjector(); + Injector injector = BlobStoreContextBuilder + .newBuilder("atmos") + .credentials(UID, KEY) + .modules( + ImmutableSet. of(new MockModule(), new TestAtmosRestClientModule(), new NullLoggingModule())) + .buildInjector(); filter = injector.getInstance(SignRequest.class); diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java index b818a6ef33..a094713c0b 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java +++ b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java @@ -19,49 +19,74 @@ package org.jclouds.byon; import java.net.URI; +import java.util.Properties; +import org.jclouds.JcloudsVersion; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.base.Supplier; +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for jclouds BYON API * + *

    note

    + * + * This class is not setup to allow a subclasses to override the type of api, + * asyncapi, or context. This is an optimization for s. + * * @author Adrian Cole */ -public class BYONApiMetadata extends BaseApiMetadata { +@SuppressWarnings("rawtypes") +public class BYONApiMetadata extends BaseComputeServiceApiMetadata, BYONApiMetadata> { - public BYONApiMetadata() { - this(builder() - .id("byon") - .type(ApiType.COMPUTE) - .name("Bring Your Own Node (BYON) API") - .identityName("Unused") - .documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected BYONApiMetadata(Builder builder) { + public BYONApiMetadata() { + this(new Builder()); + } + + protected BYONApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + return BaseComputeServiceApiMetadata.Builder.defaultProperties(); + } + + public static class Builder extends BaseComputeServiceApiMetadata.Builder, BYONApiMetadata> { + + protected Builder() { + id("byon") + .name("Bring Your Own Node (BYON) API") + .identityName("Unused") + .defaultIdentity("foo") + .defaultCredential("bar") + .defaultEndpoint("file://byon.yaml") + .documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon")) + .version(String.format("%s.%s", JcloudsVersion.get().majorVersion, JcloudsVersion.get().minorVersion)) + .buildVersion(JcloudsVersion.get().toString()) + .defaultProperties(BYONApiMetadata.defaultProperties()) + .javaApi(Supplier.class, Supplier.class) + .contextBuilder(TypeToken.of(BYONComputeServiceContextBuilder.class)); + } @Override public BYONApiMetadata build() { return new BYONApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromApiMetadata(BYONApiMetadata in) { + super.fromApiMetadata(in); + return this; + } - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java b/apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java index 15bdb626a9..2def88a0d3 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java +++ b/apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java @@ -19,12 +19,13 @@ package org.jclouds.byon; import java.util.List; -import java.util.Properties; import org.jclouds.byon.config.BYONComputeServiceContextModule; import org.jclouds.byon.config.ConfiguresNodeStore; import org.jclouds.byon.config.YamlNodeStoreModule; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.StandaloneComputeServiceContextBuilder; +import org.jclouds.providers.ProviderMetadata; import com.google.common.base.Predicate; import com.google.common.base.Supplier; @@ -36,12 +37,17 @@ import com.google.inject.Module; * @author Adrian Cole */ @SuppressWarnings("rawtypes") -public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder { +public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder, BYONApiMetadata> { - public BYONComputeServiceContextBuilder(Properties props) { - super(Supplier.class, props); + public BYONComputeServiceContextBuilder( + ProviderMetadata, BYONApiMetadata> providerMetadata) { + super(providerMetadata); } - + + public BYONComputeServiceContextBuilder(BYONApiMetadata apiMetadata) { + super(apiMetadata); + } + @Override protected void addContextModule(List modules) { modules.add(new BYONComputeServiceContextModule()); diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONPropertiesBuilder.java b/apis/byon/src/main/java/org/jclouds/byon/BYONPropertiesBuilder.java deleted file mode 100644 index 5965595704..0000000000 --- a/apis/byon/src/main/java/org/jclouds/byon/BYONPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.byon; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_IDENTITY; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in byon Clients - * - * @author Adrian Cole - */ -public class BYONPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - properties.setProperty(PROPERTY_IDENTITY, "foo"); - properties.setProperty(PROPERTY_CREDENTIAL, "bar"); - return properties; - } - - public BYONPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java index 6265ff3c0e..2e0fb1bd98 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.byon; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "BYONApiMetadataTest") -public class BYONApiMetadataTest extends BaseApiMetadataTest { +public class BYONApiMetadataTest extends BaseComputeServiceApiMetadataTest { public BYONApiMetadataTest() { - super(new BYONApiMetadata(), ApiType.COMPUTE); + super(new BYONApiMetadata()); } } diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java index 60b1a286d2..4668ad7a45 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java @@ -28,10 +28,10 @@ import java.util.Map.Entry; import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterClass; @@ -49,7 +49,7 @@ import com.google.inject.Module; @Test(groups = "live") public class BYONComputeServiceLiveTest { - private ComputeServiceContext context; + private ComputeServiceContext context; @BeforeClass(groups = "live") public void setup() throws FileNotFoundException, IOException { @@ -72,9 +72,8 @@ public class BYONComputeServiceLiveTest { .append("\n"); contextProperties.setProperty("byon.nodes", nodes.toString()); - - context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet. of( - new SshjSshClientModule(), new Log4JLoggingModule()), contextProperties); + context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties) + .modules(ImmutableSet. of(new SshjSshClientModule(), new Log4JLoggingModule())).build(); } public void testCanRunCommandAsCurrentUser() throws Exception { diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java index 2a86fb13d0..ded60ea37f 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java @@ -24,15 +24,15 @@ import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled; import static org.testng.Assert.assertEquals; import java.net.URI; -import java.util.Properties; import org.jclouds.byon.config.CacheNodeStoreModule; import org.jclouds.byon.functions.NodesFromYamlTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; +import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -68,13 +68,13 @@ public class BYONComputeServiceTest { } private void assertNodesParse(String endpoint, Iterable modules) { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Location providerLocation = expectedProviderLocationFromResource(endpoint); - Properties props = new Properties(); - props.setProperty("byon.endpoint", endpoint); - context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", modules, props); + context = ContextBuilder.newBuilder( + AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)) + .modules(modules).build(); assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); @@ -96,13 +96,11 @@ public class BYONComputeServiceTest { } public void testNodesWithLocations() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath(); - Properties props = new Properties(); - props.setProperty("byon.endpoint", endpoint); - context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet. of(), - props); + context = ContextBuilder.newBuilder( + AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)).build(); assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); diff --git a/apis/cloudfiles/pom.xml b/apis/cloudfiles/pom.xml index a7bb4b0e4a..13bb997d70 100644 --- a/apis/cloudfiles/pom.xml +++ b/apis/cloudfiles/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer https://auth.api.rackspacecloud.com 1.0 @@ -107,7 +106,6 @@ - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} ${test.cloudfiles.endpoint} diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java index 654c040c04..5d7cf50a69 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java @@ -18,51 +18,75 @@ */ package org.jclouds.cloudfiles; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.openstack.OpenStackAuthAsyncClient; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * - * @author Dan Lo Bianco + * @author Adrian Cole */ -public class CloudFilesApiMetadata extends BaseApiMetadata { - - public CloudFilesApiMetadata() { - this(builder() - .id("cloudfiles") - .type(ApiType.BLOBSTORE) - .name("Rackspace Cloud Files API") - .identityName("Username") - .credentialName("API Key") - .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))); +public class CloudFilesApiMetadata + extends + BaseBlobStoreApiMetadata, CloudFilesApiMetadata> { + private static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudFilesApiMetadata(Builder builder) { + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } + + public CloudFilesApiMetadata() { + this(builder()); + } + + protected CloudFilesApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); + properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); + return properties; + } + + public static class Builder + extends + BaseBlobStoreApiMetadata.Builder, CloudFilesApiMetadata> { + protected Builder() { + id("cloudfiles") + .name("Rackspace Cloud Files API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")) + .version(OpenStackAuthAsyncClient.VERSION) + .contextBuilder(TypeToken.of(CloudFilesContextBuilder.class)) + .defaultProperties(CloudFilesApiMetadata.defaultProperties()) + .javaApi(CloudFilesClient.class, CloudFilesAsyncClient.class); + } @Override public CloudFilesApiMetadata build() { return new CloudFilesApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); + @Override + public Builder fromApiMetadata(CloudFilesApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - } \ No newline at end of file diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java index 05f95822f4..84f966e358 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java @@ -19,34 +19,45 @@ package org.jclouds.cloudfiles; import java.util.List; -import java.util.Properties; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link CloudFilesBlobStoreContext} or {@link Injector} instances based on the most - * commonly requested arguments. + * Creates {@link CloudFilesStoreContext} or {@link Injector} instances based on + * the most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole, Andrew Newdigate - * @see CloudFilesBlobStoreContext + * @see CloudFilesStoreContext */ -public class CloudFilesContextBuilder extends BlobStoreContextBuilder { +public class CloudFilesContextBuilder + extends + BlobStoreContextBuilder, CloudFilesApiMetadata> { - public CloudFilesContextBuilder(Properties props) { - super(CloudFilesClient.class, CloudFilesAsyncClient.class, props); + public CloudFilesContextBuilder( + ProviderMetadata, CloudFilesApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public CloudFilesContextBuilder(CloudFilesApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java index 34b61b03de..af064f61c1 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java @@ -59,7 +59,7 @@ public class CloudFilesAsyncBlobStore extends SwiftAsyncBlobStore { private final EnableCDNAndCache enableCDNAndCache; @Inject - protected CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + protected CloudFilesAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, CloudFilesClient sync, CloudFilesAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java index 42be6d884c..d7309f99bc 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java @@ -53,7 +53,7 @@ public class CloudFilesBlobStore extends SwiftBlobStore { private EnableCDNAndCache enableCDNAndCache; @Inject - protected CloudFilesBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected CloudFilesBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java index 2672d7e980..ba6a4d55c9 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.cloudfiles; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "CloudFilesApiMetadataTest") -public class CloudFilesApiMetadataTest extends BaseApiMetadataTest { +public class CloudFilesApiMetadataTest extends BaseBlobStoreApiMetadataTest { public CloudFilesApiMetadataTest() { - super(new CloudFilesApiMetadata(), ApiType.BLOBSTORE); + super(new CloudFilesApiMetadata()); } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java index 7c5706a761..91bd107f73 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java @@ -41,6 +41,10 @@ import com.google.common.collect.Iterables; @Test(groups = "live") public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest { + public CloudFilesClientLiveTest(){ + provider = "cloudfiles"; + } + @Override public CloudFilesClient getApi() { return (CloudFilesClient) context.getProviderSpecificContext().getApi(); diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java index 5dc7f166eb..ce04b4f47e 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java @@ -28,6 +28,10 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class CloudFilesBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest { + public CloudFilesBlobIntegrationLiveTest(){ + provider = "cloudfiles"; + } + @Override protected void checkContentDisposition(Blob blob, String contentDisposition) { assert blob.getPayload().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java index cb66f7c794..edae3c1abf 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class CloudFilesBlobLiveTest extends SwiftBlobLiveTest { - + public CloudFilesBlobLiveTest(){ + provider = "cloudfiles"; + } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java index ff7a240fee..e091cc1642 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class CloudFilesBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest { - + public CloudFilesBlobMapIntegrationLiveTest(){ + provider = "cloudfiles"; + } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java index 1437aa506e..7add9a211d 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class CloudFilesBlobSignerLiveTest extends SwiftBlobSignerLiveTest { - + public CloudFilesBlobSignerLiveTest(){ + provider = "cloudfiles"; + } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java index f55abb8f77..c9dc3f6cf0 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class CloudFilesContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest { - + public CloudFilesContainerIntegrationLiveTest(){ + provider = "cloudfiles"; + } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java index 86b7a471e5..11217a5c10 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class CloudFilesContainerLiveTest extends BaseContainerLiveTest { - + public CloudFilesContainerLiveTest(){ + provider = "cloudfiles"; + } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java index c4f99d274e..1fd19dc1cc 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class CloudFilesInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest { - + public CloudFilesInputStreamMapIntegrationLiveTest(){ + provider = "cloudfiles"; + } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java index 1265764550..c89574c8e6 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class CloudFilesServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest { - + public CloudFilesServiceIntegrationLiveTest(){ + provider = "cloudfiles"; + } } diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java index 4885acb21d..0cadebfbc6 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java @@ -19,50 +19,71 @@ package org.jclouds.cloudloadbalancers; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadata; +import org.jclouds.openstack.OpenStackAuthAsyncClient; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for Rackspace Cloud Load Balancers API + * Implementation of {@link ApiMetadata} for CloudLoadBalancers 1.0 API * - * @author Dan Lo Bianco + * @author Adrian Cole */ -public class CloudLoadBalancersApiMetadata extends BaseApiMetadata { +public class CloudLoadBalancersApiMetadata + extends + BaseLoadBalancerServiceApiMetadata, CloudLoadBalancersApiMetadata> { - public CloudLoadBalancersApiMetadata() { - this(builder() - .id("cloudloadbalancers") - .type(ApiType.LOADBALANCER) - .name("Rackspace Cloud Load Balancers API") - .identityName("Username") - .credentialName("API Key") - .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudLoadBalancersApiMetadata(Builder builder) { + public CloudLoadBalancersApiMetadata() { + this(new Builder()); + } + + protected CloudLoadBalancersApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseLoadBalancerServiceApiMetadata.Builder.defaultProperties(); + return properties; + } + + public static class Builder + extends + BaseLoadBalancerServiceApiMetadata.Builder, CloudLoadBalancersApiMetadata> { + + protected Builder() { + id("cloudloadbalancers") + .name("Rackspace Cloud Load Balancers API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")) + .version(OpenStackAuthAsyncClient.VERSION) + .defaultEndpoint("https://auth.api.rackspacecloud.com") + .javaApi(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class) + .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(CloudLoadBalancersContextBuilder.class)); + } @Override public CloudLoadBalancersApiMetadata build() { return new CloudLoadBalancersApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromApiMetadata(CloudLoadBalancersApiMetadata in) { + super.fromApiMetadata(in); + return this; + } - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java index 93b51fc864..2e4c8e7827 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java @@ -19,11 +19,12 @@ package org.jclouds.cloudloadbalancers; import java.util.List; -import java.util.Properties; import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule; import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -31,11 +32,17 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class CloudLoadBalancersContextBuilder extends - LoadBalancerServiceContextBuilder { +public class CloudLoadBalancersContextBuilder + extends + LoadBalancerServiceContextBuilder, CloudLoadBalancersApiMetadata> { - public CloudLoadBalancersContextBuilder(Properties props) { - super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class, props); + public CloudLoadBalancersContextBuilder( + ProviderMetadata, CloudLoadBalancersApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public CloudLoadBalancersContextBuilder(CloudLoadBalancersApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -47,4 +54,4 @@ public class CloudLoadBalancersContextBuilder extends modules.add(new CloudLoadBalancersRestClientModule()); } -} +} \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersPropertiesBuilder.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersPropertiesBuilder.java deleted file mode 100644 index fe8c881636..0000000000 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersPropertiesBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudloadbalancers; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used inRackspace Cloud Load Balancers Clients - * - * @author Dan Lo Bianco - */ -public class CloudLoadBalancersPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - return properties; - } - - public CloudLoadBalancersPropertiesBuilder(Properties properties) { - super(properties); - } - - } diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java index 77aa57b660..a31007e3d9 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.cloudloadbalancers; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "CloudLoadBalancersApiMetadataTest") -public class CloudLoadBalancersApiMetadataTest extends BaseApiMetadataTest { +public class CloudLoadBalancersApiMetadataTest extends BaseLoadBalancerServiceApiMetadataTest { public CloudLoadBalancersApiMetadataTest() { - super(new CloudLoadBalancersApiMetadata(), ApiType.LOADBALANCER); + super(new CloudLoadBalancersApiMetadata()); } } diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java index e11bda0e72..b95b023667 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java @@ -46,8 +46,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive private Set lbs = Sets.newLinkedHashSet(); @Override - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); assertEquals(client.getConfiguredRegions(), Arrays.asList(regions)); Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions()); } diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java index eb8aa9132a..3ddb2f6e45 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java @@ -31,12 +31,10 @@ import java.util.Properties; import javax.inject.Singleton; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersPropertiesBuilder; import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule; -import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient; -import org.jclouds.cloudloadbalancers.features.LoadBalancerClient; import org.jclouds.cloudloadbalancers.reference.Region; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRequest; @@ -48,13 +46,10 @@ import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.Ge import org.jclouds.openstack.keystone.v1_1.domain.Auth; import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.testng.annotations.BeforeClass; import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Module; import com.google.inject.Provides; @@ -62,7 +57,7 @@ import com.google.inject.Provides; /** * @author Adrian Cole */ -public abstract class BaseCloudLoadBalancersAsyncClientTest extends RestClientTest { +public abstract class BaseCloudLoadBalancersAsyncClientTest extends BaseAsyncClientTest { protected String provider; @@ -131,15 +126,9 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest extends RestClien return overrides; } - /** - * this is only here as "cloudloadbalancers" is not in rest.properties - */ - @SuppressWarnings( { "unchecked", "rawtypes" }) @Override - public RestContextSpec createContextSpec() { - return RestContextFactory. contextSpec(provider, "https://auth", - "1.0", "", "", "identity", "credential", LoadBalancerClient.class, LoadBalancerAsyncClient.class, - (Class) CloudLoadBalancersPropertiesBuilder.class, (Class) CloudLoadBalancersContextBuilder.class, - ImmutableSet. of()); + protected ApiMetadata createApiMetadata() { + return new CloudLoadBalancersApiMetadata(); } + } \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java index b8a1fdd898..fc178ac0f7 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.cloudloadbalancers.internal; -import java.util.Properties; import java.util.concurrent.TimeUnit; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; @@ -26,32 +25,33 @@ import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; import org.jclouds.cloudloadbalancers.predicates.LoadBalancerActive; import org.jclouds.cloudloadbalancers.predicates.LoadBalancerDeleted; -import org.jclouds.loadbalancer.LoadBalancerServiceContextFactory; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.BaseRestClientLiveTest; import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseContextLiveTest; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; import com.google.inject.Guice; import com.google.inject.Injector; -import com.google.inject.Module; /** * * @author Adrian Cole */ -public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest { +public class BaseCloudLoadBalancersClientLiveTest + extends + BaseContextLiveTest> { + public BaseCloudLoadBalancersClientLiveTest() { provider = "cloudloadbalancers"; } protected CloudLoadBalancersClient client; - protected RestContext context; + protected RestContext lbContext; protected String[] regions = {}; protected Predicate socketTester; protected RetryablePredicate loadBalancerActive; @@ -59,15 +59,13 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest protected Injector injector; + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + lbContext = context.getProviderSpecificContext(); - @BeforeGroups(groups = "live") - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new LoadBalancerServiceContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides).getProviderSpecificContext(); - - client = context.getApi(); + client = lbContext.getApi(); injector = Guice.createInjector(new Log4JLoggingModule()); loadBalancerActive = new RetryablePredicate(new LoadBalancerActive(client), 300, 1, 1, @@ -80,8 +78,8 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest @AfterGroups(groups = "live") protected void tearDown() { - if (context != null) - context.close(); + if (lbContext != null) + lbContext.close(); } } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java index c41c0a1aba..7ab3010dec 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java @@ -19,50 +19,70 @@ package org.jclouds.cloudservers; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.openstack.OpenStackAuthAsyncClient; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for Rackspace Cloud Servers API + * Implementation of {@link ApiMetadata} for CloudServers 1.0 API * * @author Adrian Cole */ -public class CloudServersApiMetadata extends BaseApiMetadata { +public class CloudServersApiMetadata + extends + BaseComputeServiceApiMetadata, CloudServersApiMetadata> { - public CloudServersApiMetadata() { - this(builder() - .id("cloudservers") - .type(ApiType.COMPUTE) - .name("Rackspace Cloud Servers API") - .identityName("Username") - .credentialName("API Key") - .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudServersApiMetadata(Builder builder) { + public CloudServersApiMetadata() { + this(new Builder()); + } + + protected CloudServersApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, CloudServersApiMetadata> { + + protected Builder() { + id("cloudservers") + .name("Rackspace Cloud Servers API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")) + .version(OpenStackAuthAsyncClient.VERSION) + .defaultEndpoint("https://auth.api.rackspacecloud.com") + .javaApi(CloudServersClient.class, CloudServersAsyncClient.class) + .defaultProperties(CloudServersApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(CloudServersContextBuilder.class)); + } @Override public CloudServersApiMetadata build() { return new CloudServersApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromApiMetadata(CloudServersApiMetadata in) { + super.fromApiMetadata(in); + return this; + } - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java index 9c322927d5..52e43a7d3a 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java @@ -19,35 +19,30 @@ package org.jclouds.cloudservers; import java.util.List; -import java.util.Properties; import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule; import org.jclouds.cloudservers.config.CloudServersRestClientModule; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; -import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link CloudServersComputeServiceContext} or {@link Injector} instances based on the most - * commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

    - *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. * * @author Adrian Cole - * @see CloudServersComputeServiceContext */ -public class CloudServersContextBuilder extends - ComputeServiceContextBuilder { +public class CloudServersContextBuilder + extends + ComputeServiceContextBuilder, CloudServersApiMetadata> { - public CloudServersContextBuilder(Properties props) { - super(CloudServersClient.class, CloudServersAsyncClient.class, props); + public CloudServersContextBuilder( + ProviderMetadata, CloudServersApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public CloudServersContextBuilder(CloudServersApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -55,9 +50,8 @@ public class CloudServersContextBuilder extends modules.add(new CloudServersComputeServiceContextModule()); } - @Override protected void addClientModule(List modules) { modules.add(new CloudServersRestClientModule()); } -} +} \ No newline at end of file diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersPropertiesBuilder.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersPropertiesBuilder.java deleted file mode 100644 index b4af167dbe..0000000000 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersPropertiesBuilder.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudservers; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.jclouds.openstack.OpenStackAuthAsyncClient; - -/** - * - * @author Dan Lo Bianco - */ -public class CloudServersPropertiesBuilder extends PropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, OpenStackAuthAsyncClient.VERSION); - return properties; - } - - public CloudServersPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java index f4d822af98..6587b5ab3c 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.cloudservers; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "CloudServersApiMetadataTest") -public class CloudServersApiMetadataTest extends BaseApiMetadataTest { +public class CloudServersApiMetadataTest extends BaseComputeServiceApiMetadataTest { public CloudServersApiMetadataTest() { - super(new CloudServersApiMetadata(), ApiType.COMPUTE); + super(new CloudServersApiMetadata()); } } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java index 50713095c9..829b7a8cef 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java @@ -38,6 +38,7 @@ import java.util.Properties; import javax.inject.Singleton; import javax.ws.rs.core.MediaType; +import org.jclouds.apis.ApiMetadata; import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.cloudservers.domain.BackupSchedule; import org.jclouds.cloudservers.domain.DailyBackup; @@ -60,14 +61,12 @@ import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.Ge import org.jclouds.openstack.keystone.v1_1.domain.Auth; import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -84,7 +83,7 @@ import com.google.inject.TypeLiteral; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", singleThreaded = true, testName = "CloudServersAsyncClientTest") -public class CloudServersAsyncClientTest extends RestClientTest { +public class CloudServersAsyncClientTest extends BaseAsyncClientTest { private static final Class listOptionsVarargsClass = new ListOptions[] {}.getClass(); private static final Class createServerOptionsVarargsClass = new CreateServerOptions[] {} .getClass(); @@ -910,8 +909,8 @@ public class CloudServersAsyncClientTest extends RestClientTest createContextSpec() { - return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties()); + protected ApiMetadata createApiMetadata() { + return new CloudServersApiMetadata(); } @Override diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java index 7835e6beee..3618a2c58e 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.lang.reflect.UndeclaredThrowableException; import java.security.SecureRandom; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -45,19 +44,17 @@ import org.jclouds.cloudservers.domain.ServerStatus; import org.jclouds.cloudservers.domain.SharedIpGroup; import org.jclouds.cloudservers.domain.WeeklyBackup; import org.jclouds.cloudservers.options.RebuildServerOptions; -import org.jclouds.compute.BaseVersionedServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpResponseException; import org.jclouds.io.Payload; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; -import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; -import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.util.Strings2; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; @@ -66,10 +63,8 @@ import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Injector; -import com.google.inject.Module; /** * Tests behavior of {@code CloudServersClient} @@ -77,7 +72,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest") -public class CloudServersClientLiveTest extends BaseVersionedServiceLiveTest { +public class CloudServersClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public CloudServersClientLiveTest() { provider = "cloudservers"; } @@ -86,15 +84,11 @@ public class CloudServersClientLiveTest extends BaseVersionedServiceLiveTest { protected SshClient.Factory sshFactory; protected Predicate socketTester; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - - Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides) - .buildInjector(); - + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + Injector injector = context.utils().injector(); client = injector.getInstance(CloudServersClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java index c725549435..d7af173018 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java @@ -24,11 +24,10 @@ import java.io.IOException; import org.jclouds.cloudservers.CloudServersAsyncClient; import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.domain.LocationScope; -import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -41,7 +40,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest") -public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class CloudServersComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public CloudServersComputeServiceLiveTest() { provider = "cloudservers"; } @@ -51,12 +53,6 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe return new SshjSshClientModule(); } - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); - } - @Override protected void checkNodes(Iterable nodes, String group, String task) throws IOException { super.checkNodes(nodes, group, task); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java index fd1e37bd06..71cc584289 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java @@ -23,9 +23,9 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Date; import java.util.Properties; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudservers.CloudServersApiMetadata; import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.cloudservers.CloudServersContextBuilder; -import org.jclouds.cloudservers.CloudServersPropertiesBuilder; import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.RequiresHttp; @@ -47,14 +47,18 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient public BaseCloudServersRestClientExpectTest() { provider = "cloudservers"; } + + @Override + protected ApiMetadata createApiMetadata() { + return new CloudServersApiMetadata(); + } + @Override - protected Properties setupRestProperties() { + protected Properties setupProperties() { Properties overrides = new Properties(); overrides.setProperty(PROPERTY_REGIONS, "US"); overrides.setProperty(provider + ".endpoint", endpoint); - overrides.setProperty(provider + ".contextbuilder", CloudServersContextBuilder.class.getName()); - overrides.setProperty(provider + ".propertiesbuilder", CloudServersPropertiesBuilder.class.getName()); return overrides; } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java index 7d9a7f992e..96cfb3893a 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java @@ -18,51 +18,77 @@ */ package org.jclouds.cloudsigma; +import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for the Cloud Sigma API * * @author Adrian Cole */ -public class CloudSigmaApiMetadata extends BaseApiMetadata { +public class CloudSigmaApiMetadata + extends + BaseComputeServiceApiMetadata, CloudSigmaApiMetadata> { - public CloudSigmaApiMetadata() { - this(builder() - .id("cloudsigma") - .type(ApiType.COMPUTE) - .name("CloudSigma API") - .identityName("Email") - .credentialName("Password") - .documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudSigmaApiMetadata(Builder builder) { + public CloudSigmaApiMetadata() { + this(new Builder()); + } + + protected CloudSigmaApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); + // passwords are set post-boot, so auth failures are possible + // from a race condition applying the password set script + properties.setProperty("jclouds.ssh.max-retries", "7"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, CloudSigmaApiMetadata> { + + protected Builder() { + id("cloudsigma") + .name("CloudSigma API") + .identityName("Email") + .credentialName("Password") + .documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api")) + .version("1.0") + .defaultEndpoint("https://api.cloudsigma.com") + .defaultProperties(CloudSigmaApiMetadata.defaultProperties()) + .javaApi(CloudSigmaClient.class, CloudSigmaAsyncClient.class) + .contextBuilder(TypeToken.of(CloudSigmaContextBuilder.class)); + } @Override public CloudSigmaApiMetadata build() { return new CloudSigmaApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromApiMetadata(CloudSigmaApiMetadata in) { + super.fromApiMetadata(in); + return this; + } - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java index c777e0e408..222e790707 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java @@ -19,11 +19,12 @@ package org.jclouds.cloudsigma; import java.util.List; -import java.util.Properties; import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule; import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -31,10 +32,17 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class CloudSigmaContextBuilder extends ComputeServiceContextBuilder { +public class CloudSigmaContextBuilder + extends + ComputeServiceContextBuilder, CloudSigmaApiMetadata> { - public CloudSigmaContextBuilder(Properties props) { - super(CloudSigmaClient.class, CloudSigmaAsyncClient.class, props); + public CloudSigmaContextBuilder( + ProviderMetadata, CloudSigmaApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public CloudSigmaContextBuilder(CloudSigmaApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java deleted file mode 100644 index bf13f88b68..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudsigma; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in CloudSigma Clients - * - * @author Adrian Cole - */ -public class CloudSigmaPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); - // passwords are set post-boot, so auth failures are possible - // from a race condition applying the password set script - properties.setProperty("jclouds.ssh.max-retries", "7"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - return properties; - } - - public CloudSigmaPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java index f5a9898fd0..3394075e41 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.cloudsigma; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "CloudSigmaApiMetadataTest") -public class CloudSigmaApiMetadataTest extends BaseApiMetadataTest { +public class CloudSigmaApiMetadataTest extends BaseComputeServiceApiMetadataTest { public CloudSigmaApiMetadataTest() { - super(new CloudSigmaApiMetadata(), ApiType.COMPUTE); + super(new CloudSigmaApiMetadata()); } } diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java index 526ba3ef94..d7fafbaf17 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java @@ -22,8 +22,8 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; -import java.util.Properties; +import org.jclouds.apis.ApiMetadata; import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest; import org.jclouds.cloudsigma.domain.CreateDriveRequest; import org.jclouds.cloudsigma.domain.Drive; @@ -44,12 +44,10 @@ import org.jclouds.cloudsigma.options.CloneDriveOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -64,7 +62,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "CloudSigmaAsyncClientTest") -public class CloudSigmaAsyncClientTest extends RestClientTest { +public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest { public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException { Method method = CloudSigmaAsyncClient.class.getMethod("getProfileInfo"); @@ -243,7 +241,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest createContextSpec() { - Properties props = new Properties(); - props.setProperty("cloudsigma.endpoint", "https://api.cloudsigma.com"); - return new RestContextFactory().createContextSpec("cloudsigma", "foo", "bar", props); + protected ApiMetadata createApiMetadata() { + return new CloudSigmaApiMetadata(); } + } diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java index babe31da6a..874a59309e 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java @@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import java.io.IOException; -import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; @@ -44,12 +43,10 @@ import org.jclouds.cloudsigma.domain.VLANInfo; import org.jclouds.cloudsigma.options.CloneDriveOptions; import org.jclouds.cloudsigma.predicates.DriveClaimed; import org.jclouds.cloudsigma.util.Servers; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; @@ -67,7 +64,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.inject.Guice; -import com.google.inject.Module; /** * Tests behavior of {@code CloudSigmaClient} @@ -75,37 +71,37 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest") -public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest { +public class CloudSigmaClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public CloudSigmaClientLiveTest() { provider = "cloudsigma"; } - + protected long driveSize = 8 * 1024 * 1024 * 1024l; protected int maxDriveImageTime = 300; protected String vncPassword = "Il0veVNC"; protected CloudSigmaClient client; - protected RestContext context; + protected RestContext cloudSigmaContext; protected Predicate socketTester; protected Predicate driveNotClaimed; - protected ComputeServiceContext computeContext; + + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + cloudSigmaContext = context.getProviderSpecificContext(); - @BeforeGroups(groups = "live") - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - computeContext = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); - context = computeContext.getProviderSpecificContext(); - - client = context.getApi(); + client = cloudSigmaContext.getApi(); driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, TimeUnit.SECONDS); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), maxDriveImageTime, 1, TimeUnit.SECONDS); - + if (Strings.emptyToNull(imageId) == null) { - imageId = computeContext.getComputeService().templateBuilder().build().getImage().getId(); + imageId = context.getComputeService().templateBuilder().build().getImage().getId(); } } @@ -259,7 +255,7 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest { String prefix2 = prefix + "2"; vlan = client.renameVLAN(vlan.getUuid(), prefix2); - assertEquals(vlan.getName(),prefix2); + assertEquals(vlan.getName(), prefix2); } finally { client.destroyVLAN(id); } @@ -354,7 +350,8 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest { assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE); client.shutdownServer(server.getUuid()); - // behavior on shutdown depends on how your server OS is set up to respond to an ACPI power + // behavior on shutdown depends on how your server OS is set up to respond + // to an ACPI power // button signal assert (client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo( server.getUuid()).getStatus() == ServerStatus.STOPPED); @@ -415,8 +412,8 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest { client.destroyServer(server.getUuid()); if (server != null) client.destroyDrive(drive.getUuid()); - if (context != null) - context.close(); + if (cloudSigmaContext != null) + cloudSigmaContext.close(); } @Test @@ -444,13 +441,10 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest { protected void prepareDrive() { client.destroyDrive(drive.getUuid()); drive = client.cloneDrive(imageId, drive.getName(), - new CloneDriveOptions() - .size(driveSize) - .tags("cat:mouse", "monkey:banana") - ); + new CloneDriveOptions().size(driveSize).tags("cat:mouse", "monkey:banana")); // Block until the async clone operation has completed. assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid()); - + DriveInfo clonedDrive = client.getDriveInfo(drive.getUuid()); System.err.println("after prepare" + clonedDrive); assertEquals(clonedDrive.getTags(), ImmutableSet.of("cat:mouse", "monkey:banana")); diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java index 3410c37a60..7022468935 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java @@ -18,9 +18,12 @@ */ package org.jclouds.cloudsigma.compute; -import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.cloudsigma.CloudSigmaAsyncClient; +import org.jclouds.cloudsigma.CloudSigmaClient; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -31,7 +34,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class CloudSigmaComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public CloudSigmaComputeServiceLiveTest() { provider = "cloudsigma"; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java index d1b30a7e45..80f97b45cf 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java @@ -19,50 +19,81 @@ package org.jclouds.cloudstack; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for Citrix CloudStack API + * Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack api. + * + *

    note

    + *

    + * This class allows overriding of types {@code S}(client) and {@code A} + * (asyncClient), so that children can add additional methods not declared here, + * such as new features from AWS. + *

    + * + * As this is a popular api, we also allow overrides for type {@code C} + * (context). This allows subtypes to add in new feature groups or extensions, + * not present in the base api. For example, you could make a subtype for + * context, that exposes admin operations. * * @author Adrian Cole */ -public class CloudStackApiMetadata extends BaseApiMetadata { +public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata +{ - public CloudStackApiMetadata() { - this(builder() - .id("cloudstack") - .type(ApiType.COMPUTE) - .name("Citrix CloudStack API") - .identityName("API Key") - .credentialName("Secret Key") - .documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudStackApiMetadata(Builder builder) { + public CloudStackApiMetadata() { + this(new Builder()); + } + + protected CloudStackApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty("jclouds.ssh.max-retries", "7"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + return properties; + } + public static class Builder + extends BaseComputeServiceApiMetadata.Builder { + + protected Builder() { + id("cloudstack") + .name("Citrix CloudStack API") + .identityName("API Key") + .credentialName("Secret Key") + .documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html")) + .defaultEndpoint("http://localhost:8080/client/api") + .version("2.2") + .defaultProperties(CloudStackApiMetadata.defaultProperties()) + .javaApi(CloudStackClient.class, CloudStackAsyncClient.class) + .context(TypeToken.of(CloudStackContext.class)) + .contextBuilder(TypeToken.of(CloudStackContextBuilder.class)); + } + @Override public CloudStackApiMetadata build() { return new CloudStackApiMetadata(this); } - } + + @Override + public Builder fromApiMetadata(CloudStackApiMetadata in) { + super.fromApiMetadata(in); + return this; + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContext.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContext.java index 1eb716f5a4..add5192c58 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContext.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContext.java @@ -31,9 +31,8 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(CloudStackContextImpl.class) -public interface CloudStackContext extends ComputeServiceContext { +public interface CloudStackContext extends ComputeServiceContext { - @SuppressWarnings("unchecked") @Override RestContext getProviderSpecificContext(); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java index f1fa6232e9..904972e5ac 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java @@ -23,24 +23,26 @@ import java.util.Properties; import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule; import org.jclouds.cloudstack.config.CloudStackRestClientModule; -import org.jclouds.cloudstack.internal.CloudStackContextImpl; import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.providers.ProviderMetadata; +import com.google.common.annotations.VisibleForTesting; import com.google.inject.Module; /** * * @author Adrian Cole */ -public class CloudStackContextBuilder extends ComputeServiceContextBuilder { +public class CloudStackContextBuilder extends + ComputeServiceContextBuilder { - public CloudStackContextBuilder(Properties props) { - super(CloudStackClient.class, CloudStackAsyncClient.class, props); + public CloudStackContextBuilder( + ProviderMetadata providerMetadata) { + super(providerMetadata); } - @Override - protected void addContextModule(List modules) { - modules.add(new CloudStackComputeServiceContextModule()); + public CloudStackContextBuilder(CloudStackApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -49,7 +51,13 @@ public class CloudStackContextBuilder extends ComputeServiceContextBuilder modules) { + modules.add(new CloudStackComputeServiceContextModule()); } + + @VisibleForTesting + public Properties getOverrides() { + return overrides; + } + } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java deleted file mode 100644 index a271e36510..0000000000 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudstack; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in cloudstack Clients - * - * @author Adrian Cole - */ -public class CloudStackPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "http://localhost:8080/client/api"); - properties.setProperty(PROPERTY_API_VERSION, "2.2"); - properties.setProperty("jclouds.ssh.max-retries", "7"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - return properties; - } - - public CloudStackPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java index 3995f1cfd7..4508246b79 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java @@ -18,7 +18,7 @@ */ package org.jclouds.cloudstack.config; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContextBuilder; /** * Configuration properties and constants used in CloudStack connections. @@ -28,7 +28,7 @@ import org.jclouds.compute.ComputeServiceContextFactory; public interface CloudStackProperties { /** - * Type of credentials specified during {@link ComputeServiceContextFactory#createContext}. If + * Type of credentials specified during {@link ComputeServiceContextBuilder#overrides}. If * {@link CredentialType#API_ACCESS_KEY_CREDENTIALS}, the request signing is used. If * {@link CredentialType#PASSWORD_CREDENTIALS}, login will happen and a session will be * persisted. diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java index 34b8e7077d..2be7231dd2 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java @@ -57,7 +57,6 @@ public class CloudStackContextImpl extends ComputeServiceContextImpl getProviderSpecificContext() { return providerSpecificContext; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java index 4e9ee91773..1683fd9524 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java @@ -26,24 +26,19 @@ import java.util.Properties; import java.util.Set; import org.jclouds.Constants; +import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.CloudStackClient; +import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.ApiKeyPair; import org.jclouds.cloudstack.domain.User; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.rest.RestContextFactory; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; +import org.jclouds.compute.ComputeServiceContextBuilder; /** * @author Andrei Savu */ public class ApiKeyPairs { - private final static String PROVIDER = "cloudstack"; - /** * Retrieve the API key pair for a given CloudStack user * @@ -60,10 +55,17 @@ public class ApiKeyPairs { */ public static ApiKeyPair loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair( URI endpoint, String username, String password, String domain) { - ComputeServiceContext context = null; + CloudStackContext context = null; try { - context = new ComputeServiceContextFactory(setupRestProperties()). - createContext(PROVIDER, ImmutableSet.of(), setupProperties(endpoint, username, password, domain)); + Properties overrides = new Properties(); + overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials"); + + context = ComputeServiceContextBuilder.newBuilder(new CloudStackApiMetadata()) + .endpoint(checkNotNull(endpoint, "endpoint").toASCIIString()) + .credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password) + .overrides(overrides).build(); CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); Set listOfAccounts = client.getAccountClient().listAccounts(); @@ -85,23 +87,4 @@ public class ApiKeyPairs { } } - private static Properties setupRestProperties() { - return RestContextFactory.getPropertiesFromResource("/rest.properties"); - } - - private static Properties setupProperties(URI endpoint, String username, String password, String domain) { - Properties overrides = new Properties(); - - overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - - overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials"); - - overrides.put(PROVIDER + ".endpoint", checkNotNull(endpoint, "endpoint").toASCIIString()); - overrides.put(PROVIDER + ".identity", - String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username"))); - overrides.put(PROVIDER + ".credential", checkNotNull(password, "password")); - - return overrides; - } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java index d2d5676dad..81c9746861 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.cloudstack; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "CloudStackApiMetadataTest") -public class CloudStackApiMetadataTest extends BaseApiMetadataTest { +public class CloudStackApiMetadataTest extends BaseComputeServiceApiMetadataTest { public CloudStackApiMetadataTest() { - super(new CloudStackApiMetadata(), ApiType.COMPUTE); + super(new CloudStackApiMetadata()); } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java index 791e1d9047..8dad16187e 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java @@ -23,9 +23,7 @@ import static com.google.inject.name.Names.bindProperties; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; -import static org.testng.Assert.fail; -import java.io.IOException; import java.util.Map; import java.util.Random; import java.util.Set; @@ -97,21 +95,21 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien Map credentialStore = Maps.newLinkedHashMap(); @BeforeGroups(groups = { "live" }) - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); Module module = new AbstractModule() { @Override protected void configure() { bindProperties(binder(), setupProperties()); - bind(String.class).annotatedWith(Identity.class).toInstance(identity); + bind(String.class).annotatedWith(Identity.class).toInstance(context.getProviderSpecificContext().getIdentity()); bind(new TypeLiteral>() { }).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON); bind(new TypeLiteral>>() { }).annotatedWith(Memoized.class).to(NetworksForCurrentUser.class).in(Scopes.SINGLETON); bind(new TypeLiteral>() { }).toInstance(credentialStore); - bind(CloudStackClient.class).toInstance(context.getApi()); + bind(CloudStackClient.class).toInstance(cloudStackContext.getApi()); bind(new TypeLiteral>() {}). toInstance(new CloudStackComputeServiceContextModule().optionsConverters()); bind(Long.class).annotatedWith(Names.named(PROPERTY_SESSION_INTERVAL)).toInstance(60L); @@ -141,15 +139,10 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien CloudStackComputeServiceAdapter.class); keyPairName = prefix + "-adapter-test-keypair"; - try { - keyPair = ComputeTestUtils.setupKeyPair(); + keyPair = ComputeTestUtils.setupKeyPair(); - client.getSSHKeyPairClient().deleteSSHKeyPair(keyPairName); - client.getSSHKeyPairClient().registerSSHKeyPair(keyPairName, keyPair.get("public")); - - } catch (IOException e) { - fail("Unable to create keypair", e); - } + client.getSSHKeyPairClient().deleteSSHKeyPair(keyPairName); + client.getSSHKeyPairClient().registerSSHKeyPair(keyPairName, keyPair.get("public")); } @Test @@ -164,7 +157,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien public void testCreateNodeWithGroupEncodedIntoName() throws InterruptedException { String group = prefix + "-foo"; String name = group + "-node-" + new Random().nextInt(); - Template template = computeContext.getComputeService().templateBuilder().build(); + Template template = context.getComputeService().templateBuilder().build(); if (!client .getTemplateClient() diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java index 68b94e17ab..a0ae087295 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java @@ -20,15 +20,14 @@ package org.jclouds.cloudstack.compute; import org.jclouds.cloudstack.CloudStackAsyncClient; import org.jclouds.cloudstack.CloudStackClient; -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -38,7 +37,8 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class CloudStackComputeServiceLiveTest extends + BaseComputeServiceLiveTest { public CloudStackComputeServiceLiveTest() { provider = "cloudstack"; } @@ -50,9 +50,7 @@ public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest public void testAssignability() throws Exception { @SuppressWarnings("unused") - RestContext tmContext = new ComputeServiceContextFactory( - setupRestProperties()).createContext(provider, identity, credential, ImmutableSet. of(), - setupProperties()).getProviderSpecificContext(); + RestContext tmContext = context.getProviderSpecificContext(); } // cloudstack does not support metadata diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackExperimentLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackExperimentLiveTest.java index c99cb8bdfe..c8c8445bb7 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackExperimentLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackExperimentLiveTest.java @@ -90,9 +90,9 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { Network network = null; Set nodes = null; try { - assert computeContext.getComputeService().listAssignableLocations().size() > 0; + assert context.getComputeService().listAssignableLocations().size() > 0; - Template template = computeContext.getComputeService().templateBuilder().build(); + Template template = context.getComputeService().templateBuilder().build(); // get the zone we are launching into long zoneId = Long.parseLong(template.getLocation().getId()); @@ -102,7 +102,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { // find a network offering that supports vlans in our zone long offeringId = get( - context.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zoneId)), 0).getId(); + cloudStackContext.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zoneId)), 0).getId(); // create an arbitrary network network = domainAdminContext.getApi() @@ -115,7 +115,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { template.getOptions().as(CloudStackTemplateOptions.class).networkId(network.getId()); // launch the VM - nodes = computeContext.getComputeService().createNodesInGroup(group, 1, template); + nodes = context.getComputeService().createNodesInGroup(group, 1, template); assert nodes.size() > 0; @@ -124,7 +124,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); } finally { if (nodes != null) - computeContext.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); + context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); if (network != null) domainAdminContext.getApi().getNetworkClient().deleteNetwork(network.getId()); } @@ -143,14 +143,14 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { SshKeyPair keyPair = client.getSSHKeyPairClient().createSSHKeyPair(keyPairName); String group = prefix + "-windows-test"; - Template template = computeContext.getComputeService().templateBuilder() + Template template = context.getComputeService().templateBuilder() .imageId("290").locationId("1") .options(new CloudStackTemplateOptions().setupStaticNat(false).keyPair(keyPairName)) .build(); NodeMetadata node = null; try { - node = getOnlyElement(computeContext.getComputeService() + node = getOnlyElement(context.getComputeService() .createNodesInGroup(group, 1, template)); String encryptedPassword = client.getVirtualMachineClient() @@ -165,7 +165,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { } finally { if (node != null) { - computeContext.getComputeService().destroyNode(node.getId()); + context.getComputeService().destroyNode(node.getId()); } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java index 709601b2c1..e0484cef19 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java @@ -20,25 +20,22 @@ package org.jclouds.cloudstack.features; import static org.testng.Assert.assertEquals; -import java.util.Properties; - -import org.jclouds.cloudstack.CloudStackAsyncClient; -import org.jclouds.cloudstack.CloudStackClient; +import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.config.CloudStackRestClientModule; import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import com.google.inject.Module; /** * @author Adrian Cole */ -public abstract class BaseCloudStackAsyncClientTest extends RestClientTest { +public abstract class BaseCloudStackAsyncClientTest extends BaseAsyncClientTest { @RequiresHttp @ConfiguresRestClient @@ -58,10 +55,9 @@ public abstract class BaseCloudStackAsyncClientTest extends RestClientTest } @Override - public RestContextSpec createContextSpec() { - Properties props = new Properties(); - props.setProperty("cloudstack.endpoint", "http://localhost:8080/client/api"); - return new RestContextFactory().createContextSpec("cloudstack", "apiKey", "secretKey", props); + protected ProviderMetadata createProviderMetadata() { + return AnonymousProviderMetadata.forApiWithEndpoint(new CloudStackApiMetadata(), + "http://localhost:8080/client/api"); } } \ No newline at end of file diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java index f46a1923eb..db2510239e 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.cloudstack.features; -import static com.google.common.base.Strings.emptyToNull; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.get; import static org.testng.Assert.assertEquals; @@ -50,11 +49,9 @@ import org.jclouds.cloudstack.predicates.UserPredicates; import org.jclouds.cloudstack.predicates.VirtualMachineDestroyed; import org.jclouds.cloudstack.predicates.VirtualMachineRunning; import org.jclouds.cloudstack.strategy.BlockUntilJobCompletesAndReturnResult; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; @@ -76,7 +73,8 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { +public class BaseCloudStackClientLiveTest extends + BaseComputeServiceContextLiveTest { protected String domainAdminIdentity; protected String domainAdminCredential; protected String globalAdminIdentity; @@ -87,12 +85,13 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { } @Override - protected void setupCredentials() { - super.setupCredentials(); - domainAdminIdentity = emptyToNull(System.getProperty("test." + provider + ".domainAdminIdentity")); - domainAdminCredential = emptyToNull(System.getProperty("test." + provider + ".domainAdminCredential")); - globalAdminIdentity = emptyToNull(System.getProperty("test." + provider + ".globalAdminIdentity")); - globalAdminCredential = emptyToNull(System.getProperty("test." + provider + ".globalAdminCredential")); + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + domainAdminIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".domainAdminIdentity"); + domainAdminCredential = setIfTestSystemPropertyPresent(overrides, provider + ".domainAdminCredential"); + globalAdminIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".globalAdminIdentity"); + globalAdminCredential = setIfTestSystemPropertyPresent(overrides, provider + ".globalAdminCredential"); + return overrides; } protected Properties setupDomainAdminProperties() { @@ -146,9 +145,8 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { protected String prefix = System.getProperty("user.name"); - protected CloudStackContext computeContext; protected ComputeService computeClient; - protected RestContext context; + protected RestContext cloudStackContext; protected CloudStackClient client; protected CloudStackClient adminClient; protected User user; @@ -192,23 +190,18 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { } } - @BeforeGroups(groups = "live") - public void setupClient() { - setupCredentials(); - - computeContext = CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()). - createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), setupProperties())); - computeClient = computeContext.getComputeService(); - context = computeContext.getProviderSpecificContext(); - client = context.getApi(); - user = verifyCurrentUserIsOfType(context, Account.Type.USER); + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + computeClient = context.getComputeService(); + cloudStackContext = context.getProviderSpecificContext(); + client = cloudStackContext.getApi(); + user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER); domainAdminEnabled = setupDomainAdminProperties() != null; if (domainAdminEnabled) { - domainAdminComputeContext = CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()). - createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), setupDomainAdminProperties())); + domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()); domainAdminContext = domainAdminComputeContext.getDomainContext(); domainAdminClient = domainAdminContext.getApi(); domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN); @@ -217,16 +210,14 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { globalAdminEnabled = setupGlobalAdminProperties() != null; if (globalAdminEnabled) { - globalAdminComputeContext = CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()). - createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), setupGlobalAdminProperties())); + globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()); globalAdminContext = globalAdminComputeContext.getGlobalContext(); globalAdminClient = globalAdminContext.getApi(); globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN); adminClient = globalAdminContext.getApi(); } - injector = Guice.createInjector(new SshjSshClientModule(), new Log4JLoggingModule()); + injector = Guice.createInjector(setupModules()); sshFactory = injector.getInstance(SshClient.Factory.class); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 180, 1, 1, TimeUnit.SECONDS); injector.injectMembers(socketTester); @@ -251,6 +242,11 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { injector.injectMembers(reuseOrAssociate); } + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); + } + protected static User verifyCurrentUserIsOfType( RestContext context, Account.Type type) { Iterable users = Iterables.concat(context.getApi().getAccountClient().listAccounts()); @@ -272,8 +268,8 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest { @AfterGroups(groups = "live") protected void tearDown() { - if (context != null) - context.close(); + if (cloudStackContext != null) + cloudStackContext.close(); } } \ No newline at end of file diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java index 706767cdb3..5686229973 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java @@ -24,16 +24,15 @@ import java.net.URI; import java.net.URLEncoder; import java.util.Properties; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.CloudStackContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import com.google.common.base.Function; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -46,12 +45,16 @@ public abstract class BaseCloudStackRestClientExpectTest extends BaseRestClie public BaseCloudStackRestClientExpectTest() { provider = "cloudstack"; } + + @Override + protected ApiMetadata createApiMetadata() { + return new CloudStackApiMetadata(); + } + @Override public S createClient(Function fn, Module module, Properties props) { - return clientFrom(CloudStackContext.class.cast(new ComputeServiceContextFactory(setupRestProperties()) - .createContext(provider, "identity", "credential", ImmutableSet. of(new ExpectModule(fn), - new NullLoggingModule(), module), props))); + return (S) clientFrom(createInjector(fn, module, props).getInstance(CloudStackContext.class)); } protected abstract S clientFrom(CloudStackContext context); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallClientLiveTest.java index e25fbee915..089af5bb70 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallClientLiveTest.java @@ -61,8 +61,8 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest { private boolean networksDisabled; @BeforeGroups(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); prefix += "rule"; try { network = find(client.getNetworkClient().listNetworks(), Predicates.and(supportsPortForwarding(), diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java index e42de2287e..e3b3a1cb58 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java @@ -33,15 +33,9 @@ import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.ApiKeyPair; import org.jclouds.cloudstack.domain.User; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.crypto.CryptoStreams; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code GlobaUserClient} */ @@ -89,9 +83,7 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest { } private void checkAuthAsUser(ApiKeyPair keyPair) { - ComputeServiceContext context = new ComputeServiceContextFactory(setupRestProperties()). - createContext(provider, ImmutableSet.of( - new Log4JLoggingModule(), new SshjSshClientModule()), credentialsAsProperties(keyPair)); + ComputeServiceContext context = createContext(credentialsAsProperties(keyPair), setupModules()); CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); Set accounts = client.getAccountClient().listAccounts(); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java index d190627bdd..759579c4f4 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java @@ -66,8 +66,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest { private boolean networksDisabled; @BeforeGroups(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); loadBalancerRuleActive = new RetryablePredicate(new LoadBalancerRuleActive(client), 60, 1, 1, TimeUnit.SECONDS); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkClientLiveTest.java index 78dba8a0d9..6cc29c7112 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkClientLiveTest.java @@ -55,8 +55,8 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest { private Zone zone; @BeforeGroups(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); try { zone = find(client.getZoneClient().listZones(), ZonePredicates.supportsAdvancedNetworks()); @@ -104,7 +104,7 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest { final NetworkOffering offering; try { offering = get( - context.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zone.getId())), 0); + cloudStackContext.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zone.getId())), 0); } catch (NoSuchElementException e) { Logger.getAnonymousLogger().log(Level.SEVERE, "VLAN networks not supported, skipping test"); return; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java index eb4ec13f05..fd187ab6c4 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java @@ -34,6 +34,8 @@ import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions; import org.jclouds.cloudstack.options.ListServiceOfferingsOptions; import org.testng.annotations.Test; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; /** @@ -64,7 +66,7 @@ public class OfferingClientLiveTest extends BaseCloudStackClientLiveTest { } catch (NoSuchElementException e) { // This bug is present both in 2.2.8 and 2.2.12 - assertTrue("2.2.8".equals(apiVersion) || "2.2.12".equals(apiVersion)); + assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply(cloudStackContext.getApiVersion())); } } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SessionClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SessionClientLiveTest.java index ca7efd015d..938be58289 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SessionClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SessionClientLiveTest.java @@ -44,6 +44,7 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest { @Test public void testCreateContextUsingUserAndPasswordAuthentication() { + String endpoint = cloudStackContext.getEndpoint().toASCIIString(); assert globalAdminEnabled; Account testAccount = null; @@ -74,6 +75,7 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest { @Test(expectedExceptions = AuthorizationException.class) public void testTryToGetApiKeypairWithWrongCredentials() { + String endpoint = cloudStackContext.getEndpoint().toASCIIString(); ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair( URI.create(endpoint), "dummy-missing-user", "with-a-wrong-password", ""); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java index ab02040466..60ce768e55 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java @@ -149,7 +149,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest { String extractUrl = extract.getUrl(); assertNotNull(extractUrl); URI uri = new URI(URLDecoder.decode(extractUrl, "utf-8")); - assertTrue(context.utils().http().exists(uri), "does not exist: " + uri); + assertTrue(cloudStackContext.utils().http().exists(uri), "does not exist: " + uri); } @Test(enabled = true) diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java index fc40f9e87b..bcffc9b1f6 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java @@ -58,7 +58,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest DUMMY_SPEC = new RestContextSpec("cloudstack", - "http://localhost:8080/client/api", "2.2", "", "", "apiKey", "secretKey", IntegrationTestClient.class, IntegrationTestAsyncClient.class, - PropertiesBuilder.class, (Class) RestContextBuilder.class, ImmutableList. of(new MockModule(), - new NullLoggingModule(), new AbstractModule() { - @Override - protected void configure() { - bind(RequestSigner.class).to(QuerySigner.class); - } + public static final Injector INJECTOR = ContextBuilder + .newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, + "http://localhost:8080/client/api")) + .credentials("apiKey", "secretKey") + .apiVersion("2.2") + .modules(ImmutableList. of(new MockModule(), new NullLoggingModule())).buildInjector(); - })); @Test void testCreateStringToSign() { - QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector() - .getInstance(QuerySigner.class); + QuerySigner filter = INJECTOR.getInstance(QuerySigner.class); assertEquals( filter.createStringToSign(HttpRequest.builder().method("GET") @@ -72,8 +65,7 @@ public class QuerySignerTest { @Test void testFilter() { - QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector() - .getInstance(QuerySigner.class); + QuerySigner filter = INJECTOR.getInstance(QuerySigner.class); assertEquals( filter.filter( @@ -85,8 +77,7 @@ public class QuerySignerTest { @Test void testFilterTwice() { - QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector() - .getInstance(QuerySigner.class); + QuerySigner filter = INJECTOR.getInstance(QuerySigner.class); HttpRequest request = HttpRequest.builder().method("GET") .endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build(); for (int i = 0; i < 2; i++) { diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/StaticNATVirtualMachineInNetworkLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/StaticNATVirtualMachineInNetworkLiveTest.java index 592b937de3..c0308fac3d 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/StaticNATVirtualMachineInNetworkLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/StaticNATVirtualMachineInNetworkLiveTest.java @@ -61,7 +61,7 @@ public class StaticNATVirtualMachineInNetworkLiveTest extends NATClientLiveTest @BeforeGroups(groups = "live") public void setupClient() { - super.setupClient(); + super.setupContext(); prefix += "nat"; try { network = find(client.getNetworkClient().listNetworks(), NetworkPredicates.supportsStaticNAT()); diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java index 70a8190377..51fb3b648d 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java @@ -18,50 +18,83 @@ */ package org.jclouds.cloudwatch; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** * Implementation of {@link ApiMetadata} for Amazon's CloudWatch api. * + *

    note

    + *

    + * This class allows overriding of types {@code S}(client) and {@code A}(asyncClient), so that + * children can add additional methods not declared here, such as new features + * from AWS. + *

    + * + * This class is not setup to allow a different context than {@link RestContext} + * . By doing so, it reduces the type complexity. + * * @author Adrian Cole */ -public class CloudWatchApiMetadata extends BaseApiMetadata { +public class CloudWatchApiMetadata extends + BaseRestApiMetadata, CloudWatchApiMetadata> { + + @Override + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + } public CloudWatchApiMetadata() { - this(builder() - .id("cloudwatch") - .type(ApiType.MONITOR) - .name("Amazon CloudWatch Api") - .identityName("Access Key ID") - .credentialName("Secret Access Key") - .documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/"))); + this(new Builder(CloudWatchClient.class, CloudWatchAsyncClient.class)); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudWatchApiMetadata(Builder builder) { - super(builder); + @SuppressWarnings("unchecked") + protected CloudWatchApiMetadata(Builder builder) { + super(Builder.class.cast(builder)); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); + properties.setProperty(PROPERTY_HEADER_TAG, "amz"); + return properties; + } + + public static class Builder extends + BaseRestApiMetadata.Builder, CloudWatchApiMetadata> { + + protected Builder(Class client, Class asyncClient) { + super(client, asyncClient); + id("cloudwatch") + .type(ApiType.MONITOR) + .name("Amazon CloudWatch Api") + .identityName("Access Key ID") + .credentialName("Secret Access Key") + .version(CloudWatchAsyncClient.VERSION) + .defaultProperties(CloudWatchApiMetadata.defaultProperties()) + .defaultEndpoint("https://monitoring.us-east-1.amazonaws.com") + .documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/")); + } @Override - public CloudWatchApiMetadata build() { - return new CloudWatchApiMetadata(this); + public CloudWatchApiMetadata build() { + return new CloudWatchApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(CloudWatchApiMetadata in) { + super.fromApiMetadata(in); + return this; } } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java index b08b3bd2a6..7d60ccef2b 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java @@ -19,33 +19,42 @@ package org.jclouds.cloudwatch; import java.util.List; -import java.util.Properties; import org.jclouds.cloudwatch.config.CloudWatchRestClientModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContextBuilder; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link MonitoringContext} or {@link Injector} instances based on the most commonly requested - * arguments. + * Creates {@link MonitoringContext} or {@link Injector} instances based on the + * most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole * @see MonitoringContext */ -public class CloudWatchContextBuilder extends RestContextBuilder { +public class CloudWatchContextBuilder + extends RestContextBuilder, CloudWatchApiMetadata> { - public CloudWatchContextBuilder(Properties props) { - super(CloudWatchClient.class, CloudWatchAsyncClient.class, props); + public CloudWatchContextBuilder(ProviderMetadata, CloudWatchApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public CloudWatchContextBuilder(CloudWatchApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchPropertiesBuilder.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchPropertiesBuilder.java deleted file mode 100644 index b641d2c2e5..0000000000 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchPropertiesBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudwatch; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Cloud Watch Clients - * - * @author Adrian Cole - */ -public class CloudWatchPropertiesBuilder extends PropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_HEADER_TAG, "amz"); - properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION); - return properties; - } - - public CloudWatchPropertiesBuilder() { - super(); - } - - public CloudWatchPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java index e1a72cdba6..0321386289 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java @@ -19,15 +19,16 @@ package org.jclouds.cloudwatch; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.apis.internal.BaseRestApiMetadataTest; import org.testng.annotations.Test; /** * * @author Adrian Cole */ +@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "CloudWatchApiMetadataTest") -public class CloudWatchApiMetadataTest extends BaseApiMetadataTest { +public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest { public CloudWatchApiMetadataTest() { super(new CloudWatchApiMetadata(), ApiType.MONITOR); diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java index 2f4b4f2ce3..193b032682 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java @@ -26,11 +26,11 @@ import java.lang.reflect.Method; import java.net.URI; import java.util.Date; import java.util.Map; -import java.util.Properties; import javax.inject.Named; import org.jclouds.Constants; +import org.jclouds.apis.ApiMetadata; import org.jclouds.aws.domain.Region; import org.jclouds.aws.filters.FormSigner; import org.jclouds.cloudwatch.config.CloudWatchRestClientModule; @@ -44,9 +44,7 @@ import org.jclouds.http.functions.ParseSax; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.util.Suppliers2; import org.testng.annotations.Test; @@ -64,7 +62,7 @@ import com.google.inject.TypeLiteral; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", testName = "CloudWatchAsyncClientTest") -public class CloudWatchAsyncClientTest extends RestClientTest { +public class CloudWatchAsyncClientTest extends BaseAsyncClientTest { public void testRegisterInstancesWithMeasure() throws SecurityException, NoSuchMethodException, IOException { Date date = new Date(10000000l); @@ -125,11 +123,10 @@ public class CloudWatchAsyncClientTest extends RestClientTest createContextSpec() { - Properties props = new Properties(); - props.setProperty("cloudwatch.endpoint", "https://monitoring.us-east-1.amazonaws.com"); - return new RestContextFactory().createContextSpec("cloudwatch", "identity", "credential", props); + public ApiMetadata createApiMetadata() { + return new CloudWatchApiMetadata(); } @Override diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java index 672eaead3e..7bf1a80563 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java @@ -22,45 +22,34 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Calendar; import java.util.Date; -import java.util.Properties; import java.util.Set; import org.jclouds.cloudwatch.domain.Datapoint; import org.jclouds.cloudwatch.domain.Statistics; import org.jclouds.cloudwatch.domain.Unit; import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.BaseRestClientLiveTest; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.jclouds.rest.internal.BaseContextLiveTest; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code CloudWatchClient} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class CloudWatchClientLiveTest extends BaseRestClientLiveTest { +public class CloudWatchClientLiveTest extends BaseContextLiveTest> { public CloudWatchClientLiveTest() { provider = "cloudwatch"; } private CloudWatchClient client; - private RestContext context; - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new RestContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); client = context.getApi(); } @@ -73,15 +62,9 @@ public class CloudWatchClientLiveTest extends BaseRestClientLiveTest { Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, -60 * 24 * 3); // 3 days - Set datapoints = client.getMetricStatisticsInRegion( - region, "CPUUtilization", "AWS/EC2", cal.getTime(), new Date(), 180, Statistics.AVERAGE, - GetMetricStatisticsOptions.Builder.unit(Unit.PERCENT)); + Set datapoints = client.getMetricStatisticsInRegion(region, "CPUUtilization", "AWS/EC2", + cal.getTime(), new Date(), 180, Statistics.AVERAGE, GetMetricStatisticsOptions.Builder.unit(Unit.PERCENT)); return checkNotNull(datapoints, "Got null response for EC2 datapoints in region "); } - - @AfterTest - public void shutdown() { - context.close(); - } } diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java index ff12e02b9f..f84a352a8f 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java @@ -19,50 +19,63 @@ package org.jclouds.deltacloud; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for Apache Deltacloud API * * @author Adrian Cole */ -public class DeltacloudApiMetadata extends BaseApiMetadata { +public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata, DeltacloudApiMetadata> { - public DeltacloudApiMetadata() { - this(builder() - .id("deltacloud") - .type(ApiType.COMPUTE) - .name("Apache Deltacloud API") - .identityName("Username") - .credentialName("Password") - .documentation(URI.create("http://deltacloud.apache.org/api.html"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected DeltacloudApiMetadata(Builder builder) { + public DeltacloudApiMetadata() { + this(new Builder()); + } + + protected DeltacloudApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + return BaseComputeServiceApiMetadata.Builder.defaultProperties(); + } + + public static class Builder extends BaseComputeServiceApiMetadata.Builder, DeltacloudApiMetadata> { + + protected Builder() { + id("deltacloud") + .name("Apache Deltacloud API") + .identityName("Username") + .credentialName("Password") + .documentation(URI.create("http://deltacloud.apache.org/api.html")) + .version("0.3.0") + .defaultEndpoint("http://localhost:3001/api") + .javaApi(DeltacloudClient.class, DeltacloudAsyncClient.class) + .contextBuilder(TypeToken.of(DeltacloudContextBuilder.class)); + } + + @Override + public DeltacloudApiMetadata build() { + return new DeltacloudApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(DeltacloudApiMetadata in) { + super.fromApiMetadata(in); + return this; + } - @Override - public DeltacloudApiMetadata build() { - return new DeltacloudApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - -} \ No newline at end of file + } \ No newline at end of file diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java index b84e82c5d2..b37769c36e 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java @@ -19,11 +19,12 @@ package org.jclouds.deltacloud; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule; import org.jclouds.deltacloud.config.DeltacloudRestClientModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -31,10 +32,17 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class DeltacloudContextBuilder extends ComputeServiceContextBuilder { +public class DeltacloudContextBuilder + extends + ComputeServiceContextBuilder, DeltacloudApiMetadata> { - public DeltacloudContextBuilder(Properties props) { - super(DeltacloudClient.class, DeltacloudAsyncClient.class, props); + public DeltacloudContextBuilder( + ProviderMetadata, DeltacloudApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public DeltacloudContextBuilder(DeltacloudApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudPropertiesBuilder.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudPropertiesBuilder.java deleted file mode 100644 index eeb3d1d531..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudPropertiesBuilder.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.deltacloud; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in deltacloud Clients - * - * @author Adrian Cole - */ -public class DeltacloudPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "0.3.0"); - properties.setProperty(PROPERTY_ENDPOINT, "http://localhost:3001/api"); - return properties; - } - - public DeltacloudPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java index 2dd950d963..da1263f079 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.deltacloud; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "DeltacloudApiMetadataTest") -public class DeltacloudApiMetadataTest extends BaseApiMetadataTest { +public class DeltacloudApiMetadataTest extends BaseComputeServiceApiMetadataTest { public DeltacloudApiMetadataTest() { - super(new DeltacloudApiMetadata(), ApiType.COMPUTE); + super(new DeltacloudApiMetadata()); } } diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java index e9611fb98e..d8f0e1899b 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java @@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; import java.net.URI; -import java.util.Properties; import java.util.Set; +import org.jclouds.apis.ApiMetadata; import org.jclouds.deltacloud.config.DeltacloudRestClientModule; import org.jclouds.deltacloud.domain.DeltacloudCollection; import org.jclouds.deltacloud.functions.ReturnVoidOnRedirectedDelete; @@ -46,12 +46,10 @@ import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.ReturnEmptyMultimapOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -67,9 +65,10 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire @Test(groups = "unit", testName = "DeltacloudAsyncClientTest") -public class DeltacloudAsyncClientTest extends RestClientTest { +public class DeltacloudAsyncClientTest extends BaseAsyncClientTest { public void testGetCollections() throws SecurityException, NoSuchMethodException, IOException { Method method = DeltacloudAsyncClient.class.getMethod("getCollections"); HttpRequest httpRequest = processor.createRequest(method); @@ -85,7 +84,7 @@ public class DeltacloudAsyncClientTest extends RestClientTest httpRequest = processor.createRequest(method, "imageId-1"); assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1"); @@ -250,9 +249,9 @@ public class DeltacloudAsyncClientTest extends RestClientTest httpRequest = processor.createRequest(method, "imageId-1", - CreateInstanceOptions.Builder.named("foo")); + CreateInstanceOptions.Builder.named("foo")); assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\n"); @@ -268,8 +267,8 @@ public class DeltacloudAsyncClientTest extends RestClientTest provideHardwareProfileCollection(Supplier> collectionSupplier) { + protected Supplier provideHardwareProfileCollection( + Supplier> collectionSupplier) { return Suppliers.ofInstance(URI.create("http://localhost:3001/api/profiles")); } @@ -329,15 +329,13 @@ public class DeltacloudAsyncClientTest extends RestClientTest provideInstanceStateCollection(Supplier> collectionSupplier) { + protected Supplier provideInstanceStateCollection( + Supplier> collectionSupplier) { return Suppliers.ofInstance(URI.create("http://localhost:3001/api/instance_states")); } } - @Override - public RestContextSpec createContextSpec() { - Properties props = new Properties(); - props.setProperty("deltacloud.endpoint", "http://localhost:3001/api"); - return new RestContextFactory().createContextSpec("deltacloud", "foo", "bar", props); + protected ApiMetadata createApiMetadata() { + return new DeltacloudApiMetadata(); } } diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java index 0842c81890..82a4f46532 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java @@ -35,6 +35,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.net.IPSocket; import org.jclouds.ssh.SshClient; import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.annotations.AfterClass; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -150,9 +151,9 @@ public class DeltacloudClientLiveTest extends ReadOnlyDeltacloudClientLiveTest { } @Override - protected void tearDown() { + @AfterClass(groups = { "integration", "live" }) + protected void tearDownContext() { testDestroyInstance(); - super.tearDown(); + super.tearDownContext(); } - } diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java index 487f613b9f..3aefc77489 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java @@ -22,12 +22,11 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.deltacloud.domain.DeltacloudCollection; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Image; @@ -37,13 +36,11 @@ import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.predicates.InstanceFinished; import org.jclouds.deltacloud.predicates.InstanceRunning; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.RestContext; -import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeGroups; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -60,27 +57,24 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ReadOnlyDeltacloudClientLiveTest") -public class ReadOnlyDeltacloudClientLiveTest extends BaseVersionedServiceLiveTest { +public class ReadOnlyDeltacloudClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public ReadOnlyDeltacloudClientLiveTest() { provider = "deltacloud"; } protected DeltacloudClient client; - protected RestContext context; - protected Predicate socketTester; protected ImmutableMap> stateChanges; - - @BeforeGroups(groups = "live") - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides).getProviderSpecificContext(); - - client = context.getApi(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi(); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS); stateChanges = ImmutableMap.> of(// Instance.State.RUNNING, new RetryablePredicate(new InstanceRunning(client), 600, 1, @@ -168,10 +162,9 @@ public class ReadOnlyDeltacloudClientLiveTest extends BaseVersionedServiceLiveTe } } - @AfterGroups(groups = "live") - protected void tearDown() { - if (context != null) - context.close(); + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); } } diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java index e2c8522958..7fc4ca3ff2 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java @@ -22,9 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.deltacloud.DeltacloudAsyncClient; import org.jclouds.deltacloud.DeltacloudClient; import org.jclouds.domain.LocationScope; @@ -41,7 +41,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "DeltacloudComputeServiceLiveTest") -public class DeltacloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class DeltacloudComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public DeltacloudComputeServiceLiveTest() { provider = "deltacloud"; } @@ -60,8 +63,7 @@ public class DeltacloudComputeServiceLiveTest extends BaseComputeServiceLiveTest public void testAssignability() throws Exception { @SuppressWarnings("unused") - RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + RestContext tmContext = context.getProviderSpecificContext(); } @Override diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java index bfbc4ca6cf..b1aaea7f7c 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.deltacloud.DeltacloudAsyncClient; +import org.jclouds.deltacloud.DeltacloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class DeltacloudTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public DeltacloudTemplateBuilderLiveTest() { provider = "deltacloud"; diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java index c74823b97d..1403fdf20e 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java @@ -25,22 +25,13 @@ import static org.easymock.EasyMock.verify; import java.net.URI; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.BaseRestClientTest.MockModule; -import org.jclouds.rest.config.RestModule; import org.testng.annotations.Test; -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; import com.google.inject.Injector; -import com.google.inject.Provides; /** * Tests behavior of {@code DeltacloudRedirectionRetry} @@ -49,19 +40,7 @@ import com.google.inject.Provides; */ @Test(groups = "unit") public class DeltacloudRedirectionRetryHandlerTest { - Injector injector = Guice.createInjector(new MockModule(), new RestModule(), new AbstractModule() { - @SuppressWarnings("unused") - @Provides - @Singleton - @Named("CONSTANTS") - protected Multimap constants() { - return LinkedHashMultimap.create(); - } - - @Override - protected void configure() { - } - }); + Injector injector = ComputeServiceContextBuilder.forTests().buildInjector(); @Test public void test302DoesNotRetryOnDelete() { diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java index 6e5120ab3d..80c26fc456 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java @@ -18,58 +18,111 @@ */ package org.jclouds.ec2; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; +import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; + +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for Amazon's EC2 api. * + *

    note

    + *

    + * This class allows overriding of types {@code S}(client) and {@code A} + * (asyncClient), so that children can add additional methods not declared here, + * such as new features from AWS. + *

    + * + * As this is a popular api, we also allow overrides for type {@code C} + * (context). This allows subtypes to add in new feature groups or extensions, + * not present in the base api. For example, you could make a subtype for + * context, that exposes admin operations. + * * @author Adrian Cole */ -public class EC2ApiMetadata extends BaseApiMetadata { +public class EC2ApiMetadata, M extends EC2ApiMetadata> + extends BaseComputeServiceApiMetadata { - public EC2ApiMetadata() { - this(builder() - .id("ec2") - .type(ApiType.COMPUTE) - .name("Amazon Elastic Compute Cloud (EC2) API") - .identityName("Access Key ID") - .credentialName("Secret Access Key") - .documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference"))); + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public Builder toBuilder() { + return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected EC2ApiMetadata(EC2ApiMetadataBuilder builder) { + @SuppressWarnings({ "unchecked", "rawtypes" }) + public EC2ApiMetadata() { + this(new Builder(EC2Client.class, EC2AsyncClient.class)); + } + + protected EC2ApiMetadata(Builder builder) { super(builder); } - public static class EC2ApiMetadataBuilder> extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); + properties.setProperty(PROPERTY_HEADER_TAG, "amz"); + properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); + properties.setProperty(PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT, "500"); + properties.setProperty(PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "false"); + properties.setProperty(RESOURCENAME_DELIMITER, "#"); + return properties; + } - @Override - public EC2ApiMetadata build() { - return new EC2ApiMetadata(this); + public static class Builder, M extends EC2ApiMetadata> + extends BaseComputeServiceApiMetadata.Builder { + + protected Builder(Class syncClient, Class asyncClient) { + id("ec2") + .name("Amazon Elastic Compute Cloud (EC2) API") + .identityName("Access Key ID") + .credentialName("Secret Access Key") + .defaultEndpoint("https://ec2.us-east-1.amazonaws.com") + .documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference")) + .version(EC2AsyncClient.VERSION) + .defaultProperties(EC2ApiMetadata.defaultProperties()) + .javaApi(syncClient, asyncClient) + .contextBuilder(new TypeToken>(getClass()) { + private static final long serialVersionUID = 1L; + }); } - } - - private static class EC2ConcreteBuilder extends EC2ApiMetadataBuilder { - + + /** + * {@inheritDoc} + */ @Override - public EC2ApiMetadata build() { - return new EC2ApiMetadata(this); + @SuppressWarnings("rawtypes") + protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { + return new TypeToken>() { + private static final long serialVersionUID = 1L; + }.where(new TypeParameter() { + }, clientToken).where(new TypeParameter() { + }, asyncClientToken); } + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public M build() { + return (M) new EC2ApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(M in) { + super.fromApiMetadata(in); + return this; + } + } - private static EC2ConcreteBuilder builder() { - return new EC2ConcreteBuilder(); - } - - @Override - public EC2ApiMetadataBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java index d5be95c855..4836d97f87 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java @@ -19,40 +19,44 @@ package org.jclouds.ec2; import java.util.List; -import java.util.Properties; import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; import org.jclouds.ec2.config.EC2RestClientModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link EC2ComputeServiceContext} or {@link Injector} instances based on the most commonly - * requested arguments. + * Creates {@link EC2ComputeServiceContext} or {@link Injector} instances based + * on the most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole * @see EC2ComputeServiceContext */ -public class EC2ContextBuilder extends ComputeServiceContextBuilder { +public class EC2ContextBuilder, M extends EC2ApiMetadata> + extends ComputeServiceContextBuilder { - public EC2ContextBuilder(Properties props) { - super(EC2Client.class, EC2AsyncClient.class, props); + public EC2ContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); } - @Override - public EC2ContextBuilder withModules(Iterable modules) { - return (EC2ContextBuilder) super.withModules(modules); + public EC2ContextBuilder(M apiMetadata) { + super(apiMetadata); } @Override @@ -62,7 +66,8 @@ public class EC2ContextBuilder extends ComputeServiceContextBuilder modules) { - modules.add(EC2RestClientModule.create()); + modules.add(new EC2RestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi(), + EC2RestClientModule.DELEGATE_MAP)); } @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2PropertiesBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2PropertiesBuilder.java deleted file mode 100644 index f117597c96..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2PropertiesBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ec2; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; -import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in EC2 Clients - * - * @author Adrian Cole - */ -public class EC2PropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_HEADER_TAG, "amz"); - properties.setProperty(PROPERTY_API_VERSION, EC2AsyncClient.VERSION); - properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); - properties.setProperty(PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT, "500"); - properties.setProperty(PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "false"); - properties.setProperty(RESOURCENAME_DELIMITER, "#"); - return properties; - } - - public EC2PropertiesBuilder(Properties properties) { - super(properties); - } - - public EC2PropertiesBuilder() { - super(); - } -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java index 3ea04e1638..be5f90d46f 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java @@ -87,7 +87,7 @@ public class EC2ComputeService extends BaseComputeService { private final LoadingCache securityGroupMap; @Inject - protected EC2ComputeService(ComputeServiceContext context, Map credentialStore, + protected EC2ComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesPropertiesBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java similarity index 63% rename from apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesPropertiesBuilder.java rename to apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java index cef4e42ca2..255d4dd868 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesPropertiesBuilder.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java @@ -16,26 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.cloudfiles; +package org.jclouds.ec2.compute; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl; -import org.jclouds.openstack.swift.SwiftPropertiesBuilder; +import com.google.inject.ImplementedBy; /** - * * @author Adrian Cole */ -public class CloudFilesPropertiesBuilder extends SwiftPropertiesBuilder { +@ImplementedBy(EC2ComputeServiceContextImpl.class) +public interface EC2ComputeServiceContext extends ComputeServiceContext { @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - return properties; - } - - public CloudFilesPropertiesBuilder(Properties properties) { - super(properties); - } - + EC2ComputeService getComputeService(); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java index e801bbb2fa..9055515736 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java @@ -93,6 +93,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule { return instanceToNodeState; } + @SuppressWarnings("rawtypes") @Override protected void configure() { bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java new file mode 100644 index 0000000000..1d55021e64 --- /dev/null +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java @@ -0,0 +1,52 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.ec2.compute.internal; + +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.compute.Utils; +import org.jclouds.compute.internal.ComputeServiceContextImpl; +import org.jclouds.domain.Credentials; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeService; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.rest.RestContext; + +/** + * @author Adrian Cole + */ +@Singleton +public class EC2ComputeServiceContextImpl extends + ComputeServiceContextImpl implements EC2ComputeServiceContext { + @Inject + public EC2ComputeServiceContextImpl(EC2ComputeService computeService, Map credentialStore, + Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { + super(computeService, credentialStore, utils, providerSpecificContext); + } + + @Override + public EC2ComputeService getComputeService() { + return EC2ComputeService.class.cast(super.getComputeService()); + } + +} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java index 0495303dd3..e9d1862270 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java @@ -73,10 +73,6 @@ public class EC2RestClientModule .put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)// .build(); - public static EC2RestClientModule create() { - return new EC2RestClientModule(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP); - } - public EC2RestClientModule(Class sync, Class async, Map, Class> delegateMap) { super(sync, async, delegateMap); } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java index f83af9a86c..8efc145d76 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java @@ -27,16 +27,16 @@ import static org.testng.Assert.assertNotNull; import java.io.IOException; import java.net.UnknownHostException; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jclouds.aws.AWSResponseException; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Image.EbsBlockDevice; import org.jclouds.ec2.domain.InstanceState; @@ -50,25 +50,21 @@ import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; import org.jclouds.ec2.predicates.InstanceHasIpAddress; import org.jclouds.ec2.predicates.InstanceStateRunning; import org.jclouds.http.HttpResponseException; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; -import org.jclouds.rest.RestContextFactory; import org.jclouds.scriptbuilder.ScriptBuilder; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.inject.Injector; -import com.google.inject.Module; /** * Follows the book Cloud Application Architectures ISBN: 978-0-596-15636-7 @@ -80,7 +76,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = false, singleThreaded = true, testName = "CloudApplicationArchitecturesEC2ClientLiveTest") -public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseVersionedServiceLiveTest { +public class CloudApplicationArchitecturesEC2ClientLiveTest> extends BaseComputeServiceContextLiveTest { public CloudApplicationArchitecturesEC2ClientLiveTest() { provider = "ec2"; } @@ -97,12 +93,10 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseVersione private RetryablePredicate hasIpTester; private RetryablePredicate runningTester; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).buildInjector(); + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + Injector injector = context.utils().injector(); client = injector.getInstance(EC2Client.class); sshFactory = injector.getInstance(SshClient.Factory.class); runningTester = new RetryablePredicate(new InstanceStateRunning(client), 180, 5, diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java index 077cf7953b..c51173f3d0 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java @@ -27,16 +27,16 @@ import static org.testng.Assert.assertNotNull; import java.net.UnknownHostException; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jclouds.aws.AWSResponseException; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Image; @@ -60,28 +60,24 @@ import org.jclouds.ec2.predicates.VolumeAttached; import org.jclouds.ec2.predicates.VolumeAvailable; import org.jclouds.http.HttpResponseException; import org.jclouds.io.Payloads; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; -import org.jclouds.rest.RestContextFactory; import org.jclouds.scriptbuilder.InitScript; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.inject.Injector; -import com.google.inject.Module; /** * Adapted from the following sources: {@link http://gist.github.com/249915}, {@link http @@ -93,7 +89,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = false, singleThreaded = true, testName = "EBSBootEC2ClientLiveTest") -public class EBSBootEC2ClientLiveTest extends BaseVersionedServiceLiveTest { +public class EBSBootEC2ClientLiveTest> extends BaseComputeServiceContextLiveTest { public EBSBootEC2ClientLiveTest() { provider = "ec2"; } @@ -127,12 +123,11 @@ public class EBSBootEC2ClientLiveTest extends BaseVersionedServiceLiveTest { private Attachment attachment; private String mkEbsBoot; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).buildInjector(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + Injector injector = context.utils().injector(); client = injector.getInstance(EC2Client.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java index 14f62cdc91..74478bf7b0 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java @@ -18,18 +18,18 @@ */ package org.jclouds.ec2; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** * * @author Adrian Cole */ +@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "EC2ApiMetadataTest") -public class EC2ApiMetadataTest extends BaseApiMetadataTest { +public class EC2ApiMetadataTest extends BaseComputeServiceApiMetadataTest { public EC2ApiMetadataTest() { - super(new EC2ApiMetadata(), ApiType.COMPUTE); + super(new EC2ApiMetadata()); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index 233cc93a47..41d53a20fd 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -27,17 +27,17 @@ import java.util.NoSuchElementException; import java.util.Properties; import java.util.Set; -import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; +import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.options.EC2TemplateOptions; import org.jclouds.ec2.domain.BlockDevice; @@ -54,7 +54,6 @@ import org.jclouds.ec2.services.ElasticBlockStoreClient; import org.jclouds.ec2.services.InstanceClient; import org.jclouds.ec2.services.KeyPairClient; import org.jclouds.ec2.services.SecurityGroupClient; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.sshj.config.SshjSshClientModule; @@ -63,7 +62,6 @@ import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; @@ -74,7 +72,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class EC2ComputeServiceLiveTest> extends BaseComputeServiceLiveTest { public EC2ComputeServiceLiveTest() { provider = "ec2"; @@ -177,14 +175,13 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Test(enabled = true) //, dependsOnMethods = "testCompareSizes") public void testAutoIpAllocation() throws Exception { - ComputeServiceContext context = null; + ComputeServiceContext context = null; String group = this.group + "aip"; try { Properties overrides = setupProperties(); overrides.setProperty(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true"); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); + context = createContext(overrides, setupModules()); // create a node Set nodes = diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java index 6495c88c2f..f8cae411ba 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java @@ -27,10 +27,11 @@ import java.lang.reflect.Method; import java.util.Collection; import java.util.List; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions; import org.jclouds.ec2.options.DescribeImagesOptions; import org.jclouds.ec2.options.DescribeRegionsOptions; @@ -47,7 +48,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.Module; -public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public abstract class EC2TemplateBuilderLiveTest> extends BaseTemplateBuilderLiveTest { @Test public void testTemplateBuilderCanUseImageIdWithoutFetchingAllImages() throws Exception { @@ -55,14 +56,14 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive String defaultImageId = defaultTemplate.getImage().getId(); String defaultImageProviderId = defaultTemplate.getImage().getProviderId(); - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { // Track http commands final List commandsInvoked = Lists.newArrayList(); - context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), - TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked)), - setupProperties()); + context = createContext( + setupProperties(), + ImmutableSet. of(new Log4JLoggingModule(), + TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked))); Template template = context.getComputeService().templateBuilder().imageId(defaultImageId) .build(); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java index 1e80331689..c0dbdb145f 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java @@ -18,45 +18,26 @@ */ package org.jclouds.ec2.compute; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Properties; - -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.predicates.NodePredicates; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.BeforeGroups; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; import org.testng.annotations.Test; import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; /** * * @author Adrian Cole */ @Test(groups = "live", testName="TestCanRecreateGroupLiveTest") -public class TestCanRecreateGroupLiveTest extends BaseVersionedServiceLiveTest { +public class TestCanRecreateGroupLiveTest> extends BaseComputeServiceContextLiveTest { public TestCanRecreateGroupLiveTest() { provider = "ec2"; } - private ComputeServiceContext context; - - @BeforeGroups(groups = { "live" }) - public void setupClient() throws FileNotFoundException, IOException { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); - } - public void testCanRecreateGroup() throws Exception { String tag = PREFIX + "recreate"; diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java index ef8a59dcdb..dff51b3b23 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java @@ -26,26 +26,20 @@ import static org.testng.Assert.assertNotNull; import java.net.URI; import java.util.Iterator; import java.util.Map.Entry; -import java.util.Properties; import java.util.Set; import java.util.SortedMap; import org.jclouds.aws.domain.Region; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.AvailabilityZoneInfo; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.google.inject.Module; /** * Tests behavior of {@code AvailabilityZoneAndRegionClient} @@ -53,21 +47,18 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AvailabilityZoneAndRegionClientLiveTest") -public class AvailabilityZoneAndRegionClientLiveTest extends BaseVersionedServiceLiveTest { +public class AvailabilityZoneAndRegionClientLiveTest> extends BaseComputeServiceContextLiveTest { public AvailabilityZoneAndRegionClientLiveTest() { provider = "ec2"; } private AvailabilityZoneAndRegionClient client; - private RestContext context; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - client = context.getApi().getAvailabilityZoneAndRegionServices(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getAvailabilityZoneAndRegionServices(); } public void testDescribeAvailabilityZones() { @@ -106,8 +97,4 @@ public class AvailabilityZoneAndRegionClientLiveTest extends BaseVersionedServic assertEquals(iterator.next().getKey(), r2); } - @AfterTest - public void shutdown() { - context.close(); - } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java index 3e1ae2ab85..7b141a9563 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java @@ -28,14 +28,14 @@ import java.util.Set; import javax.inject.Singleton; +import org.jclouds.apis.ApiMetadata; import org.jclouds.aws.domain.Region; import org.jclouds.aws.filters.FormSigner; import org.jclouds.compute.domain.Image; import org.jclouds.date.DateService; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.EC2ContextBuilder; -import org.jclouds.ec2.EC2PropertiesBuilder; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.config.EC2RestClientModule; import org.jclouds.http.HttpRequest; @@ -44,9 +44,7 @@ import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.util.Suppliers2; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -64,7 +62,7 @@ import com.google.inject.Provides; * @author Adrian Cole */ @Test(groups = "unit") -public abstract class BaseEC2AsyncClientTest extends RestClientTest { +public abstract class BaseEC2AsyncClientTest extends BaseAsyncClientTest { @RequiresHttp @ConfiguresRestClient protected static class StubEC2RestClientModule extends EC2RestClientModule { @@ -133,10 +131,6 @@ public abstract class BaseEC2AsyncClientTest extends RestClientTest { assertEquals(request.getFilters().get(0).getClass(), FormSigner.class); } - public BaseEC2AsyncClientTest() { - super(); - } - @Override @BeforeTest protected void setupFactory() throws IOException { @@ -148,17 +142,10 @@ public abstract class BaseEC2AsyncClientTest extends RestClientTest { protected Module createModule() { return new StubEC2RestClientModule(); } - - protected String provider = "ec2"; - - /** - * this is only here as "ec2" is not in rest.properties - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + + @SuppressWarnings("rawtypes") @Override - public RestContextSpec createContextSpec() { - return RestContextFactory. contextSpec(provider, "https://ec2.us-east-1.amazonaws.com", - EC2AsyncClient.VERSION, "", "", "identity", "credential", EC2Client.class, EC2AsyncClient.class, - (Class) EC2PropertiesBuilder.class, (Class) EC2ContextBuilder.class, ImmutableSet. of()); + protected ApiMetadata createApiMetadata() { + return new EC2ApiMetadata(); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java index a1f50b76ae..6871c9cc7c 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java @@ -22,33 +22,27 @@ import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.snapshotI import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.util.Properties; import java.util.Set; import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.predicates.SnapshotCompleted; import org.jclouds.ec2.predicates.VolumeAvailable; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.RestContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.google.inject.Module; /** * Tests behavior of {@code ElasticBlockStoreClient} @@ -56,28 +50,25 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ElasticBlockStoreClientLiveTest") -public class ElasticBlockStoreClientLiveTest extends BaseVersionedServiceLiveTest { +public class ElasticBlockStoreClientLiveTest> extends BaseComputeServiceContextLiveTest { public ElasticBlockStoreClientLiveTest() { provider = "ec2"; } private ElasticBlockStoreClient client; - private RestContext context; private String volumeId; private Snapshot snapshot; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - client = context.getApi().getElasticBlockStoreServices(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getElasticBlockStoreServices(); } @Test void testDescribeVolumes() { - for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : context.getProviderSpecificContext().getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { SortedSet allResults = Sets.newTreeSet(client.describeVolumesInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { @@ -227,8 +218,4 @@ public class ElasticBlockStoreClientLiveTest extends BaseVersionedServiceLiveTes assert client.describeSnapshotsInRegion(snapshot.getRegion(), snapshotIds(snapshot.getId())).size() == 0; } - @AfterTest - public void shutdown() { - context.close(); - } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java index d35074b34e..a1de5fc423 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java @@ -21,25 +21,19 @@ package org.jclouds.ec2.services; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.util.Properties; import java.util.SortedSet; import org.jclouds.aws.domain.Region; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.google.inject.Module; /** * Tests behavior of {@code ElasticIPAddressClient} @@ -47,21 +41,18 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ElasticIPAddressClientLiveTest") -public class ElasticIPAddressClientLiveTest extends BaseVersionedServiceLiveTest { +public class ElasticIPAddressClientLiveTest> extends BaseComputeServiceContextLiveTest { public ElasticIPAddressClientLiveTest() { provider = "ec2"; } private ElasticIPAddressClient client; - private RestContext context; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides).getProviderSpecificContext(); - client = context.getApi().getElasticIPAddressServices(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getElasticIPAddressServices(); } @Test @@ -81,8 +72,4 @@ public class ElasticIPAddressClientLiveTest extends BaseVersionedServiceLiveTest } } - @AfterTest - public void shutdown() { - context.close(); - } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java index 9a4d9f065d..9915a9d98a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java @@ -20,25 +20,19 @@ package org.jclouds.ec2.services; import static org.testng.Assert.assertNotNull; -import java.util.Properties; import java.util.Set; import org.jclouds.aws.domain.Region; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import com.google.inject.Module; /** * Tests behavior of {@code EC2Client} @@ -46,23 +40,18 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "InstanceClientLiveTest") -public class InstanceClientLiveTest extends BaseVersionedServiceLiveTest { +public class InstanceClientLiveTest> extends BaseComputeServiceContextLiveTest { public InstanceClientLiveTest() { provider = "ec2"; } private InstanceClient client; - private RestContext context; - - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides).getProviderSpecificContext(); - client = context.getApi().getInstanceServices(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getInstanceServices(); } @Test @@ -74,9 +63,4 @@ public class InstanceClientLiveTest extends BaseVersionedServiceLiveTest { assert allResults.size() >= 0 : allResults.size(); } } - - @AfterTest - public void shutdown() { - context.close(); - } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java index a0d3b86ac2..c4b6c5b359 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java @@ -21,26 +21,20 @@ package org.jclouds.ec2.services; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.util.Properties; import java.util.Set; import java.util.SortedSet; import org.jclouds.aws.domain.Region; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import com.google.inject.Module; /** * Tests behavior of {@code KeyPairClient} @@ -48,22 +42,18 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "KeyPairClientLiveTest") -public class KeyPairClientLiveTest extends BaseVersionedServiceLiveTest { +public class KeyPairClientLiveTest> extends BaseComputeServiceContextLiveTest { public KeyPairClientLiveTest() { provider = "ec2"; } private KeyPairClient client; - private RestContext context; - - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - client = context.getApi().getKeyPairServices(); + + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getKeyPairServices(); } @Test @@ -109,8 +99,4 @@ public class KeyPairClientLiveTest extends BaseVersionedServiceLiveTest { assertEquals(listPair.getSha1OfPrivateKey(), result.getSha1OfPrivateKey()); } - @AfterTest - public void shutdown() { - context.close(); - } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java index 5ff0d10bb3..3ab63ec70c 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java @@ -22,23 +22,20 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import java.util.Iterator; -import java.util.Properties; import java.util.Set; import java.util.SortedSet; import org.jclouds.aws.domain.Region; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.IpPermission; import org.jclouds.ec2.domain.IpProtocol; import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.ec2.domain.UserIdGroupPair; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -47,7 +44,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.inject.Module; /** * Tests behavior of {@code SecurityGroupClient} @@ -55,21 +51,18 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "SecurityGroupClientLiveTest") -public class SecurityGroupClientLiveTest extends BaseVersionedServiceLiveTest { +public class SecurityGroupClientLiveTest> extends BaseComputeServiceContextLiveTest { public SecurityGroupClientLiveTest() { provider = "ec2"; } protected SecurityGroupClient client; - private RestContext context; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - client = context.getApi().getSecurityGroupServices(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getSecurityGroupServices(); } @Test diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsClientLiveTest.java index 4c47ba7178..7fdee8dc5d 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsClientLiveTest.java @@ -28,36 +28,28 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.LoginCredentials; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.EC2ContextBuilder; -import org.jclouds.ec2.EC2PropertiesBuilder; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.compute.domain.PasswordDataAndPrivateKey; import org.jclouds.ec2.compute.functions.WindowsLoginCredentialsFromEncryptedData; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.PasswordData; import org.jclouds.ec2.reference.EC2Constants; -import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.RestContext; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.base.Strings; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.inject.Module; /** * Tests behavior of {@code WindowsClient} @@ -65,7 +57,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "WindowsClientLiveTest") -public class WindowsClientLiveTest extends BaseVersionedServiceLiveTest { +public class WindowsClientLiveTest> extends BaseComputeServiceContextLiveTest { public WindowsClientLiveTest() { provider = "ec2"; } @@ -74,29 +66,23 @@ public class WindowsClientLiveTest extends BaseVersionedServiceLiveTest { private WindowsClient client; private static final String DEFAULT_INSTANCE = "i-TODO"; private static final String DEFAULT_BUCKET = "TODO"; - - private RestContext context; + + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + overrides.put(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "206029621532"); /* Amazon Owner ID */ + return overrides; + } @Override - public Properties setupRestProperties() { - Properties rest = super.setupRestProperties(); - rest.put("ec2.contextbuilder", EC2ContextBuilder.class.getName()); - rest.put("ec2.propertiesbuilder", EC2PropertiesBuilder.class.getName()); - return rest; - } - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - overrides.put(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "206029621532"); /* Amazon Owner ID */ - ComputeServiceContext serviceContext = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet.of(new Log4JLoggingModule(), new BouncyCastleCryptoModule()), overrides); - computeService = serviceContext.getComputeService(); - context = serviceContext.getProviderSpecificContext(); - client = context.getApi().getWindowsServices(); + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getWindowsServices(); + computeService = context.getComputeService(); } + @Test(enabled = false) // TODO get instance public void testBundleInstanceInRegion() { @@ -135,7 +121,6 @@ public class WindowsClientLiveTest extends BaseVersionedServiceLiveTest { Set nodes = computeService.createNodesInGroup("test", 1, template); NodeMetadata node = Iterables.getOnlyElement(nodes); - boolean shutdown = true; try { // The Administrator password will take some time before it is ready - Amazon says sometimes 15 minutes. diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java index bdc2d7fd0b..dd847fd26b 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java @@ -18,51 +18,77 @@ */ package org.jclouds.elasticstack; +import static org.jclouds.elasticstack.reference.ElasticStackConstants.PROPERTY_VNC_PASSWORD; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for the ElasticStack API * * @author Adrian Cole */ -public class ElasticStackApiMetadata extends BaseApiMetadata { +public class ElasticStackApiMetadata + extends + BaseComputeServiceApiMetadata, ElasticStackApiMetadata> { - public ElasticStackApiMetadata() { - this(builder() - .id("elasticstack") - .type(ApiType.COMPUTE) - .name("ElasticStack API") - .identityName("UUID") - .credentialName("Secret API key") - .documentation(URI.create("http://www.elasticstack.com/cloud-platform/api"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected ElasticStackApiMetadata(ConcreteBuilder builder) { + public ElasticStackApiMetadata() { + this(new Builder()); + } + + protected ElasticStackApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); + // passwords are set post-boot, so auth failures are possible + // from a race condition applying the password set script + properties.setProperty("jclouds.ssh.max-retries", "5"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("elasticstack") + .name("ElasticStack API") + .identityName("UUID") + .credentialName("Secret API key") + .documentation(URI.create("http://www.elasticstack.com/cloud-platform/api")) + .version("1.0") + .defaultEndpoint("https://api.lon-p.elastichosts.com") + .defaultProperties(ElasticStackApiMetadata.defaultProperties()) + .javaApi(ElasticStackClient.class, ElasticStackAsyncClient.class) + .contextBuilder(TypeToken.of(ElasticStackContextBuilder.class)); + } @Override public ElasticStackApiMetadata build() { return new ElasticStackApiMetadata(this); } + + @Override + public Builder fromApiMetadata(ElasticStackApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - -} \ No newline at end of file +} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java index a8d1ad1b29..63b5f65cb5 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java @@ -19,11 +19,12 @@ package org.jclouds.elasticstack; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule; import org.jclouds.elasticstack.config.ElasticStackRestClientModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -31,12 +32,19 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class ElasticStackContextBuilder extends - ComputeServiceContextBuilder { +public class ElasticStackContextBuilder + extends + ComputeServiceContextBuilder, ElasticStackApiMetadata> { - public ElasticStackContextBuilder(Properties props) { - super(ElasticStackClient.class, ElasticStackAsyncClient.class, props); + public ElasticStackContextBuilder( + ProviderMetadata, ElasticStackApiMetadata> providerMetadata) { + super(providerMetadata); } + + public ElasticStackContextBuilder(ElasticStackApiMetadata apiMetadata) { + super(apiMetadata); + } + @Override protected void addContextModule(List modules) { modules.add(new ElasticStackComputeServiceContextModule()); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackPropertiesBuilder.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackPropertiesBuilder.java deleted file mode 100644 index 20395769c4..0000000000 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackPropertiesBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elasticstack; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.elasticstack.reference.ElasticStackConstants.PROPERTY_VNC_PASSWORD; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in elasticstack Clients - * - * @author Adrian Cole - */ -public class ElasticStackPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); - // passwords are set post-boot, so auth failures are possible - // from a race condition applying the password set script - properties.setProperty("jclouds.ssh.max-retries", "5"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - return properties; - } - - public ElasticStackPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiMetadataTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiMetadataTest.java index 8d80a68503..b93636dc87 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiMetadataTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.elasticstack; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "ElasticStackApiMetadataTest") -public class ElasticStackApiMetadataTest extends BaseApiMetadataTest { +public class ElasticStackApiMetadataTest extends BaseComputeServiceApiMetadataTest { public ElasticStackApiMetadataTest() { - super(new ElasticStackApiMetadata(), ApiType.COMPUTE); + super(new ElasticStackApiMetadata()); } } diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java index eaab145d91..37dccdfe18 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java @@ -22,10 +22,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; -import java.util.Properties; import javax.ws.rs.core.MediaType; +import org.jclouds.apis.ApiMetadata; import org.jclouds.elasticstack.binders.BindServerToPlainTextStringTest; import org.jclouds.elasticstack.domain.CreateDriveRequest; import org.jclouds.elasticstack.domain.Drive; @@ -43,12 +43,10 @@ import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -63,12 +61,12 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "ElasticStackAsyncClientTest") -public class ElasticStackAsyncClientTest extends RestClientTest { +public class ElasticStackAsyncClientTest extends BaseAsyncClientTest { public void testListServers() throws SecurityException, NoSuchMethodException, IOException { Method method = ElasticStackAsyncClient.class.getMethod("listServers"); HttpRequest httpRequest = processor.createRequest(method); - assertRequestLineEquals(httpRequest, "GET https://api.elasticstack.com/servers/list HTTP/1.1"); + assertRequestLineEquals(httpRequest, "GET https://api.lon-p.elastichosts.com/servers/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); assertPayloadEquals(httpRequest, null, null, false); @@ -76,10 +74,10 @@ public class ElasticStackAsyncClientTest extends RestClientTest createContextSpec() { - Properties props = new Properties(); - props.setProperty("elasticstack.endpoint", "https://api.elasticstack.com"); - return new RestContextFactory().createContextSpec("elasticstack", "foo", "bar", props); + protected ApiMetadata createApiMetadata() { + return new ElasticStackApiMetadata(); } + } diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java index 43f35aee26..3a199e02b5 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java @@ -22,15 +22,13 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import java.io.IOException; -import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; import org.jclouds.elasticstack.domain.ClaimType; import org.jclouds.elasticstack.domain.CreateDriveRequest; @@ -46,7 +44,6 @@ import org.jclouds.elasticstack.domain.ServerStatus; import org.jclouds.elasticstack.predicates.DriveClaimed; import org.jclouds.elasticstack.util.Servers; import org.jclouds.io.Payloads; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; @@ -65,7 +62,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.inject.Guice; -import com.google.inject.Module; /** * Tests behavior of {@code ElasticStackClient} @@ -73,7 +69,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ElasticStackClientLiveTest") -public class ElasticStackClientLiveTest extends BaseVersionedServiceLiveTest { +public class ElasticStackClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public ElasticStackClientLiveTest() { provider = "elasticstack"; } @@ -82,28 +81,24 @@ public class ElasticStackClientLiveTest extends BaseVersionedServiceLiveTest { protected int maxDriveImageTime = 360; protected String vncPassword = "Il0veVNC"; protected ElasticStackClient client; - protected ComputeServiceContext computeContext; - protected RestContext context; + protected RestContext cloudStackContext; protected Predicate socketTester; protected Predicate driveNotClaimed; - - @BeforeGroups(groups = "live") - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - computeContext = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); - context = computeContext.getProviderSpecificContext(); + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + cloudStackContext = context.getProviderSpecificContext(); - client = context.getApi(); + client = cloudStackContext.getApi(); driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, TimeUnit.SECONDS); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), maxDriveImageTime, 1, TimeUnit.SECONDS); if (Strings.emptyToNull(imageId) == null) { - imageId = computeContext.getComputeService().templateBuilder().build().getImage().getId(); + imageId = context.getComputeService().templateBuilder().build().getImage().getId(); } } @@ -322,8 +317,8 @@ public class ElasticStackClientLiveTest extends BaseVersionedServiceLiveTest { } catch (Exception e) { } - if (context != null) - context.close(); + if (cloudStackContext != null) + cloudStackContext.close(); } private DriveInfo drive2; diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java index c87539fc57..6f4e93ebae 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java @@ -18,9 +18,12 @@ */ package org.jclouds.elasticstack.compute; -import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -31,7 +34,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticStackComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class ElasticStackComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public ElasticStackComputeServiceLiveTest() { provider = "elasticstack"; } diff --git a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java index c8e8877108..0297ea0b50 100644 --- a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java +++ b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java @@ -18,43 +18,68 @@ */ package org.jclouds.eucalyptus; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_PORT_OPEN; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + +import java.util.Properties; + import org.jclouds.apis.ApiMetadata; import org.jclouds.ec2.EC2ApiMetadata; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; /** * Implementation of {@link ApiMetadata} for the Eucalyptus (EC2 clone) api. * * @author Adrian Cole */ -public class EucalyptusApiMetadata extends EC2ApiMetadata { +public class EucalyptusApiMetadata extends EC2ApiMetadata, EucalyptusApiMetadata> { + private static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } public EucalyptusApiMetadata() { - this(builder().fromApiMetadata(new EC2ApiMetadata()) - .id("eucalyptus") - .name("Eucalyptus (EC2 clone) API")); + this(builder()); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected EucalyptusApiMetadata(ConcreteBuilder builder) { + protected EucalyptusApiMetadata(Builder builder) { super(builder); } + + protected static Properties defaultProperties() { + Properties properties = EC2ApiMetadata.defaultProperties(); + properties.setProperty(PROPERTY_REGIONS, "Eucalyptus"); + properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin"); + properties.setProperty(TIMEOUT_PORT_OPEN, 5 * 60 * 1000 + ""); + return properties; + } - private static class ConcreteBuilder extends EC2ApiMetadataBuilder { - + public static class Builder extends EC2ApiMetadata.Builder, EucalyptusApiMetadata> { + protected Builder(){ + super(EC2Client.class, EC2AsyncClient.class); + id("eucalyptus") + .defaultEndpoint("http://173.205.188.130:8773/services/Eucalyptus") + .name("Eucalyptus (EC2 clone) API") + .defaultProperties(EucalyptusApiMetadata.defaultProperties()); + } + @Override public EucalyptusApiMetadata build() { return new EucalyptusApiMetadata(this); } + + @Override + public Builder fromApiMetadata(EucalyptusApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } - private static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusPropertiesBuilder.java b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusPropertiesBuilder.java deleted file mode 100644 index c995b4d940..0000000000 --- a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusPropertiesBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.eucalyptus; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_PORT_OPEN; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.ec2.EC2PropertiesBuilder; - -/** - * Builds properties used in Eucalyptus Clients - * - * @author Adrian Cole - */ -public class EucalyptusPropertiesBuilder extends EC2PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "http://173.205.188.130:8773/services/Eucalyptus"); - properties.setProperty(PROPERTY_REGIONS, "Eucalyptus"); - properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin"); - properties.setProperty(TIMEOUT_PORT_OPEN, 5 * 60 * 1000 + ""); - return properties; - } - - public EucalyptusPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/EucalyptusApiMetadataTest.java b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/EucalyptusApiMetadataTest.java index 7473d8a3e6..e2fcff6d83 100644 --- a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/EucalyptusApiMetadataTest.java +++ b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/EucalyptusApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.eucalyptus; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "EucalyptusApiMetadataTest") -public class EucalyptusApiMetadataTest extends BaseApiMetadataTest { +public class EucalyptusApiMetadataTest extends BaseComputeServiceApiMetadataTest { public EucalyptusApiMetadataTest() { - super(new EucalyptusApiMetadata(), ApiType.COMPUTE); + super(new EucalyptusApiMetadata()); } } diff --git a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java index 49f4f34b19..13c5945786 100644 --- a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java +++ b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java @@ -20,6 +20,9 @@ package org.jclouds.eucalyptus.compute; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest; import org.jclouds.http.HttpResponseException; import org.testng.annotations.Test; @@ -29,7 +32,8 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "EucalyptusComputeServiceLiveTest") -public class EucalyptusComputeServiceLiveTest extends EC2ComputeServiceLiveTest { +public class EucalyptusComputeServiceLiveTest extends + EC2ComputeServiceLiveTest> { public EucalyptusComputeServiceLiveTest() { provider = "eucalyptus"; diff --git a/apis/filesystem/pom.xml b/apis/filesystem/pom.xml index 84628b2cf9..ff342df44d 100644 --- a/apis/filesystem/pom.xml +++ b/apis/filesystem/pom.xml @@ -67,10 +67,6 @@ - - org.jclouds.filesystem.integration.FilesystemTestInitializer - - @@ -84,6 +80,7 @@ test + 1 **/*LiveTest.java **/Base*Test.java @@ -92,7 +89,6 @@ **/*IntegrationTest.java - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java index 99d51e6402..91595c3389 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java @@ -18,50 +18,70 @@ */ package org.jclouds.filesystem; +import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; +import static org.jclouds.Constants.PROPERTY_USER_THREADS; + import java.net.URI; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; + +import com.google.common.collect.ImmutableMap; +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for jclouds Filesystem-based BlobStore * * @author Adrian Cole */ -public class FilesystemApiMetadata extends BaseApiMetadata { +public class FilesystemApiMetadata + extends + BaseBlobStoreApiMetadata, FilesystemApiMetadata> { - public FilesystemApiMetadata() { - this(builder() - .id("filesystem") - .type(ApiType.BLOBSTORE) - .name("Filesystem-based BlobStore") - .identityName("Unused") - .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide"))); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected FilesystemApiMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromApiMetadata(this)); + } + + public FilesystemApiMetadata() { + super(builder()); + } + + protected FilesystemApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { +public static class Builder extends + BaseBlobStoreApiMetadata.Builder, FilesystemApiMetadata> { + + protected Builder() { + id("filesystem") + .name("Filesystem-based BlobStore") + .identityName("Unused") + .contextBuilder(TypeToken.of(FilesystemBlobStoreContextBuilder.class)) + .javaApi(BlobStore.class, FilesystemAsyncBlobStore.class) + .identityName("Unused") + .defaultEndpoint("http://localhost/transient") + .defaultIdentity(System.getProperty("user.name")) + .defaultCredential("bar") + .version("1") + .defaultProperties( + BaseBlobStoreApiMetadata.Builder.defaultPropertiesAnd(ImmutableMap.of(PROPERTY_USER_THREADS, "0", + PROPERTY_IO_WORKER_THREADS, "0"))) + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")); + } @Override public FilesystemApiMetadata build() { return new FilesystemApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java index e6c3ade4db..6b9013fb76 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java @@ -126,7 +126,7 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore { protected final FilesystemStorageStrategy storageStrategy; @Inject - protected FilesystemAsyncBlobStore(BlobStoreContext context, DateService dateService, Crypto crypto, + protected FilesystemAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, DateService dateService, Crypto crypto, HttpGetOptionsListToGetOptions httpGetOptionsConverter, IfDirectoryReturnNameStrategy ifDirectoryReturnName, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java index 08a44ca6b9..eb5cd39033 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java @@ -19,33 +19,31 @@ package org.jclouds.filesystem; import java.util.List; -import java.util.Properties; -import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.filesystem.config.FilesystemBlobStoreContextModule; import org.jclouds.filesystem.config.FilesystemBlobStoreModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; /** - * + * * @author Alfredo "Rainbowbreeze" Morresi */ -public class FilesystemBlobStoreContextBuilder extends - BlobStoreContextBuilder { +public class FilesystemBlobStoreContextBuilder + extends + BlobStoreContextBuilder, FilesystemApiMetadata> { - /** - * This is only to have the same syntax. - * - */ - public FilesystemBlobStoreContextBuilder() { - this(new Properties()); + public FilesystemBlobStoreContextBuilder( + ProviderMetadata, FilesystemApiMetadata> providerMetadata) { + super(providerMetadata); } - public FilesystemBlobStoreContextBuilder(Properties props) { - super(BlobStore.class, AsyncBlobStore.class, props); + public FilesystemBlobStoreContextBuilder(FilesystemApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStorePropertiesBuilder.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStorePropertiesBuilder.java deleted file mode 100644 index 4da3e86741..0000000000 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStorePropertiesBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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. - */ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package org.jclouds.filesystem; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_IDENTITY; -import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; -import static org.jclouds.Constants.PROPERTY_USER_THREADS; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * - * @author rainbowbreeze - */ -public class FilesystemBlobStorePropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "http://localhost/transient"); - properties.setProperty(PROPERTY_API_VERSION, "1"); - properties.setProperty(PROPERTY_IDENTITY, System.getProperty("user.name")); - properties.setProperty(PROPERTY_USER_THREADS, "0"); - properties.setProperty(PROPERTY_IO_WORKER_THREADS, "0"); - return properties; - } - - public FilesystemBlobStorePropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java index 1cc4267910..8223e1280b 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java @@ -49,6 +49,7 @@ import com.google.inject.TypeLiteral; */ public class FilesystemBlobStoreContextModule extends AbstractModule { + @SuppressWarnings("rawtypes") @Override protected void configure() { bind(new TypeLiteral() { diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java index dee50900e4..f836d82ab0 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java @@ -24,7 +24,7 @@ import org.jclouds.filesystem.FilesystemBlobStore; import org.jclouds.rest.config.RestClientModule; /** - * + * * @author Alfredo "Rainbowbreeze" Morresi */ public class FilesystemBlobStoreModule extends RestClientModule { @@ -33,12 +33,10 @@ public class FilesystemBlobStoreModule extends RestClientModule context = null; private BlobStore blobStore = null; private Set resourcesToBeDeleted = new HashSet(); @@ -96,7 +94,7 @@ public class FilesystemAsyncBlobStoreTest { // create context for filesystem container Properties prop = new Properties(); prop.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); - context = (BlobStoreContext) new BlobStoreContextFactory().createContext(PROVIDER, "identity", "credential", Collections.emptyList(), prop); + context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(prop).build(); // create a container in the default location blobStore = context.getBlobStore(); @@ -133,7 +131,7 @@ public class FilesystemAsyncBlobStoreTest { // no base directory declared in properties try { Properties props = new Properties(); - new BlobStoreContextFactory().createContext(PROVIDER, props); + context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(props).build(); fail("No error if base directory is not specified"); } catch (CreationException e) { } @@ -142,7 +140,7 @@ public class FilesystemAsyncBlobStoreTest { try { Properties props = new Properties(); props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, null); - new BlobStoreContextFactory().createContext(PROVIDER, props); + context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(props).build(); fail("No error if base directory is null in the option"); } catch (NullPointerException e) { } diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTestDisabled.java similarity index 55% rename from apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTest.java rename to apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTestDisabled.java index 2d49307d7e..8cde760310 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTestDisabled.java @@ -18,7 +18,12 @@ */ package org.jclouds.filesystem.integration; +import java.util.Properties; + import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest; +import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; +import org.jclouds.filesystem.reference.FilesystemConstants; +import org.jclouds.filesystem.utils.TestUtils; import org.testng.annotations.Test; /** @@ -26,7 +31,18 @@ import org.testng.annotations.Test; * @author James Murty * @author Adrian Cole */ -@Test(groups = { "integration" }, testName = "blobstore.FilesystemBlobIntegrationTest") -public class FilesystemBlobIntegrationTest extends BaseBlobIntegrationTest { +@Test(groups = { "integration" }, singleThreaded = true, testName = "blobstore.FilesystemBlobIntegrationTest") +public class FilesystemBlobIntegrationTestDisabled extends BaseBlobIntegrationTest { + public FilesystemBlobIntegrationTestDisabled() { + provider = "filesystem"; + BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true; + } + + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); + return props; + } } \ No newline at end of file diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobMapIntegrationTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobMapIntegrationTestDisabled.java similarity index 60% rename from apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobMapIntegrationTest.java rename to apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobMapIntegrationTestDisabled.java index 17cab91141..e39b830af3 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobMapIntegrationTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobMapIntegrationTestDisabled.java @@ -18,7 +18,12 @@ */ package org.jclouds.filesystem.integration; +import java.util.Properties; + import org.jclouds.blobstore.integration.internal.BaseBlobMapIntegrationTest; +import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; +import org.jclouds.filesystem.reference.FilesystemConstants; +import org.jclouds.filesystem.utils.TestUtils; import org.testng.annotations.Test; /** @@ -26,6 +31,16 @@ import org.testng.annotations.Test; */ @Test(groups = { "integration", "live" }, testName = "blobstore.FilesystemBlobMapIntegrationTest") -public class FilesystemBlobMapIntegrationTest extends BaseBlobMapIntegrationTest { +public class FilesystemBlobMapIntegrationTestDisabled extends BaseBlobMapIntegrationTest { + public FilesystemBlobMapIntegrationTestDisabled() { + provider = "filesystem"; + BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true; + } + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); + return props; + } } \ No newline at end of file diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTestDisabled.java similarity index 78% rename from apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTest.java rename to apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTestDisabled.java index 3cec809698..4950969167 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTestDisabled.java @@ -21,13 +21,18 @@ package org.jclouds.filesystem.integration; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults; import static org.testng.Assert.assertEquals; +import java.util.Properties; + import javax.ws.rs.core.MediaType; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; +import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest; +import org.jclouds.filesystem.reference.FilesystemConstants; +import org.jclouds.filesystem.utils.TestUtils; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -38,8 +43,18 @@ import com.google.common.collect.Iterables; * @author Adrian Cole */ @Test(groups = { "integration", "live" }, testName = "blobstore.FilesystemContainerIntegrationTest") -public class FilesystemContainerIntegrationTest extends BaseContainerIntegrationTest { +public class FilesystemContainerIntegrationTestDisabled extends BaseContainerIntegrationTest { + public FilesystemContainerIntegrationTestDisabled() { + provider = "filesystem"; + BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true; + } + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); + return props; + } @Test(groups = { "integration", "live" }) public void testNotWithDetails() throws InterruptedException { diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemInputStreamMapIntegrationTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemInputStreamMapIntegrationTestDisabled.java similarity index 60% rename from apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemInputStreamMapIntegrationTest.java rename to apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemInputStreamMapIntegrationTestDisabled.java index ae46ee916f..b224e36224 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemInputStreamMapIntegrationTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemInputStreamMapIntegrationTestDisabled.java @@ -18,13 +18,28 @@ */ package org.jclouds.filesystem.integration; +import java.util.Properties; + +import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.blobstore.integration.internal.BaseInputStreamMapIntegrationTest; +import org.jclouds.filesystem.reference.FilesystemConstants; +import org.jclouds.filesystem.utils.TestUtils; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = { "integration", "live" }, testName = "blobstore.FilesystemInputStreamMapIntegrationTest") -public class FilesystemInputStreamMapIntegrationTest extends BaseInputStreamMapIntegrationTest { +public class FilesystemInputStreamMapIntegrationTestDisabled extends BaseInputStreamMapIntegrationTest { + public FilesystemInputStreamMapIntegrationTestDisabled() { + provider = "filesystem"; + BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true; + } + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); + return props; + } } \ No newline at end of file diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemServiceIntegrationTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemServiceIntegrationTestDisabled.java similarity index 60% rename from apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemServiceIntegrationTest.java rename to apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemServiceIntegrationTestDisabled.java index a6877d3607..24e1f64f59 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemServiceIntegrationTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemServiceIntegrationTestDisabled.java @@ -18,13 +18,28 @@ */ package org.jclouds.filesystem.integration; +import java.util.Properties; + +import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.blobstore.integration.internal.BaseServiceIntegrationTest; +import org.jclouds.filesystem.reference.FilesystemConstants; +import org.jclouds.filesystem.utils.TestUtils; import org.testng.annotations.Test; /** * @author Adrian Cole */ @Test(groups = { "integration", "live" }, testName = "blobstore.FilesystemServiceIntegrationTest") -public class FilesystemServiceIntegrationTest extends BaseServiceIntegrationTest { +public class FilesystemServiceIntegrationTestDisabled extends BaseServiceIntegrationTest { + public FilesystemServiceIntegrationTestDisabled() { + provider = "filesystem"; + BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true; + } + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); + return props; + } } \ No newline at end of file diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemTestInitializer.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemTestInitializer.java deleted file mode 100644 index 12fbb61633..0000000000 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemTestInitializer.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.filesystem.integration; - -import java.io.IOException; -import java.util.Properties; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer; -import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; -import org.jclouds.filesystem.reference.FilesystemConstants; -import org.jclouds.filesystem.utils.TestUtils; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class FilesystemTestInitializer extends TransientBlobStoreTestInitializer { - - public FilesystemTestInitializer() { - provider = "filesystem"; - BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true; - } - - @Override - protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiVersion, - String buildVersion, String app, String identity, String credential) throws IOException { - return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule, - new Log4JLoggingModule()), setupProperties(endpoint, apiVersion, buildVersion, identity, credential)); - } - - @Override - protected Properties setupProperties(String endpoint, String apiVersion, String buildVersion, String identity, - String credential) { - Properties props = super.setupProperties(endpoint, apiVersion, buildVersion, identity, credential); - props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); - return props; - } - -} diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java index ef27f4770e..80a98df306 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java @@ -19,49 +19,69 @@ package org.jclouds.openstack.nova; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for OpenStack Nova Pre-Diablo + * Implementation of {@link ApiMetadata} for Nova 1.0 API * * @author Adrian Cole */ -public class NovaApiMetadata extends BaseApiMetadata { +public class NovaApiMetadata + extends + BaseComputeServiceApiMetadata, NovaApiMetadata> { - public NovaApiMetadata() { - this(builder() - .id("nova") - .type(ApiType.COMPUTE) - .name("OpenStack Nova Pre-Diablo API") - .identityName("accessKey") - .credentialName("secretKey") - .documentation(URI.create("http://api.openstack.org/"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected NovaApiMetadata(ConcreteBuilder builder) { + public NovaApiMetadata() { + this(new Builder()); + } + + protected NovaApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, NovaApiMetadata> { + + protected Builder() { + id("nova") + .name("OpenStack Nova Pre-Diablo API") + .identityName("accessKey") + .credentialName("secretKey") + .documentation(URI.create("http://api.openstack.org/")) + .version("1.1") + .defaultEndpoint("http://localhost:5000") + .javaApi(NovaClient.class, NovaAsyncClient.class) + .defaultProperties(NovaApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(NovaContextBuilder.class)); + } @Override public NovaApiMetadata build() { return new NovaApiMetadata(this); } + + @Override + public Builder fromApiMetadata(NovaApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java index 903c983bd0..6a147dbfe6 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java @@ -19,35 +19,30 @@ package org.jclouds.openstack.nova; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.openstack.nova.compute.config.NovaComputeServiceContextModule; import org.jclouds.openstack.nova.config.NovaRestClientModule; +import org.jclouds.providers.ProviderMetadata; -import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link NovaComputeServiceContext} or {@link Injector} instances based on the most - * commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

    - *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. * * @author Adrian Cole - * @see NovaComputeServiceContext */ -public class NovaContextBuilder extends - ComputeServiceContextBuilder { +public class NovaContextBuilder + extends + ComputeServiceContextBuilder, NovaApiMetadata> { - public NovaContextBuilder(Properties props) { - super(NovaClient.class, NovaAsyncClient.class, props); + public NovaContextBuilder( + ProviderMetadata, NovaApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public NovaContextBuilder(NovaApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -55,9 +50,8 @@ public class NovaContextBuilder extends modules.add(new NovaComputeServiceContextModule()); } - @Override protected void addClientModule(List modules) { modules.add(new NovaRestClientModule()); } -} +} \ No newline at end of file diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaApiMetadataTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaApiMetadataTest.java index 448a1e04b2..6ca1e8ae5a 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaApiMetadataTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.openstack.nova; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "NovaApiMetadataTest") -public class NovaApiMetadataTest extends BaseApiMetadataTest { +public class NovaApiMetadataTest extends BaseComputeServiceApiMetadataTest { public NovaApiMetadataTest() { - super(new NovaApiMetadata(), ApiType.COMPUTE); + super(new NovaApiMetadata()); } } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java index d2e6c2387f..eaef7e29af 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.openstack.nova; -import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withMetadata; import static org.jclouds.openstack.nova.options.ListOptions.Builder.changesSince; @@ -29,7 +28,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; import java.util.Date; -import java.util.Properties; import javax.ws.rs.core.MediaType; @@ -46,13 +44,13 @@ import org.jclouds.openstack.nova.domain.RebootType; import org.jclouds.openstack.nova.options.CreateServerOptions; import org.jclouds.openstack.nova.options.ListOptions; import org.jclouds.openstack.nova.options.RebuildServerOptions; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -67,7 +65,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", singleThreaded = true, testName = "NovaAsyncClientTest") -public class NovaAsyncClientTest extends RestClientTest { +public class NovaAsyncClientTest extends BaseAsyncClientTest { private static final Class listOptionsVarargsClass = new ListOptions[]{}.getClass(); private static final Class createServerOptionsVarargsClass = new CreateServerOptions[]{} .getClass(); @@ -777,18 +775,10 @@ public class NovaAsyncClientTest extends RestClientTest { } - protected String provider = "nova"; - - @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties()); - } - - @Override - protected Properties setupProperties() { - Properties overrides = new Properties(); - overrides.setProperty(PROPERTY_API_VERSION, "api-version"); - overrides.setProperty(provider + ".endpoint", "http://endpoint"); - return overrides; + protected String provider = "nova"; + + @Override + protected ProviderMetadata createProviderMetadata() { + return AnonymousProviderMetadata.forApiWithEndpoint(new NovaApiMetadata(), "http://endpoint"); } } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java index 0796718958..d93ec24277 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java @@ -29,15 +29,14 @@ import java.io.IOException; import java.lang.reflect.UndeclaredThrowableException; import java.security.SecureRandom; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.BaseVersionedServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpResponseException; import org.jclouds.io.Payload; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.openstack.nova.domain.Flavor; import org.jclouds.openstack.nova.domain.Image; @@ -48,10 +47,8 @@ import org.jclouds.openstack.nova.domain.ServerStatus; import org.jclouds.openstack.nova.options.RebuildServerOptions; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; -import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; -import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.util.Strings2; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; @@ -59,10 +56,8 @@ import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Injector; -import com.google.inject.Module; /** * Tests behavior of {@code NovaClient} @@ -70,7 +65,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaClientLiveTest") -public class NovaClientLiveTest extends BaseVersionedServiceLiveTest { +public class NovaClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public NovaClientLiveTest() { provider = "nova"; } @@ -79,15 +77,11 @@ public class NovaClientLiveTest extends BaseVersionedServiceLiveTest { protected SshClient.Factory sshFactory; protected Predicate socketTester; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - - Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides) - .buildInjector(); - + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + Injector injector = context.utils().injector(); client = injector.getInstance(NovaClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java index 4d1f225a0f..eb0dc9eea2 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java @@ -22,13 +22,12 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.domain.LocationScope; import org.jclouds.openstack.nova.NovaAsyncClient; import org.jclouds.openstack.nova.NovaClient; -import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -40,7 +39,9 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "NovaComputeServiceLiveTest") -public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class NovaComputeServiceLiveTest extends + BaseComputeServiceLiveTest> { + public NovaComputeServiceLiveTest() { provider = "nova"; } @@ -49,13 +50,7 @@ public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest { protected Module getSshModule() { return new SshjSshClientModule(); } - - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); - } - + @Override protected void checkNodes(Iterable nodes, String group, String task) throws IOException { super.checkNodes(nodes, group, task); diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java index e8ba97cce6..240b37c49f 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java @@ -18,43 +18,84 @@ */ package org.jclouds.openstack.nova.ec2; +import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME; +import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS; +import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + +import java.util.Properties; + import org.jclouds.apis.ApiMetadata; import org.jclouds.ec2.EC2ApiMetadata; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for Nova's EC2-clone API + * Implementation of {@link ApiMetadata} for the OpenStack Nova's EC2-clone API * * @author Adrian Cole */ -public class NovaEC2ApiMetadata extends EC2ApiMetadata { +public class NovaEC2ApiMetadata extends EC2ApiMetadata, NovaEC2ApiMetadata> { + private static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } public NovaEC2ApiMetadata() { - this(builder().fromApiMetadata(new EC2ApiMetadata()) - .id("openstack-nova-ec2") - .name("Nova's EC2-clone API")); + this(builder()); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected NovaEC2ApiMetadata(ConcreteBuilder builder) { + protected NovaEC2ApiMetadata(Builder builder) { super(builder); } + + protected static Properties defaultProperties() { + Properties properties = EC2ApiMetadata.defaultProperties(); + properties.setProperty(PROPERTY_REGIONS, "nova"); + properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin"); + // hash characters are banned + properties.setProperty(RESOURCENAME_DELIMITER, "-"); + // often, we are dealing with IP addresses, not hostnames + properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true"); + properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); + properties.setProperty(PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true"); + // auth fail sometimes happens in EC2, as the rc.local script that injects the + // authorized key executes after ssh has started. + properties.setProperty("jclouds.ssh.max-retries", "7"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + return properties; + } - private static class ConcreteBuilder extends EC2ApiMetadataBuilder { - + public static class Builder extends EC2ApiMetadata.Builder, NovaEC2ApiMetadata> { + protected Builder(){ + super(EC2Client.class, EC2AsyncClient.class); + id("openstack-nova-ec2") + .name("OpenStack Nova's EC2-clone API") + .version("2009-04-04") + .defaultEndpoint("http://localhost:8773/services/Cloud") + .defaultProperties(NovaEC2ApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(NovaEC2ContextBuilder.class)); + } + @Override public NovaEC2ApiMetadata build() { return new NovaEC2ApiMetadata(this); } + + @Override + public Builder fromApiMetadata(NovaEC2ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } - private static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ContextBuilder.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ContextBuilder.java index 7131666d99..af5d8391de 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ContextBuilder.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ContextBuilder.java @@ -19,11 +19,14 @@ package org.jclouds.openstack.nova.ec2; import java.util.List; -import java.util.Properties; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.EC2ContextBuilder; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.openstack.nova.ec2.config.NovaEC2ComputeServiceContextModule; import org.jclouds.openstack.nova.ec2.config.NovaEC2RestClientModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -31,13 +34,17 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class NovaEC2ContextBuilder extends EC2ContextBuilder { +public class NovaEC2ContextBuilder extends EC2ContextBuilder, NovaEC2ApiMetadata> { - public NovaEC2ContextBuilder(Properties props) { - super(props); + public NovaEC2ContextBuilder( + ProviderMetadata, NovaEC2ApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public NovaEC2ContextBuilder(NovaEC2ApiMetadata apiMetadata) { + super(apiMetadata); } - @Override protected void addClientModule(List modules) { modules.add(new NovaEC2RestClientModule()); diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2PropertiesBuilder.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2PropertiesBuilder.java deleted file mode 100644 index 41c4b59a67..0000000000 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2PropertiesBuilder.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openstack.nova.ec2; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME; -import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS; -import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.ec2.EC2PropertiesBuilder; - -/** - * Builds properties used in NovaEC2 Clients - * - * @author Adrian Cole - */ -public class NovaEC2PropertiesBuilder extends EC2PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "2009-04-04"); - properties.setProperty(PROPERTY_ENDPOINT, "http://localhost:8773/services/Cloud"); - properties.setProperty(PROPERTY_REGIONS, "nova"); - properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin"); - // hash characters are banned - properties.setProperty(RESOURCENAME_DELIMITER, "-"); - // often, we are dealing with IP addresses, not hostnames - properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true"); - properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); - properties.setProperty(PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true"); - // auth fail sometimes happens in EC2, as the rc.local script that injects the - // authorized key executes after ssh has started. - properties.setProperty("jclouds.ssh.max-retries", "7"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - return properties; - } - - public NovaEC2PropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadataTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadataTest.java index 7d63c3a991..9c511cfdac 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadataTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.openstack.nova.ec2; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "NovaEC2ApiMetadataTest") -public class NovaEC2ApiMetadataTest extends BaseApiMetadataTest { +public class NovaEC2ApiMetadataTest extends BaseComputeServiceApiMetadataTest { public NovaEC2ApiMetadataTest() { - super(new NovaEC2ApiMetadata(), ApiType.COMPUTE); + super(new NovaEC2ApiMetadata()); } } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java index 14d614e7b6..253a799832 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java @@ -20,6 +20,9 @@ package org.jclouds.openstack.nova.ec2.compute; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest; import org.testng.annotations.Test; @@ -28,7 +31,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaEC2ComputeServiceLiveTest") -public class NovaEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { +public class NovaEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest> { public NovaEC2ComputeServiceLiveTest() { provider = "openstack-nova-ec2"; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java index 3df8fa8925..578d6b929d 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java @@ -1,58 +1,105 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.openstack.nova.v1_1; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; +import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; +import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.services.ServiceType; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for OpenStack Nova Diablo+ + * Implementation of {@link ApiMetadata} for Nova 1.0 API * * @author Adrian Cole */ -public class NovaApiMetadata extends BaseApiMetadata { +public class NovaApiMetadata + extends + BaseComputeServiceApiMetadata, NovaApiMetadata> { - public NovaApiMetadata() { - this(builder() - .id("openstack-nova") - .type(ApiType.COMPUTE) - .name("OpenStack Nova Diablo+ API") - .identityName("tenantId:user") - .credentialName("password") - .documentation(URI.create("http://api.openstack.org/"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } + public NovaApiMetadata() { + this(new Builder()); + } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected NovaApiMetadata(NovaApiMetadataBuilder builder) { + protected NovaApiMetadata(Builder builder) { super(builder); } - public static class NovaApiMetadataBuilder> extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + // auth fail can happen while cloud-init applies keypair updates + properties.setProperty("jclouds.ssh.max-retries", "7"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + + properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE); + // TODO: this doesn't actually do anything yet. + properties.setProperty(KeystoneProperties.VERSION, "2.0"); + + properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false"); + properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false"); + properties.setProperty(TIMEOUT_SECURITYGROUP_PRESENT, "500"); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, NovaApiMetadata> { + + protected Builder() { + id("openstack-nova") + .name("OpenStack Nova Diablo+ API") + .identityName("tenantId:user") + .credentialName("password") + .documentation(URI.create("http://api.openstack.org/")) + .version("1.1") + .defaultEndpoint("http://localhost:5000") + .javaApi(NovaClient.class, NovaAsyncClient.class) + .defaultProperties(NovaApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(NovaContextBuilder.class)); + } @Override public NovaApiMetadata build() { return new NovaApiMetadata(this); } - } - - private static class NovaConcreteBuilder extends NovaApiMetadataBuilder { @Override - public NovaApiMetadata build() { - return new NovaApiMetadata(this); + public Builder fromApiMetadata(NovaApiMetadata in) { + super.fromApiMetadata(in); + return this; } + } - private static NovaConcreteBuilder builder() { - return new NovaConcreteBuilder(); - } - - @Override - public NovaApiMetadataBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java index 08eb18e0a4..06be070cb8 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java @@ -19,32 +19,39 @@ package org.jclouds.openstack.nova.v1_1; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; /** - * A context builder for getting nova clients. * * @author Adrian Cole */ -public class NovaContextBuilder extends ComputeServiceContextBuilder { +public class NovaContextBuilder + extends + ComputeServiceContextBuilder, NovaApiMetadata> { - public NovaContextBuilder(Properties props) { - super(NovaClient.class, NovaAsyncClient.class, props); + public NovaContextBuilder( + ProviderMetadata, NovaApiMetadata> providerMetadata) { + super(providerMetadata); } - @Override - protected void addClientModule(List modules) { - modules.add(new NovaRestClientModule()); + public NovaContextBuilder(NovaApiMetadata apiMetadata) { + super(apiMetadata); } @Override protected void addContextModule(List modules) { modules.add(new NovaComputeServiceContextModule()); } -} + + protected void addClientModule(List modules) { + modules.add(new NovaRestClientModule()); + } + +} \ No newline at end of file diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaPropertiesBuilder.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaPropertiesBuilder.java deleted file mode 100644 index 5331a87cb9..0000000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaPropertiesBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openstack.nova.v1_1; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; -import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; -import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; -import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; -import org.jclouds.openstack.services.ServiceType; - -/** - * Builds properties used in Nova Clients - * - * @author Adrian Cole - */ -public class NovaPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "http://localhost:5000"); - properties.setProperty(PROPERTY_API_VERSION, "1.1"); - // auth fail can happen while cloud-init applies keypair updates - properties.setProperty("jclouds.ssh.max-retries", "7"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - - properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE); - // TODO: this doesn't actually do anything yet. - properties.setProperty(KeystoneProperties.VERSION, "2.0"); - - properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false"); - properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false"); - properties.setProperty(TIMEOUT_SECURITYGROUP_PRESENT, "500"); - return properties; - } - - public NovaPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java index bd799523ce..d3f56d941c 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java @@ -86,7 +86,7 @@ public class NovaComputeService extends BaseComputeService { protected final GroupNamingConvention.Factory namingConvention; @Inject - protected NovaComputeService(ComputeServiceContext context, Map credentialStore, + protected NovaComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadataTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadataTest.java index 2057e42892..db3c3b2d1c 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadataTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadataTest.java @@ -1,7 +1,6 @@ package org.jclouds.openstack.nova.v1_1; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -9,9 +8,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "NovaApiMetadataTest") -public class NovaApiMetadataTest extends BaseApiMetadataTest { +public class NovaApiMetadataTest extends BaseComputeServiceApiMetadataTest { public NovaApiMetadataTest() { - super(new NovaApiMetadata(), ApiType.COMPUTE); + super(new NovaApiMetadata()); } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java index 5ffe5deb98..e2072a77b3 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java @@ -161,6 +161,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC assertNotNull(server); assertEquals(server.getCredentials(), LoginCredentials.builder().privateKey("privateKey").build()); } + @Override public Injector apply(ComputeServiceContext input) { return input.utils().injector(); diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java index f0879a0003..683fb6b301 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java @@ -1,6 +1,9 @@ package org.jclouds.openstack.nova.v1_1.compute; -import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; +import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; +import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -11,7 +14,8 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaComputeServiceLiveTest") -public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class NovaComputeServiceLiveTest extends + BaseComputeServiceLiveTest> { public NovaComputeServiceLiveTest() { provider = "openstack-nova"; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java index 95c3c27ce4..1db260412f 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java @@ -51,8 +51,8 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { @Test public void testListFloatingIPs() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - Optional clientOption = context.getApi().getFloatingIPExtensionForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + Optional clientOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId); if (!clientOption.isPresent()) continue; FloatingIPClient client = clientOption.get(); @@ -73,8 +73,8 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { @Test public void testAllocateAndDeallocateFloatingIPs() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - Optional clientOption = context.getApi().getFloatingIPExtensionForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + Optional clientOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId); if (!clientOption.isPresent()) continue; FloatingIPClient client = clientOption.get(); @@ -104,12 +104,12 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { @Test public void testAddAndRemoveFloatingIp() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - Optional clientOption = context.getApi().getFloatingIPExtensionForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + Optional clientOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId); if (!clientOption.isPresent()) continue; FloatingIPClient client = clientOption.get(); - ServerClient serverClient = context.getApi().getServerClientForZone(zoneId); + ServerClient serverClient = novaContext.getApi().getServerClientForZone(zoneId); Server server = serverClient.createServer("test", imageIdForZone(zoneId), flavorRefForZone(zoneId)); blockUntilServerActive(server.getId(), serverClient); FloatingIP floatingIP = client.allocate(); @@ -125,12 +125,12 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { } private String imageIdForZone(String zoneId) { - ImageClient imageClient = context.getApi().getImageClientForZone(zoneId); + ImageClient imageClient = novaContext.getApi().getImageClientForZone(zoneId); return Iterables.getLast(imageClient.listImages()).getId(); } private String flavorRefForZone(String zoneId) { - FlavorClient flavorClient = context.getApi().getFlavorClientForZone(zoneId); + FlavorClient flavorClient = novaContext.getApi().getFlavorClientForZone(zoneId); return Iterables.getLast(flavorClient.listFlavors()).getId(); } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClientLiveTest.java index 1e28e5861f..62ce2e0860 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClientLiveTest.java @@ -36,8 +36,8 @@ import org.testng.annotations.Test; public class KeyPairClientLiveTest extends BaseNovaClientLiveTest { public void testListKeyPairs() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - KeyPairClient client = context.getApi().getKeyPairExtensionForZone(zoneId).get(); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + KeyPairClient client = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get(); Set> keyPairsList = client.listKeyPairs(); assertNotNull(keyPairsList); } @@ -45,8 +45,8 @@ public class KeyPairClientLiveTest extends BaseNovaClientLiveTest { public void testCreateAndDeleteKeyPair() throws Exception { final String KEYPAIR_NAME = "testkp"; - for (String zoneId : context.getApi().getConfiguredZones()) { - KeyPairClient client = context.getApi().getKeyPairExtensionForZone(zoneId).get(); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + KeyPairClient client = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get(); KeyPair keyPair = null; try { keyPair = client.createKeyPair(KEYPAIR_NAME); @@ -63,8 +63,8 @@ public class KeyPairClientLiveTest extends BaseNovaClientLiveTest { final String KEYPAIR_NAME = "testkp"; final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002"; - for (String zoneId : context.getApi().getConfiguredZones()) { - KeyPairClient client = context.getApi().getKeyPairExtensionForZone(zoneId).get(); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + KeyPairClient client = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get(); KeyPair keyPair = null; try { keyPair = client.createKeyPairWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY); diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClientLiveTest.java index 52ea12ba14..a4572b27c5 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClientLiveTest.java @@ -42,16 +42,16 @@ public class SecurityGroupClientLiveTest extends BaseNovaClientLiveTest { public static final String SECURITY_GROUP_NAME = "testsg"; public void listSecurityGroups() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - SecurityGroupClient client = context.getApi().getSecurityGroupExtensionForZone(zoneId).get(); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + SecurityGroupClient client = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get(); Set securityGroupsList = client.listSecurityGroups(); assertNotNull(securityGroupsList); } } public void createGetAndDeleteSecurityGroup() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - SecurityGroupClient client = context.getApi().getSecurityGroupExtensionForZone(zoneId).get(); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + SecurityGroupClient client = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get(); SecurityGroup securityGroup = null; String id; try { @@ -70,8 +70,8 @@ public class SecurityGroupClientLiveTest extends BaseNovaClientLiveTest { } public void createAndDeleteSecurityGroupRule() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - SecurityGroupClient client = context.getApi().getSecurityGroupExtensionForZone(zoneId).get(); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + SecurityGroupClient client = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get(); SecurityGroup securityGroup = null; try { diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ExtensionClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ExtensionClientLiveTest.java index d56e4199bd..a581894986 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ExtensionClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ExtensionClientLiveTest.java @@ -42,8 +42,8 @@ public class ExtensionClientLiveTest extends BaseNovaClientLiveTest { */ @Test public void testListExtensions() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - ExtensionClient client = context.getApi().getExtensionClientForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + ExtensionClient client = novaContext.getApi().getExtensionClientForZone(zoneId); Set response = client.listExtensions(); assert null != response; assertTrue(response.size() >= 0); diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java index 4a913fe4a1..02974c2849 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java @@ -43,8 +43,8 @@ public class FlavorClientLiveTest extends BaseNovaClientLiveTest { */ @Test public void testListFlavors() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - FlavorClient client = context.getApi().getFlavorClientForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + FlavorClient client = novaContext.getApi().getFlavorClientForZone(zoneId); Set response = client.listFlavors(); assert null != response; assertTrue(response.size() >= 0); @@ -64,8 +64,8 @@ public class FlavorClientLiveTest extends BaseNovaClientLiveTest { */ @Test public void testListFlavorsInDetail() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - FlavorClient client = context.getApi().getFlavorClientForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + FlavorClient client = novaContext.getApi().getFlavorClientForZone(zoneId); Set response = client.listFlavorsInDetail(); assert null != response; assertTrue(response.size() >= 0); diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientLiveTest.java index 6fce20b5d4..23744fa8d2 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientLiveTest.java @@ -39,8 +39,8 @@ public class ImageClientLiveTest extends BaseNovaClientLiveTest { @Test public void testListImages() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - ImageClient client = context.getApi().getImageClientForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + ImageClient client = novaContext.getApi().getImageClientForZone(zoneId); Set response = client.listImages(); assertNotNull(response); assertTrue(response.size() >= 0); @@ -56,8 +56,8 @@ public class ImageClientLiveTest extends BaseNovaClientLiveTest { @Test public void testListImagesInDetail() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - ImageClient client = context.getApi().getImageClientForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + ImageClient client = novaContext.getApi().getImageClientForZone(zoneId); Set response = client.listImagesInDetail(); assertNotNull(response); assertTrue(response.size() >= 0); diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientLiveTest.java index 2ddf1e7acb..470b4ba54b 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientLiveTest.java @@ -38,8 +38,8 @@ public class ServerClientLiveTest extends BaseNovaClientLiveTest { @Test public void testListServersInDetail() throws Exception { - for (String zoneId : context.getApi().getConfiguredZones()) { - ServerClient client = context.getApi().getServerClientForZone(zoneId); + for (String zoneId : novaContext.getApi().getConfiguredZones()) { + ServerClient client = novaContext.getApi().getServerClientForZone(zoneId); Set response = client.listServers(); assert null != response; assertTrue(response.size() >= 0); diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientExpectTest.java index 00720cdce1..7509ae04e1 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaAsyncClientExpectTest.java @@ -18,20 +18,13 @@ */ package org.jclouds.openstack.nova.v1_1.internal; -import static org.jclouds.rest.RestContextFactory.createContext; - import java.util.Properties; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -41,9 +34,6 @@ import com.google.inject.Module; */ public class BaseNovaAsyncClientExpectTest extends BaseNovaExpectTest { public NovaAsyncClient createClient(Function fn, Module module, Properties props) { - RestContextSpec contextSpec = new RestContextFactory(setupRestProperties()) - .createContextSpec(provider, identity, credential, new Properties()); - return createContext(contextSpec, - ImmutableSet. of(new ExpectModule(fn), new NullLoggingModule(), module), props).getAsyncApi(); + return createInjector(fn, module, props).getInstance(NovaAsyncClient.class); } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java index 8ecfd8dcdb..3e6679ed37 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java @@ -18,46 +18,42 @@ */ package org.jclouds.openstack.nova.v1_1.internal; -import java.util.Properties; - -import org.jclouds.compute.BaseVersionedServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code NovaClient} * * @author Adrian Cole */ @Test(groups = "live") -public class BaseNovaClientLiveTest extends BaseVersionedServiceLiveTest { +public class BaseNovaClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public BaseNovaClientLiveTest() { provider = "openstack-nova"; } - protected RestContext context; + protected RestContext novaContext; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new RestContextFactory().createContext(provider, identity, credential, - ImmutableSet. of(getLoggingModule(), new SshjSshClientModule()), overrides); + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + novaContext = context.getProviderSpecificContext(); } @AfterGroups(groups = "live") protected void tearDown() { - if (context != null) - context.close(); + if (novaContext != null) + novaContext.close(); } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java index aa730d3350..59f81af989 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java @@ -23,12 +23,12 @@ import java.net.URI; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; +import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.io.CopyInputStreamInputSupplierMap; -import org.jclouds.logging.config.NullLoggingModule; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; import org.jclouds.rest.config.CredentialStoreModule; import com.google.common.base.Function; @@ -84,10 +84,20 @@ public abstract class BaseNovaComputeServiceContextExpectTest extends BaseNov private ComputeServiceContext createComputeServiceContext(Function fn, Module module, Properties props) { - // the following will wipe out credential store between tests - return new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, identity, credential, - ImmutableSet. of(new ExpectModule(fn), new NullLoggingModule(), new CredentialStoreModule( - new CopyInputStreamInputSupplierMap(new ConcurrentHashMap>())), - module), props); + return createInjector(fn, module, props).getInstance(ComputeServiceContext.class); + } + + @Override + protected ApiMetadata createApiMetadata() { + return new NovaApiMetadata(); + } + + // isolate tests from eachother, as default credentialStore is static + protected Module credentialStoreModule = new CredentialStoreModule(new CopyInputStreamInputSupplierMap( + new ConcurrentHashMap>())); + + @Override + protected Module createModule() { + return credentialStoreModule; } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java index 15f68e6afa..d79e19dc45 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java @@ -30,7 +30,7 @@ import org.jclouds.compute.ComputeServiceContext; public class BaseNovaComputeServiceExpectTest extends BaseNovaComputeServiceContextExpectTest { @Override - public ComputeService apply(ComputeServiceContext input) { + public ComputeService apply(@SuppressWarnings("rawtypes") ComputeServiceContext input) { return input.getComputeService(); } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaExpectTest.java index 2b38d4cd7e..c311dbcbe0 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaExpectTest.java @@ -23,7 +23,7 @@ import java.net.URI; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import com.google.common.collect.ImmutableMultimap; diff --git a/apis/s3/pom.xml b/apis/s3/pom.xml index 4a29312792..ba491d8531 100644 --- a/apis/s3/pom.xml +++ b/apis/s3/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.s3.blobstore.integration.S3TestInitializer https://s3.amazonaws.com 2006-03-01 @@ -105,7 +104,6 @@ - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} ${test.s3.endpoint} diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java index d6a30143a1..45b84df2e6 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java @@ -18,58 +18,115 @@ */ package org.jclouds.s3; +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; +import static org.jclouds.blobstore.reference.BlobStoreConstants.DIRECTORY_SUFFIX_FOLDER; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; +import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH; +import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.s3.blobstore.S3BlobStoreContext; +import org.jclouds.s3.reference.S3Headers; + +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for Amazon's S3 api. * + *

    note

    + *

    + * This class allows overriding of types {@code S}(client) and {@code A} + * (asyncClient), so that children can add additional methods not declared here, + * such as new features from AWS. + *

    + * + * As this is a popular api, we also allow overrides for type {@code C} + * (context). This allows subtypes to add in new feature groups or extensions, + * not present in the base api. For example, you could make a subtype for + * context, that exposes admin operations. + * * @author Adrian Cole */ -public class S3ApiMetadata extends BaseApiMetadata { +public class S3ApiMetadata, M extends S3ApiMetadata> + extends BaseBlobStoreApiMetadata { - public S3ApiMetadata() { - this(builder() - .id("s3") - .type(ApiType.BLOBSTORE) - .name("Amazon Simple Storage Service (S3) API") - .identityName("Access Key ID") - .credentialName("Secret Access Key") - .documentation(URI.create("http://docs.amazonwebservices.com/AmazonS3/latest/API"))); + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public Builder toBuilder() { + return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected S3ApiMetadata(S3ApiMetadataBuilder builder) { + @SuppressWarnings({ "unchecked", "rawtypes" }) + public S3ApiMetadata() { + this(new Builder(S3Client.class, S3AsyncClient.class)); + } + + protected S3ApiMetadata(Builder builder) { super(builder); } + + protected static Properties defaultProperties() { + Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_API_VERSION, S3AsyncClient.VERSION); + properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); + properties.setProperty(PROPERTY_HEADER_TAG, S3Headers.DEFAULT_AMAZON_HEADERTAG); + properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/"); + properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "true"); + properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true"); + properties.setProperty(PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX, DIRECTORY_SUFFIX_FOLDER); + properties.setProperty(PROPERTY_USER_METADATA_PREFIX, String.format("x-${%s}-meta-", PROPERTY_HEADER_TAG)); + return properties; + } - public static class S3ApiMetadataBuilder> extends Builder { + public static class Builder, M extends S3ApiMetadata> extends BaseBlobStoreApiMetadata.Builder { + protected Builder(Class syncClient, Class asyncClient){ + id("s3") + .name("Amazon Simple Storage Service (S3) API") + .identityName("Access Key ID") + .credentialName("Secret Access Key") + .defaultEndpoint("https://s3.amazonaws.com") + .documentation(URI.create("http://docs.amazonwebservices.com/AmazonS3/latest/API")) + .version(S3AsyncClient.VERSION) + .defaultProperties(S3ApiMetadata.defaultProperties()) + .javaApi(syncClient, asyncClient) + .contextBuilder(new TypeToken>(getClass()){ + private static final long serialVersionUID = 1L; + }); + } + + /** + * {@inheritDoc} + */ @Override - public S3ApiMetadata build() { - return new S3ApiMetadata(this); + @SuppressWarnings("rawtypes") + protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { + return new TypeToken>() { + private static final long serialVersionUID = 1L; + }.where(new TypeParameter() { + }, clientToken).where(new TypeParameter() { + }, asyncClientToken); + } + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public M build() { + return (M) new S3ApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(M in) { + super.fromApiMetadata(in); + return this; } } - private static class S3ConcreteBuilder extends S3ApiMetadataBuilder { - - @Override - public S3ApiMetadata build() { - return new S3ApiMetadata(this); - } - } - - private static S3ConcreteBuilder builder() { - return new S3ConcreteBuilder(); - } - - @Override - public S3ApiMetadataBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java b/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java index 64ccf6cec2..8c011628d1 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java +++ b/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java @@ -19,11 +19,12 @@ package org.jclouds.s3; import java.util.List; -import java.util.Properties; import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.s3.blobstore.S3BlobStoreContext; import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; import org.jclouds.s3.config.S3RestClientModule; @@ -43,10 +44,15 @@ import com.google.inject.Module; * @author Adrian Cole, Andrew Newdigate * @see S3Context */ -public class S3ContextBuilder extends BlobStoreContextBuilder { +public class S3ContextBuilder, M extends S3ApiMetadata> + extends BlobStoreContextBuilder { - public S3ContextBuilder(Properties props) { - super(S3Client.class, S3AsyncClient.class, props); + public S3ContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); + } + + public S3ContextBuilder(M apiMetadata) { + super(apiMetadata); } @Override diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3PropertiesBuilder.java b/apis/s3/src/main/java/org/jclouds/s3/S3PropertiesBuilder.java deleted file mode 100644 index e2158f769d..0000000000 --- a/apis/s3/src/main/java/org/jclouds/s3/S3PropertiesBuilder.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.s3; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; -import static org.jclouds.blobstore.reference.BlobStoreConstants.DIRECTORY_SUFFIX_FOLDER; -import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX; -import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; -import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH; -import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.jclouds.s3.reference.S3Headers; - -/** - * Builds properties used in S3 Connections - * - * @author Adrian Cole - */ -public class S3PropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, S3AsyncClient.VERSION); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_HEADER_TAG, S3Headers.DEFAULT_AMAZON_HEADERTAG); - properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/"); - properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "true"); - properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true"); - properties.setProperty(PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX, DIRECTORY_SUFFIX_FOLDER); - properties.setProperty(PROPERTY_USER_METADATA_PREFIX, String.format("x-${%s}-meta-", PROPERTY_HEADER_TAG)); - return properties; - } - - public S3PropertiesBuilder(Properties properties) { - super(properties); - } - - public S3PropertiesBuilder() { - super(); - } - -} diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java index 3bded56016..0bd44b881c 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java @@ -93,7 +93,7 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore { private final LoadingCache bucketAcls; @Inject - protected S3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + protected S3AsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, S3AsyncClient async, S3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java index 3c75d3d3c2..2e2104879b 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java @@ -84,7 +84,7 @@ public class S3BlobStore extends BaseBlobStore { private final LoadingCache bucketAcls; @Inject - protected S3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected S3BlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, S3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob, diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobStoreTestInitializer.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java similarity index 64% rename from blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobStoreTestInitializer.java rename to apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java index 201287fa9b..58e8b1fec6 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobStoreTestInitializer.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java @@ -16,26 +16,24 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.blobstore.integration; - -import java.io.IOException; +package org.jclouds.s3.blobstore; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.integration.internal.BaseTestInitializer; +import org.jclouds.s3.S3AsyncClient; +import org.jclouds.s3.S3Client; +import org.jclouds.s3.blobstore.internal.S3BlobStoreContextImpl; -import com.google.inject.Module; +import com.google.inject.ImplementedBy; /** - * * @author Adrian Cole */ -public class TransientBlobStoreTestInitializer extends BaseTestInitializer { +@ImplementedBy(S3BlobStoreContextImpl.class) +public interface S3BlobStoreContext extends BlobStoreContext { @Override - protected BlobStoreContext createLiveContext(Module configurationModule, String url, String apiVersion,String buildVersion, String app, - String identity, String key) throws IOException { - return createStubContext(); - } - + S3BlobStore getBlobStore(); + @Override + S3AsyncBlobStore getAsyncBlobStore(); } diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java new file mode 100644 index 0000000000..92f9066a67 --- /dev/null +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java @@ -0,0 +1,61 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.s3.blobstore.internal; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.InputStreamMap; +import org.jclouds.blobstore.attr.ConsistencyModel; +import org.jclouds.blobstore.internal.BlobStoreContextImpl; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.Utils; +import org.jclouds.s3.S3AsyncClient; +import org.jclouds.s3.S3Client; +import org.jclouds.s3.blobstore.S3AsyncBlobStore; +import org.jclouds.s3.blobstore.S3BlobStore; +import org.jclouds.s3.blobstore.S3BlobStoreContext; + +/** + * @author Adrian Cole + */ +@Singleton +public class S3BlobStoreContextImpl extends + BlobStoreContextImpl implements S3BlobStoreContext { + + @Inject + public S3BlobStoreContextImpl(BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, + InputStreamMap.Factory inputStreamMapFactory, S3AsyncBlobStore ablobStore, S3BlobStore blobStore, + @SuppressWarnings("rawtypes") RestContext providerSpecificContext, BlobRequestSigner blobRequestSigner) { + super(blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, blobStore, providerSpecificContext, blobRequestSigner); + } + + @Override + public S3BlobStore getBlobStore() { + return S3BlobStore.class.cast(super.getBlobStore()); + } + + @Override + public S3AsyncBlobStore getAsyncBlobStore() { + return S3AsyncBlobStore.class.cast(super.getAsyncBlobStore()); + } + +} diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java index b18deec218..8445d01a19 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java @@ -18,18 +18,18 @@ */ package org.jclouds.s3; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; import org.testng.annotations.Test; /** * * @author Adrian Cole */ +@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "S3ApiMetadataTest") -public class S3ApiMetadataTest extends BaseApiMetadataTest { +public class S3ApiMetadataTest extends BaseBlobStoreApiMetadataTest { public S3ApiMetadataTest() { - super(new S3ApiMetadata(), ApiType.BLOBSTORE); + super(new S3ApiMetadata()); } } diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java index 0fed98817b..c5ee33c702 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java @@ -62,6 +62,10 @@ import com.google.common.collect.Maps; */ @Test(groups = { "integration", "live" }) public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest { + public S3ClientLiveTest() { + this.provider = "s3"; + } + public S3Client getApi() { return (S3Client) context.getProviderSpecificContext().getApi(); } diff --git a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java index 489b3bc09f..10e45102f4 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java @@ -45,9 +45,6 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit", testName = "BindAsHostPrefixIfConfiguredTest") public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest { - public BindAsHostPrefixIfConfiguredTest(){ - endpoint = "http://euc/services/Walrus"; - } @Override protected TypeLiteral> createTypeLiteral() { return new TypeLiteral>() { @@ -98,6 +95,7 @@ public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest extends RestClientTest { +public abstract class BaseS3AsyncClientTest extends BaseAsyncClientTest { protected BlobToObject blobToS3Object; protected RequestAuthorizeSignature filter; @@ -67,18 +60,10 @@ public abstract class BaseS3AsyncClientTest extends Res super(); } - protected String provider = "s3"; - protected String endpoint = "https://s3.amazonaws.com"; - - /** - * this is only here as "s3" is not in rest.properties - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public RestContextSpec createContextSpec() { - return RestContextFactory. contextSpec(provider, endpoint, - S3AsyncClient.VERSION, "", "", "identity", "credential", S3Client.class, S3AsyncClient.class, - (Class) S3PropertiesBuilder.class, (Class) S3ContextBuilder.class, ImmutableSet. of()); + public S3ApiMetadata createApiMetadata() { + return new S3ApiMetadata(); } } diff --git a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java index 57318b55d6..c759c546ff 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java @@ -18,16 +18,13 @@ */ package org.jclouds.s3.internal; -import java.util.Properties; - import org.jclouds.date.TimeStamp; import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.BaseRestClientExpectTest; import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.internal.BaseRestClientExpectTest; +import org.jclouds.s3.S3ApiMetadata; import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3Client; -import org.jclouds.s3.S3ContextBuilder; -import org.jclouds.s3.S3PropertiesBuilder; import org.jclouds.s3.config.S3RestClientModule; import com.google.common.base.Supplier; @@ -41,19 +38,6 @@ public abstract class BaseS3ClientExpectTest extends BaseRestClientExpectTest { @@ -72,4 +56,11 @@ public abstract class BaseS3ClientExpectTest extends BaseRestClientExpectTestbundle - org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer http://localhost:11000 1.0 @@ -105,7 +104,6 @@ - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} ${test.swift.endpoint} diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java index 665b84e9f6..4c26352ab1 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java @@ -1,49 +1,94 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.openstack.swift; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.openstack.OpenStackAuthAsyncClient; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for OpenStack Swift Pre-Diablo + * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * * @author Adrian Cole */ -public class SwiftApiMetadata extends BaseApiMetadata { - - public SwiftApiMetadata() { - this(builder() - .id("swift") - .type(ApiType.BLOBSTORE) - .name("OpenStack Swift Pre-Diablo API") - .identityName("tenantId:user") - .credentialName("password") - .documentation(URI.create("http://api.openstack.org/"))); +public class SwiftApiMetadata + extends + BaseBlobStoreApiMetadata, SwiftApiMetadata> { + private static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SwiftApiMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } + + public SwiftApiMetadata() { + this(builder()); + } + + protected SwiftApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); + properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); + return properties; + } + + public static class Builder + extends + BaseBlobStoreApiMetadata.Builder, SwiftApiMetadata> { + protected Builder() { + id("swift") + .type(ApiType.BLOBSTORE) + .name("OpenStack Swift Pre-Diablo API") + .identityName("tenantId:user") + .credentialName("password") + .documentation(URI.create("http://api.openstack.org/")) + .version(OpenStackAuthAsyncClient.VERSION) + .contextBuilder(TypeToken.of(SwiftContextBuilder.class)) + .defaultProperties(SwiftApiMetadata.defaultProperties()) + .javaApi(SwiftClient.class, SwiftAsyncClient.class); + } @Override public SwiftApiMetadata build() { return new SwiftApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); + @Override + public Builder fromApiMetadata(SwiftApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java index bdca5d130b..a64a01c24a 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java @@ -19,34 +19,45 @@ package org.jclouds.openstack.swift; import java.util.List; -import java.util.Properties; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; import org.jclouds.openstack.swift.config.SwiftRestClientModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link CloudFilesBlobStoreContext} or {@link Injector} instances based on the most - * commonly requested arguments. + * Creates {@link SwiftStoreContext} or {@link Injector} instances based on + * the most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole, Andrew Newdigate - * @see CloudFilesBlobStoreContext + * @see SwiftStoreContext */ -public class SwiftContextBuilder extends BlobStoreContextBuilder { +public class SwiftContextBuilder + extends + BlobStoreContextBuilder, SwiftApiMetadata> { - public SwiftContextBuilder(Properties props) { - super(SwiftClient.class, SwiftAsyncClient.class, props); + public SwiftContextBuilder( + ProviderMetadata, SwiftApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public SwiftContextBuilder(SwiftApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -58,4 +69,4 @@ public class SwiftContextBuilder extends BlobStoreContextBuilder modules) { modules.add(new SwiftRestClientModule()); } -} +} \ No newline at end of file diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftPropertiesBuilder.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftPropertiesBuilder.java deleted file mode 100644 index 02c1cb981c..0000000000 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftPropertiesBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openstack.swift; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.jclouds.openstack.OpenStackAuthAsyncClient; - -/** - * Builds properties used in CloudFiles Connections - * - * @author Adrian Cole - */ -public class SwiftPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); - properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); - properties.setProperty(PROPERTY_API_VERSION, OpenStackAuthAsyncClient.VERSION); - return properties; - } - - public SwiftPropertiesBuilder(Properties properties) { - super(properties); - } - - protected SwiftPropertiesBuilder withMetaPrefix(String prefix) { - properties.setProperty(PROPERTY_USER_METADATA_PREFIX, prefix); - return this; - } -} diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java index b0873c9af6..ec12eec9ec 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java @@ -83,7 +83,7 @@ public class SwiftAsyncBlobStore extends BaseAsyncBlobStore { private final Provider fetchBlobMetadataProvider; @Inject - protected SwiftAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + protected SwiftAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, CommonSwiftAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java index e96909ba18..9d2fab5638 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java @@ -73,7 +73,7 @@ public class SwiftBlobStore extends BaseBlobStore { private final Provider fetchBlobMetadataProvider; @Inject - protected SwiftBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected SwiftBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientLiveTest.java index 01ce8ee90f..554a39f3ef 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientLiveTest.java @@ -55,7 +55,7 @@ import com.google.common.collect.Maps; */ @Test(groups = "live") public abstract class CommonSwiftClientLiveTest extends BaseBlobStoreIntegrationTest { - + public abstract C getApi(); /** diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java index 74a77d2407..4906ebd24e 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java @@ -24,14 +24,13 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; +import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.openstack.TestOpenStackAuthenticationModule; import org.jclouds.openstack.swift.config.BaseSwiftRestClientModule; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.testng.annotations.Test; import com.google.inject.Module; @@ -43,7 +42,7 @@ import com.google.inject.Module; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SwiftClientTest") -public abstract class CommonSwiftClientTest extends RestClientTest { +public abstract class CommonSwiftClientTest extends BaseAsyncClientTest { @Override protected void checkFilters(HttpRequest request) { @@ -65,11 +64,10 @@ public abstract class CommonSwiftClientTest ex protected String provider = "swift"; - @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties()); + protected ApiMetadata createApiMetadata() { + return new SwiftApiMetadata(); } - + @Override protected Properties setupProperties() { Properties properties = new Properties(); diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java index 299f16ea43..f9cd2b4882 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java @@ -1,7 +1,6 @@ package org.jclouds.openstack.swift; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; import org.testng.annotations.Test; /** @@ -9,9 +8,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "SwiftApiMetadataTest") -public class SwiftApiMetadataTest extends BaseApiMetadataTest { +public class SwiftApiMetadataTest extends BaseBlobStoreApiMetadataTest { public SwiftApiMetadataTest() { - super(new SwiftApiMetadata(), ApiType.BLOBSTORE); + super(new SwiftApiMetadata()); } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java index ff1f77ba64..8cc7bd1e1a 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java @@ -26,7 +26,11 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class SwiftClientLiveTest extends CommonSwiftClientLiveTest { - + + public SwiftClientLiveTest(){ + provider = "swift"; + } + @Override public SwiftClient getApi() { return (SwiftClient) context.getProviderSpecificContext().getApi(); diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java index 71c4c128f2..8268a4a339 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java @@ -30,7 +30,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest { - + public SwiftBlobIntegrationLiveTest() { + provider = "swift"; + } @Override @Test(enabled = false) public void testGetTwoRanges() { diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java index 89b3e02b7d..81ac376673 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobLiveTest.java @@ -28,5 +28,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class SwiftBlobLiveTest extends BaseBlobLiveTest { - + public SwiftBlobLiveTest() { + provider = "swift"; + } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobMapIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobMapIntegrationLiveTest.java index 7d6600d6a2..a2303a0702 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobMapIntegrationLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class SwiftBlobMapIntegrationLiveTest extends BaseBlobMapIntegrationTest { - + public SwiftBlobMapIntegrationLiveTest() { + provider = "swift"; + } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java index 06fb6a326f..3b116c7e15 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class SwiftBlobSignerLiveTest extends BaseBlobSignerLiveTest { - + public SwiftBlobSignerLiveTest() { + provider = "swift"; + } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java index 946a12f4f8..73862bf7da 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerIntegrationLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationTest { - + public SwiftContainerIntegrationLiveTest() { + provider = "swift"; + } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java index d095628b95..7901ac4fa8 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java @@ -29,7 +29,9 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class SwiftContainerLiveTest extends BaseContainerLiveTest { - + public SwiftContainerLiveTest() { + provider = "swift"; + } @Test(expectedExceptions=UnsupportedOperationException.class) public void testPublicAccess() throws MalformedURLException, InterruptedException, IOException { super.testPublicAccess(); diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftInputStreamMapIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftInputStreamMapIntegrationLiveTest.java index 90352f3599..b4c75add16 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftInputStreamMapIntegrationLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftInputStreamMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class SwiftInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest { - + public SwiftInputStreamMapIntegrationLiveTest() { + provider = "swift"; + } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java index ee48005503..5c559e2549 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftServiceIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class SwiftServiceIntegrationLiveTest extends BaseServiceIntegrationTest { - + public SwiftServiceIntegrationLiveTest() { + provider = "swift"; + } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftTestInitializer.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftTestInitializer.java deleted file mode 100644 index 6f51336a44..0000000000 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftTestInitializer.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openstack.swift.blobstore.integration; - -import java.io.IOException; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class SwiftTestInitializer extends TransientBlobStoreTestInitializer { - - public SwiftTestInitializer() { - provider = "swift"; - } - - @Override - protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiVersion, - String buildVersion, String app, String identity, String credential) throws IOException { - return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule, - new Log4JLoggingModule()), setupProperties(endpoint, apiVersion, buildVersion, identity, credential)); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java index 8b00adb062..9238fca5ea 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java @@ -18,50 +18,90 @@ */ package org.jclouds.vcloud; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.vcloud.domain.network.FenceMode; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for VCloud 1.0 API * * @author Adrian Cole */ -public class VCloudApiMetadata extends BaseApiMetadata { +public class VCloudApiMetadata + extends + BaseComputeServiceApiMetadata, VCloudApiMetadata> { - public VCloudApiMetadata() { - this(builder() - .id("vcloud") - .type(ApiType.COMPUTE) - .name("VCloud 1.0 API") - .identityName("User at Organization (user@org)") - .credentialName("Password") - .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected VCloudApiMetadata(ConcreteBuilder builder) { + public VCloudApiMetadata() { + this(new Builder()); + } + + protected VCloudApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1"); + properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, + String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA)); + properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + ""); + properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); + properties.setProperty("jclouds.dns_name_length_min", "1"); + properties.setProperty("jclouds.dns_name_length_max", "80"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED.toString()); + // TODO integrate this with the {@link ComputeTimeouts} instead of having + // a single timeout for + // everything. + properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 1200l * 1000l + ""); + properties.setProperty(PROPERTY_SESSION_INTERVAL, 300 + ""); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, VCloudApiMetadata> { + + protected Builder() { + id("vcloud") + .name("VCloud 1.0 API") + .identityName("User at Organization (user@org)") + .credentialName("Password") + .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) + .version("1.0") + .javaApi(VCloudClient.class, VCloudAsyncClient.class) + .defaultProperties(VCloudApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(VCloudContextBuilder.class)); + } @Override public VCloudApiMetadata build() { return new VCloudApiMetadata(this); } + + @Override + public Builder fromApiMetadata(VCloudApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } -} \ No newline at end of file +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java index a14f6f3091..a69b0105c2 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java @@ -19,38 +19,30 @@ package org.jclouds.vcloud; import java.util.List; -import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; import org.jclouds.vcloud.config.VCloudRestClientModule; -import com.google.inject.Injector; -import com.google.inject.Key; import com.google.inject.Module; -import com.google.inject.TypeLiteral; /** - * Creates {@link VCloudComputeServiceContext} or {@link Injector} instances based on the most - * commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

    - *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. * * @author Adrian Cole - * @see VCloudComputeServiceContext */ -public class VCloudContextBuilder extends ComputeServiceContextBuilder { +public class VCloudContextBuilder + extends + ComputeServiceContextBuilder, VCloudApiMetadata> { - public VCloudContextBuilder(Properties props) { - super(VCloudClient.class, VCloudAsyncClient.class, props); + public VCloudContextBuilder( + ProviderMetadata, VCloudApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public VCloudContextBuilder(VCloudApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -58,16 +50,8 @@ public class VCloudContextBuilder extends ComputeServiceContextBuilder modules) { modules.add(new VCloudRestClientModule()); } - @Override - public ComputeServiceContext buildComputeServiceContext() { - // need the generic type information - return (ComputeServiceContext) this.buildInjector().getInstance( - Key.get(new TypeLiteral>() { - })); - } } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudPropertiesBuilder.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudPropertiesBuilder.java deleted file mode 100644 index d5522c343b..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudPropertiesBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.jclouds.vcloud.domain.network.FenceMode; - -/** - * Builds properties used in VCloud Clients - * - * @author Adrian Cole - */ -public class VCloudPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1"); - properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, - String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA)); - properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + ""); - properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); - properties.setProperty("jclouds.dns_name_length_min", "1"); - properties.setProperty("jclouds.dns_name_length_max", "80"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED.toString()); - // TODO integrate this with the {@link ComputeTimeouts} instead of having a single timeout for - // everything. - properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 1200l * 1000l + ""); - properties.setProperty(PROPERTY_SESSION_INTERVAL, 300 + ""); - return properties; - } - - public VCloudPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java index 338494962b..9bb06859b2 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java @@ -19,7 +19,7 @@ package org.jclouds.vcloud; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.apis.internal.BaseApiMetadataTest; import org.testng.annotations.Test; /** diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java index cc3d8c7098..6b37820b16 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.vcloud; -import static org.jclouds.rest.RestContextFactory.contextSpec; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -26,8 +25,9 @@ import java.lang.reflect.Method; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.vcloud.xml.SupportedVersionsHandler; import org.testng.annotations.Test; @@ -41,7 +41,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "VCloudVersionsAsyncClientTest") -public class VCloudVersionsAsyncClientTest extends RestClientTest { +public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest { public void testVersions() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudVersionsAsyncClient.class.getMethod("getSupportedVersions"); @@ -70,9 +70,8 @@ public class VCloudVersionsAsyncClientTest extends RestClientTest createContextSpec() { - return contextSpec("test", "http://localhost:8080", "1", "", "", "identity", "credential", - VCloudVersionsClient.class, VCloudVersionsAsyncClient.class); + protected ProviderMetadata createProviderMetadata() { + return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudVersionsClient.class, + VCloudVersionsAsyncClient.class, "http://localhost:8080"); } - } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java index 28d506bd0c..d59b818d32 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java @@ -26,10 +26,9 @@ import static org.easymock.EasyMock.verify; import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Properties; import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.VCloudPropertiesBuilder; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.options.CatalogItemOptions; import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; @@ -51,7 +50,7 @@ public class BindCatalogItemToXmlPayloadTest { @Override protected void bindConfigurations() { - bindProperties(new VCloudPropertiesBuilder(new Properties()).build()); + bindProperties(new VCloudApiMetadata().getDefaultProperties()); } })); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java index fbece0ba68..5c4dd3170c 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java @@ -26,10 +26,9 @@ import static org.easymock.EasyMock.verify; import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Properties; import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.VCloudPropertiesBuilder; +import org.jclouds.vcloud.VCloudApiMetadata; import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import org.testng.annotations.Test; @@ -49,7 +48,7 @@ public class BindDeployVAppParamsToXmlPayloadTest { @Override protected void bindConfigurations() { - bindProperties(new VCloudPropertiesBuilder(new Properties()).build()); + bindProperties(new VCloudApiMetadata().getDefaultProperties()); } })); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java index 1b5151563e..8fbca524fd 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java @@ -28,14 +28,13 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAU import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Properties; import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; -import org.jclouds.vcloud.VCloudPropertiesBuilder; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; @@ -90,7 +89,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest { @Override protected void bindConfigurations() { - bindProperties(new VCloudPropertiesBuilder(new Properties()).build()); + bindProperties(new VCloudApiMetadata().getDefaultProperties()); } @SuppressWarnings("unused") diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java index 2975f56af1..a0552e1e1f 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java @@ -22,10 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.net.URI; -import java.util.Properties; import org.jclouds.http.HttpRequest; -import org.jclouds.vcloud.VCloudPropertiesBuilder; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.domain.NetworkConnection; import org.jclouds.vcloud.domain.NetworkConnectionSection; import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; @@ -48,7 +47,7 @@ public class BindNetworkConnectionSectionToXmlPayloadTest { @Override protected void bindConfigurations() { - bindProperties(new VCloudPropertiesBuilder(new Properties()).build()); + bindProperties(new VCloudApiMetadata().getDefaultProperties()); } })); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java index 123a07fc14..790ee6c8da 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java @@ -26,10 +26,9 @@ import static org.easymock.EasyMock.verify; import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Properties; import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.VCloudPropertiesBuilder; +import org.jclouds.vcloud.VCloudApiMetadata; import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import org.testng.annotations.Test; @@ -49,7 +48,7 @@ public class BindUndeployVAppParamsToXmlPayloadTest { @Override protected void bindConfigurations() { - bindProperties(new VCloudPropertiesBuilder(new Properties()).build()); + bindProperties(new VCloudApiMetadata().getDefaultProperties()); } })); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java index 833e9ba46e..59b371f4e3 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java @@ -23,17 +23,16 @@ import java.util.Properties; import javax.ws.rs.core.MediaType; +import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.VCloudMediaType; import com.google.common.base.Function; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; import com.google.common.net.HttpHeaders; import com.google.inject.Module; @@ -57,7 +56,7 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE URI.create(ENDPOINT + "/v1.0/login")) .headers(ImmutableMultimap. builder() .put(HttpHeaders.ACCEPT, VCloudMediaType.ORGLIST_XML) - .put(HttpHeaders.AUTHORIZATION, "Basic dXNlckBvcmc6cGFzc3dvcmQ=").build()).build(); + .put(HttpHeaders.AUTHORIZATION, "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build()).build(); protected String sessionToken = "AtatAgvJMrwOc9pDQq4RRCRLazThpnTKJDxSVH9oB2I="; @@ -148,14 +147,18 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE @Override public ComputeService createClient(Function fn, Module module, Properties props) { - return new ComputeServiceContextFactory(setupRestProperties()) - .createContext(provider, "user@org", "password", ImmutableSet. of(new ExpectModule(fn), - new NullLoggingModule(), module), props).getComputeService(); + return createInjector(fn, module, props).getInstance(ComputeService.class); } + + @Override + protected ApiMetadata createApiMetadata() { + return new VCloudApiMetadata(); + } + @Override protected Properties setupProperties() { Properties props = super.setupProperties(); - props.setProperty(provider+".endpoint", ENDPOINT); + props.setProperty(provider + ".endpoint", ENDPOINT); return props; } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java index aa6185c6c5..e10e9dc449 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java @@ -18,9 +18,12 @@ */ package org.jclouds.vcloud.compute; -import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -32,7 +35,9 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class VCloudComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { public VCloudComputeServiceLiveTest() { provider = "vcloud"; diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java index 7ce1aefb97..f3d5df5188 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java @@ -18,13 +18,11 @@ */ package org.jclouds.vcloud.compute.functions; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Properties; import java.util.Set; import javax.inject.Singleton; @@ -41,7 +39,7 @@ import org.jclouds.domain.LocationScope; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.VCloudPropertiesBuilder; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.compute.config.VCloudComputeServiceDependenciesModule; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Status; @@ -75,8 +73,7 @@ public class VAppToNodeMetadataTest { @Override protected void configure() { - Properties props = new Properties(); - Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties")); + Names.bindProperties(binder(), new VCloudApiMetadata().getDefaultProperties()); bind(new TypeLiteral>() { }).to(new TypeLiteral() { }); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java index adc2563eb8..28e1aeed00 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java @@ -46,7 +46,7 @@ public class CatalogClientLiveTest extends BaseVCloudClientLiveTest { public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception { // when we are in vCloud 1.0.0 public catalogs don't work, so our default // catalog is private - if (!buildVersion.startsWith("1.5")) + if (!context.getProviderSpecificContext().getApiVersion().startsWith("1.5")) assertTrue(getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).isReadOnly()); } } \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java index 96b696cf30..e13e85fb12 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java @@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals; import java.net.URI; import java.util.Map; -import java.util.Properties; import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; @@ -34,11 +33,12 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.ovf.Envelope; import org.jclouds.ovf.xml.EnvelopeHandlerTest; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudVersionsClient; import org.jclouds.vcloud.config.VCloudRestClientModule; @@ -78,7 +78,7 @@ import com.google.inject.TypeLiteral; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", testName = "BaseVCloudAsyncClientTest") -public abstract class BaseVCloudAsyncClientTest extends RestClientTest { +public abstract class BaseVCloudAsyncClientTest extends BaseAsyncClientTest { @Override protected void checkFilters(HttpRequest request) { @@ -90,14 +90,13 @@ public abstract class BaseVCloudAsyncClientTest extends RestClientTest { protected Module createModule() { return new VCloudRestClientModuleExtension(); } - + @Override - public RestContextSpec createContextSpec() { - Properties overrides = new Properties(); - overrides.setProperty("vcloud.endpoint", "https://vcenterprise.bluelock.com/api/v1.0"); - return new RestContextFactory().createContextSpec("vcloud", "identity", "credential", overrides); + protected ProviderMetadata createProviderMetadata() { + return AnonymousProviderMetadata.forApiWithEndpoint(new VCloudApiMetadata(), + "https://vcenterprise.bluelock.com/api/v1.0"); } - + protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", VCloudMediaType.ORG_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1")); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java index 8b3b86b884..07edbf1379 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java @@ -18,22 +18,15 @@ */ package org.jclouds.vcloud.internal; -import java.util.Properties; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; - -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContextFactory; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.vcloud.VCloudAsyncClient; import org.jclouds.vcloud.VCloudClient; -import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -41,38 +34,32 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseVCloudClientLiveTest extends BaseVersionedServiceLiveTest { +public abstract class BaseVCloudClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + // username is too long for name constraints protected String prefix = "vcd"; protected ComputeService client; public BaseVCloudClientLiveTest() { - provider = "vcloud"; + provider = "vcloud"; } protected VCloudClient getVCloudApi() { - return VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi()); + return VCloudClient.class.cast(context.getProviderSpecificContext().getApi()); } - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - client = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides).getComputeService(); - } - - protected Properties setupRestProperties() { - return RestContextFactory.getPropertiesFromResource("/rest.properties"); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getComputeService(); } + @Override protected Module getSshModule() { return new SshjSshClientModule(); } - - @AfterGroups(groups = { "live" }) - protected void cleanup() throws InterruptedException, ExecutionException, TimeoutException { - client.getContext().close(); - } } \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java index 3679fc808c..e4f2cb3725 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.vcloud.internal; -import static org.jclouds.rest.RestContextFactory.contextSpec; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -30,8 +29,9 @@ import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.vcloud.endpoints.VCloudLogin; import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders; @@ -50,7 +50,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "VCloudLoginAsyncClientTest") -public class VCloudLoginAsyncClientTest extends RestClientTest { +public class VCloudLoginAsyncClientTest extends BaseAsyncClientTest { public void testLogin() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudLoginAsyncClient.class.getMethod("login"); @@ -97,10 +97,10 @@ public class VCloudLoginAsyncClientTest extends RestClientTest createContextSpec() { - return contextSpec("test", "http://localhost:8080/login", "1", "", "", "identity", "credential", - VCloudLoginClient.class, VCloudLoginAsyncClient.class); + protected ProviderMetadata createProviderMetadata() { + return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudLoginClient.class, + VCloudLoginAsyncClient.class, "http://localhost:8080/login"); } + } diff --git a/apis/walrus/pom.xml b/apis/walrus/pom.xml index 96d9236c1b..553d6bc2ce 100644 --- a/apis/walrus/pom.xml +++ b/apis/walrus/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.walrus.blobstore.WalrusTestInitializer http://ecc.eucalyptus.com:8773/services/Walrus 2006-03-01 @@ -101,7 +100,6 @@ - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} ${test.walrus.endpoint} diff --git a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java index 50ac5ace9d..d69db928ac 100644 --- a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java +++ b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java @@ -18,43 +18,69 @@ */ package org.jclouds.walrus; +import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH; +import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; + +import java.util.Properties; + import org.jclouds.apis.ApiMetadata; import org.jclouds.s3.S3ApiMetadata; +import org.jclouds.s3.S3AsyncClient; +import org.jclouds.s3.S3Client; +import org.jclouds.s3.blobstore.S3BlobStoreContext; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for the Walrus (S3 clone) api. + * Implementation of {@link ApiMetadata} for the Walrus S3 API * * @author Adrian Cole */ -public class WalrusApiMetadata extends S3ApiMetadata { +public class WalrusApiMetadata extends S3ApiMetadata, WalrusApiMetadata> { + private static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } public WalrusApiMetadata() { - this(builder().fromApiMetadata(new S3ApiMetadata()) - .id("walrus") - .name("Walrus (S3 clone) API")); + this(builder()); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected WalrusApiMetadata(ConcreteBuilder builder) { + protected WalrusApiMetadata(Builder builder) { super(builder); } + + protected static Properties defaultProperties() { + Properties properties = S3ApiMetadata.defaultProperties(); + properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus"); + properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false"); + return properties; + } - private static class ConcreteBuilder extends S3ApiMetadataBuilder { - + public static class Builder extends S3ApiMetadata.Builder, WalrusApiMetadata> { + protected Builder(){ + super(S3Client.class, S3AsyncClient.class); + id("walrus") + .name("Walrus (S3 clone) API") + .version("Walrus-1.6") + .defaultProperties(WalrusApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(WalrusContextBuilder.class)); + } + @Override public WalrusApiMetadata build() { return new WalrusApiMetadata(this); } + + @Override + public Builder fromApiMetadata(WalrusApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } - private static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } -} \ No newline at end of file +} diff --git a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusContextBuilder.java b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusContextBuilder.java index b7f6f33438..c6d3d1902f 100644 --- a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusContextBuilder.java +++ b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusContextBuilder.java @@ -19,9 +19,12 @@ package org.jclouds.walrus; import java.util.List; -import java.util.Properties; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.s3.S3AsyncClient; +import org.jclouds.s3.S3Client; import org.jclouds.s3.S3ContextBuilder; +import org.jclouds.s3.blobstore.S3BlobStoreContext; import org.jclouds.walrus.config.WalrusRestClientModule; import com.google.inject.Module; @@ -31,10 +34,19 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class WalrusContextBuilder extends S3ContextBuilder { +public class WalrusContextBuilder extends + S3ContextBuilder, WalrusApiMetadata> { + public WalrusContextBuilder() { + this(new WalrusApiMetadata()); + } - public WalrusContextBuilder(Properties props) { - super(props); + public WalrusContextBuilder( + ProviderMetadata, WalrusApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public WalrusContextBuilder(WalrusApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusPropertiesBuilder.java b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusPropertiesBuilder.java deleted file mode 100644 index 6d61163568..0000000000 --- a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.walrus; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH; -import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; - -import java.util.Properties; - -import org.jclouds.s3.S3PropertiesBuilder; - -/** - * Builds properties used in Walrus Clients - * - * @author Adrian Cole - */ -public class WalrusPropertiesBuilder extends S3PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "Walrus-1.6"); - properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus"); - properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false"); - return properties; - } - - public WalrusPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusApiMetadataTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusApiMetadataTest.java index ca5dbf801d..abc4963b0a 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusApiMetadataTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.walrus; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "WalrusApiMetadataTest") -public class WalrusApiMetadataTest extends BaseApiMetadataTest { +public class WalrusApiMetadataTest extends BaseBlobStoreApiMetadataTest { public WalrusApiMetadataTest() { - super(new WalrusApiMetadata(), ApiType.BLOBSTORE); + super(new WalrusApiMetadata()); } } diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusAsyncClientTestDisabled.java b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusAsyncClientTestDisabled.java deleted file mode 100644 index dee43e8856..0000000000 --- a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusAsyncClientTestDisabled.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.walrus; - -import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.jclouds.s3.S3AsyncClient; -import org.jclouds.s3.S3AsyncClientTest; -import org.testng.annotations.Test; - -import com.google.inject.TypeLiteral; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(enabled = false, groups = "unit", testName = "WalrusAsyncClientTest") -public class WalrusAsyncClientTestDisabled extends S3AsyncClientTest { - - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } - - public WalrusAsyncClientTestDisabled() { - this.provider = "walrus"; - this.url = "commondatastorage.googleapis.com"; - } - - // TODO parameterize this test so that it can pass -} diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobIntegrationLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobIntegrationLiveTest.java index a132e97528..e6b26491e2 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobIntegrationLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobIntegrationLiveTest.java @@ -29,7 +29,11 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "WalrusBlobIntegrationLiveTest") public class WalrusBlobIntegrationLiveTest extends S3BlobIntegrationLiveTest { - + + public WalrusBlobIntegrationLiveTest() { + provider = "walrus"; + } + // no support for content encoding @Override protected void checkContentEncoding(Blob blob, String contentEncoding) { diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobLiveTest.java index 2432d2369d..509f47bf0d 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobLiveTest.java @@ -26,5 +26,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "WalrusBlobLiveTest") public class WalrusBlobLiveTest extends S3BlobLiveTest { - + + public WalrusBlobLiveTest() { + provider = "walrus"; + } + } diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobMapIntegrationLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobMapIntegrationLiveTest.java index 66b6816a93..c9b2fbd35d 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobMapIntegrationLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobMapIntegrationLiveTest.java @@ -26,5 +26,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "WalrusBlobMapIntegrationLiveTest") public class WalrusBlobMapIntegrationLiveTest extends S3BlobMapIntegrationLiveTest { - + + public WalrusBlobMapIntegrationLiveTest() { + provider = "walrus"; + } + } diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobSignerLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobSignerLiveTest.java index 3d72a567a9..0254aef9dd 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobSignerLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusBlobSignerLiveTest.java @@ -27,5 +27,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "WalrusBlobSignerLiveTest") public class WalrusBlobSignerLiveTest extends S3BlobSignerLiveTest { - + + public WalrusBlobSignerLiveTest() { + provider = "walrus"; + } + } diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusContainerIntegrationLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusContainerIntegrationLiveTest.java index 7864cc5e31..145e9d30ff 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusContainerIntegrationLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusContainerIntegrationLiveTest.java @@ -26,5 +26,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "WalrusContainerIntegrationLiveTest") public class WalrusContainerIntegrationLiveTest extends S3ContainerIntegrationLiveTest { - + + public WalrusContainerIntegrationLiveTest() { + provider = "walrus"; + } + } diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusContainerLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusContainerLiveTest.java index 1ae6e69527..cca820a115 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusContainerLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusContainerLiveTest.java @@ -26,5 +26,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "WalrusContainerLiveTest") public class WalrusContainerLiveTest extends S3ContainerLiveTest { - + + public WalrusContainerLiveTest() { + provider = "walrus"; + } + } diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusInputStreamMapIntegrationLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusInputStreamMapIntegrationLiveTest.java index d182ed87c5..6e447ac4ad 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusInputStreamMapIntegrationLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusInputStreamMapIntegrationLiveTest.java @@ -26,5 +26,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "WalrusInputStreamMapIntegrationLiveTest") public class WalrusInputStreamMapIntegrationLiveTest extends S3InputStreamMapIntegrationLiveTest { - + + public WalrusInputStreamMapIntegrationLiveTest() { + provider = "walrus"; + } + } diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusServiceIntegrationLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusServiceIntegrationLiveTest.java index c1cb853d59..b502fd6e6e 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusServiceIntegrationLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusServiceIntegrationLiveTest.java @@ -26,5 +26,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "WalrusServiceIntegrationLiveTest") public class WalrusServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest { - + + public WalrusServiceIntegrationLiveTest() { + provider = "walrus"; + } + } diff --git a/archetypes/rest-client-archetype/src/main/resources/archetype-resources/src/test/java/__providerName__AsyncClientTest.java b/archetypes/rest-client-archetype/src/main/resources/archetype-resources/src/test/java/__providerName__AsyncClientTest.java index b367b4a8f1..5097e7caa9 100644 --- a/archetypes/rest-client-archetype/src/main/resources/archetype-resources/src/test/java/__providerName__AsyncClientTest.java +++ b/archetypes/rest-client-archetype/src/main/resources/archetype-resources/src/test/java/__providerName__AsyncClientTest.java @@ -32,7 +32,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnStringIf2xx; -import org.jclouds.rest.RestClientTest; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; @@ -52,7 +52,7 @@ import com.google.inject.TypeLiteral; * @author ${author} */ @Test(groups = "unit", testName = "${lcaseProviderName}.${providerName}AsyncClientTest") -public class ${providerName}AsyncClientTest extends RestClientTest<${providerName}AsyncClient> { +public class ${providerName}AsyncClientTest extends BaseAsyncClientTest<${providerName}AsyncClient> { public void testList() throws SecurityException, NoSuchMethodException, IOException { diff --git a/blobstore/pom.xml b/blobstore/pom.xml index 7a3ebe5522..892e18495a 100644 --- a/blobstore/pom.xml +++ b/blobstore/pom.xml @@ -38,10 +38,6 @@ http://jclouds.googlecode.com/svn/trunk/blobstore - - org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer - - ${project.groupId} @@ -77,7 +73,6 @@ **/*IntegrationTest.java - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} diff --git a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java index cf2897988b..1a7427e43d 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java @@ -43,7 +43,7 @@ public interface AsyncBlobStore { /** * @see BlobStore#getContext */ - BlobStoreContext getContext(); + BlobStoreContext getContext(); /** * @see BlobStore#blobBuilder diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index b9fa416c25..89a9b4359a 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -44,7 +44,7 @@ public interface BlobStore { /** * @return a reference to the context that created this BlobStore. */ - BlobStoreContext getContext(); + BlobStoreContext getContext(); /** * diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java new file mode 100644 index 0000000000..77d55ce334 --- /dev/null +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java @@ -0,0 +1,20 @@ +package org.jclouds.blobstore; + +import org.jclouds.apis.ApiMetadata; + +import com.google.common.annotations.Beta; + +/** + * + * @author Adrian Cole + * @since 1.5 + */ +@Beta +public interface BlobStoreApiMetadata, M extends BlobStoreApiMetadata> + extends ApiMetadata { + + public static interface Builder, M extends BlobStoreApiMetadata> + extends ApiMetadata.Builder { + } + +} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java index 04df9d598a..81f42afbe1 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java @@ -18,10 +18,12 @@ */ package org.jclouds.blobstore; +import java.io.Closeable; + import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.options.ListContainerOptions; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.BackedByRestContext; import org.jclouds.rest.Utils; import com.google.inject.ImplementedBy; @@ -34,7 +36,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(BlobStoreContextImpl.class) -public interface BlobStoreContext { +public interface BlobStoreContext extends Closeable, BackedByRestContext { /** * * Generates signed requests for blobs. useful in other tools such as backup utilities. @@ -105,12 +107,6 @@ public interface BlobStoreContext { */ ConsistencyModel getConsistencyModel(); - /** - * - * @return a context you can use to the access provider or vendor specific api underlying this - * context. - */ - RestContext getProviderSpecificContext(); Utils getUtils(); @@ -123,5 +119,6 @@ public interface BlobStoreContext { * closes threads and resources related to this connection. * */ + @Override void close(); } \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java index fe507350b9..e38fad5fa1 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java @@ -17,32 +17,47 @@ * under the License. */ package org.jclouds.blobstore; +import static com.google.common.base.Preconditions.checkArgument; -import java.util.Properties; +import java.util.NoSuchElementException; -import org.jclouds.rest.RestContextBuilder; - -import com.google.inject.Module; +import org.jclouds.blobstore.config.TransientBlobStore; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.ContextBuilder; /** * @author Adrian Cole */ -public abstract class BlobStoreContextBuilder extends RestContextBuilder { - - @Override - public BlobStoreContextBuilder withModules(Iterable modules) { - return (BlobStoreContextBuilder) super.withModules(modules); +public abstract class BlobStoreContextBuilder, M extends BlobStoreApiMetadata> + extends ContextBuilder { + + /** + * looks up a provider or api with the given id + * + * @param providerOrApi + * id of the provider or api + * @return means to build a context to that provider + * @throws NoSuchElementException + * if the id was not configured. + * @throws IllegalArgumentException + * if the api or provider isn't assignable from BlobStoreContext + */ + public static BlobStoreContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { + ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); + checkArgument(builder instanceof BlobStoreContextBuilder, + "type of providerOrApi[%s] is not BlobStoreContextBuilder: %s", providerOrApi, builder); + return BlobStoreContextBuilder.class.cast(builder); + } + + public static ContextBuilder, TransientApiMetadata> forTests() { + return ContextBuilder.newBuilder(new TransientApiMetadata()); } - public BlobStoreContextBuilder(Class syncClientType, Class asyncClientType) { - this(syncClientType, asyncClientType, new Properties()); + public BlobStoreContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); } - public BlobStoreContextBuilder(Class syncClientType, Class asyncClientType, Properties properties) { - super(syncClientType, asyncClientType, properties); - } - - public BlobStoreContext buildBlobStoreContext() { - return buildInjector().getInstance(BlobStoreContext.class); + public BlobStoreContextBuilder(M apiMetadata) { + super(apiMetadata); } } \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java index b217065484..9c32b49d99 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java @@ -18,124 +18,114 @@ */ package org.jclouds.blobstore; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; -import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; - +import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.Providers; +import org.jclouds.rest.internal.ContextBuilder; +import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** - * Helper class to instantiate {@code BlobStoreContext} instances. * + * @see ContextBuilder + * @see BlobStoreContextBuilder * @author Adrian Cole */ +@Deprecated public class BlobStoreContextFactory { - private final RestContextFactory contextFactory; - /** - * Initializes with the default properties built-in to jclouds. This is - * typically stored in the classpath resource {@code rest.properties} - * - * @see RestContextFactory#getPropertiesFromResource + * for porting old code to {@link ContextBuilder} */ public BlobStoreContextFactory() { - this(new RestContextFactory()); } /** - * Finds definitions in the specified properties. + * for porting old code to {@link ContextBuilder} */ public BlobStoreContextFactory(Properties properties) { - this(new RestContextFactory(properties)); } /** + * @see #createContext(String, String,String, Iterable, Properties) + */ + public BlobStoreContext createContext(String providerOrApi, String identity, String credential) { + return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); + } + + /** + * @see #createContext(String, String, String, Iterable, Properties) + */ + public BlobStoreContext createContext(String providerOrApi, Properties overrides) { + return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); + } + + /** + * @see #createContext(String, String,String, Iterable, Properties) + */ + public BlobStoreContext createContext(String providerOrApi, Iterable wiring, + Properties overrides) { + return createContext(providerOrApi, null, null, wiring, overrides); + } + + /** + * @see #createContext(String, String,String, Iterable, Properties) + */ + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Properties overrides) { + return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); + } + + /** + * @see createContext(String, String,String, Iterable, Properties) + */ + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Iterable wiring) { + return createContext(providerOrApi, identity, credential, wiring, new Properties()); + } + + /** + * for porting old code to {@link ContextBuilder} * - * Uses the supplied RestContextFactory to create {@link BlobStoreContext}s + * @param providerOrApi + * @param identity + * nullable, if credentials are present in the overrides + * @param credential + * nullable, if credentials are present in the overrides + * @param wiring + * Configuration you'd like to pass to the context. Ex. + * ImmutableSet.of(new ExecutorServiceModule(myexecutor)) + * @param overrides + * properties to override defaults with. + * @return initialized context ready for use */ - public BlobStoreContextFactory(RestContextFactory restContextFactory) { - this.contextFactory = restContextFactory; - } - - public static BlobStoreContext buildContextUnwrappingExceptions(BlobStoreContextBuilder builder) { + @SuppressWarnings("unchecked") + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Iterable wiring, Properties overrides) { + ContextBuilder builder = null; try { - return builder.buildBlobStoreContext(); - } catch (Exception e) { - return propagateAuthorizationOrOriginalException(e); + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = BlobStoreContextBuilder.newBuilder(pm); + } catch (NoSuchElementException e) { + builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); + } + builder.modules(Iterable.class.cast(wiring)); + builder.overrides(overrides); + if (identity != null) + builder.credentials(identity, credential); + Object context = builder.build(); + if (context instanceof BlobStoreContext) { + return BlobStoreContext.class.cast(context); + } else { + throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " + + context.getClass().getSimpleName()); } - } - - /** - * @see RestContextFactory#createContextBuilder(String, String, String) - */ - public BlobStoreContext createContext(String provider, String identity, String credential) { - BlobStoreContextBuilder builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder( - provider, identity, credential)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, Properties) - */ - public BlobStoreContext createContext(String provider, Properties overrides) { - BlobStoreContextBuilder builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder( - provider, overrides)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, Iterable) - */ - public BlobStoreContext createContext(String provider, Iterable modules, Properties overrides) { - BlobStoreContextBuilder builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder( - provider, modules, overrides)); - return buildContextUnwrappingExceptions(builder); } - /** - * @see RestContextFactory#createContextBuilder(String, String,String, - * Iterable) - */ - public BlobStoreContext createContext(String provider, @Nullable String identity, @Nullable String credential, - Iterable modules) { - BlobStoreContextBuilder builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder( - provider, identity, credential, modules)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, String,String, - * Iterable, Properties) - */ - public BlobStoreContext createContext(String provider, @Nullable String identity, @Nullable String credential, - Iterable modules, Properties overrides) { - BlobStoreContextBuilder builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder( - provider, identity, credential, modules, overrides)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec) - */ - public BlobStoreContext createContext(RestContextSpec contextSpec) { - BlobStoreContextBuilder builder = BlobStoreContextBuilder.class.cast(createContextBuilder(contextSpec)); - return buildContextUnwrappingExceptions(builder); - - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec, Properties) - */ - public BlobStoreContext createContext(RestContextSpec contextSpec, Properties overrides) { - BlobStoreContextBuilder builder = BlobStoreContextBuilder.class.cast(createContextBuilder(contextSpec, - overrides)); - return buildContextUnwrappingExceptions(builder); - } -} \ No newline at end of file +} diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java index 815114d2eb..fbd1465eb7 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java @@ -18,50 +18,68 @@ */ package org.jclouds.blobstore; +import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; +import static org.jclouds.Constants.PROPERTY_USER_THREADS; + import java.net.URI; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.blobstore.config.TransientBlobStore; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; + +import com.google.common.collect.ImmutableMap; +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for jclouds in-memory (Transient) API * * @author Adrian Cole */ -public class TransientApiMetadata extends BaseApiMetadata { +public class TransientApiMetadata extends + BaseBlobStoreApiMetadata, TransientApiMetadata> { - public TransientApiMetadata() { - this(builder() - .id("transient") - .type(ApiType.BLOBSTORE) - .name("in-memory (Transient) API") - .identityName("Unused") - .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide"))); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected TransientApiMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromApiMetadata(this)); + } + + public TransientApiMetadata() { + super(builder()); + } + + protected TransientApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + public static class Builder extends + BaseBlobStoreApiMetadata.Builder, TransientApiMetadata> { + + protected Builder() { + id("transient") + .name("in-memory (Transient) API") + .javaApi(TransientBlobStore.class, AsyncBlobStore.class) + .contextBuilder(TypeToken.of(TransientBlobStoreContextBuilder.class)) + .identityName("Unused") + .defaultEndpoint("http://localhost") + .defaultIdentity(System.getProperty("user.name")) + .defaultCredential("bar") + .version("1") + .defaultProperties( + BaseBlobStoreApiMetadata.Builder.defaultPropertiesAnd(ImmutableMap.of(PROPERTY_USER_THREADS, "0", + PROPERTY_IO_WORKER_THREADS, "0"))) + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")); + } @Override public TransientApiMetadata build() { return new TransientApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java index 81ef2f5dfd..44fdce6afa 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java @@ -128,7 +128,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore { protected final Factory blobFactory; @Inject - protected TransientAsyncBlobStore(BlobStoreContext context, DateService dateService, Crypto crypto, + protected TransientAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, DateService dateService, Crypto crypto, ConcurrentMap> containerToBlobs, Provider uriBuilders, ConcurrentMap containerToLocation, HttpGetOptionsListToGetOptions httpGetOptionsConverter, diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java index 6c14b2909f..e85910ecad 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java @@ -19,10 +19,11 @@ package org.jclouds.blobstore; import java.util.List; -import java.util.Properties; +import org.jclouds.blobstore.config.TransientBlobStore; import org.jclouds.blobstore.config.TransientBlobStoreContextModule; import org.jclouds.blobstore.config.TransientBlobStoreModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -30,18 +31,15 @@ import com.google.inject.Module; * @author Adrian Cole */ public class TransientBlobStoreContextBuilder extends - BlobStoreContextBuilder { + BlobStoreContextBuilder, TransientApiMetadata> { - /** - * This is only to have the same syntax. - * - */ - public TransientBlobStoreContextBuilder() { - this(new Properties()); + public TransientBlobStoreContextBuilder( + ProviderMetadata, TransientApiMetadata> providerMetadata) { + super(providerMetadata); } - - public TransientBlobStoreContextBuilder(Properties props) { - super(BlobStore.class, AsyncBlobStore.class, props); + + public TransientBlobStoreContextBuilder(TransientApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStorePropertiesBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStorePropertiesBuilder.java deleted file mode 100644 index a9de3a0d85..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStorePropertiesBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.blobstore; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_IDENTITY; -import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; -import static org.jclouds.Constants.PROPERTY_USER_THREADS; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in transient blobstores - * - * @author Adrian Cole - */ -public class TransientBlobStorePropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "http://localhost"); - properties.setProperty(PROPERTY_API_VERSION, "1"); - properties.setProperty(PROPERTY_IDENTITY, System.getProperty("user.name")); - properties.setProperty(PROPERTY_USER_THREADS, "0"); - properties.setProperty(PROPERTY_IO_WORKER_THREADS, "0"); - return properties; - } - - public TransientBlobStorePropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStore.java index 2f50c12186..b088d5fa28 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStore.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.blobstore.BlobStore; import org.jclouds.concurrent.Timeout; -@Timeout(duration = 2, timeUnit = TimeUnit.MINUTES) interface TransientBlobStore extends BlobStore { +@Timeout(duration = 2, timeUnit = TimeUnit.MINUTES) +public interface TransientBlobStore extends BlobStore { } \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java index 001db97086..2381329687 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java @@ -47,6 +47,7 @@ public class TransientBlobStoreContextModule extends AbstractModule { static final ConcurrentHashMap> map = new ConcurrentHashMap>(); static final ConcurrentHashMap containerToLocation = new ConcurrentHashMap(); + @SuppressWarnings("rawtypes") @Override protected void configure() { bind(new TypeLiteral() { diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java index ef1b3f455b..f698a7b6ca 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java @@ -53,14 +53,14 @@ import com.google.common.util.concurrent.ListenableFuture; */ public abstract class BaseAsyncBlobStore implements AsyncBlobStore { - protected final BlobStoreContext context; + protected final BlobStoreContext context; protected final BlobUtils blobUtils; protected final ExecutorService service; protected final Supplier defaultLocation; protected final Supplier> locations; @Inject - protected BaseAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + protected BaseAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations) { this.context = checkNotNull(context, "context"); @@ -71,7 +71,7 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore { } @Override - public BlobStoreContext getContext() { + public BlobStoreContext getContext() { return context; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java index dc344cf454..8b2d980452 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java @@ -47,13 +47,13 @@ import com.google.common.base.Supplier; */ public abstract class BaseBlobStore implements BlobStore { - protected final BlobStoreContext context; + protected final BlobStoreContext context; protected final BlobUtils blobUtils; protected final Supplier defaultLocation; protected final Supplier> locations; @Inject - protected BaseBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected BaseBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations) { this.context = checkNotNull(context, "context"); this.blobUtils = checkNotNull(blobUtils, "blobUtils"); @@ -62,7 +62,7 @@ public abstract class BaseBlobStore implements BlobStore { } @Override - public BlobStoreContext getContext() { + public BlobStoreContext getContext() { return context; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java new file mode 100644 index 0000000000..d89c1f0d8e --- /dev/null +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java @@ -0,0 +1,65 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.blobstore.internal; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.blobstore.BlobStoreApiMetadata; +import org.jclouds.blobstore.BlobStoreContext; + +import com.google.common.annotations.Beta; +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; + +/** + * + * @author Adrian Cole + * @since 1.5 + */ +@Beta +public abstract class BaseBlobStoreApiMetadata, M extends BlobStoreApiMetadata> + extends BaseApiMetadata implements BlobStoreApiMetadata { + + public static class Builder, M extends BlobStoreApiMetadata> + extends BaseApiMetadata.Builder implements BlobStoreApiMetadata.Builder { + public Builder() { + type(ApiType.BLOBSTORE); + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("rawtypes") + protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { + return new TypeToken>() { + private static final long serialVersionUID = 1L; + }.where(new TypeParameter() { + }, clientToken).where(new TypeParameter() { + }, asyncClientToken); + } + + } + + + protected BaseBlobStoreApiMetadata(BaseBlobStoreApiMetadata.Builder builder) { + super(builder); + } + +} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java index 85289899db..6c8abad039 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java @@ -38,7 +38,7 @@ import org.jclouds.rest.Utils; * @author Adrian Cole */ @Singleton -public class BlobStoreContextImpl implements BlobStoreContext { +public class BlobStoreContextImpl implements BlobStoreContext { private final BlobMap.Factory blobMapFactory; private final InputStreamMap.Factory inputStreamMapFactory; private final AsyncBlobStore ablobStore; @@ -100,10 +100,9 @@ public class BlobStoreContextImpl implements BlobStoreContext { return ablobStore; } - @SuppressWarnings("unchecked") @Override public RestContext getProviderSpecificContext() { - return (RestContext) providerSpecificContext; + return providerSpecificContext; } @Override diff --git a/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java b/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java index 93866c3512..994960d254 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java @@ -27,7 +27,7 @@ import java.util.regex.Pattern; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; @@ -38,11 +38,11 @@ import org.jclouds.functions.ExceptionToValueOrPropagate; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpUtils; -import org.jclouds.rest.Providers; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import com.google.common.collect.ImmutableMultimap; +import com.google.common.reflect.TypeToken; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -159,7 +159,8 @@ public class BlobStoreUtils { } } + @Deprecated public static Iterable getSupportedProviders() { - return Providers.getSupportedProvidersOfType(BlobStoreContextBuilder.class); + return org.jclouds.rest.Providers.getSupportedProvidersOfType(TypeToken.of(BlobStoreContext.class)); } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java b/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java index 0d8c8bd571..3422312966 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java @@ -47,7 +47,7 @@ public class BlobStoresTest { public void testListAllForUnknownContainerFromTransientBlobStoreEagerly() throws Exception { ListContainerOptions containerOptions = ListContainerOptions.NONE; ListAllOptions listAllOptions = ListAllOptions.Builder.eager(true); - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummyid", "dummykey"); + BlobStoreContext context = blobStoreContext(); try { BlobStore blobStore = context.getBlobStore(); BlobStores.listAll(blobStore, "wrongcontainer", containerOptions, listAllOptions); @@ -62,7 +62,7 @@ public class BlobStoresTest { @Test(expectedExceptions = { ContainerNotFoundException.class }) public void testListAllForUnknownContainerFromTransientBlobStore() throws Exception { ListContainerOptions options = ListContainerOptions.NONE; - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummyid", "dummykey"); + BlobStoreContext context = blobStoreContext(); try { BlobStore blobStore = context.getBlobStore(); Iterable iterable = BlobStores.listAll(blobStore, "wrongcontainer", options); @@ -72,6 +72,10 @@ public class BlobStoresTest { } } + protected BlobStoreContext blobStoreContext() { + return BlobStoreContextBuilder.forTests().build(); + } + @Test public void testListAllFromTransientBlobStore() throws Exception { runListAllFromTransientBlobStore(false); @@ -86,7 +90,7 @@ public class BlobStoresTest { final int numTimesToIterate = 2; final int NUM_BLOBS = 31; ListContainerOptions containerOptions = ListContainerOptions.Builder.maxResults(10); - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummyid", "dummykey"); + BlobStoreContext context = blobStoreContext(); BlobStore blobStore = null; try { blobStore = context.getBlobStore(); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/TransientApiMetadataTest.java b/blobstore/src/test/java/org/jclouds/blobstore/TransientApiMetadataTest.java index 98fa8767fa..a10abe188e 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/TransientApiMetadataTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/TransientApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.blobstore; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "TransientApiMetadataTest") -public class TransientApiMetadataTest extends BaseApiMetadataTest { +public class TransientApiMetadataTest extends BaseBlobStoreApiMetadataTest { public TransientApiMetadataTest() { - super(new TransientApiMetadata(), ApiType.BLOBSTORE); + super(new TransientApiMetadata()); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java b/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java index 73c5a43ebc..f3edf1a509 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java @@ -21,16 +21,14 @@ package org.jclouds.blobstore; import static org.testng.Assert.assertEquals; import java.io.IOException; -import java.util.Properties; import javax.inject.Provider; +import org.jclouds.apis.ApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobBuilder; import org.jclouds.http.HttpRequest; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -44,14 +42,14 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "TransientBlobRequestSignerTest") -public class TransientBlobRequestSignerTest extends RestClientTest { +public class TransientBlobRequestSignerTest extends BaseAsyncClientTest { private BlobRequestSigner signer; private Provider blobFactory; - private final String endPoint = "http://localhost:8080"; + private final String endpoint = new TransientApiMetadata().getDefaultEndpoint().get(); private final String containerName = "container"; private final String blobName = "blob"; - private final String fullUrl = String.format("%s/%s/%s", endPoint, containerName, blobName); + private final String fullUrl = String.format("%s/%s/%s", endpoint, containerName, blobName); public void testSignGetBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { @@ -123,17 +121,15 @@ public class TransientBlobRequestSignerTest extends RestClientTest createContextSpec() { - Properties properties = new Properties(); - properties.setProperty("transient.endpoint", endPoint); - return new RestContextFactory().createContextSpec("transient", "identity", "credential", properties); - } - @Override protected TypeLiteral> createTypeLiteral() { return new TypeLiteral>() { }; } + @Override + public ApiMetadata createApiMetadata() { + return new TransientApiMetadata(); + } + } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java index f3fc0584dd..4b0be65a8d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java @@ -28,10 +28,10 @@ import java.net.URI; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.MediaType; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.http.HttpRequest; -import org.jclouds.rest.RestContextFactory; import org.jclouds.util.Strings2; import org.testng.annotations.Test; @@ -47,8 +47,7 @@ public class BindBlobToMultipartFormTest { public static final Blob TEST_BLOB; static { - blobProvider = new RestContextFactory().createContextBuilder("transient", "identity", "credential") - .buildInjector().getInstance(Blob.Factory.class); + blobProvider = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class); StringBuilder builder = new StringBuilder("--"); addData(BOUNDARY, "hello", builder); builder.append("--").append(BOUNDARY).append("--").append("\r\n"); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java index 515c2c972d..5f5e4c798c 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java @@ -25,9 +25,9 @@ import java.net.URI; import javax.ws.rs.HttpMethod; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.http.HttpRequest; -import org.jclouds.rest.RestContextFactory; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -47,8 +47,8 @@ public class BindUserMetadataToHeadersWithPrefixTest { BindUserMetadataToHeadersWithPrefix binder = new BindUserMetadataToHeadersWithPrefix( new BindMapToHeadersWithPrefix("prefix:")); - Blob blob = new RestContextFactory().createContextBuilder("transient", "identity", "credential").buildInjector() - .getInstance(Blob.Factory.class).create(null); + Blob blob = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class).create(null); + blob.getMetadata().setUserMetadata(ImmutableMap.of("imageName", "foo", "serverId", "2")); assertEquals( diff --git a/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java b/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java index 0fa90822fb..551ff1147d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java @@ -22,9 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.File; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; -import org.jclouds.rest.RestContextFactory; import org.testng.annotations.Test; /** @@ -34,8 +34,8 @@ import org.testng.annotations.Test; @Test(groups = "unit") public class BlobNameTest { BlobName fn = new BlobName(); - private static final Factory BLOB_FACTORY = new RestContextFactory() - .createContextBuilder("transient", "identity", "credential").buildInjector().getInstance(Blob.Factory.class); + + private static final Factory BLOB_FACTORY = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class); @Test public void testCorrect() throws SecurityException, NoSuchMethodException { diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobIntegrationTest.java index ba82ddb569..2fab14048d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobIntegrationTest.java @@ -28,5 +28,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "integration" }) public class TransientBlobIntegrationTest extends BaseBlobIntegrationTest { - + public TransientBlobIntegrationTest() { + provider = "transient"; + } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobMapIntegrationTest.java index e5ffe56df6..6823869aa4 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobMapIntegrationTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; @Test(groups = { "integration", "live" }) public class TransientBlobMapIntegrationTest extends BaseBlobMapIntegrationTest { - + public TransientBlobMapIntegrationTest() { + provider = "transient"; + } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java index 2a6fdc0123..5ab15a7137 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java @@ -43,7 +43,10 @@ import com.google.common.collect.ImmutableMap; */ @Test(groups = { "integration", "live" }) public class TransientContainerIntegrationTest extends BaseContainerIntegrationTest { - + public TransientContainerIntegrationTest() { + provider = "transient"; + } + @Test(groups = { "integration", "live" }) public void testNotWithDetails() throws InterruptedException { diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientInputStreamMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientInputStreamMapIntegrationTest.java index 44c655f921..ed298f9cc1 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientInputStreamMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientInputStreamMapIntegrationTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "integration", "live" }) public class TransientInputStreamMapIntegrationTest extends BaseInputStreamMapIntegrationTest { - + public TransientInputStreamMapIntegrationTest() { + provider = "transient"; + } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientServiceIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientServiceIntegrationTest.java index bfb32bf0d5..5f0ea0c1ce 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientServiceIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientServiceIntegrationTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "integration", "live" }) public class TransientServiceIntegrationTest extends BaseServiceIntegrationTest { - + public TransientServiceIntegrationTest() { + provider = "transient"; + } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java index 6b90d4d4fe..e9aac1bc3a 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java @@ -91,7 +91,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { private byte[] oneHundredOneConstitutionsMD5; private static long oneHundredOneConstitutionsLength; - @BeforeClass(groups = { "integration", "live" }) + @BeforeClass(groups = { "integration", "live" }, dependsOnMethods = "setupContext") @Override public void setUpResourcesOnThisThread(ITestContext testContext) throws Exception { super.setUpResourcesOnThisThread(testContext); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java index a4780a7e87..e5667e2325 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java @@ -265,11 +265,13 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< return 100; } - protected BlobMap createMap(BlobStoreContext context, String bucket) { + @Override + protected BlobMap createMap(BlobStoreContext context, String bucket) { return createMap(context, bucket, maxResults(maxResultsForTestListings())); } - - protected BlobMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { + + @Override + protected BlobMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { return context.createBlobMap(bucket, options); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java index 58dc9bfb55..c57d41ed55 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.blobstore.integration.internal; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Throwables.propagateIfPossible; import static org.jclouds.blobstore.util.BlobStoreUtils.getContentAsStringOrNullAndClose; import static org.testng.Assert.assertEquals; @@ -44,6 +43,7 @@ import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.rest.internal.BaseContextLiveTest; import org.testng.ITestContext; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -58,7 +58,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import com.google.inject.Module; -public class BaseBlobStoreIntegrationTest { +public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest>{ protected static final String LOCAL_ENCODING = System.getProperty("file.encoding"); protected static final String XML_STRING_FORMAT = " "; protected static final String TEST_STRING = String.format(XML_STRING_FORMAT, "apple"); @@ -75,7 +75,6 @@ public class BaseBlobStoreIntegrationTest { public static long INCONSISTENCY_WINDOW = 10000; protected static volatile AtomicInteger containerIndex = new AtomicInteger(0); - protected volatile BlobStoreContext context; protected static volatile int containerCount = Integer.parseInt(System.getProperty("test.blobstore.container-count", "10")); public static final String CONTAINER_PREFIX = System.getProperty("user.name") + "-blobstore"; @@ -89,17 +88,14 @@ public class BaseBlobStoreIntegrationTest { */ @BeforeSuite public void setUpResourcesForAllThreads(ITestContext testContext) throws Exception { - // TODO: close this context - createContainersSharedByAllThreads(getCloudResources(testContext), testContext); + setupContext(); + createContainersSharedByAllThreads(context, testContext); + context.close(); + context = null; } - - @SuppressWarnings("unchecked") - private BlobStoreContext getCloudResources(ITestContext testContext) throws ClassNotFoundException, - InstantiationException, IllegalAccessException, Exception { - String initializerClass = checkNotNull(System.getProperty("test.initializer"), "test.initializer"); - Class clazz = (Class) Class.forName(initializerClass); - BaseTestInitializer initializer = clazz.newInstance(); - return initializer.init(createHttpModule(), testContext); + + protected Iterable setupModules() { + return ImmutableSet. of(getLoggingModule(), createHttpModule()); } protected ExecutorService exec; @@ -110,24 +106,24 @@ public class BaseBlobStoreIntegrationTest { * want to have a different implementation of context.getBlobStore(). For example, one class may * want non-blocking i/o and another class google appengine. */ - @BeforeClass(groups = { "integration", "live" }) + @BeforeClass(groups = { "integration", "live" }, dependsOnMethods = "setupContext") public void setUpResourcesOnThisThread(ITestContext testContext) throws Exception { - context = getCloudResources(testContext); exec = Executors.newCachedThreadPool(); } + @AfterClass(groups = { "integration", "live" }) - protected void tearDownClient() throws Exception { + @Override + protected void tearDownContext() { if (exec != null) { - exec.shutdown(); - exec.awaitTermination(60, TimeUnit.SECONDS); + exec.shutdownNow(); } context.close(); } private static volatile boolean initialized = false; - protected void createContainersSharedByAllThreads(BlobStoreContext context, ITestContext testContext) + protected void createContainersSharedByAllThreads(BlobStoreContext context, ITestContext testContext) throws Exception { while (!initialized) { synchronized (BaseBlobStoreIntegrationTest.class) { @@ -160,7 +156,7 @@ public class BaseBlobStoreIntegrationTest { } } - private static void deleteContainerOrWarnIfUnable(BlobStoreContext context, String containerName) { + private static void deleteContainerOrWarnIfUnable(BlobStoreContext context, String containerName) { try { context.getBlobStore().deleteContainer(containerName); } catch (Throwable ex) { @@ -175,7 +171,7 @@ public class BaseBlobStoreIntegrationTest { /** * Tries to delete all containers, runs up to two times */ - protected static void deleteEverything(final BlobStoreContext context) throws Exception { + protected static void deleteEverything(final BlobStoreContext context) throws Exception { try { for (int i = 0; i < 2; i++) { Iterable testContainers = Iterables.filter(context.getBlobStore().list(), @@ -204,7 +200,7 @@ public class BaseBlobStoreIntegrationTest { * Due to eventual consistency, container commands may not return correctly immediately. Hence, * we will try up to the inconsistency window to see if the assertion completes. */ - protected static void assertConsistencyAware(BlobStoreContext context, Runnable assertion) + protected static void assertConsistencyAware(BlobStoreContext context, Runnable assertion) throws InterruptedException { if (context.getConsistencyModel() == ConsistencyModel.STRICT) { assertion.run(); @@ -230,7 +226,7 @@ public class BaseBlobStoreIntegrationTest { assertConsistencyAware(context, assertion); } - protected static void createContainerAndEnsureEmpty(BlobStoreContext context, final String containerName) + protected static void createContainerAndEnsureEmpty(BlobStoreContext context, final String containerName) throws InterruptedException { context.getBlobStore().createContainerInLocation(null, containerName); if (context.getConsistencyModel() == ConsistencyModel.EVENTUAL) diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java index 085b0d7fc9..a92952c6e0 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java @@ -330,11 +330,11 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati return 100; } - protected InputStreamMap createMap(BlobStoreContext context, String bucket) { + protected InputStreamMap createMap(BlobStoreContext context, String bucket) { return createMap(context, bucket, maxResults(maxResultsForTestListings())); } - protected InputStreamMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { + protected InputStreamMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { return context.createInputStreamMap(bucket, options); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java index 6e59bd2a58..5d0e089ab1 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java @@ -97,9 +97,9 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration } } - protected abstract Map createMap(BlobStoreContext context, String containerName); + protected abstract Map createMap(BlobStoreContext context, String containerName); - protected abstract Map createMap(BlobStoreContext context, String containerName, + protected abstract Map createMap(BlobStoreContext context, String containerName, ListContainerOptions options); @Test(groups = { "integration", "live" }) diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseTestInitializer.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseTestInitializer.java deleted file mode 100644 index ecfb4167c4..0000000000 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseTestInitializer.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.blobstore.integration.internal; - -import java.io.IOException; -import java.util.Properties; - -import org.jclouds.Constants; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.testng.ITestContext; - -import com.google.inject.Module; - -public abstract class BaseTestInitializer { - - protected String provider = "transient"; - - public BlobStoreContext init(Module configurationModule, ITestContext testContext) throws Exception { - String endpoint = System.getProperty("test." + provider + ".endpoint"); - String app = System.getProperty("test.app"); - String identity = System.getProperty("test." + provider + ".identity"); - String credential = System.getProperty("test." + provider + ".credential"); - String apiVersion = System.getProperty("test." + provider + ".api-version"); - String buildVersion = System.getProperty("test." + provider + ".build-version"); - if (endpoint != null) - testContext.setAttribute("test." + provider + ".endpoint", endpoint); - if (app != null) - testContext.setAttribute("test.app", app); - if (identity != null) - testContext.setAttribute("test." + provider + ".identity", identity); - if (credential != null) - testContext.setAttribute("test." + provider + ".credential", credential); - if (apiVersion != null) - testContext.setAttribute("test." + provider + ".api-version", apiVersion); - if (buildVersion != null) - testContext.setAttribute("test." + provider + ".build-version", buildVersion); - if (identity != null) { - return createLiveContext(configurationModule, endpoint, apiVersion, buildVersion, app, identity, credential); - } else { - return createStubContext(); - } - } - - - /** - * To be removed in jclouds 1.4 - */ - @Deprecated - protected Properties setupProperties(String endpoint, String apiVersion, String identity, String credential) { - return setupProperties(endpoint, apiVersion, "", identity, credential); - } - - protected Properties setupProperties(String endpoint, String apiVersion, String buildVersion, String identity, String credential) { - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - if (identity != null) - overrides.setProperty(provider + ".identity", identity); - if (credential != null) - overrides.setProperty(provider + ".credential", credential); - if (endpoint != null) - overrides.setProperty(provider + ".endpoint", endpoint); - if (buildVersion != null) - overrides.setProperty(provider + ".build-version", buildVersion); - if (apiVersion != null) - overrides.setProperty(provider + ".api-version", apiVersion); - return overrides; - } - - protected BlobStoreContext createStubContext() throws IOException { - return new BlobStoreContextFactory().createContext("transient", "foo", "bar"); - } - - protected abstract BlobStoreContext createLiveContext(Module configurationModule, String url, String apiVersion, - String buildVersion, String app, String identity, String key) throws IOException; -} diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java index d88a33a21e..a109ea9317 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java @@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals; import java.util.Map; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -40,13 +40,13 @@ import com.google.inject.util.Types; @Test(groups = { "unit" }) public class BaseBlobMapTest { - BlobStoreContext context; + BlobStoreContext context; InputStreamMapImpl map; @BeforeClass void addDefaultObjectsSoThatTestsWillPass() { - context = new BlobStoreContextFactory().createContext("transient", "identity", "credential"); + context = BlobStoreContextBuilder.forTests().build(); map = (InputStreamMapImpl) context.createInputStreamMap("test"); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java new file mode 100644 index 0000000000..32a2303059 --- /dev/null +++ b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java @@ -0,0 +1,34 @@ +package org.jclouds.blobstore.internal; + +import java.util.Set; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.Apis; +import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.blobstore.BlobStoreApiMetadata; +import org.jclouds.blobstore.BlobStoreContext; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public abstract class BaseBlobStoreApiMetadataTest extends BaseApiMetadataTest { + + @SuppressWarnings("rawtypes") + public BaseBlobStoreApiMetadataTest(BlobStoreApiMetadata toTest) { + super(toTest, ApiType.BLOBSTORE); + } + + @Test + public void testContextAssignableFromBlobStoreContext() { + Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(BlobStoreContext.class))); + assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); + } + +} \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java b/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java index 0154e4c7d8..a95f01ca9c 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java @@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.options.ListContainerOptions; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -38,7 +38,7 @@ public class BiggerThanPageSizeTest { @BeforeTest void setupBlobStore() { - blobstore = new BlobStoreContextFactory().createContext("transient", "foo", "bar").getBlobStore(); + blobstore = BlobStoreContextBuilder.forTests().build().getBlobStore(); } public void test() throws IOException { diff --git a/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java b/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java index 6cfffe4899..adeb2f8f10 100644 --- a/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java +++ b/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java @@ -24,23 +24,22 @@ import java.net.URI; import javax.ws.rs.core.HttpHeaders; -import org.jclouds.PropertiesBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.io.Payloads; import org.jclouds.logging.config.NullLoggingModule; +import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.RequestSigner; -import org.jclouds.rest.RestContextBuilder; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; -import org.jclouds.rest.BaseRestClientTest.MockModule; +import org.jclouds.rest.internal.BaseRestClientTest.MockModule; +import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultimap; import com.google.inject.AbstractModule; +import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.name.Names; @@ -52,11 +51,13 @@ import com.google.inject.name.Names; // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "FormSignerTest") public class FormSignerTest { - @SuppressWarnings("unchecked") - public static final RestContextSpec DUMMY_SPEC = new RestContextSpec( - "provider", "endpoint", "apiVersion", "buildVersion", "", "identity", "credential", - IntegrationTestClient.class, IntegrationTestAsyncClient.class, PropertiesBuilder.class, - (Class) RestContextBuilder.class, ImmutableList. of(new MockModule(), new NullLoggingModule(), + public static final Injector INJECTOR = ContextBuilder + .newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, + "http://localhost")) + .credentials("identity", "credential") + .apiVersion("apiVersion") + .modules(ImmutableList. of(new MockModule(), new NullLoggingModule(), new AbstractModule() { @Override protected void configure() { @@ -65,11 +66,11 @@ public class FormSignerTest { bind(String.class).annotatedWith(TimeStamp.class).toInstance("2009-11-08T15:54:08.897Z"); } - })); + })).buildInjector(); + FormSigner filter = INJECTOR.getInstance(FormSigner.class); + @Test void testBuildCanonicalizedStringSetsVersion() { - FormSigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector().getInstance( - FormSigner.class); assertEquals( filter.filter( @@ -82,9 +83,6 @@ public class FormSignerTest { @Test void testBuildCanonicalizedString() { - FormSigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector().getInstance( - FormSigner.class); - assertEquals( filter.buildCanonicalizedString(new ImmutableMultimap.Builder().put("AWSAccessKeyId", "foo").put("Action", "DescribeImages").put("Expires", "2008-02-10T12:00:00Z").put("ImageId.1", diff --git a/common/aws/src/test/java/org/jclouds/aws/util/AWSUtilsTest.java b/common/aws/src/test/java/org/jclouds/aws/util/AWSUtilsTest.java index 220bd81f09..ed64ef6a24 100644 --- a/common/aws/src/test/java/org/jclouds/aws/util/AWSUtilsTest.java +++ b/common/aws/src/test/java/org/jclouds/aws/util/AWSUtilsTest.java @@ -32,20 +32,18 @@ import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.io.Payloads; -import org.jclouds.rest.RestContextFactory; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; -import com.google.inject.Injector; /** * Tests parsing of S3 responses * * @author Adrian Cole */ -@Test(sequential = true, groups = { "unit" }) +@Test(singleThreaded = true, groups = { "unit" }) public class AWSUtilsTest { AWSUtils utils = null; private HttpCommand command; @@ -53,9 +51,7 @@ public class AWSUtilsTest { @BeforeTest protected void setUpInjector() throws IOException { - Injector injector = RestContextFactory.createContextBuilder(FormSignerTest.DUMMY_SPEC).buildInjector(); - - utils = injector.getInstance(AWSUtils.class); + utils = FormSignerTest.INJECTOR.getInstance(AWSUtils.class); command = createMock(HttpCommand.class); expect(command.getCurrentRequest()).andReturn(createMock(HttpRequest.class)).atLeastOnce(); diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java b/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java index dbcf8dd38d..ef23a9a7d8 100644 --- a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java +++ b/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java @@ -18,39 +18,47 @@ */ package org.jclouds.azure.storage; +import java.io.Closeable; import java.util.List; -import java.util.Properties; +import org.jclouds.apis.ApiMetadata; import org.jclouds.azure.storage.config.AzureStorageRestClientModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.rest.RestContextBuilder; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.ContextBuilder; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link AzureStorageStoreContext} or {@link Injector} instances based on the most commonly - * requested arguments. + * Creates {@link AzureStorageStoreContext} or {@link Injector} instances based + * on the most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole, Andrew Newdigate * @see AzureStorageStoreContext */ -public class AzureStorageContextBuilder extends RestContextBuilder { +public class AzureStorageContextBuilder> extends + ContextBuilder { + public AzureStorageContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); + } - public AzureStorageContextBuilder(Class syncClientClass, Class asyncClientClass, - Properties properties) { - super(syncClientClass, asyncClientClass, properties); + public AzureStorageContextBuilder(M apiMetadata) { + super(apiMetadata); } @Override protected void addClientModule(List modules) { - modules.add(new AzureStorageRestClientModule(syncClientType, asyncClientType)); + modules.add(new AzureStorageRestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi())); } } diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java index dd68b2b4f6..5e3b0e16c6 100644 --- a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java +++ b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java @@ -26,21 +26,19 @@ import java.net.URI; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.HttpHeaders; -import org.jclouds.PropertiesBuilder; import org.jclouds.azure.storage.config.AzureStorageRestClientModule; import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientTest.MockModule; -import org.jclouds.rest.RestContextBuilder; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.AnonymousRestApiMetadata; +import org.jclouds.rest.internal.BaseRestClientTest.MockModule; +import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.inject.Injector; import com.google.inject.Module; @@ -58,18 +56,19 @@ public class SharedKeyLiteAuthenticationTest { @DataProvider(parallel = true) public Object[][] dataProvider() { return new Object[][] { - { new HttpRequest(HttpMethod.PUT, URI.create("http://" + ACCOUNT - + ".blob.core.windows.net/movies/MOV1.avi?comp=block&blockid=BlockId1&timeout=60")) }, - { new HttpRequest(HttpMethod.PUT, URI.create("http://" + ACCOUNT - + ".blob.core.windows.net/movies/MOV1.avi?comp=blocklist&timeout=120")) }, - { new HttpRequest(HttpMethod.GET, URI.create("http://" + ACCOUNT - + ".blob.core.windows.net/movies/MOV1.avi")) } }; + { new HttpRequest(HttpMethod.PUT, URI.create("http://" + ACCOUNT + + ".blob.core.windows.net/movies/MOV1.avi?comp=block&blockid=BlockId1&timeout=60")) }, + { new HttpRequest(HttpMethod.PUT, URI.create("http://" + ACCOUNT + + ".blob.core.windows.net/movies/MOV1.avi?comp=blocklist&timeout=120")) }, + { new HttpRequest(HttpMethod.GET, + URI.create("http://" + ACCOUNT + ".blob.core.windows.net/movies/MOV1.avi")) } }; } /** - * NOTE this test is dependent on how frequently the timestamp updates. At the time of writing, - * this was once per second. If this timestamp update interval is increased, it could make this - * test appear to hang for a long time. + * NOTE this test is dependent on how frequently the timestamp updates. At + * the time of writing, this was once per second. If this timestamp update + * interval is increased, it could make this test appear to hang for a long + * time. */ @Test(threadPoolSize = 3, dataProvider = "dataProvider", timeOut = 3000) void testIdempotent(HttpRequest request) { @@ -84,7 +83,7 @@ public class SharedKeyLiteAuthenticationTest { request = filter.filter(request); } System.out.printf("%s: %d iterations before the timestamp updated %n", Thread.currentThread().getName(), - iterations); + iterations); } @Test @@ -117,7 +116,7 @@ public class SharedKeyLiteAuthenticationTest { @Test void testAclQueryStringRelativeWithExtraJunk() { URI host = URI.create("http://" + ACCOUNT - + ".blob.core.windows.net/mycontainer?comp=list&marker=marker&maxresults=1&prefix=prefix"); + + ".blob.core.windows.net/mycontainer?comp=list&marker=marker&maxresults=1&prefix=prefix"); HttpRequest request = new HttpRequest(HttpMethod.GET, host); StringBuilder builder = new StringBuilder(); filter.appendUriPath(request, builder); @@ -132,16 +131,17 @@ public class SharedKeyLiteAuthenticationTest { */ @BeforeClass protected void createFilter() throws IOException { - injector = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector(); + injector = ContextBuilder + .newBuilder( + AnonymousRestApiMetadata + .forClientMappedToAsyncClient(IntegrationTestClient.class, IntegrationTestAsyncClient.class) + .toBuilder().build()) + .endpoint("https://${jclouds.identity}.blob.core.windows.net") + .credentials(ACCOUNT, "credential") + .modules( + ImmutableSet. of(new MockModule(), new NullLoggingModule(), + new AzureStorageRestClientModule( + IntegrationTestClient.class, IntegrationTestAsyncClient.class))).buildInjector(); filter = injector.getInstance(SharedKeyLiteAuthentication.class); } - - @SuppressWarnings("unchecked") - public static final RestContextSpec DUMMY_SPEC = new RestContextSpec( - "provider", "endpoint", "apiVersion", "buildVersion", "", "identity", "credential", IntegrationTestClient.class, - IntegrationTestAsyncClient.class, PropertiesBuilder.class, (Class) RestContextBuilder.class, ImmutableList - . of(new MockModule(), new NullLoggingModule(), - new AzureStorageRestClientModule(IntegrationTestClient.class, - IntegrationTestAsyncClient.class))); - } \ No newline at end of file diff --git a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java index aa556da34a..bcfcc5017f 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java @@ -18,16 +18,17 @@ */ package org.jclouds.openstack; -import static org.jclouds.rest.RestContextFactory.contextSpec; - import java.io.IOException; import java.lang.reflect.Method; +import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -40,7 +41,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "OpenStackAuthAsyncClientTest") -public class OpenStackAuthAsyncClientTest extends RestClientTest { +public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest { public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException { Method method = OpenStackAuthAsyncClient.class.getMethod("authenticate", String.class, String.class); @@ -71,9 +72,9 @@ public class OpenStackAuthAsyncClientTest extends RestClientTest createContextSpec() { - return contextSpec("test", "http://localhost:8080", "1.0", "", "", "identity", "credential", - OpenStackAuthClient.class, OpenStackAuthAsyncClient.class); + public ApiMetadata createApiMetadata() { + return AnonymousRestApiMetadata.forClientMappedToAsyncClient(IntegrationTestClient.class, IntegrationTestAsyncClient.class).toBuilder().defaultEndpoint( + "http://localhost:8080").version("1.0").build(); } @Override diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v1_1/internal/BaseKeystoneRestClientExpectTest.java b/common/openstack/src/test/java/org/jclouds/openstack/keystone/v1_1/internal/BaseKeystoneRestClientExpectTest.java index 9ffd22aa1d..4e162a8a2a 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v1_1/internal/BaseKeystoneRestClientExpectTest.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/keystone/v1_1/internal/BaseKeystoneRestClientExpectTest.java @@ -23,7 +23,7 @@ import java.net.URI; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import com.google.common.collect.ImmutableMultimap; import com.google.common.net.HttpHeaders; diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java b/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java index 7494229810..3da8d77a45 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.keystone.v2_0.internal; import static java.lang.String.format; -import static org.jclouds.rest.BaseRestClientExpectTest.payloadFromStringWithContentType; +import static org.jclouds.rest.internal.BaseRestClientExpectTest.payloadFromStringWithContentType; import java.io.IOException; import java.net.URI; diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java index fd3bd951d7..2876428613 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java @@ -19,11 +19,13 @@ package org.jclouds.trmk.vcloud_0_8; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceApiMetadata; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.trmk.vcloud_0_8.compute.config.TerremarkVCloudComputeServiceContextModule; import org.jclouds.trmk.vcloud_0_8.config.TerremarkVCloudRestClientModule; @@ -46,11 +48,15 @@ import com.google.inject.Module; * @author Adrian Cole * @see VCloudComputeServiceContext */ -public class TerremarkVCloudContextBuilder - extends ComputeServiceContextBuilder { +public class TerremarkVCloudContextBuilder, M extends ComputeServiceApiMetadata> + extends ComputeServiceContextBuilder { - public TerremarkVCloudContextBuilder(Class syncClientType, Class asyncClientType, Properties props) { - super(syncClientType, asyncClientType, props); + public TerremarkVCloudContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); + } + + public TerremarkVCloudContextBuilder(M apiMetadata) { + super(apiMetadata); } @Override @@ -60,6 +66,6 @@ public class TerremarkVCloudContextBuilder modules) { - modules.add(new TerremarkVCloudRestClientModule(syncClientType, asyncClientType)); + modules.add(new TerremarkVCloudRestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi())); } } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeService.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeService.java index 87107915e6..1185a977c2 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeService.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeService.java @@ -64,6 +64,7 @@ import com.google.common.base.Supplier; public class TerremarkVCloudComputeService extends BaseComputeService { private final CleanupOrphanKeys cleanupOrphanKeys; + @SuppressWarnings("rawtypes") @Inject protected TerremarkVCloudComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java index a507ac1c3c..5d13535e30 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -77,6 +77,7 @@ public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServi return VAPPSTATUS_TO_NODESTATE; } + @SuppressWarnings("rawtypes") @Override protected void configure() { super.configure(); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java new file mode 100644 index 0000000000..713450b93e --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java @@ -0,0 +1,83 @@ +package org.jclouds.trmk.vcloud_0_8.internal; + +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; +import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS; +import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; +import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; +import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; +import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA; +import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; +import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; +import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; + +/** + * Implementation of {@link ApiMetadata} for Amazon's TerremarkVCloud api. + * + *

    note

    + *

    + * This class allows overriding of types {@code S}(client) and {@code A} + * (asyncClient), so that children can add additional methods not declared here, + * such as new features from AWS. + *

    + * + * As this is a popular api, we also allow overrides for type {@code C} + * (context). This allows subtypes to add in new feature groups or extensions, + * not present in the base api. For example, you could make a subtype for + * context, that exposes admin operations. + * + * @author Adrian Cole + */ +public abstract class TerremarkVCloudApiMetadata> + extends BaseComputeServiceApiMetadata, M> { + + protected TerremarkVCloudApiMetadata(Builder builder) { + super(builder); + } + + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8"); + properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + ""); + properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, "allowInOut"); + properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NS, String.format("urn:tmrk:${%s}-${%s}", + PROPERTY_TERREMARK_EXTENSION_NAME, PROPERTY_TERREMARK_EXTENSION_VERSION)); + properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, + String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA)); + properties.setProperty("jclouds.dns_name_length_min", "1"); + properties.setProperty("jclouds.dns_name_length_max", "15"); + // terremark can sometimes block extremely long times + properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, TimeUnit.MINUTES.toMillis(20) + ""); + return properties; + } + + public static abstract class Builder> + extends BaseComputeServiceApiMetadata.Builder, M> { + + protected Builder(Class syncClient, Class asyncClient) { + id("vcloud-common") + .identityName("Email") + .credentialName("Password") + .version("0.8") + .defaultProperties(TerremarkVCloudApiMetadata.defaultProperties()) + .javaApi(syncClient, asyncClient); + } + + @Override + public Builder fromApiMetadata(M in) { + super.fromApiMetadata(in); + return this; + } + + } + +} \ No newline at end of file diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java index 2a7c953c3f..b25256d6f3 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java @@ -42,19 +42,16 @@ import java.util.concurrent.TimeoutException; import org.jclouds.cim.CIMPredicates; import org.jclouds.cim.ResourceAllocationSettingData; import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.SshException; -import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.domain.Catalog; import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem; import org.jclouds.trmk.vcloud_0_8.domain.CustomizationParameters; @@ -77,19 +74,18 @@ import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions; import org.jclouds.trmk.vcloud_0_8.predicates.TaskSuccess; import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants; import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.inject.Injector; -import com.google.inject.Module; -@Test(groups = "live" , singleThreaded = true) -public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTest { +@Test(groups = "live", singleThreaded = true) +public abstract class TerremarkClientLiveTest + extends BaseComputeServiceContextLiveTest> { protected String expectedOs = "Ubuntu Linux (64-bit)"; protected String itemName = "Ubuntu JeOS 9.10 (64-bit)"; @@ -107,7 +103,7 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe protected VDC vdc; protected String serverName; protected KeyPair key; - + public static final String PREFIX = System.getProperty("user.name") + "-terremark"; public TerremarkClientLiveTest() { @@ -117,7 +113,7 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe name.append("d"); serverName = name.toString();// "adriantest"; } - + @Test public void testKeysList() throws Exception { for (Org org : orgs) { @@ -192,9 +188,10 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe // lookup the datacenter you are deploying into vdc = connection.findVDCInOrgNamed(null, null); - + // create an options object to collect the configuration we want. - InstantiateVAppTemplateOptions instantiateOptions = createInstantiateOptions().sshKeyFingerprint(key.getFingerPrint()); + InstantiateVAppTemplateOptions instantiateOptions = createInstantiateOptions().sshKeyFingerprint( + key.getFingerPrint()); CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(null, null, itemName); @@ -205,7 +202,6 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe CustomizationParameters customizationOptions = connection.getCustomizationOptions(item.getCustomizationOptions() .getHref()); - if (customizationOptions.canCustomizePassword()) instantiateOptions.withPassword("robotsarefun"); @@ -275,8 +271,7 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe assertNotNull(key.getPrivateKey()); assertNotNull(key.getFingerPrint()); assertEquals(key.isDefault(), false); - assertEquals(key.getFingerPrint(), connection.findKeyPairInOrg(org.getHref(), key.getName()) - .getFingerPrint()); + assertEquals(key.getFingerPrint(), connection.findKeyPairInOrg(org.getHref(), key.getName()).getFingerPrint()); } protected abstract Entry getNewInternetServiceAndIpForSSH(VApp vApp); @@ -483,13 +478,11 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe } - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - - injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides).buildInjector(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + injector = context.utils().injector(); sshFactory = injector.getInstance(SshClient.Factory.class); socketTester = new RetryablePredicate(injector.getInstance(SocketOpen.class), 300, 10, TimeUnit.SECONDS);// make @@ -499,13 +492,11 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe // default internet // service timeout successTester = new RetryablePredicate(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS); - context = createContextWithProperties(setupProperties()); - connection = context.getApi(); + connection = context.getProviderSpecificContext().getApi(); orgs = listOrgs(); } - protected TerremarkVCloudClient connection; - protected RestContext context; + protected S connection; @Test public void testOrg() throws Exception { @@ -522,10 +513,11 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe @Test public void testPropertiesCanOverrideDefaultOrg() throws Exception { for (Org org : orgs) { - RestContext newContext = null; + RestContext newContext = null; try { - newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName()))); + newContext = createContext( + overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName())), + setupModules()).getProviderSpecificContext(); assertEquals(newContext.getApi().findOrgNamed(null), org); } finally { newContext.close(); @@ -556,11 +548,12 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe public void testPropertiesCanOverrideDefaultCatalog() throws Exception { for (Org org : orgs) { for (ReferenceType cat : org.getCatalogs().values()) { - RestContext newContext = null; + RestContext newContext = null; try { - newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName()))); + newContext = createContext( + overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules()) + .getProviderSpecificContext(); assertEquals(newContext.getApi().findCatalogInOrgNamed(null, null), connection.getCatalog(cat.getHref())); } finally { newContext.close(); @@ -598,12 +591,13 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe for (ReferenceType vdc : org.getVDCs().values()) { VDC response = connection.getVDC(vdc.getHref()); for (ReferenceType net : response.getAvailableNetworks().values()) { - RestContext newContext = null; + RestContext newContext = null; try { - newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(), - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName()))); + newContext = createContext( + overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules()) + .getProviderSpecificContext(); assertEquals(newContext.getApi().findNetworkInOrgVDCNamed(null, null, net.getName()), connection.getNetwork(net.getHref())); } finally { @@ -676,11 +670,12 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe public void testPropertiesCanOverrideDefaultVDC() throws Exception { for (Org org : orgs) { for (ReferenceType vdc : org.getVDCs().values()) { - RestContext newContext = null; + RestContext newContext = null; try { - newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName()))); + newContext = createContext( + overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules()) + .getProviderSpecificContext(); assertEquals(newContext.getApi().findVDCInOrgNamed(null, null), connection.getVDC(vdc.getHref())); } finally { newContext.close(); @@ -707,11 +702,12 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe public void testPropertiesCanOverrideDefaultTasksList() throws Exception { for (Org org : orgs) { for (ReferenceType tasksList : org.getTasksLists().values()) { - RestContext newContext = null; + RestContext newContext = null; try { - newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), - VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName()))); + newContext = createContext( + overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules()) + .getProviderSpecificContext(); assertEquals(newContext.getApi().findTasksListInOrgNamed(null, null), connection.getTasksList(tasksList.getHref())); } finally { @@ -740,12 +736,6 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe protected Iterable orgs; - public RestContext createContextWithProperties( - Properties overrides) { - return new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - } - @AfterGroups(groups = { "live" }) public void teardownClient() { context.close(); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java index 29374b3a84..1d16d71736 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java @@ -20,27 +20,20 @@ package org.jclouds.trmk.vcloud_0_8.compute.suppliers; import static org.testng.Assert.assertEquals; -import java.io.IOException; -import java.util.Properties; import java.util.Set; -import org.jclouds.compute.BaseVersionedServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; -import org.jclouds.lifecycle.Closer; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem; import org.jclouds.trmk.vcloud_0_8.functions.AllCatalogItemsInOrg; -import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Injector; -import com.google.inject.Module; /** * Tests behavior of {@code VAppTemplatesInOrgs} @@ -48,29 +41,26 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "VAppTemplatesInOrgsLiveTest") -public class VAppTemplatesInOrgsLiveTest extends BaseVersionedServiceLiveTest { +public class VAppTemplatesInOrgsLiveTest +extends BaseComputeServiceContextLiveTest> { + public VAppTemplatesInOrgsLiveTest() { provider = "trmk-vcloudexpress"; } private TerremarkVCloudClient tmClient; private VAppTemplatesInOrgs parser; - private Closer closer; private AllCatalogItemsInOrg allCatalogItemsInOrg; - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - - Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()),overrides).buildInjector(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + Injector injector = context.utils().injector(); tmClient = injector.getInstance(TerremarkVCloudClient.class); allCatalogItemsInOrg = injector.getInstance(AllCatalogItemsInOrg.class); parser = injector.getInstance(VAppTemplatesInOrgs.class); - closer = injector.getInstance(Closer.class); } @Test @@ -85,8 +75,4 @@ public class VAppTemplatesInOrgsLiveTest extends BaseVersionedServiceLiveTest { assert images.size() > 0; } - @AfterGroups(groups = { "live" }) - public void close() throws IOException { - closer.close(); - } } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java index b4d2a28909..f8e90f1d2c 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java @@ -18,28 +18,22 @@ */ package org.jclouds.trmk.vcloud_0_8.internal; -import java.util.Properties; -import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient.Factory; import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; -import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; +import com.google.inject.Injector; import com.google.inject.Module; /** @@ -47,7 +41,9 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseTerremarkClientLiveTest extends BaseVersionedServiceLiveTest { +public abstract class BaseTerremarkClientLiveTest + extends BaseComputeServiceContextLiveTest> { + protected String prefix = System.getProperty("user.name"); protected ComputeService client; @@ -59,31 +55,21 @@ public abstract class BaseTerremarkClientLiveTest socketTester; protected Factory sshFactory; - @SuppressWarnings("unchecked") - protected T getApi() { - return (T) client.getContext().getProviderSpecificContext().getApi(); + protected S getApi() { + return context.getProviderSpecificContext().getApi(); } - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - client = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getComputeService(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + Injector injector = context.utils().injector(); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS); - sshFactory = Guice.createInjector(getSshModule()).getInstance(Factory.class); + sshFactory = injector.getInstance(Factory.class); } - - protected Properties setupRestProperties() { - return RestContextFactory.getPropertiesFromResource("/rest.properties"); - } - + protected Module getSshModule() { return new SshjSshClientModule(); } - @AfterGroups(groups = { "live" }) - protected void cleanup() throws InterruptedException, ExecutionException, TimeoutException { - client.getContext().close(); - } } \ No newline at end of file diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java index 89a9ba2178..99e8f6862b 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.trmk.vcloud_0_8.internal; -import static org.jclouds.rest.RestContextFactory.contextSpec; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -30,8 +29,9 @@ import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.trmk.vcloud_0_8.endpoints.VCloudLogin; import org.jclouds.trmk.vcloud_0_8.functions.ParseLoginResponseFromHeaders; @@ -48,9 +48,10 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire @Test(groups = "unit", testName = "VCloudLoginAsyncClientTest") -public class TerremarkVCloudLoginAsyncClientTest extends RestClientTest { +public class TerremarkVCloudLoginAsyncClientTest extends BaseAsyncClientTest { public void testLogin() throws SecurityException, NoSuchMethodException, IOException { Method method = TerremarkVCloudLoginAsyncClient.class.getMethod("login"); @@ -97,10 +98,10 @@ public class TerremarkVCloudLoginAsyncClientTest extends RestClientTest createContextSpec() { - return contextSpec("test", "http://localhost:8080/login", "1", "", "", "identity", "credential", - TerremarkVCloudLoginClient.class, TerremarkVCloudLoginAsyncClient.class); + protected ProviderMetadata createProviderMetadata() { + return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(TerremarkVCloudLoginClient.class, + TerremarkVCloudLoginAsyncClient.class, "http://localhost:8080/login"); } + } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java index 5a5e03e7d5..c1226a3945 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.trmk.vcloud_0_8.internal; -import static org.jclouds.rest.RestContextFactory.contextSpec; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -26,8 +25,9 @@ import java.lang.reflect.Method; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.trmk.vcloud_0_8.xml.SupportedVersionsHandler; import org.testng.annotations.Test; @@ -41,7 +41,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "VCloudVersionsAsyncClientTest") -public class TerremarkVCloudVersionsAsyncClientTest extends RestClientTest { +public class TerremarkVCloudVersionsAsyncClientTest extends BaseAsyncClientTest { public void testVersions() throws SecurityException, NoSuchMethodException, IOException { Method method = TerremarkVCloudVersionsAsyncClient.class.getMethod("getSupportedVersions"); @@ -70,9 +70,9 @@ public class TerremarkVCloudVersionsAsyncClientTest extends RestClientTest createContextSpec() { - return contextSpec("test", "http://localhost:8080", "1", "", "", "identity", "credential", - TerremarkVCloudVersionsClient.class, TerremarkVCloudVersionsAsyncClient.class); + protected ProviderMetadata createProviderMetadata() { + return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(TerremarkVCloudVersionsClient.class, + TerremarkVCloudVersionsAsyncClient.class, "http://localhost:8080"); } } diff --git a/compute/src/main/java/org/jclouds/compute/ComputeService.java b/compute/src/main/java/org/jclouds/compute/ComputeService.java index 701f8f3102..1fd310b619 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeService.java @@ -54,7 +54,7 @@ public interface ComputeService { /** * @return a reference to the context that created this ComputeService. */ - ComputeServiceContext getContext(); + ComputeServiceContext getContext(); /** * Makes a new template builder for this service diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusTestInitializer.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java similarity index 63% rename from apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusTestInitializer.java rename to compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java index b9e3ca7f63..f3927be7f6 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/blobstore/WalrusTestInitializer.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java @@ -16,20 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.walrus.blobstore; +package org.jclouds.compute; -import org.jclouds.s3.blobstore.integration.S3TestInitializer; +import org.jclouds.apis.ApiMetadata; +import com.google.common.annotations.Beta; /** * * @author Adrian Cole + * @since 1.5 */ -public class WalrusTestInitializer extends S3TestInitializer { +@Beta +public interface ComputeServiceApiMetadata, M extends ComputeServiceApiMetadata> + extends ApiMetadata { - public WalrusTestInitializer() { - provider = "walrus"; + public static interface Builder, M extends ComputeServiceApiMetadata> + extends ApiMetadata.Builder { } - -} +} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java index acfa69710f..e89f428708 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java @@ -18,11 +18,12 @@ */ package org.jclouds.compute; +import java.io.Closeable; import java.util.Map; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.domain.Credentials; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.BackedByRestContext; import com.google.common.annotations.Beta; import com.google.inject.ImplementedBy; @@ -35,12 +36,10 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(ComputeServiceContextImpl.class) -public interface ComputeServiceContext { +public interface ComputeServiceContext extends Closeable, BackedByRestContext { ComputeService getComputeService(); - RestContext getProviderSpecificContext(); - /** * retrieves a list of credentials for resources created within this context, keyed on {@code id} * of the resource with a namespace prefix (ex. {@code node#}. We are testing this approach for @@ -73,5 +72,6 @@ public interface ComputeServiceContext { */ Utils utils(); + @Override void close(); } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java index 2f88d3f282..5a1c302eac 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java @@ -18,55 +18,69 @@ */ package org.jclouds.compute; -import java.util.Properties; +import static com.google.common.base.Preconditions.checkArgument; + +import java.util.NoSuchElementException; +import java.util.concurrent.ConcurrentMap; import org.jclouds.compute.config.ResolvesImages; -import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.rest.RestContextBuilder; +import org.jclouds.compute.stub.StubApiMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.ContextBuilder; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.inject.Injector; -import com.google.inject.Key; import com.google.inject.Module; -import com.google.inject.util.Types; /** * @author Adrian Cole */ -public abstract class ComputeServiceContextBuilder extends RestContextBuilder { - - public ComputeServiceContextBuilder(Class syncClientType, Class asyncClientType) { - this(syncClientType, asyncClientType, new Properties()); +public abstract class ComputeServiceContextBuilder, M extends ComputeServiceApiMetadata> extends + ContextBuilder { + + /** + * looks up a provider or api with the given id + * + * @param providerOrApi + * id of the provider or api + * @return means to build a context to that provider + * @throws NoSuchElementException + * if the id was not configured. + * @throws IllegalArgumentException + * if the api or provider isn't assignable from ComputeServiceContext + */ + public static ComputeServiceContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { + ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); + checkArgument(builder instanceof ComputeServiceContextBuilder, + "type of providerOrApi[%s] is not ComputeServiceContextBuilder: %s", providerOrApi, builder); + return ComputeServiceContextBuilder.class.cast(builder); + } + + @SuppressWarnings("rawtypes") + public static ContextBuilder, StubApiMetadata> forTests() { + return ContextBuilder.newBuilder(new StubApiMetadata()); } - public ComputeServiceContextBuilder(Class syncClientType, Class asyncClientType, - Properties properties) { - super(syncClientType, asyncClientType, properties); - + public ComputeServiceContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); } + public ComputeServiceContextBuilder(M apiMetadata) { + super(apiMetadata); + } + + protected void addImageResolutionModule() { + // do nothing; + // this is to be overridden when needed + } + @Override public Injector buildInjector() { addImageResolutionModuleIfNotPresent(); return super.buildInjector(); } - - /** - * {@inheritDoc} - */ - @Override - public ComputeServiceContextBuilder withModules(Iterable modules) { - return (ComputeServiceContextBuilder) super.withModules(modules); - } - - public ComputeServiceContext buildComputeServiceContext() { - // need the generic type information - return (ComputeServiceContext) buildInjector().getInstance( - Key.get(Types.newParameterizedType(ComputeServiceContextImpl.class, syncClientType, - asyncClientType))); - } - + protected void addImageResolutionModuleIfNotPresent() { if (!Iterables.any(modules, new Predicate() { public boolean apply(Module input) { @@ -78,8 +92,4 @@ public abstract class ComputeServiceContextBuilder extends RestContextBuil } } - protected void addImageResolutionModule() { - // do nothing; - // this is to be overridden when needed - } } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java index ab54485971..0aaa4f3b06 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java @@ -18,135 +18,114 @@ */ package org.jclouds.compute; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; -import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; - +import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.Providers; +import org.jclouds.rest.internal.ContextBuilder; +import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** - * Helper class to instantiate {@code ComputeServiceContext} instances. * + * @see ContextBuilder + * @see ComputeServiceContextBuilder * @author Adrian Cole */ +@Deprecated public class ComputeServiceContextFactory { - private final RestContextFactory contextFactory; - /** - * Initializes with the default properties built-in to jclouds. This is typically stored in the - * classpath resource {@code rest.properties} - * - * @see RestContextFactory#getPropertiesFromResource + * for porting old code to {@link ContextBuilder} */ public ComputeServiceContextFactory() { - this(new RestContextFactory()); } /** - * Finds definitions in the specified properties. + * for porting old code to {@link ContextBuilder} */ public ComputeServiceContextFactory(Properties properties) { - this(new RestContextFactory(properties)); } /** - * - * Uses the supplied RestContextFactory to create {@link ComputeServiceContext}s + * @see #createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContextFactory(RestContextFactory restContextFactory) { - this.contextFactory = restContextFactory; - } - - public static ComputeServiceContext buildContextUnwrappingExceptions( - ComputeServiceContextBuilder builder) { - try { - return builder.buildComputeServiceContext(); - } catch (Exception e) { - return propagateAuthorizationOrOriginalException(e); - } + public ComputeServiceContext createContext(String providerOrApi, String identity, String credential) { + return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** - * @see RestContextFactory#createContextBuilder(String, String, String) + * @see #createContext(String, String, String, Iterable, Properties) */ - public ComputeServiceContext createContext(String provider, String identity, String credential) { - ComputeServiceContextBuilder builder = ComputeServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, identity, credential)); - return buildContextUnwrappingExceptions(builder); + public ComputeServiceContext createContext(String providerOrApi, Properties overrides) { + return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** - * @see RestContextFactory#createContextBuilder(String, Properties) + * @see #createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String provider, Properties overrides) { - ComputeServiceContextBuilder builder = ComputeServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, overrides)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, Iterable) - */ - public ComputeServiceContext createContext(String provider, Iterable modules, Properties overrides) { - ComputeServiceContextBuilder builder = ComputeServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, modules, overrides)); - return buildContextUnwrappingExceptions(builder); - - } - - /** - * @see RestContextFactory#createContextBuilder(String, String,String, Iterable) - */ - public ComputeServiceContext createContext(String provider, @Nullable String identity, @Nullable String credential, - Iterable modules) { - ComputeServiceContextBuilder builder = ComputeServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, identity, credential, modules)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, String,String, Iterable, Properties) - */ - public ComputeServiceContext createContext(String provider, @Nullable String identity, @Nullable String credential, - Iterable modules, Properties overrides) { - ComputeServiceContextBuilder builder = ComputeServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, identity, credential, modules, overrides)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec) - */ - public ComputeServiceContext createContext(RestContextSpec contextSpec) { - ComputeServiceContextBuilder builder = ComputeServiceContextBuilder.class - .cast(createContextBuilder(contextSpec)); - return buildContextUnwrappingExceptions(builder); - - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec, Properties) - */ - public ComputeServiceContext createContext(RestContextSpec contextSpec, Properties overrides) { - ComputeServiceContextBuilder builder = ComputeServiceContextBuilder.class.cast(createContextBuilder( - contextSpec, overrides)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec, Iterable, Properties) - */ - public ComputeServiceContext createContext(RestContextSpec contextSpec, Iterable modules, + public ComputeServiceContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { - ComputeServiceContextBuilder builder = ComputeServiceContextBuilder.class.cast(createContextBuilder( - contextSpec, modules, overrides)); - return buildContextUnwrappingExceptions(builder); + return createContext(providerOrApi, null, null, wiring, overrides); } -} \ No newline at end of file + /** + * @see #createContext(String, String,String, Iterable, Properties) + */ + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Properties overrides) { + return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); + } + + /** + * @see createContext(String, String,String, Iterable, Properties) + */ + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Iterable wiring) { + return createContext(providerOrApi, identity, credential, wiring, new Properties()); + } + + /** + * for porting old code to {@link ContextBuilder} + * + * @param providerOrApi + * @param identity + * nullable, if credentials are present in the overrides + * @param credential + * nullable, if credentials are present in the overrides + * @param wiring + * Configuration you'd like to pass to the context. Ex. + * ImmutableSet.of(new ExecutorServiceModule(myexecutor)) + * @param overrides + * properties to override defaults with. + * @return initialized context ready for use + */ + @SuppressWarnings("unchecked") + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Iterable wiring, Properties overrides) { + ContextBuilder builder = null; + try { + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = ComputeServiceContextBuilder.newBuilder(pm); + } catch (NoSuchElementException e) { + builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); + } + builder.modules(Iterable.class.cast(wiring)); + builder.overrides(overrides); + if (identity != null) + builder.credentials(identity, credential); + Object context = builder.build(); + if (context instanceof ComputeServiceContext) { + return ComputeServiceContext.class.cast(context); + } else { + throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " + + context.getClass().getSimpleName()); + } + + } + +} diff --git a/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java index 8dc8600dc9..218c2d876b 100644 --- a/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java @@ -18,15 +18,11 @@ */ package org.jclouds.compute; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_IDENTITY; - import java.util.List; -import java.util.Properties; -import org.jclouds.PropertiesBuilder; +import org.jclouds.compute.ComputeServiceApiMetadata; import org.jclouds.compute.config.StandaloneComputeServiceClientModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -34,25 +30,21 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class StandaloneComputeServiceContextBuilder extends ComputeServiceContextBuilder { +public class StandaloneComputeServiceContextBuilder, M extends ComputeServiceApiMetadata> + extends ComputeServiceContextBuilder { - public StandaloneComputeServiceContextBuilder(Class driverClass, Properties props) { - super(driverClass, driverClass, props); - if (properties.size() == 0) - properties.putAll(new PropertiesBuilder().build()); - if (!properties.containsKey("jclouds.provider")) - properties.setProperty("jclouds.provider", "standalone"); - if (!properties.containsKey(PROPERTY_ENDPOINT)) - properties.setProperty(PROPERTY_ENDPOINT, "standalone"); - if (!properties.containsKey(PROPERTY_API_VERSION)) - properties.setProperty(PROPERTY_API_VERSION, "1"); - if (!properties.containsKey(PROPERTY_IDENTITY)) - properties.setProperty(PROPERTY_IDENTITY, System.getProperty("user.name")); + public StandaloneComputeServiceContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); } - + + public StandaloneComputeServiceContextBuilder(M apiMetadata) { + super(apiMetadata); + } + @Override protected void addClientModule(List modules) { - modules.add(new StandaloneComputeServiceClientModule(syncClientType)); + modules.add(new StandaloneComputeServiceClientModule(providerMetadata.getApiMetadata() + .getApi())); } } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextSpec.java b/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextSpec.java deleted file mode 100644 index b22661071f..0000000000 --- a/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextSpec.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.compute; - -import org.jclouds.PropertiesBuilder; -import org.jclouds.rest.RestContextSpec; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -public class StandaloneComputeServiceContextSpec extends RestContextSpec { - public StandaloneComputeServiceContextSpec(String provider, String endpoint, String apiVersion, String buildVersion, - String iso3166Codes, String identity, String credential, Class driverClass, - Class> contextBuilderClass) { - this(provider, endpoint, apiVersion, buildVersion, iso3166Codes, identity, credential, driverClass, - contextBuilderClass, ImmutableSet. of()); - } - - public StandaloneComputeServiceContextSpec(String provider, String endpoint, String apiVersion, String buildVersion, - String iso3166Codes, String identity, String credential, Class driverClass, - Class> contextBuilderClass, Iterable modules) { - this(provider, endpoint, apiVersion, buildVersion, iso3166Codes, identity, credential, driverClass, - PropertiesBuilder.class, contextBuilderClass, modules); - } - - @SuppressWarnings( { "unchecked", "rawtypes" }) - public StandaloneComputeServiceContextSpec(String provider, String endpoint, String apiVersion, String buildVersion, - String iso3166Codes, String identity, String credential, Class driverClass, - Class propertiesBuilderClass, - Class> contextBuilderClass, Iterable modules) { - super(provider, endpoint, apiVersion, buildVersion, iso3166Codes, identity, credential, driverClass, driverClass, - (Class) propertiesBuilderClass, (Class) contextBuilderClass, modules); - } -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index bd4496b219..72fd556769 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -110,7 +110,7 @@ public class BaseComputeService implements ComputeService { @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - protected final ComputeServiceContext context; + protected final ComputeServiceContext context; protected final Map credentialStore; private final Supplier> images; @@ -136,7 +136,7 @@ public class BaseComputeService implements ComputeService { private final ExecutorService executor; @Inject - protected BaseComputeService(ComputeServiceContext context, Map credentialStore, + protected BaseComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, @@ -178,7 +178,7 @@ public class BaseComputeService implements ComputeService { * {@inheritDoc} */ @Override - public ComputeServiceContext getContext() { + public ComputeServiceContext getContext() { return context; } diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java new file mode 100644 index 0000000000..c5d828eac0 --- /dev/null +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java @@ -0,0 +1,63 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.compute.internal; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceApiMetadata; +import org.jclouds.compute.ComputeServiceContext; + +import com.google.common.annotations.Beta; +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; + +/** + * + * @author Adrian Cole + * @since 1.5 + */ +@Beta +public abstract class BaseComputeServiceApiMetadata, M extends ComputeServiceApiMetadata> + extends BaseApiMetadata implements ComputeServiceApiMetadata { + + public static class Builder, M extends ComputeServiceApiMetadata> + extends BaseApiMetadata.Builder implements ComputeServiceApiMetadata.Builder { + public Builder() { + type(ApiType.COMPUTE); + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("rawtypes") + protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { + return new TypeToken>() { + private static final long serialVersionUID = 1L; + }.where(new TypeParameter() { + }, clientToken).where(new TypeParameter() { + }, asyncClientToken); + } + } + + protected BaseComputeServiceApiMetadata(BaseComputeServiceApiMetadata.Builder builder) { + super(builder); + } + +} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java index 17c1a38d4d..b880525b78 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java @@ -35,7 +35,7 @@ import org.jclouds.rest.RestContext; * @author Adrian Cole */ @Singleton -public class ComputeServiceContextImpl implements ComputeServiceContext { +public class ComputeServiceContextImpl implements ComputeServiceContext { private final ComputeService computeService; private final RestContext providerSpecificContext; private final Utils utils; @@ -55,9 +55,8 @@ public class ComputeServiceContextImpl implements ComputeServiceContext { return computeService; } - @SuppressWarnings( { "unchecked", "hiding" }) @Override - public RestContext getProviderSpecificContext() { + public RestContext getProviderSpecificContext() { return (RestContext) providerSpecificContext; } diff --git a/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java b/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java index 30b6ffcc6c..c8c299c620 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java +++ b/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java @@ -19,49 +19,60 @@ package org.jclouds.compute.stub; import java.net.URI; +import java.util.concurrent.ConcurrentMap; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.compute.stub.internal.StubComputeServiceContextBuilder; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for jclouds in-memory (Stub) API * * @author Adrian Cole */ -public class StubApiMetadata extends BaseApiMetadata { - - public StubApiMetadata() { - this(builder() - .id("stub") - .type(ApiType.COMPUTE) - .name("in-memory (Stub) API") - .identityName("Unused") - .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute"))); +@SuppressWarnings("rawtypes") +public class StubApiMetadata extends BaseComputeServiceApiMetadata, StubApiMetadata> { + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected StubApiMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromApiMetadata(this)); + } + + public StubApiMetadata() { + super(builder()); + } + + protected StubApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + public static class Builder extends BaseComputeServiceApiMetadata.Builder, StubApiMetadata> { + + protected Builder(){ + id("stub") + .name("in-memory (Stub) API") + .identityName("Unused") + .defaultIdentity("stub") + .defaultCredential("stub") + .defaultEndpoint("stub") + .context(new TypeToken>(getClass()){ + private static final long serialVersionUID = 1L; + }) + .javaApi(ConcurrentMap.class, ConcurrentMap.class) + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute")) + .contextBuilder(TypeToken.of(StubComputeServiceContextBuilder.class)); + } @Override public StubApiMetadata build() { return new StubApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/stub/StubComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java similarity index 63% rename from compute/src/main/java/org/jclouds/compute/stub/StubComputeServiceContextBuilder.java rename to compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java index dcfea05ac3..843939dcb8 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/StubComputeServiceContextBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java @@ -16,14 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.compute.stub; +package org.jclouds.compute.stub.internal; import java.util.List; -import java.util.Properties; import java.util.concurrent.ConcurrentMap; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.StandaloneComputeServiceContextBuilder; +import org.jclouds.compute.stub.StubApiMetadata; import org.jclouds.compute.stub.config.StubComputeServiceContextModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -32,12 +34,18 @@ import com.google.inject.Module; * @author Adrian Cole */ @SuppressWarnings("rawtypes") -public class StubComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder { +public class StubComputeServiceContextBuilder extends + StandaloneComputeServiceContextBuilder, StubApiMetadata> { - public StubComputeServiceContextBuilder(Properties props) { - super(ConcurrentMap.class, props); + public StubComputeServiceContextBuilder( + ProviderMetadata, StubApiMetadata> providerMetadata) { + super(providerMetadata); } - + + public StubComputeServiceContextBuilder(StubApiMetadata apiMetadata) { + super(apiMetadata); + } + @Override protected void addContextModule(List modules) { modules.add(new StubComputeServiceContextModule()); diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java index d044693424..a5f0ab0035 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java @@ -34,7 +34,7 @@ import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.regex.Pattern; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; @@ -44,13 +44,13 @@ import org.jclouds.compute.domain.Volume; import org.jclouds.compute.predicates.RetryIfSocketNotYetOpen; import org.jclouds.http.HttpRequest; import org.jclouds.net.IPSocket; -import org.jclouds.rest.Providers; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statements; import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; +import com.google.common.reflect.TypeToken; /** * @@ -160,8 +160,9 @@ public class ComputeServiceUtils { }); } + @Deprecated public static Iterable getSupportedProviders() { - return Providers.getSupportedProvidersOfType(ComputeServiceContextBuilder.class); + return org.jclouds.rest.Providers.getSupportedProvidersOfType(TypeToken.of(ComputeServiceContext.class)); } public static IPSocket findReachableSocketOnNode(RetryIfSocketNotYetOpen socketTester, final NodeMetadata node, diff --git a/compute/src/test/java/org/jclouds/compute/ComputeTestUtils.java b/compute/src/test/java/org/jclouds/compute/ComputeTestUtils.java index 3b73b6ba16..8fe46dd526 100644 --- a/compute/src/test/java/org/jclouds/compute/ComputeTestUtils.java +++ b/compute/src/test/java/org/jclouds/compute/ComputeTestUtils.java @@ -23,7 +23,6 @@ import static com.google.common.collect.Iterables.get; import static org.testng.Assert.assertEquals; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.UndeclaredThrowableException; import java.net.URI; @@ -35,6 +34,7 @@ import org.jclouds.rest.HttpClient; import org.jclouds.util.Preconditions2; import com.google.common.base.Charsets; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.io.Files; @@ -45,7 +45,7 @@ import com.google.common.io.Files; */ public class ComputeTestUtils { - public static Map setupKeyPair() throws FileNotFoundException, IOException { + public static Map setupKeyPair() { String secretKeyFile; try { secretKeyFile = checkNotNull(System.getProperty("test.ssh.keyfile"), "test.ssh.keyfile"); @@ -53,16 +53,20 @@ public class ComputeTestUtils { secretKeyFile = System.getProperty("user.home") + "/.ssh/id_rsa"; } checkSecretKeyFile(secretKeyFile); - String secret = Files.toString(new File(secretKeyFile), Charsets.UTF_8); - assert secret.startsWith("-----BEGIN RSA PRIVATE KEY-----") : "invalid key:\n" + secret; - return ImmutableMap. of("private", secret, "public", Files.toString(new File(secretKeyFile - + ".pub"), Charsets.UTF_8)); + try { + String secret = Files.toString(new File(secretKeyFile), Charsets.UTF_8); + assert secret.startsWith("-----BEGIN RSA PRIVATE KEY-----") : "invalid key:\n" + secret; + return ImmutableMap. of("private", secret, "public", Files.toString(new File(secretKeyFile + + ".pub"), Charsets.UTF_8)); + } catch (IOException e) { + throw Throwables.propagate(e); + } } - public static void checkSecretKeyFile(String secretKeyFile) throws FileNotFoundException { + public static void checkSecretKeyFile(String secretKeyFile) { Preconditions2.checkNotEmpty(secretKeyFile, "System property: [test.ssh.keyfile] set to an empty string"); if (!new File(secretKeyFile).exists()) { - throw new FileNotFoundException("secretKeyFile not found at: " + secretKeyFile); + throw new IllegalStateException("secretKeyFile not found at: " + secretKeyFile); } } diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index cccd9f735f..8b42c1e2eb 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -25,7 +25,6 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.reportMatcher; import static org.testng.Assert.assertEquals; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.Serializable; import java.util.Map; @@ -38,6 +37,7 @@ import java.util.concurrent.TimeoutException; import org.easymock.IArgumentMatcher; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.crypto.Pems; import org.jclouds.domain.LoginCredentials; import org.jclouds.io.Payload; @@ -45,7 +45,6 @@ import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.RestContext; import org.jclouds.scriptbuilder.statements.login.AdminAccess; import org.jclouds.scriptbuilder.statements.login.AdminAccess.Configuration; import org.jclouds.ssh.SshClient; @@ -65,8 +64,10 @@ import com.google.inject.Module; * * @author Adrian Cole */ +@SuppressWarnings("rawtypes") @Test(groups = "live", testName="StubComputeServiceIntegrationTest") -public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTest { +public class StubComputeServiceIntegrationTest extends + BaseComputeServiceLiveTest> { private static final ExecResponse EXEC_GOOD = new ExecResponse("", "", 0); private static final ExecResponse EXEC_BAD = new ExecResponse("", "", 1); @@ -377,12 +378,6 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes }; } - @Override - protected void setupCredentials() { - identity = "stub"; - credential = "stub"; - } - protected void assertNodeZero(Set metadataSet) { // TODO: this fails so we override it. } @@ -392,12 +387,6 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes return null; } - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext, ConcurrentMap> stubContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); - } - private static class PayloadEquals implements IArgumentMatcher, Serializable { private static final long serialVersionUID = 583055160049982067L; @@ -453,7 +442,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes } @Override - protected void setupKeyPairForTest() throws FileNotFoundException, IOException { + protected void setupKeyPairForTest() { keyPair = ImmutableMap. of("public", "ssh-rsa", "private", "-----BEGIN RSA PRIVATE KEY-----"); } diff --git a/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java index 957f5ee8c1..50955a05cf 100644 --- a/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java @@ -19,7 +19,9 @@ package org.jclouds.compute; import java.util.Set; +import java.util.concurrent.ConcurrentMap; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -29,19 +31,15 @@ import com.google.common.collect.ImmutableSet; * * @author Adrian Cole */ +@SuppressWarnings("rawtypes") @Test(groups = { "integration", "live" }) -public class StubTemplateBuilderIntegrationTest extends BaseTemplateBuilderLiveTest { +public class StubTemplateBuilderIntegrationTest extends + BaseTemplateBuilderLiveTest> { public StubTemplateBuilderIntegrationTest() { provider = "stub"; } - @Override - protected void setupCredentials() { - identity = "stub"; - credential = "stub"; - } - @Override protected Set getIso3166Codes() { return ImmutableSet. of(); diff --git a/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java b/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java index 10323446fc..206d6d574c 100644 --- a/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java +++ b/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java @@ -22,13 +22,10 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.reference.ComputeServiceConstants.InitStatusProperties; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * * @author Adrian Cole @@ -36,7 +33,7 @@ import com.google.inject.Module; @Test(groups = "unit", testName = "ComputeServicePropertiesTest") public class ComputeServicePropertiesTest { public void testDefaultInitStatusProperties() { - InitStatusProperties props = new ComputeServiceContextFactory().createContext("stub", "", "").utils().injector() + InitStatusProperties props = ComputeServiceContextBuilder.forTests().buildInjector() .getInstance(InitStatusProperties.class); assertEquals(props.initStatusInitialPeriod, 500); assertEquals(props.initStatusMaxPeriod, 5000); @@ -47,8 +44,7 @@ public class ComputeServicePropertiesTest { overrides.setProperty(ComputeServiceProperties.INIT_STATUS_INITIAL_PERIOD, "501"); overrides.setProperty(ComputeServiceProperties.INIT_STATUS_MAX_PERIOD, "5001"); - InitStatusProperties props = new ComputeServiceContextFactory() - .createContext("stub", "", "", ImmutableSet. of(), overrides).utils().injector() + InitStatusProperties props = ComputeServiceContextBuilder.forTests().overrides(overrides).buildInjector() .getInstance(InitStatusProperties.class); assertEquals(props.initStatusInitialPeriod, 501); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java new file mode 100644 index 0000000000..acbe40a87f --- /dev/null +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java @@ -0,0 +1,34 @@ +package org.jclouds.compute.internal; + +import java.util.Set; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.Apis; +import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.compute.ComputeServiceApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public abstract class BaseComputeServiceApiMetadataTest extends BaseApiMetadataTest { + + @SuppressWarnings("rawtypes") + public BaseComputeServiceApiMetadataTest(ComputeServiceApiMetadata toTest) { + super(toTest, ApiType.COMPUTE); + } + + @Test + public void testContextAssignableFromComputeServiceContext() { + Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(ComputeServiceContext.class))); + assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); + } + +} \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java similarity index 55% rename from compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java rename to compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java index eca69b2d08..a9f8eb3b3d 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java @@ -16,52 +16,48 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.compute; +package org.jclouds.compute.internal; +import java.io.InputStream; import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials.Builder; -import org.jclouds.logging.LoggingModules; -import org.jclouds.logging.config.LoggingModule; -import org.jclouds.rest.BaseRestClientLiveTest; -import org.testng.annotations.BeforeClass; +import org.jclouds.io.CopyInputStreamInputSupplierMap; +import org.jclouds.rest.config.CredentialStoreModule; +import org.jclouds.rest.internal.BaseContextLiveTest; import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.common.io.InputSupplier; +import com.google.inject.Module; +import com.google.inject.util.Modules; /** - * @author Jason King + * @author Jason King, Adrian Cole */ -public abstract class BaseVersionedServiceLiveTest extends BaseRestClientLiveTest { +public abstract class BaseComputeServiceContextLiveTest> extends BaseContextLiveTest { protected String imageId; protected String loginUser; protected String authenticateSudo; protected LoginCredentials loginCredentials = LoginCredentials.builder().user("root").build(); + // isolate tests from eachother, as default credentialStore is static + protected Module credentialStoreModule = new CredentialStoreModule(new CopyInputStreamInputSupplierMap( + new ConcurrentHashMap>())); + @Override protected Properties setupProperties() { - Properties overrides= super.setupProperties(); - if (imageId != null) - overrides.setProperty(provider + ".image-id", imageId); - if (loginUser != null) - overrides.setProperty(provider + ".image.login-user", loginUser); - if (authenticateSudo != null) - overrides.setProperty(provider + ".image.authenticate-sudo", authenticateSudo); - return overrides; - } + Properties overrides = super.setupProperties(); + imageId = setIfTestSystemPropertyPresent(overrides, provider + ".image-id"); + loginUser = setIfTestSystemPropertyPresent(overrides, provider + ".image.login-user"); + authenticateSudo = setIfTestSystemPropertyPresent(overrides, provider + ".image.authenticate-sudo"); - @Override - @BeforeClass - protected void setupCredentials() { - super.setupCredentials(); - - imageId = System.getProperty("test." + provider + ".image-id"); - loginUser = System.getProperty("test." + provider + ".image.login-user"); - authenticateSudo = System.getProperty("test." + provider + ".image.authenticate-sudo"); - - if (loginUser != null){ + if (loginUser != null) { Iterable userPass = Splitter.on(':').split(loginUser); Builder loginCredentialsBuilder = LoginCredentials.builder(); loginCredentialsBuilder.user(Iterables.get(userPass, 0)); @@ -71,10 +67,15 @@ public abstract class BaseVersionedServiceLiveTest extends BaseRestClientLiveTes loginCredentialsBuilder.authenticateSudo(Boolean.valueOf(authenticateSudo)); loginCredentials = loginCredentialsBuilder.build(); } + return overrides; } - protected LoggingModule getLoggingModule() { - return LoggingModules.firstOrJDKLoggingModule(); + @Override + protected Iterable setupModules() { + return ImmutableSet. of(getLoggingModule(), credentialStoreModule, getSshModule()); + } + + protected Module getSshModule() { + return Modules.EMPTY_MODULE; } - } diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java similarity index 92% rename from compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java rename to compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index f65cbedbd9..fbde83d12d 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.compute; +package org.jclouds.compute.internal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.and; @@ -48,7 +48,6 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.URI; @@ -56,12 +55,10 @@ import java.util.Collection; import java.util.Map; import java.util.Map.Entry; import java.util.NoSuchElementException; -import java.util.Properties; import java.util.Set; import java.util.SortedSet; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -69,6 +66,12 @@ import java.util.concurrent.TimeoutException; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jclouds.compute.ComputeService; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.ComputeTestUtils; +import org.jclouds.compute.RunNodesException; +import org.jclouds.compute.RunScriptData; +import org.jclouds.compute.RunScriptOnNodesException; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.ExecResponse; @@ -84,14 +87,10 @@ import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; -import org.jclouds.io.CopyInputStreamInputSupplierMap; -import org.jclouds.logging.LoggingModules; -import org.jclouds.logging.config.LoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.config.CredentialStoreModule; import org.jclouds.scriptbuilder.domain.SaveHttpResponseTo; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.scriptbuilder.statements.java.InstallJDK; @@ -110,11 +109,9 @@ import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.common.io.InputSupplier; import com.google.common.net.InetAddresses; import com.google.common.util.concurrent.ListenableFuture; import com.google.gson.annotations.SerializedName; -import com.google.inject.Guice; import com.google.inject.Module; /** @@ -122,24 +119,21 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = { "integration", "live" }, singleThreaded = true) -public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiveTest { +public abstract class BaseComputeServiceLiveTest> extends BaseComputeServiceContextLiveTest { protected String group; protected Predicate socketTester; protected Predicate preciseSocketTester; protected SortedSet nodes; - protected ComputeServiceContext context; protected ComputeService client; protected Template template; protected Map keyPair; - // isolate tests from eachother, as default credentialStore is static - protected Module credentialStoreModule = new CredentialStoreModule( - new CopyInputStreamInputSupplierMap(new ConcurrentHashMap>())); - + @BeforeGroups(groups = { "integration", "live" }) - public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { + @Override + public void setupContext() { setServiceDefaults(); if (group == null) group = checkNotNull(provider, "provider"); @@ -147,9 +141,8 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv // one! if (group.indexOf('-') == -1) group = group + "-"; - setupCredentials(); setupKeyPairForTest(); - initializeContextAndClient(); + super.setupContext(); buildSocketTester(); } @@ -157,25 +150,13 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv } - protected void setupKeyPairForTest() throws FileNotFoundException, IOException { + protected void setupKeyPairForTest() { keyPair = ComputeTestUtils.setupKeyPair(); } - private void initializeContextAndClient() throws IOException { - if (context != null) - context.close(); - Properties props = setupProperties(); - context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet.of(getLoggingModule(), getSshModule()), props); - client = context.getComputeService(); - } - - protected LoggingModule getLoggingModule() { - return LoggingModules.firstOrJDKLoggingModule(); - } protected void buildSocketTester() { - SocketOpen socketOpen = Guice.createInjector(getSshModule()).getInstance(SocketOpen.class); + SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class); socketTester = new RetryablePredicate(socketOpen, 60, 1, TimeUnit.SECONDS); // wait a maximum of 60 seconds for port 8080 to open. long maxWait = TimeUnit.SECONDS.toMillis(60); @@ -184,19 +165,21 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv preciseSocketTester = new RetryablePredicate(socketOpen, maxWait, interval, interval, TimeUnit.MILLISECONDS); } - - abstract protected Module getSshModule(); + @Override + protected void initializeContext() { + super.initializeContext(); + client = context.getComputeService(); + } // wait up to 5 seconds for an auth exception @Test(enabled = true, expectedExceptions = AuthorizationException.class) public void testCorrectAuthException() throws Exception { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - Properties overrides = setupProperties(); - overrides.setProperty(provider + ".identity", "MOMMA"); - overrides.setProperty(provider + ".credential", "MIA"); - context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(getLoggingModule(), credentialStoreModule), overrides); + context = newBuilder() + .credentials("MOMMA", "MIA") + .modules(ImmutableSet.of(getLoggingModule(), credentialStoreModule)) + .overrides(setupProperties()).build(); context.getComputeService().listNodes(); } catch (AuthorizationException e) { throw e; @@ -295,8 +278,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv runningInGroup(group), "echo I put a bad password", wrapInInitScript(false).runAsRoot(false).overrideLoginCredentials( - LoginCredentials.builder().user(good.identity).noPrivateKey().password("romeo") - .build())); + LoginCredentials.builder().user(good.identity).noPrivateKey().password("romeo").build())); assert responses.size() == 0 : "shouldn't pass with a bad password\n" + responses; } catch (AssertionError e) { throw e; @@ -316,12 +298,12 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv assert false : node.getId() + ": " + response; } catch (TimeoutException e) { assert !future.isDone(); - response = client.runScriptOnNode(node.getId(), Statements.exec("/tmp/init-sleeper status"), wrapInInitScript(false) - .runAsRoot(false)); + response = client.runScriptOnNode(node.getId(), Statements.exec("/tmp/init-sleeper status"), + wrapInInitScript(false).runAsRoot(false)); assert !response.getOutput().trim().equals("") : node.getId() + ": " + response; future.cancel(true); - response = client.runScriptOnNode(node.getId(), Statements.exec("/tmp/init-sleeper status"), wrapInInitScript(false) - .runAsRoot(false)); + response = client.runScriptOnNode(node.getId(), Statements.exec("/tmp/init-sleeper status"), + wrapInInitScript(false).runAsRoot(false)); assert response.getOutput().trim().equals("") : node.getId() + ": " + response; try { future.get(); @@ -381,8 +363,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv } protected static Template addRunScriptToTemplate(Template template) { - template.getOptions().runScript( - Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK())); + template.getOptions().runScript(Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK())); return template; } @@ -408,7 +389,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv @Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript") public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception { - initializeContextAndClient(); + initializeContext(); Location existingLocation = Iterables.get(this.nodes, 0).getLocation(); boolean existingLocationIsAssignable = Iterables.any(client.listAssignableLocations(), @@ -439,15 +420,15 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv @Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") public void testCredentialsCache() throws Exception { - initializeContextAndClient(); + initializeContext(); for (NodeMetadata node : nodes) assert (context.getCredentialStore().get("node#" + node.getId()) != null) : "credentials for " + node.getId(); } protected Map runScriptWithCreds(final String group, OperatingSystem os, LoginCredentials creds) throws RunScriptOnNodesException { - return client.runScriptOnNodesMatching(runningInGroup(group), InstallJDK.fromOpenJDK(), overrideLoginCredentials(creds) - .nameTask("runScriptWithCreds")); + return client.runScriptOnNodesMatching(runningInGroup(group), InstallJDK.fromOpenJDK(), + overrideLoginCredentials(creds).nameTask("runScriptWithCreds")); } protected void checkNodes(Iterable nodes, String group, String taskName) throws IOException { @@ -495,9 +476,9 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv assert (metadata.getState() == NodeState.RUNNING) : metadata; // due to DHCP the addresses can actually change in-between runs. assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size(), String.format( - "[%s] didn't match: [%s]", metadata.getPrivateAddresses(), node.getPrivateAddresses().size())); + "[%s] didn't match: [%s]", metadata.getPrivateAddresses(), node.getPrivateAddresses().size())); assertEquals(metadata.getPublicAddresses().size(), node.getPublicAddresses().size(), String.format( - "[%s] didn't match: [%s]", metadata.getPublicAddresses(), node.getPublicAddresses().size())); + "[%s] didn't match: [%s]", metadata.getPublicAddresses(), node.getPublicAddresses().size())); } assertNodeZero(metadataMap.values()); } @@ -620,7 +601,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv } public ExecResponse init(NodeMetadata node, String processName, String command) { - return client.runScriptOnNode(node.getId(), "/tmp/init-" + processName + " "+command, runAsRoot(false) + return client.runScriptOnNode(node.getId(), "/tmp/init-" + processName + " " + command, runAsRoot(false) .wrapInInitScript(false)); } @@ -897,7 +878,8 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv ExecResponse hello = ssh.exec("echo hello"); assertEquals(hello.getOutput().trim(), "hello"); ExecResponse exec = ssh.exec("java -version"); - assert exec.getError().indexOf("1.7") != -1 || exec.getOutput().indexOf("1.7") != -1 : exec + "\n" + assert exec.getError().indexOf("1.7") != -1 || exec.getOutput().indexOf("1.7") != -1 : exec + + "\n" + ssh.exec("cat /tmp/" + taskName + "/" + taskName + ".sh /tmp/" + taskName + "/stdout.log /tmp/" + taskName + "/stderr.log"); } finally { @@ -911,7 +893,10 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv if (nodes != null) { testDestroyNodes(); } - context.close(); } + @Override + protected Module getSshModule() { + throw new IllegalStateException("ssh is required for this test!"); + } } diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java similarity index 86% rename from compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java rename to compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java index 8577e98068..7dc9760c6c 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.compute; +package org.jclouds.compute.internal; import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; @@ -29,9 +29,8 @@ import java.util.NoSuchElementException; import java.util.Properties; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.OsFamily; @@ -45,11 +44,7 @@ import org.jclouds.domain.LoginCredentials; import org.jclouds.io.CopyInputStreamInputSupplierMap; import org.jclouds.json.Json; import org.jclouds.json.config.GsonModule; -import org.jclouds.logging.LoggingModules; -import org.jclouds.logging.config.LoggingModule; import org.jclouds.rest.config.CredentialStoreModule; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -68,9 +63,8 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "integration,live") -public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLiveTest { - - protected ComputeServiceContext context; +public abstract class BaseTemplateBuilderLiveTest> extends + BaseComputeServiceContextLiveTest { public void testCompareSizes() throws Exception { Hardware defaultSize = context.getComputeService().templateBuilder().build().getHardware(); @@ -101,17 +95,6 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi defaultTemplate.toString()); } - @BeforeClass - public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { - setupCredentials(); - context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(getLoggingModule()), setupProperties()); - } - - protected LoggingModule getLoggingModule() { - return LoggingModules.firstOrJDKLoggingModule(); - } - @DataProvider(name = "osSupported") public Object[][] osSupported() { return convertToArray(Sets.filter(provideAllOperatingSystems(), @@ -176,7 +159,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi public void testTemplateBuilderCanUseImageId() throws Exception { Template defaultTemplate = context.getComputeService().templateBuilder().build(); context.close(); - setupClient(); + setupContext(); Template template = context.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId()) .locationId(defaultTemplate.getLocation().getId()).build(); @@ -238,13 +221,12 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi public void testTemplateBuilderWithImageIdSpecified() throws IOException { Template defaultTemplate = context.getComputeService().templateBuilder().build(); - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty("jclouds.image-id", defaultTemplate.getImage().getId()); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(getLoggingModule()), overrides); + context = createContext(overrides, setupModules()); assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString()); } finally { @@ -257,8 +239,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi Properties overrides = setupProperties(); overrides.setProperty(provider + ".image-id", defaultTemplate.getImage().getId()); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(getLoggingModule()), overrides); + context = createContext(overrides, setupModules()); assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString()); } finally { @@ -275,10 +256,10 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi protected void tryOverrideUsingPropertyKey(String propertyKey) { // isolate tests from eachother, as default credentialStore is static - Module credentialStoreModule = new CredentialStoreModule( - new CopyInputStreamInputSupplierMap(new ConcurrentHashMap>())); - - ComputeServiceContext context = null; + Module credentialStoreModule = new CredentialStoreModule(new CopyInputStreamInputSupplierMap( + new ConcurrentHashMap>())); + + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); String login = loginUser != null ? loginUser : "foo:bar"; @@ -286,8 +267,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi boolean auth = authenticateSudo != null ? Boolean.valueOf(authenticateSudo) : true; overrides.setProperty(propertyKey + ".image.authenticate-sudo", auth + ""); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(getLoggingModule(), credentialStoreModule), overrides); + context = createContext(overrides, ImmutableSet.of(credentialStoreModule)); Iterable userPass = Splitter.on(':').split(login); String user = Iterables.get(userPass, 0); @@ -295,7 +275,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi assertEquals(context.getComputeService().templateBuilder().build().getImage().getDefaultCredentials(), LoginCredentials.builder().user(user).password(pass).authenticateSudo(auth).build()); } finally { - if (context != null){ + if (context != null) { context.close(); } } @@ -307,9 +287,4 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi assertEquals(provider.getIso3166Codes(), getIso3166Codes()); } - @AfterTest - protected void cleanup() throws InterruptedException, ExecutionException, TimeoutException { - context.close(); - } - } \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java b/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java index cbc2e311f0..23ccd6f0af 100644 --- a/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java +++ b/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java @@ -19,7 +19,7 @@ package org.jclouds.compute.predicates; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.testng.annotations.Test; @@ -34,8 +34,7 @@ import com.google.common.collect.Iterables; */ @Test public class ImagePredicatesTest { - ComputeService computeService = new ComputeServiceContextFactory().createContext("stub", "foo", "bar") - .getComputeService(); + ComputeService computeService = ComputeServiceContextBuilder.forTests().build().getComputeService(); public void testImageId() { Image first = Iterables.get(computeService.listImages(), 0); diff --git a/compute/src/test/java/org/jclouds/compute/stub/StubApiMetadataTest.java b/compute/src/test/java/org/jclouds/compute/stub/StubApiMetadataTest.java index 64690551e6..ffab600fba 100644 --- a/compute/src/test/java/org/jclouds/compute/stub/StubApiMetadataTest.java +++ b/compute/src/test/java/org/jclouds/compute/stub/StubApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.compute.stub; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "StubApiMetadataTest") -public class StubApiMetadataTest extends BaseApiMetadataTest { +public class StubApiMetadataTest extends BaseComputeServiceApiMetadataTest { public StubApiMetadataTest() { - super(new StubApiMetadata(), ApiType.COMPUTE); + super(new StubApiMetadata()); } } diff --git a/core/src/main/java/org/jclouds/apis/ApiMetadata.java b/core/src/main/java/org/jclouds/apis/ApiMetadata.java index 2f00ada5f6..f81e3040a5 100644 --- a/core/src/main/java/org/jclouds/apis/ApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/ApiMetadata.java @@ -18,13 +18,17 @@ */ package org.jclouds.apis; - +import java.io.Closeable; import java.net.URI; +import java.util.Properties; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.rest.internal.ContextBuilder; import com.google.common.annotations.Beta; - +import com.google.common.base.Optional; +import com.google.common.reflect.TypeToken; +import com.google.common.util.concurrent.ListenableFuture; /** * The ApiMetadata interface allows jclouds to provide a plugin framework for @@ -34,86 +38,225 @@ import com.google.common.annotations.Beta; * @since 1.5 */ @Beta -public interface ApiMetadata { +public interface ApiMetadata> { - public static interface Builder> { + public static interface Builder> { /** * @see ApiMetadata#getId() */ - B id(String id); + Builder id(String id); /** * @see ApiMetadata#getName() */ - B name(String name); + Builder name(String name); /** * @see ApiMetadata#getType() */ - B type(ApiType type); + Builder type(ApiType type); + + /** + * @see ApiMetadata#getEndpointName() + */ + Builder endpointName(String endpointName); /** * @see ApiMetadata#getIdentityName() */ - B identityName(String identityName); + Builder identityName(String identityName); /** * @see ApiMetadata#getCredentialName() */ - B credentialName(@Nullable String credentialName); + Builder credentialName(@Nullable String credentialName); + + /** + * @see ApiMetadata#getVersion() + */ + Builder version(String version); + + /** + * @see ApiMetadata#getBuildVersion() + */ + Builder buildVersion(@Nullable String buildVersion); + + /** + * @see ApiMetadata#getDefaultEndpoint() + */ + Builder defaultEndpoint(@Nullable String defaultEndpoint); + + /** + * @see ApiMetadata#getDefaultIdentity() + */ + Builder defaultIdentity(@Nullable String defaultIdentity); + + /** + * @see ApiMetadata#getDefaultCredential() + */ + Builder defaultCredential(@Nullable String defaultCredential); + + /** + * @see ApiMetadata#getDefaultProperties() + */ + Builder defaultProperties(Properties defaultProperties); + + /** + * @see ApiMetadata#getApi() + * @see ApiMetadata#getAsyncApi() + */ + Builder javaApi(Class api, Class asyncApi); /** * @see ApiMetadata#getDocumentation() */ - B documentation(URI documentation); + Builder documentation(URI documentation); - ApiMetadata build(); + M build(); - B fromApiMetadata(ApiMetadata in); + Builder fromApiMetadata(M from); + + Builder context(TypeToken context); + + Builder contextBuilder(TypeToken> contextBuilder); + } /** * @see Builder */ - Builder toBuilder(); + Builder> toBuilder(); /** * - * @return the api's unique identifier + * @return the api's unique identifier (ex. vcloud, virtualbox) */ - public String getId(); + String getId(); /** * - * @return the name (display name) of the api + * @return the name (display name) of the api (ex. EC2 Base API) */ - public String getName(); + String getName(); /** * - * @return the api's type + * @return the api's type (ex. COMPUTE or MONITOR) */ - public ApiType getType(); + ApiType getType(); + /** + * + * The {@code endpointName} helps the user supply the correct data when + * prompted. + *

    + * For example, on OpenStack APIs, this could be: {@code Keystone url}
    + * For file-based apis, this could be: {@code Path of byon.yaml} + *

    + * Default: {@code "https endpoint"} + *

    + * + * @return the name (display name) of an endpoint to this api (ex. Keystone + * url, vCloud Director URL). + */ + String getEndpointName(); + /** * * @return the name (display name) of an identity on this api (ex. user, - * email, account, apikey) + * email, account, apikey, tenantId:username) */ - public String getIdentityName(); + String getIdentityName(); /** + * Note: if the api doesn't need a credential, this will return absent. * - * @return the name (display name) of a credential on this api, or null if - * there is none (ex. password, secret, rsaKey) + * @return the name (display name) of a credential on this api, if it is + * required (ex. password, secret, rsaKey) */ - @Nullable - public String getCredentialName(); + Optional getCredentialName(); + + /** + * Explicitly identifies the version of an api. + */ + String getVersion(); + + /** + * Explicitly identifies the build that the server jclouds connects to is + * running. + * + * For example, for virtualbox, the api version may be {@code 4.1.8} while + * the build version is {@code 4.1.8r75467}. Or a vcloud endpoint may be api + * version {@code 1.0} while the build is {@code 1.5.0.0.124312} + */ + Optional getBuildVersion(); + + /** + * Explicitly identifies the most top-level endpoint to a service provider. + * This helps differentiate two providers of the same api, or a different + * environments providing the same api. + * + *

    note

    + * + * The type of endpoint is {@code String} as we permit endpoints that require + * variable expansion. + * + * ex. + * + *
    +    * https://${jclouds.identity}.blob.core.windows.net
    +    * 
    + * + * @return the api's default endpoint, if known. + */ + Optional getDefaultEndpoint(); + + /** + * Explicitly identifies the login identity into a provider + * + * @return the login identity into a provider, if known. + */ + Optional getDefaultIdentity(); + + /** + * Explicitly sets the secret, which when combined with the identity, will + * create an authenticated subject or session + * + * @return the api's default credential, if known. + * @see #getDefaultIdentity + * @see #getCredentialName + */ + Optional getDefaultCredential(); + + /** + * Configuration Properties used when creating connections to this api + * + * @return properties used to create connections to this api + */ + Properties getDefaultProperties(); /** * * @return the url for the API documentation related to this service */ - public URI getDocumentation(); + URI getDocumentation(); + + /** + * + * @return the type of the api which blocks on all requests + */ + Class getApi(); + + /** + * + * @return the type of the api, which is the same as {@link #getApi}, except + * all methods return {@link ListenableFuture} + */ + Class
    getAsyncApi(); + + TypeToken getContext(); + + // internal use + TypeToken> getContextBuilder(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/ApiPredicates.java b/core/src/main/java/org/jclouds/apis/ApiPredicates.java index 466de17e03..45b8e5e770 100644 --- a/core/src/main/java/org/jclouds/apis/ApiPredicates.java +++ b/core/src/main/java/org/jclouds/apis/ApiPredicates.java @@ -24,6 +24,7 @@ import org.jclouds.util.Preconditions2; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.reflect.TypeToken; /** * Container for api filters (predicates). @@ -37,8 +38,8 @@ public class ApiPredicates { * * @return all available apis */ - public static Predicate all() { - return Predicates. alwaysTrue(); + public static Predicate> all() { + return Predicates.> alwaysTrue(); } /** @@ -49,14 +50,14 @@ public class ApiPredicates { * * @return the apis with the given id */ - public static Predicate id(final String id) { + public static Predicate> id(final String id) { Preconditions2.checkNotEmpty(id, "id must be defined"); - return new Predicate() { + return new Predicate>() { /** * {@inheritDoc} */ @Override - public boolean apply(ApiMetadata apiMetadata) { + public boolean apply(ApiMetadata apiMetadata) { return apiMetadata.getId().equals(id); } @@ -78,14 +79,14 @@ public class ApiPredicates { * * @return the apis with the given type */ - public static Predicate type(final ApiType type) { + public static Predicate> type(final ApiType type) { checkNotNull(type, "type must be defined"); - return new Predicate() { + return new Predicate>() { /** * {@inheritDoc} */ @Override - public boolean apply(ApiMetadata apiMetadata) { + public boolean apply(ApiMetadata apiMetadata) { return apiMetadata.getType().equals(type); } @@ -99,4 +100,61 @@ public class ApiPredicates { }; } + /** + * Returns all apis with the given type. + * + * @param type + * the type of the api to return + * + * @return the apis with the given type + */ + public static Predicate> apiAssignableFrom(final TypeToken type) { + checkNotNull(type, "type must be defined"); + return new Predicate>() { + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ApiMetadata apiMetadata) { + return type.isAssignableFrom(apiMetadata.getApi()); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "contextAssignableFrom(" + type + ")"; + } + }; + } + + /** + * Returns all apis who's contexts are assignable from the parameter + * + * @param type + * the type of the context to search for + * + * @return the apis with contexts assignable from given type + */ + public static Predicate> contextAssignableFrom(final TypeToken contextType) { + checkNotNull(contextType, "context must be defined"); + return new Predicate>() { + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ApiMetadata apiMetadata) { + return contextType.isAssignableFrom(apiMetadata.getContext().getRawType()); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "contextAssignableFrom(" + contextType + ")"; + } + }; + } } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/Apis.java b/core/src/main/java/org/jclouds/apis/Apis.java index f2d6df4e83..2629f1edc8 100644 --- a/core/src/main/java/org/jclouds/apis/Apis.java +++ b/core/src/main/java/org/jclouds/apis/Apis.java @@ -24,6 +24,9 @@ import static com.google.common.collect.Iterables.find; import java.util.NoSuchElementException; import java.util.ServiceLoader; +import com.google.common.base.Function; +import com.google.common.reflect.TypeToken; + /** * The Apis class provides static methods for accessing apis. * @@ -31,14 +34,29 @@ import java.util.ServiceLoader; */ public class Apis { + public static enum IdFunction implements Function, String> { + INSTANCE; + + @Override + public String apply(ApiMetadata input) { + return input.getId(); + } + + } + + public static Function, String> idFunction() { + return IdFunction.INSTANCE; + } + /** * Returns the apis located on the classpath via * {@link java.util.ServiceLoader}. * * @return all available apis loaded from classpath via ServiceLoader */ - private static Iterable fromServiceLoader() { - return ServiceLoader.load(ApiMetadata.class); + @SuppressWarnings("unchecked") + private static Iterable> fromServiceLoader() { + return Iterable.class.cast(ServiceLoader.load(ApiMetadata.class)); } /** @@ -46,7 +64,7 @@ public class Apis { * * @return all available apis */ - public static Iterable all() { + public static Iterable> all() { return fromServiceLoader(); } @@ -61,7 +79,7 @@ public class Apis { * @throws NoSuchElementException * whenever there are no apis with the provided id */ - public static ApiMetadata withId(String id) throws NoSuchElementException { + public static ApiMetadata withId(String id) throws NoSuchElementException { return find(all(), ApiPredicates.id(id)); } @@ -71,7 +89,7 @@ public class Apis { * * @return the blobstore apis */ - public static Iterable allBlobStore() { + public static Iterable> allBlobStore() { return filter(all(), ApiPredicates.type(ApiType.BLOBSTORE)); } @@ -81,7 +99,7 @@ public class Apis { * * @return the compute service apis */ - public static Iterable allCompute() { + public static Iterable> allCompute() { return filter(all(), ApiPredicates.type(ApiType.COMPUTE)); } @@ -91,7 +109,7 @@ public class Apis { * * @return the queue service apis */ - public static Iterable allQueue() { + public static Iterable> allQueue() { return filter(all(), ApiPredicates.type(ApiType.QUEUE)); } @@ -101,7 +119,7 @@ public class Apis { * * @return the table service apis */ - public static Iterable allTable() { + public static Iterable> allTable() { return filter(all(), ApiPredicates.type(ApiType.TABLE)); } @@ -111,7 +129,7 @@ public class Apis { * * @return the load balancer service apis */ - public static Iterable allLoadBalancer() { + public static Iterable> allLoadBalancer() { return filter(all(), ApiPredicates.type(ApiType.LOADBALANCER)); } @@ -121,7 +139,7 @@ public class Apis { * * @return the load balancer service apis */ - public static Iterable allMonitor() { + public static Iterable> allMonitor() { return filter(all(), ApiPredicates.type(ApiType.MONITOR)); } @@ -133,7 +151,20 @@ public class Apis { * * @return the apis of the provided type */ - public static Iterable ofType(ApiType type) { + public static Iterable> ofType(ApiType type) { return filter(all(), ApiPredicates.type(type)); } -} + + /** + * Returns all apis who's contexts are assignable from the parameter + * + * @param type + * the type of the context to search for + * + * @return the apis with contexts assignable from given type + */ + public static Iterable> contextAssignableFrom(TypeToken type) { + return filter(all(), ApiPredicates.contextAssignableFrom(type)); + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/BaseApiMetadata.java b/core/src/main/java/org/jclouds/apis/BaseApiMetadata.java deleted file mode 100644 index c60a7272ce..0000000000 --- a/core/src/main/java/org/jclouds/apis/BaseApiMetadata.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.apis; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * The BaseApiMetadata class is an abstraction of {@link ApiMetadata} to be - * extended by those implementing ApiMetadata. - * - * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} - * to work properly. - * - * @author Jeremy Whitlock , Adrian Cole - */ -public abstract class BaseApiMetadata implements ApiMetadata { - - public static abstract class Builder> implements ApiMetadata.Builder { - protected String id; - protected String name; - protected ApiType type; - protected String identityName; - protected String credentialName; - protected URI documentation; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * {@inheritDoc} - */ - @Override - public B id(String id) { - this.id = checkNotNull(id, "id"); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public B name(String name) { - this.name = checkNotNull(name, "name"); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public B type(ApiType type) { - this.type = checkNotNull(type, "type"); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public B identityName(String identityName) { - this.identityName = checkNotNull(identityName, "identityName"); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public B credentialName(@Nullable String credentialName) { - this.credentialName = credentialName; - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public B documentation(URI documentation) { - this.documentation = checkNotNull(documentation, "documentation"); - return self(); - } - - public B fromApiMetadata(ApiMetadata in) { - return id(in.getId()).type(in.getType()).name(in.getName()).identityName(in.getIdentityName()) - .credentialName(in.getCredentialName()); - } - } - - protected final String id; - protected final String name; - protected final ApiType type; - protected final String identityName; - protected final String credentialName; - protected final URI documentation; - - protected BaseApiMetadata(Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.type = builder.type; - this.identityName = builder.identityName; - this.credentialName = builder.credentialName; - this.documentation = builder.documentation; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - // subclass equivalence is ok, since we don't know the classloader - // we'll get things from - if (o == null || !(o instanceof ApiMetadata)) - return false; - ApiMetadata that = ApiMetadata.class.cast(o); - return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) - && equal(this.getType(), that.getType()) && equal(this.getIdentityName(), that.getIdentityName()) - && equal(this.getCredentialName(), that.getCredentialName()) - && equal(this.getDocumentation(), that.getDocumentation()); - } - - @Override - public int hashCode() { - return Objects - .hashCode(getId(), getName(), getType(), getIdentityName(), getCredentialName(), getDocumentation()); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").add("id", getId()).add("name", getName()).add("type", getType()) - .add("identityName", getIdentityName()).add("credentialName", getCredentialName()) - .add("documentation", getDocumentation()); - } - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return id; - } - - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return name; - } - - /** - * {@inheritDoc} - */ - @Override - public ApiType getType() { - return type; - } - - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return identityName; - } - - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return credentialName; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getDocumentation() { - return documentation; - } - -} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java new file mode 100644 index 0000000000..8496c32620 --- /dev/null +++ b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java @@ -0,0 +1,509 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.apis.internal; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT; +import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT; +import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST; +import static org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE; +import static org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES; +import static org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; +import static org.jclouds.Constants.PROPERTY_USER_THREADS; + +import java.io.Closeable; +import java.net.URI; +import java.util.Map; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.ContextBuilder; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.base.Optional; +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; + +/** + * The BaseApiMetadata class is an abstraction of {@link ApiMetadata} to be + * extended by those implementing ApiMetadata. + * + * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} + * to work properly. + * + * @author Jeremy Whitlock , Adrian Cole + */ +public abstract class BaseApiMetadata> implements + ApiMetadata { + + public static class Builder> implements + ApiMetadata.Builder { + protected String id; + protected String name; + protected ApiType type; + protected String endpointName = "https endpoint"; + protected String identityName; + protected Optional credentialName = Optional.absent(); + protected String version = ""; + protected Optional buildVersion = Optional.of(""); + protected Optional defaultEndpoint = Optional.absent(); + protected Optional defaultIdentity = Optional.absent(); + protected Optional defaultCredential = Optional.absent(); + protected Properties defaultProperties = defaultProperties(); + protected URI documentation; + // + protected Class api; + protected Class asyncApi; + protected TypeToken context; + protected TypeToken> contextBuilder = new TypeToken>(getClass()) { + private static final long serialVersionUID = 1L; + }; + + public static Properties defaultProperties() { + Properties props = new Properties(); + // TODO: move this to ApiMetadata + props.setProperty(PROPERTY_ISO3166_CODES, ""); + props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + ""); + props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + ""); + props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + ""); + props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); + props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); + props.setProperty(PROPERTY_USER_THREADS, 0 + ""); + props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); + props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); + props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); + props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "true"); + return props; + } + + public static Properties defaultPropertiesAnd(Map overrides) { + Properties props = defaultProperties(); + props.putAll(overrides); + return props; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder id(String id) { + this.id = checkNotNull(id, "id"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder name(String name) { + this.name = checkNotNull(name, "name"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder type(ApiType type) { + this.type = checkNotNull(type, "type"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder endpointName(String endpointName) { + this.endpointName = checkNotNull(endpointName, "endpointName"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder identityName(String identityName) { + this.identityName = checkNotNull(identityName, "identityName"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder credentialName(String credentialName) { + this.credentialName = Optional.fromNullable(credentialName); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder version(String version) { + this.version = checkNotNull(version, "version"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder buildVersion(String buildVersion) { + this.buildVersion = Optional.fromNullable(buildVersion); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder defaultEndpoint(String defaultEndpoint) { + this.defaultEndpoint = Optional.fromNullable(defaultEndpoint); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder defaultIdentity(String defaultIdentity) { + this.defaultIdentity = Optional.fromNullable(defaultIdentity); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder defaultCredential(String defaultCredential) { + this.defaultCredential = Optional.fromNullable(defaultCredential); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder defaultProperties(Properties defaultProperties) { + this.defaultProperties = checkNotNull(defaultProperties, "defaultProperties"); + return this; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public Builder javaApi(Class api, Class asyncApi) { + this.api = checkNotNull(api, "api"); + this.asyncApi = checkNotNull(asyncApi, "asyncApi"); + if (context == null) + context(contextToken(TypeToken.of(checkNotNull(api, "api")), TypeToken.of(checkNotNull(asyncApi, "asyncApi")))); + return this; + } + + @SuppressWarnings("rawtypes") + protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { + return new TypeToken>() { + private static final long serialVersionUID = 1L; + }.where(new TypeParameter() { + }, clientToken).where(new TypeParameter() { + }, asyncClientToken); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder documentation(URI documentation) { + this.documentation = checkNotNull(documentation, "documentation"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder context(TypeToken context) { + this.context = checkNotNull(context, "context"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder contextBuilder(TypeToken> contextBuilder) { + this.contextBuilder = checkNotNull(contextBuilder, "contextBuilder"); + return this; + } + + public Builder fromApiMetadata(M in) { + return id(in.getId()).type(in.getType()).name(in.getName()).endpointName(in.getEndpointName()) + .identityName(in.getIdentityName()).credentialName(in.getCredentialName().orNull()) + .version(in.getVersion()).buildVersion(in.getBuildVersion().orNull()) + .defaultEndpoint(in.getDefaultEndpoint().orNull()).defaultIdentity(in.getDefaultIdentity().orNull()) + .defaultCredential(in.getDefaultCredential().orNull()).defaultProperties(in.getDefaultProperties()) + .documentation(in.getDocumentation()).javaApi(in.getApi(), in.getAsyncApi()).context(in.getContext()) + .contextBuilder(in.getContextBuilder()); + } + + @SuppressWarnings("unchecked") + @Override + public M build() { + return (M) new BaseApiMetadata(this) { + }; + } + + } + + protected final String id; + protected final String name; + protected final ApiType type; + protected final String endpointName; + protected final String identityName; + protected final Optional credentialName; + protected final String version; + protected final Optional buildVersion; + protected final Optional defaultEndpoint; + protected final Optional defaultIdentity; + protected final Optional defaultCredential; + protected final Properties defaultProperties; + protected final URI documentation; + protected final Class api; + protected final Class asyncApi; + protected final TypeToken context; + protected final TypeToken> contextBuilder; + + @SuppressWarnings("unchecked") + protected BaseApiMetadata(Builder builder) { + this(builder.id, builder.name, builder.type, builder.endpointName, builder.identityName, builder.credentialName, + builder.version, builder.buildVersion, builder.defaultEndpoint, builder.defaultIdentity, + builder.defaultCredential, builder.defaultProperties, builder.documentation, Class.class.cast(builder.api), + Class.class.cast(builder.asyncApi), TypeToken.class.cast(builder.context), TypeToken.class + .cast(builder.contextBuilder)); + } + + + public BaseApiMetadata(String id, String name, ApiType type, String endpointName, String identityName, + Optional credentialName, String version, Optional buildVersion, + Optional defaultEndpoint, Optional defaultIdentity, Optional defaultCredential, + Properties defaultProperties, URI documentation, Class api, Class asyncApi, TypeToken context, + TypeToken> contextBuilder) { + this.id = checkNotNull(id, "id"); + this.name = checkNotNull(name, "name"); + this.type = checkNotNull(type, "type"); + this.endpointName = checkNotNull(endpointName, "endpointName"); + this.identityName = checkNotNull(identityName, "identityName"); + this.credentialName = checkNotNull(credentialName, "credentialName"); + this.version = checkNotNull(version, "version"); + this.buildVersion = checkNotNull(buildVersion, "buildVersion"); + this.defaultEndpoint = checkNotNull(defaultEndpoint, "defaultEndpoint"); + this.defaultIdentity = checkNotNull(defaultIdentity, "defaultIdentity"); + this.defaultCredential = checkNotNull(defaultCredential, "defaultCredential"); + this.defaultProperties = checkNotNull(defaultProperties, "defaultProperties"); + this.documentation = checkNotNull(documentation, "documentation"); + this.api = checkNotNull(api, "api"); + this.asyncApi = checkNotNull(asyncApi, "asyncApi"); + this.context = checkNotNull(context, "context"); + this.contextBuilder = checkNotNull(contextBuilder, "contextBuilder"); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + // subclass equivalence is ok, since we don't know the classloader + // we'll get things from + if (o == null || !(o instanceof ApiMetadata)) + return false; + ApiMetadata that = ApiMetadata.class.cast(o); + return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) + && equal(this.getType(), that.getType()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId(), getName(), getType()); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return Objects.toStringHelper("").add("id", getId()).add("name", getName()).add("type", getType()) + .add("endpointName", getEndpointName()).add("identityName", getIdentityName()) + .add("credentialName", getCredentialName()).add("documentation", getDocumentation()).add("api", getApi()) + .add("asyncApi", getAsyncApi()); + } + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return id; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return name; + } + + /** + * {@inheritDoc} + */ + @Override + public ApiType getType() { + return type; + } + + /** + * {@inheritDoc} + */ + @Override + public String getEndpointName() { + return endpointName; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return identityName; + } + + /** + * {@inheritDoc} + */ + @Override + public Optional getCredentialName() { + return credentialName; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return version; + } + + /** + * {@inheritDoc} + */ + @Override + public Optional getBuildVersion() { + return buildVersion; + } + + /** + * {@inheritDoc} + */ + @Override + public Optional getDefaultEndpoint() { + return defaultEndpoint; + } + + /** + * {@inheritDoc} + */ + @Override + public Optional getDefaultIdentity() { + return defaultIdentity; + } + + /** + * {@inheritDoc} + */ + @Override + public Optional getDefaultCredential() { + return defaultCredential; + } + + /** + * {@inheritDoc} + */ + @Override + public Properties getDefaultProperties() { + return defaultProperties; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getDocumentation() { + return documentation; + } + + /** + * {@inheritDoc} + */ + @Override + public Class getApi() { + return api; + } + + /** + * {@inheritDoc} + */ + @Override + public Class getAsyncApi() { + return asyncApi; + } + + /** + * {@inheritDoc} + */ + @Override + public TypeToken getContext() { + return context; + } + + /** + * {@inheritDoc} + */ + @Override + public TypeToken> getContextBuilder() { + return contextBuilder; + } + + @SuppressWarnings("unchecked") + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata((M) this); + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/ProviderMetadata.java b/core/src/main/java/org/jclouds/providers/ProviderMetadata.java index 8542fd0c63..b4b4f25318 100644 --- a/core/src/main/java/org/jclouds/providers/ProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/ProviderMetadata.java @@ -18,195 +18,164 @@ */ package org.jclouds.providers; +import java.io.Closeable; import java.net.URI; +import java.util.Properties; import java.util.Set; import org.jclouds.apis.ApiMetadata; import org.jclouds.javax.annotation.Nullable; +import com.google.common.base.Optional; + /** * The ProviderMetadata interface allows jclouds to provide a plugin framework * for gathering cloud provider metadata. * - * @author Jeremy Whitlock + * @author Jeremy Whitlock , Adrian Cole */ -public interface ProviderMetadata { - /** - * @see ApiMetadata#BLOBSTORE_TYPE - */ - @Deprecated - public static final String BLOBSTORE_TYPE = "blobstore"; - /** - * @see ApiMetadata#COMPUTE_TYPE - */ - @Deprecated - public static final String COMPUTE_TYPE = "compute"; - /** - * @see ApiMetadata#LOADBALANCER_TYPE - */ - @Deprecated - public static final String LOADBALANCER_TYPE = "loadbalancer"; - /** - * @see ApiMetadata#TABLE_TYPE - */ - @Deprecated - public static final String TABLE_TYPE = "table"; - /** - * @see ApiMetadata#QUEUE_TYPE - */ - @Deprecated - public static final String QUEUE_TYPE = "queue"; - /** - * @see ApiMetadata#MONITOR_TYPE - */ - @Deprecated - public static final String MONITOR_TYPE = "monitor"; - +public interface ProviderMetadata> { + /** * * @author Adrian Cole * @since 1.5 */ - public static interface Builder> { + public static interface Builder> { /** * @see ProviderMetadata#getId() */ - B id(String id); + Builder id(String id); /** * @see ProviderMetadata#getName() */ - B name(String name); + Builder name(String name); /** - * @see ProviderMetadata#getApi() + * @see ProviderMetadata#getApiMetadata() */ - B api(ApiMetadata api); + Builder apiMetadata(M api); + + /** + * @see ProviderMetadata#getEndpoint() + */ + Builder endpoint(String endpoint); + + /** + * @see ProviderMetadata#getDefaultProperties() + */ + Builder defaultProperties(Properties defaultProperties); /** * @see ProviderMetadata#getConsole() */ - B console(@Nullable URI console); + Builder console(@Nullable URI console); /** * @see ProviderMetadata#getHomepage() */ - B homepage(@Nullable URI homepage); + Builder homepage(@Nullable URI homepage); /** * @see ProviderMetadata#getLinkedServices() */ - B linkedServices(Iterable linkedServices); + Builder linkedServices(Iterable linkedServices); /** * @see ProviderMetadata#getLinkedServices() */ - B linkedServices(String... linkedServices); + Builder linkedServices(String... linkedServices); /** * @see ProviderMetadata#getLinkedServices() */ - B linkedService(String linkedService); + Builder linkedService(String linkedService); /** * @see ProviderMetadata#getIso3166Code() */ - B iso3166Codes(Iterable iso3166Codes); + Builder iso3166Codes(Iterable iso3166Codes); /** * @see ProviderMetadata#getIso3166Code() */ - B iso3166Codes(String... iso3166Codes); + Builder iso3166Codes(String... iso3166Codes); /** * @see ProviderMetadata#getIso3166Code() */ - B iso3166Code(String iso3166Code); + Builder iso3166Code(String iso3166Code); - ProviderMetadata build(); + ProviderMetadata build(); + + Builder fromProviderMetadata(ProviderMetadata in); - B fromProviderMetadata(ProviderMetadata in); } /** * @see Builder * @since 1.5 */ - Builder toBuilder(); + Builder toBuilder(); /** * - * @return the provider's unique identifier + * @return the provider's unique identifier (ex. aws-ec2, trystack-nova) */ public String getId(); /** * - * @return the name (display name) of the provider + * @return the name (display name) of the provider (ex. GoGrid) */ public String getName(); - /** - * - * @see #getApi() - * @see ApiMetadata#getType - */ - @Deprecated - public String getType(); - /** * * @return the provider's api * @since 1.5 */ - public ApiMetadata getApi(); + public M getApiMetadata(); + + /** + * @see ApiMetadata#getEndpoint + * @return the url for the provider's api + */ + public String getEndpoint(); + + /** + * Configuration Properties used when creating connections to this provider. + * For example, location information, or default networking configuration. + * + * @return properties used to create connections to this provider + * @see ApiMetadata#getDefaultProperties + */ + Properties getDefaultProperties(); /** * - * @see #getApi() - * @see ApiMetadata#getIdentityName + * @return the url for the provider's console, or absent if one doesn't exist */ - @Deprecated - public String getIdentityName(); + Optional getConsole(); /** * - * @see #getApi() - * @see ApiMetadata#getCredentialName + * @return the url for the provider's homepage, or absent if unknown */ - @Deprecated - public String getCredentialName(); + Optional getHomepage(); /** * - * @see #getApi() - * @see ApiMetadata#getDocumentation + * @return ids of all known {@link ProviderMetadata providers} which have the + * same account as this. */ - @Deprecated - public URI getApiDocumentation(); - - /** - * - * @return the url for the provider's console, or null if one doesn't exist - */ - @Nullable - public URI getConsole(); - - /** - * - * @return the url for the provider's homepage - */ - public URI getHomepage(); - - /** - * - * @return all known services linked to the same account on this provider - */ - public Set getLinkedServices(); + Set getLinkedServices(); /** + * iso 3166 codes; ex. US-CA,US * * @return all known region/location ISO 3166 codes */ - public Set getIso3166Codes(); + Set getIso3166Codes(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/ProviderPredicates.java b/core/src/main/java/org/jclouds/providers/ProviderPredicates.java index f3b81950fd..079d9c9f28 100644 --- a/core/src/main/java/org/jclouds/providers/ProviderPredicates.java +++ b/core/src/main/java/org/jclouds/providers/ProviderPredicates.java @@ -18,13 +18,17 @@ */ package org.jclouds.providers; +import java.io.Closeable; + import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiPredicates; import org.jclouds.apis.ApiType; import org.jclouds.util.Preconditions2; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.reflect.TypeToken; /** * Container for provider filters (predicates). @@ -33,13 +37,38 @@ import com.google.common.base.Predicates; */ public class ProviderPredicates { + public static class ContextAssignableFrom> implements Predicate> { + private final TypeToken contextClass; + + public ContextAssignableFrom(TypeToken contextClass) { + Preconditions.checkNotNull(contextClass, "context must be defined"); + this.contextClass = contextClass; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ProviderMetadata providerMetadata) { + return ApiPredicates.contextAssignableFrom(contextClass).apply(providerMetadata.getApiMetadata()); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "contextAssignableFrom(" + contextClass + ")"; + } + } + /** * Returns all providers available to jclouds regardless of type. * * @return all available providers */ - public static Predicate all() { - return Predicates. alwaysTrue(); + public static Predicate> all() { + return Predicates.> alwaysTrue(); } /** @@ -50,14 +79,14 @@ public class ProviderPredicates { * * @return the providers with the given id */ - public static Predicate id(final String id) { + public static Predicate> id(final String id) { Preconditions2.checkNotEmpty(id, "id must be defined"); - return new Predicate() { + return new Predicate>() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { return providerMetadata.getId().equals(id); } @@ -79,15 +108,15 @@ public class ProviderPredicates { * * @return the providers with the given type */ - public static Predicate type(final ApiType type) { + public static Predicate> type(final ApiType type) { Preconditions.checkNotNull(type, "type must be defined"); - return new Predicate() { + return new Predicate>() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { - return providerMetadata.getApi().getType().equals(type); + public boolean apply(ProviderMetadata providerMetadata) { + return providerMetadata.getApiMetadata().getType().equals(type); } /** @@ -104,7 +133,7 @@ public class ProviderPredicates { * @see #type(ApiMetadata) */ @Deprecated - public static Predicate type(final String type) { + public static Predicate> type(final String type) { return type(ApiType.fromValue(type)); } @@ -117,15 +146,15 @@ public class ProviderPredicates { * * @return the providers with the given ISO 3166 code */ - public static Predicate boundedByIso3166Code(final String iso3166Code) { + public static Predicate> boundedByIso3166Code(final String iso3166Code) { Preconditions.checkNotNull(iso3166Code, "iso3166Code must not be null"); - return new Predicate() { + return new Predicate>() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { return providerContainsIso3166Code(providerMetadata, iso3166Code); } @@ -148,15 +177,16 @@ public class ProviderPredicates { * * @return the providers that have at least one ISO 3166 code in common */ - public static Predicate intersectingIso3166Code(final ProviderMetadata refProviderMetadata) { + public static Predicate> intersectingIso3166Code( + final ProviderMetadata refProviderMetadata) { Preconditions.checkNotNull(refProviderMetadata, "refProviderMetadata must not be null"); - return new Predicate() { + return new Predicate>() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { for (String refIso3166Code : refProviderMetadata.getIso3166Codes()) { // Return only if the potential provider contains the same ISO // 3166 code and the provider and @@ -191,7 +221,7 @@ public class ProviderPredicates { * * @return the result */ - private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) { + private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) { for (String availCode : providerMetadata.getIso3166Codes()) { if (iso3166Code.indexOf('-') == -1) { if (availCode.startsWith(iso3166Code + "-")) { @@ -206,22 +236,23 @@ public class ProviderPredicates { } /** - * Returns all providers with an instance of the given api. + * Returns all providers with an apimetadata assignable from the given api. * * @param apiClass * the api of the provider to return * - * @return the providers with the given api + * @return the providers with an apimetadata assignable from the given api. */ - public static Predicate apiInstanceOf(final Class apiClass) { + public static > Predicate> apiMetadataAssignableFrom( + final TypeToken apiClass) { Preconditions.checkNotNull(apiClass, "api must be defined"); - return new Predicate() { + return new Predicate>() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { - return Predicates.instanceOf(apiClass).apply(providerMetadata.getApi()); + public boolean apply(ProviderMetadata providerMetadata) { + return apiClass.isAssignableFrom(providerMetadata.getApiMetadata().getClass()); } /** @@ -229,8 +260,22 @@ public class ProviderPredicates { */ @Override public String toString() { - return "apiInstanceOf(" + apiClass + ")"; + return "apiAssignableFrom(" + apiClass + ")"; } }; } + + /** + * Returns all providers with an context assignable from the given class. + * + * @param contextClass + * the context of the provider to return + * + * @return the providers with an context assignable from the given class. + */ + public static > Predicate> contextAssignableFrom( + final TypeToken contextClass) { + return new ContextAssignableFrom(contextClass); + } + } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/Providers.java b/core/src/main/java/org/jclouds/providers/Providers.java index 5b883adc0c..32fb5844db 100644 --- a/core/src/main/java/org/jclouds/providers/Providers.java +++ b/core/src/main/java/org/jclouds/providers/Providers.java @@ -21,14 +21,17 @@ package org.jclouds.providers; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; +import java.io.Closeable; import java.util.NoSuchElementException; import java.util.ServiceLoader; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; +import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Predicates; +import com.google.common.reflect.TypeToken; /** * The Providers class provides static methods for accessing providers. @@ -37,14 +40,42 @@ import com.google.common.base.Predicates; */ public class Providers { + public static enum IdFunction implements Function, String> { + INSTANCE; + + @Override + public String apply(ProviderMetadata input) { + return input.getId(); + } + + } + + public static Function, String> idFunction() { + return IdFunction.INSTANCE; + } + + public static class ApiMetadataFunction> implements + Function, ApiMetadata> { + @Override + public ApiMetadata apply(ProviderMetadata input) { + return input.getApiMetadata(); + } + + } + + public static > Function, ApiMetadata> apiMetadataFunction() { + return new ApiMetadataFunction(); + } + /** * 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() { - return ServiceLoader.load(ProviderMetadata.class); + @SuppressWarnings("unchecked") + public static Iterable> fromServiceLoader() { + return Iterable.class.cast(ServiceLoader.load(ProviderMetadata.class)); } /** @@ -52,7 +83,7 @@ public class Providers { * * @return all available providers */ - public static Iterable all() { + public static Iterable> all() { return fromServiceLoader(); } @@ -67,7 +98,7 @@ public class Providers { * @throws NoSuchElementException * 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)); } @@ -77,7 +108,7 @@ public class Providers { * * @return the blobstore providers */ - public static Iterable allBlobStore() { + public static Iterable> allBlobStore() { return filter(all(), ProviderPredicates.type(ApiType.BLOBSTORE)); } @@ -87,7 +118,7 @@ public class Providers { * * @return the compute service providers */ - public static Iterable allCompute() { + public static Iterable> allCompute() { return filter(all(), ProviderPredicates.type(ApiType.COMPUTE)); } @@ -97,7 +128,7 @@ public class Providers { * * @return the queue service providers */ - public static Iterable allQueue() { + public static Iterable> allQueue() { return filter(all(), ProviderPredicates.type(ApiType.QUEUE)); } @@ -107,7 +138,7 @@ public class Providers { * * @return the table service providers */ - public static Iterable allTable() { + public static Iterable> allTable() { return filter(all(), ProviderPredicates.type(ApiType.TABLE)); } @@ -117,7 +148,7 @@ public class Providers { * * @return the load balancer service providers */ - public static Iterable allLoadBalancer() { + public static Iterable> allLoadBalancer() { return filter(all(), ProviderPredicates.type(ApiType.LOADBALANCER)); } @@ -129,7 +160,7 @@ public class Providers { * * @return the providers of the provided type */ - public static Iterable ofType(ApiType type) { + public static Iterable> ofType(ApiType type) { return filter(all(), ProviderPredicates.type(type)); } @@ -141,19 +172,25 @@ public class Providers { * * @return the providers of the provided api */ - public static Iterable ofApi(ApiMetadata api) { + public static Iterable> apiMetadataAssignableFrom(TypeToken api) { Preconditions.checkNotNull(api, "api must be defined"); - return filter(all(), ProviderPredicates.apiInstanceOf(api.getClass())); + return filter(all(), ProviderPredicates.apiMetadataAssignableFrom(api)); } - + /** - * @see #ofType(ApiMetadata) + * Returns the providers that are of the provided context. + * + * @param context + * the context to providers to return + * + * @return the providers of the provided context */ - @Deprecated - public static Iterable ofType(String type) { - return ofType(ApiType.fromValue(type)); + public static Iterable> contextAssignableFrom(TypeToken context) { + Preconditions.checkNotNull(context, "context must be defined"); + return filter(all(), new ProviderPredicates.ContextAssignableFrom(context)); } + /** * Returns the providers that are bound to the same location as the given ISO * 3166 code regardless of type. @@ -163,7 +200,7 @@ public class Providers { * * @return the providers bound by the given ISO 3166 code */ - public static Iterable boundedByIso3166Code(String iso3166Code) { + public static Iterable> boundedByIso3166Code(String iso3166Code) { return filter(all(), ProviderPredicates.boundedByIso3166Code(iso3166Code)); } @@ -179,19 +216,11 @@ public class Providers { * @return the providers bound by the given ISO 3166 code and of the proper * type */ - public static Iterable boundedByIso3166Code(String iso3166Code, ApiType type) { + public static Iterable> boundedByIso3166Code(String iso3166Code, ApiType type) { return filter(all(), Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), ProviderPredicates.type(type))); } - /** - * @see #boundedByIso3166Code(String iso3166Code, ApiType) - */ - @Deprecated - public static Iterable boundedByIso3166Code(String iso3166Code, String type) { - return boundedByIso3166Code(iso3166Code, ApiType.fromValue(type)); - } - /** * Returns the providers that have at least one common ISO 3166 code in * common regardless of type. @@ -201,7 +230,7 @@ public class Providers { * * @return the providers that share at least one common ISO 3166 code */ - public static Iterable collocatedWith(ProviderMetadata providerMetadata) { + public static Iterable> collocatedWith(ProviderMetadata providerMetadata) { return filter(all(), ProviderPredicates.intersectingIso3166Code(providerMetadata)); } @@ -217,17 +246,10 @@ public class Providers { * @return the providers that share at least one common ISO 3166 code and of * the given type */ - public static Iterable collocatedWith(ProviderMetadata providerMetadata, ApiType type) { + public static Iterable> collocatedWith(ProviderMetadata providerMetadata, + ApiType type) { return filter(all(), Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), ProviderPredicates.type(type))); } - /** - * @see #collocatedWith(ProviderMetadata iso3166Code, ApiType) - */ - @Deprecated - public static Iterable collocatedWith(ProviderMetadata providerMetadata, String type) { - return collocatedWith(providerMetadata, ApiType.fromValue(type)); - } - } diff --git a/core/src/main/java/org/jclouds/providers/BaseProviderMetadata.java b/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java similarity index 50% rename from core/src/main/java/org/jclouds/providers/BaseProviderMetadata.java rename to core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java index f9c5765c38..89376f9d23 100644 --- a/core/src/main/java/org/jclouds/providers/BaseProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java @@ -16,21 +16,25 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.providers; +package org.jclouds.providers.internal; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.addAll; import static com.google.common.collect.Sets.newLinkedHashSet; +import java.io.Closeable; import java.net.URI; +import java.util.Properties; import java.util.Set; import org.jclouds.apis.ApiMetadata; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.providers.ProviderMetadata; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; /** @@ -42,27 +46,31 @@ import com.google.common.collect.ImmutableSet; * * @author Adrian Cole */ -public abstract class BaseProviderMetadata implements ProviderMetadata { +public abstract class BaseProviderMetadata> + implements ProviderMetadata { - public static abstract class Builder> implements ProviderMetadata.Builder { + @Override + public ProviderMetadata.Builder toBuilder() { + return new BaseProviderMetadata.Builder().fromProviderMetadata(this); + } + + public static class Builder> implements + ProviderMetadata.Builder { protected String id; protected String name; - protected ApiMetadata api; + protected M api; + protected String endpoint; + protected Properties defaultProperties = new Properties(); protected URI console; protected URI homepage; protected Set linkedServices = newLinkedHashSet(); protected Set iso3166Codes = newLinkedHashSet(); - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - /** * {@inheritDoc} */ @Override - public B id(String id) { + public Builder id(String id) { this.id = checkNotNull(id, "id"); return linkedService(id); } @@ -71,52 +79,72 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { * {@inheritDoc} */ @Override - public B name(String name) { + public Builder name(String name) { this.name = checkNotNull(name, "name"); - return self(); + return this; } /** * {@inheritDoc} */ @Override - public B api(ApiMetadata api) { + public Builder apiMetadata(M api) { this.api = checkNotNull(api, "api"); - return self(); + if (this.endpoint == null) + this.endpoint = api.getDefaultEndpoint().orNull(); + return this; } /** * {@inheritDoc} */ @Override - public B console(@Nullable URI console) { + public Builder endpoint(String endpoint) { + this.endpoint = checkNotNull(endpoint, "endpoint"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder defaultProperties(Properties defaultProperties) { + this.defaultProperties = checkNotNull(defaultProperties, "defaultProperties"); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder console(@Nullable URI console) { this.console = console; - return self(); + return this; } /** * {@inheritDoc} */ @Override - public B homepage(URI homepage) { + public Builder homepage(URI homepage) { this.homepage = homepage; - return self(); + return this; } /** * {@inheritDoc} */ @Override - public B linkedServices(Iterable linkedServices) { + public Builder linkedServices(Iterable linkedServices) { addAll(this.linkedServices, checkNotNull(linkedServices, "linkedServices")); - return self(); + return this; } /** * {@inheritDoc} */ @Override - public B linkedServices(String... linkedServices) { + public Builder linkedServices(String... linkedServices) { return linkedServices(ImmutableSet.copyOf(checkNotNull(linkedServices, "linkedServices"))); } @@ -124,25 +152,25 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { * {@inheritDoc} */ @Override - public B linkedService(String linkedService) { + public Builder linkedService(String linkedService) { this.linkedServices.add(checkNotNull(linkedService, "linkedService")); - return self(); + return this; } /** * {@inheritDoc} */ @Override - public B iso3166Codes(Iterable iso3166Codes) { + public Builder iso3166Codes(Iterable iso3166Codes) { addAll(this.iso3166Codes, checkNotNull(iso3166Codes, "iso3166Codes")); - return self(); + return this; } /** * {@inheritDoc} */ @Override - public B iso3166Codes(String... iso3166Codes) { + public Builder iso3166Codes(String... iso3166Codes) { return iso3166Codes(ImmutableSet.copyOf(checkNotNull(iso3166Codes, "iso3166Codes"))); } @@ -150,37 +178,55 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { * {@inheritDoc} */ @Override - public B iso3166Code(String iso3166Code) { + public Builder iso3166Code(String iso3166Code) { this.iso3166Codes.add(checkNotNull(iso3166Code, "iso3166Code")); - return self(); + return this; } /** * {@inheritDoc} */ @Override - public B fromProviderMetadata(ProviderMetadata in) { - return id(in.getId()).name(in.getName()).api(in.getApi()).console(in.getConsole()).homepage(in.getHomepage()) - .linkedServices(in.getLinkedServices()).iso3166Codes(in.getIso3166Codes()); + public Builder fromProviderMetadata(ProviderMetadata in) { + return id(in.getId()).name(in.getName()).apiMetadata(in.getApiMetadata()).endpoint(in.getEndpoint()) + .defaultProperties(in.getDefaultProperties()).console(in.getConsole().orNull()) + .homepage(in.getHomepage().orNull()).linkedServices(in.getLinkedServices()) + .iso3166Codes(in.getIso3166Codes()); + } + + @Override + public ProviderMetadata build() { + return new BaseProviderMetadata(this){}; } } protected final String id; protected final String name; - protected final ApiMetadata api; - protected final URI homepage; - protected final URI console; + protected final M api; + protected final String endpoint; + protected final Properties defaultProperties; + protected final Optional homepage; + protected final Optional console; protected final Set linkedServices; protected final Set iso3166Codes; - protected BaseProviderMetadata(Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.api = builder.api; - this.console = builder.console; - this.homepage = builder.homepage; - this.linkedServices = ImmutableSet.copyOf(builder.linkedServices); - this.iso3166Codes = ImmutableSet.copyOf(builder.iso3166Codes); + public BaseProviderMetadata(Builder builder) { + this(builder.id, builder.name, builder.api, builder.endpoint, builder.defaultProperties, Optional + .fromNullable(builder.homepage), Optional.fromNullable(builder.console), builder.linkedServices, + builder.iso3166Codes); + } + + public BaseProviderMetadata(String id, String name, M api, String endpoint, Properties defaultProperties, + Optional homepage, Optional console, Set linkedServices, Set iso3166Codes) { + this.id = checkNotNull(id, "id"); + this.name = checkNotNull(name, "name"); + this.api = checkNotNull(api, "api"); + this.endpoint = checkNotNull(endpoint, "endpoint"); + this.console = checkNotNull(console, "console"); + this.defaultProperties = checkNotNull(defaultProperties, "defaultProperties"); + this.homepage = checkNotNull(homepage, "homepage"); + this.linkedServices = ImmutableSet.copyOf(linkedServices); + this.iso3166Codes = ImmutableSet.copyOf(iso3166Codes); } @Override @@ -191,18 +237,14 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { // we'll get things from if (o == null || !(o instanceof ProviderMetadata)) return false; - ProviderMetadata that = ProviderMetadata.class.cast(o); + ProviderMetadata that = ProviderMetadata.class.cast(o); return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) - && equal(this.getApi(), that.getApi()) && equal(this.getConsole(), that.getConsole()) - && equal(this.getHomepage(), that.getHomepage()) - && equal(this.getLinkedServices(), that.getLinkedServices()) - && equal(this.getIso3166Codes(), that.getIso3166Codes()); + && equal(this.getApiMetadata(), that.getApiMetadata()) && equal(this.getEndpoint(), that.getEndpoint()); } @Override public int hashCode() { - return Objects.hashCode(getId(), getName(), getApi(), getConsole(), getHomepage(), getLinkedServices(), - getIso3166Codes()); + return Objects.hashCode(getId(), getName(), getApiMetadata(), getEndpoint()); } @Override @@ -211,9 +253,9 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { } public ToStringHelper string() { - return Objects.toStringHelper("").add("id", getId()).add("name", getName()).add("api", getApi()) - .add("console", getConsole()).add("homepage", getHomepage()).add("linkedServices", getLinkedServices()) - .add("iso3166Codes", getIso3166Codes()); + return Objects.toStringHelper("").add("id", getId()).add("name", getName()).add("api", getApiMetadata()) + .add("endpoint", getEndpoint()).add("console", getConsole()).add("homepage", getHomepage()) + .add("linkedServices", getLinkedServices()).add("iso3166Codes", getIso3166Codes()); } /** @@ -236,7 +278,7 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { * {@inheritDoc} */ @Override - public ApiMetadata getApi() { + public M getApiMetadata() { return api; } @@ -244,7 +286,15 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { * {@inheritDoc} */ @Override - public URI getConsole() { + public String getEndpoint() { + return endpoint; + } + + /** + * {@inheritDoc} + */ + @Override + public Optional getConsole() { return console; } @@ -252,7 +302,15 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { * {@inheritDoc} */ @Override - public URI getHomepage() { + public Properties getDefaultProperties() { + return defaultProperties; + } + + /** + * {@inheritDoc} + */ + @Override + public Optional getHomepage() { return homepage; } @@ -272,35 +330,5 @@ public abstract class BaseProviderMetadata implements ProviderMetadata { return iso3166Codes; } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return getApi().getType().toString(); - } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return getApi().getIdentityName(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return getApi().getCredentialName(); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return getApi().getDocumentation(); - } } diff --git a/core/src/main/java/org/jclouds/rest/AnonymousProviderMetadata.java b/core/src/main/java/org/jclouds/rest/AnonymousProviderMetadata.java new file mode 100644 index 0000000000..2675f01e13 --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/AnonymousProviderMetadata.java @@ -0,0 +1,79 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.rest; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.Closeable; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Useful in creating arbitrary clients. + * + * @author Adrian Cole + */ +public class AnonymousProviderMetadata> extends + BaseProviderMetadata { + + public static ProviderMetadata, AnonymousRestApiMetadata> forClientMappedToAsyncClientOnEndpoint(Class client, Class asyncClient, + String endpoint) { + return forApiWithEndpoint(AnonymousRestApiMetadata.forClientMappedToAsyncClient(client, asyncClient), endpoint); + } + + public static > ProviderMetadata forApiWithEndpoint(M md, + String endpoint) { + checkNotNull(md, "api"); + checkNotNull(endpoint, "endpoint (%s)", md.getEndpointName()); + return new AnonymousProviderMetadata(md, endpoint); + } + + @Override + public Builder toBuilder() { + return (Builder) new Builder(getApiMetadata(), getEndpoint()).fromProviderMetadata(this); + } + + public AnonymousProviderMetadata(M apiMetadata, String endpoint) { + super(new Builder(apiMetadata, endpoint)); + } + + public AnonymousProviderMetadata(Builder builder) { + super(builder); + } + + public static class Builder> extends + BaseProviderMetadata.Builder { + + public Builder(M apiMetadata, String endpoint) { + id(checkNotNull(apiMetadata, "apiMetadata").getId()) + .name(apiMetadata.getName()) + .apiMetadata(apiMetadata) + .endpoint(endpoint); + } + + @Override + public AnonymousProviderMetadata build() { + return new AnonymousProviderMetadata(this); + } + + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/AnonymousRestApiMetadata.java b/core/src/main/java/org/jclouds/rest/AnonymousRestApiMetadata.java new file mode 100644 index 0000000000..1cae714604 --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/AnonymousRestApiMetadata.java @@ -0,0 +1,78 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.rest; + +import java.net.URI; + +import org.jclouds.apis.ApiType; +import org.jclouds.rest.internal.BaseRestApiMetadata; + +import com.google.common.annotations.Beta; + +/** + * Useful in creating arbitrary clients. + * + * @author Adrian Cole + */ +@Beta +public class AnonymousRestApiMetadata extends BaseRestApiMetadata, AnonymousRestApiMetadata> { + + public static AnonymousRestApiMetadata forClientMappedToAsyncClient(Class client, Class asyncClient) { + return new AnonymousRestApiMetadata(client, asyncClient); + } + + @Override + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + } + + public AnonymousRestApiMetadata(Class client, Class asyncClient) { + super(new Builder(client, asyncClient)); + } + + protected AnonymousRestApiMetadata(Builder builder) { + super(builder); + } + + public static class Builder extends BaseRestApiMetadata.Builder, AnonymousRestApiMetadata> { + + public Builder(Class client, Class asyncClient) { + super(client, asyncClient); + id(client.getSimpleName()) + .type(ApiType.UNRECOGNIZED) + .name(String.format("%s->%s", client.getSimpleName(), asyncClient.getSimpleName())) + .identityName("unused") + .defaultIdentity("foo") + .version("1") + .documentation(URI.create("http://jclouds.org/documentation")); + } + + @Override + public AnonymousRestApiMetadata build() { + return new AnonymousRestApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(AnonymousRestApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } + +} diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaZurichComputeServiceContextModule.java b/core/src/main/java/org/jclouds/rest/BackedByRestContext.java similarity index 72% rename from providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaZurichComputeServiceContextModule.java rename to core/src/main/java/org/jclouds/rest/BackedByRestContext.java index c9bf69c8ed..a595b334dc 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaZurichComputeServiceContextModule.java +++ b/core/src/main/java/org/jclouds/rest/BackedByRestContext.java @@ -16,13 +16,22 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.cloudsigma.compute.config; +package org.jclouds.rest; +import com.google.common.annotations.Beta; /** + * * * @author Adrian Cole + * */ -public class CloudSigmaZurichComputeServiceContextModule extends CloudSigmaComputeServiceContextModule { - +@Beta +public interface BackedByRestContext { + /** + * + * @return a context you can use to the access provider or vendor specific + * api underlying this context. + */ + RestContext getProviderSpecificContext(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/Providers.java b/core/src/main/java/org/jclouds/rest/Providers.java index 8ff65fff85..fe395b9374 100644 --- a/core/src/main/java/org/jclouds/rest/Providers.java +++ b/core/src/main/java/org/jclouds/rest/Providers.java @@ -18,139 +18,42 @@ */ package org.jclouds.rest; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Predicates.notNull; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.get; -import static com.google.common.collect.Iterables.transform; +import java.io.Closeable; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; +import org.jclouds.apis.Apis; -import org.jclouds.PropertiesBuilder; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.util.ClassLoadingUtils; -import org.jclouds.util.SaxUtils; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; +import com.google.common.collect.Iterables; +import com.google.common.reflect.TypeToken; /** - * + * @see org.jclouds.providers.Providers + * @see org.jclouds.apis.Apis * @author Adrian Cole */ +@Deprecated public class Providers { /** - * Gets a set of supported providers. Idea stolen from pallets (supported-clouds). Uses - * rest.properties to populate the set. - * + * Gets a set of supported providers. Idea stolen from pallets (supported-clouds). */ public static Iterable getSupportedProviders() { - return Providers.getSupportedProvidersOfType(RestContextBuilder.class); + return getSupportedProvidersOfType(TypeToken.of(Closeable.class)); } /** - * Gets a set of supported providers. Idea stolen from pallets (supported-clouds). Uses - * rest.properties to populate the set. + * Gets a set of supported providers. Idea stolen from pallets + * (supported-clouds). * */ - public static Iterable getSupportedProvidersOfType( - @SuppressWarnings("rawtypes") Class type) { - Properties properties = new Properties(); - try { - properties.load(SaxUtils.class.getResourceAsStream("/rest.properties")); - } catch (IOException e) { - throw new RuntimeException(e); - } - return Providers.getSupportedProvidersOfTypeInProperties(type, properties); + public static Iterable getSupportedProvidersOfType(TypeToken type) { + Builder builder = ImmutableSet. builder(); + builder.addAll(Iterables.transform(Apis.contextAssignableFrom(type), Apis.idFunction())); + builder.addAll(Iterables.transform(org.jclouds.providers.Providers.contextAssignableFrom(type), + org.jclouds.providers.Providers.idFunction())); + return builder.build(); } - public static Iterable getSupportedProvidersOfTypeInProperties( - @SuppressWarnings("rawtypes") final Class type, final Properties properties) { - return filter(transform(filter(properties.entrySet(), new Predicate>() { - - @Override - public boolean apply(Entry input) { - String keyString = input.getKey().toString(); - return keyString.endsWith(".contextbuilder") || keyString.endsWith(".sync"); - } - - }), new Function, String>() { - - @Override - public String apply(Entry from) { - String keyString = from.getKey().toString(); - try { - String provider = get(Splitter.on('.').split(keyString), 0); - Class> clazz = Providers.resolveContextBuilderClass(provider, - properties); - if (clazz != null && type.isAssignableFrom(clazz)) - return provider; - } catch (ClassNotFoundException e) { - } catch (Exception e) { - propagate(e); - } - return null; - } - - }), notNull()); - } - - @SuppressWarnings("unchecked") - public static Class> resolveContextBuilderClass(String provider, - Properties properties) throws ClassNotFoundException, IllegalArgumentException, SecurityException, - InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { - String contextBuilderClassName = properties.getProperty(provider + ".contextbuilder"); - String syncClassName = properties.getProperty(provider + ".sync"); - String asyncClassName = properties.getProperty(provider + ".async"); - if (syncClassName != null) { - checkArgument(asyncClassName != null, "please configure async class for " + syncClassName); - if(ClassLoadingUtils.loadClass(Providers.class, syncClassName) == null) { - throw new ClassNotFoundException(); - } - if(ClassLoadingUtils.loadClass(Providers.class, asyncClassName) == null) { - throw new ClassNotFoundException(); - } - return (Class>) (contextBuilderClassName != null ? ClassLoadingUtils. - loadClass(Providers.class, contextBuilderClassName) : RestContextBuilder.class); - } else { - checkArgument(contextBuilderClassName != null, "please configure contextbuilder class for " + provider); - return (Class>) ClassLoadingUtils. - loadClass(Providers.class, contextBuilderClassName); - } - } - - public static RestContextBuilder initContextBuilder( - Class> contextBuilderClass, @Nullable Class sync, @Nullable Class async, - Properties properties) throws ClassNotFoundException, IllegalArgumentException, SecurityException, - InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { - checkArgument(properties != null, "please configure properties for " + contextBuilderClass); - try { - return (RestContextBuilder) contextBuilderClass.getConstructor(Properties.class).newInstance(properties); - } catch (NoSuchMethodException e) { - checkArgument(sync != null, "please configure sync class for " + contextBuilderClass); - checkArgument(async != null, "please configure async class for " + contextBuilderClass); - return (RestContextBuilder) contextBuilderClass.getConstructor(sync.getClass(), async.getClass(), - Properties.class).newInstance(sync, async, properties); - } - } - - @SuppressWarnings("unchecked") - public static Class resolvePropertiesBuilderClass(String providerName, Properties props) - throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, - NoSuchMethodException { - String propertiesBuilderClassName = props.getProperty(providerName + ".propertiesbuilder", null); - if (propertiesBuilderClassName != null) { - return (Class) ClassLoadingUtils.loadClass(Providers.class, propertiesBuilderClassName); - } else { - return PropertiesBuilder.class; - } - } } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageTestInitializer.java b/core/src/main/java/org/jclouds/rest/RestApiMetadata.java similarity index 65% rename from providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageTestInitializer.java rename to core/src/main/java/org/jclouds/rest/RestApiMetadata.java index 3f18e16a65..84bd50d2f0 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageTestInitializer.java +++ b/core/src/main/java/org/jclouds/rest/RestApiMetadata.java @@ -16,20 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.cloudonestorage.blobstore.integration; +package org.jclouds.rest; -import org.jclouds.atmos.blobstore.integration.AtmosTestInitializer; +import org.jclouds.apis.ApiMetadata; +import com.google.common.annotations.Beta; /** * * @author Adrian Cole + * @since 1.5 */ -public class CloudOneStorageTestInitializer extends AtmosTestInitializer { +@Beta +public interface RestApiMetadata, M extends RestApiMetadata> extends + ApiMetadata { - public CloudOneStorageTestInitializer() { - provider = "cloudonestorage"; + public static interface Builder, M extends RestApiMetadata> extends + ApiMetadata.Builder { } - -} +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/RestContext.java b/core/src/main/java/org/jclouds/rest/RestContext.java index c03665d798..f564ace886 100644 --- a/core/src/main/java/org/jclouds/rest/RestContext.java +++ b/core/src/main/java/org/jclouds/rest/RestContext.java @@ -18,6 +18,7 @@ */ package org.jclouds.rest; +import java.io.Closeable; import java.net.URI; import java.util.Map; import java.util.concurrent.Future; @@ -41,7 +42,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(RestContextImpl.class) -public interface RestContext extends Location { +public interface RestContext extends Location, Closeable { /** * low-level api to the cloud. Threadsafe implementations will return a singleton. @@ -96,6 +97,7 @@ public interface RestContext extends Location { /** * Closes all connections to Cloud Files. */ + @Override void close(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java index 86f5c4f763..7d5475b244 100644 --- a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java +++ b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java @@ -1,277 +1,40 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rest; +import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.instanceOf; -import static com.google.common.collect.Iterables.addAll; -import static com.google.common.collect.Iterables.any; -import static com.google.inject.Scopes.SINGLETON; -import static com.google.inject.util.Types.newParameterizedType; +import java.util.NoSuchElementException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import javax.inject.Inject; - -import org.jclouds.concurrent.MoreExecutors; -import org.jclouds.concurrent.SingleThreaded; -import org.jclouds.concurrent.config.ConfiguresExecutorService; -import org.jclouds.concurrent.config.ExecutorServiceModule; -import org.jclouds.events.config.ConfiguresEventBus; -import org.jclouds.events.config.EventBusModule; -import org.jclouds.http.RequiresHttp; -import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.lifecycle.config.LifeCycleModule; -import org.jclouds.logging.config.LoggingModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.rest.config.BindPropertiesToAnnotations; -import org.jclouds.rest.config.CredentialStoreModule; -import org.jclouds.rest.config.RestClientModule; -import org.jclouds.rest.config.RestModule; -import org.jclouds.rest.internal.RestContextImpl; -import org.nnsoft.guice.rocoto.Rocoto; -import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Predicate; -import com.google.common.util.concurrent.ExecutionList; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.Module; -import com.google.inject.Stage; -import com.google.inject.TypeLiteral; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.ContextBuilder; /** - * Creates {@link RestContext} or {@link Injector} instances based on the most commonly requested - * arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

    - *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see RestContext + * @author Adrian Cole */ -public class RestContextBuilder { - protected Properties properties; - protected List modules = new ArrayList(3); - protected Class asyncClientType; - protected Class syncClientType; - - @Inject - public RestContextBuilder(Class syncClientClass, Class asyncClientClass, Properties properties) { - this.asyncClientType = checkNotNull(asyncClientClass, "asyncClientType"); - this.syncClientType = checkNotNull(syncClientClass, "syncClientType"); - this.properties = checkNotNull(properties, "properties"); - } - - public RestContextBuilder withModules(Iterable modules) { - addAll(this.modules, modules); - return this; - } - - public Injector buildInjector() { - modules.add(Rocoto.expandVariables(new ConfigurationModule(){ - - @Override - protected void bindConfigurations() { - Properties toBind = new Properties(); - toBind.putAll(checkNotNull(properties, "properties")); - toBind.putAll(System.getProperties()); - bindProperties(toBind); - } - - })); - addContextModule(modules); - addClientModuleIfNotPresent(modules); - addLoggingModuleIfNotPresent(modules); - addHttpModuleIfNeededAndNotPresent(modules); - ifHttpConfigureRestOtherwiseGuiceClientFactory(modules); - addExecutorServiceIfNotPresent(modules); - addEventBusIfNotPresent(modules); - addCredentialStoreIfNotPresent(modules); - modules.add(new LifeCycleModule()); - modules.add(new BindPropertiesToAnnotations()); - Injector returnVal = Guice.createInjector(Stage.PRODUCTION, modules); - returnVal.getInstance(ExecutionList.class).execute(); - return returnVal; - } - - @VisibleForTesting - protected void addLoggingModuleIfNotPresent(List modules) { - if (!any(modules, instanceOf(LoggingModule.class))) - modules.add(new JDKLoggingModule()); - } - - @VisibleForTesting - protected void addHttpModuleIfNeededAndNotPresent(List modules) { - if (defaultOrAtLeastOneModuleRequiresHttp(modules) && nothingConfiguresAnHttpService(modules)) - modules.add(new JavaUrlHttpCommandExecutorServiceModule()); - } - - private boolean nothingConfiguresAnHttpService(List modules) { - return (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresHttpCommandExecutorService.class); - } - - })); - } - - @VisibleForTesting - protected void addContextModuleIfNotPresent(List modules) { - if (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresRestContext.class); - } - - })) { - addContextModule(modules); - } - } - - @VisibleForTesting - protected void addContextModule(List modules) { - modules.add(new AbstractModule() { - - @SuppressWarnings( { "unchecked", "rawtypes" }) - @Override - protected void configure() { - bind( - (TypeLiteral) TypeLiteral.get(newParameterizedType(RestContext.class, syncClientType, - asyncClientType))).to( - TypeLiteral.get(newParameterizedType(RestContextImpl.class, syncClientType, asyncClientType))).in( - SINGLETON); - - } - - public String toString() { - return String.format("configure rest context %s->%s", syncClientType.getSimpleName(), asyncClientType - .getSimpleName()); - } - - }); - } - - @VisibleForTesting - protected void ifHttpConfigureRestOtherwiseGuiceClientFactory(List modules) { - if (defaultOrAtLeastOneModuleRequiresHttp(modules)) { - modules.add(new RestModule()); - } - } - - private boolean defaultOrAtLeastOneModuleRequiresHttp(List modules) { - return atLeastOneModuleRequiresHttp(modules) || !restClientModulePresent(modules); - } - - private boolean atLeastOneModuleRequiresHttp(List modules) { - return any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(RequiresHttp.class); - } - }); - } - - @VisibleForTesting - protected void addClientModuleIfNotPresent(List modules) { - if (!restClientModulePresent(modules)) { - addClientModule(modules); - } - } - - private boolean restClientModulePresent(List modules) { - return any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresRestClient.class); - } - - }); - } - - protected void addClientModule(List modules) { - modules.add(new RestClientModule(syncClientType, asyncClientType)); - } +public class RestContextBuilder, M extends RestApiMetadata> + extends ContextBuilder { - @VisibleForTesting - protected void addEventBusIfNotPresent(List modules) { - if (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresEventBus.class); - } - } - - )) { - modules.add(new EventBusModule()); - } + /** + * looks up a provider or api with the given id + * + * @param providerOrApi + * id of the provider or api + * @return means to build a context to that provider + * @throws NoSuchElementException + * if the id was not configured. + * @throws IllegalArgumentException + * if the api or provider isn't assignable from RestContext + */ + public static RestContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { + ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); + checkArgument(builder instanceof RestContextBuilder, + "type of providerOrApi[%s] is not RestContextBuilder: %s", providerOrApi, builder); + return RestContextBuilder.class.cast(builder); } - @VisibleForTesting - protected void addExecutorServiceIfNotPresent(List modules) { - if (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); - } - } - - )) { - if (any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(SingleThreaded.class); - } - })) { - modules.add(new ExecutorServiceModule(MoreExecutors.sameThreadExecutor(), MoreExecutors - .sameThreadExecutor())); - } else { - modules.add(new ExecutorServiceModule()); - } - } + public RestContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); } - @VisibleForTesting - protected void addCredentialStoreIfNotPresent(List modules) { - if (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresCredentialStore.class); - } - } - - )) { - modules.add(new CredentialStoreModule()); - } + public RestContextBuilder(M apiMetadata) { + super(apiMetadata); } - - @VisibleForTesting - protected Properties getProperties() { - return properties; - } - - @SuppressWarnings("unchecked") - public > T buildContext() { - Injector injector = buildInjector(); - return (T) injector - .getInstance(Key.get(newParameterizedType(RestContext.class, syncClientType, asyncClientType))); - } -} +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/RestContextFactory.java b/core/src/main/java/org/jclouds/rest/RestContextFactory.java index 4aacd74a28..fbdf38ee09 100644 --- a/core/src/main/java/org/jclouds/rest/RestContextFactory.java +++ b/core/src/main/java/org/jclouds/rest/RestContextFactory.java @@ -18,465 +18,115 @@ */ package org.jclouds.rest; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.size; -import static com.google.common.collect.Iterables.transform; -import static java.util.Collections.EMPTY_LIST; -import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; - -import java.io.File; -import java.io.IOException; +import java.util.NoSuchElementException; import java.util.Properties; -import javax.inject.Inject; - -import org.jclouds.PropertiesBuilder; +import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.reference.LocationConstants; -import org.jclouds.util.ClassLoadingUtils; -import org.jclouds.util.Modules2; -import org.jclouds.util.Strings2; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.Providers; +import org.jclouds.rest.internal.ContextBuilder; -import com.google.common.base.Charsets; -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; -import com.google.common.io.Files; import com.google.inject.Module; /** - * Helper class to instantiate {@code RestContext} instances. "blobstore.properties" - * - * At least one property is needed needed per context: - *

    - * - * Optional properties are as follows - *
      - *
    • tag.contextbuilder=classname extends RestContextBuilder
    • - *
    • tag.propertiesbuilder=classname extends HttpPropertiesBuilder
    • - *
    - * Ex. - * - *
    - * azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureRestContextBuilder
    - * azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder
    - * 
    * + * @see ContextBuilder * @author Adrian Cole */ +@Deprecated public class RestContextFactory { - public static RestContextSpec contextSpec(String provider, String endpoint, String apiVersion, - String buildVersion, String iso3166Codes, String identity, String credential, Class sync, Class
    async, - Class propertiesBuilderClass, Class> contextBuilderClass, - Iterable modules) { - return new RestContextSpec(provider, endpoint, apiVersion, buildVersion, iso3166Codes, identity, - credential, sync, async, propertiesBuilderClass, contextBuilderClass, modules); - } - - public static RestContextSpec contextSpec(String provider, String endpoint, String apiVersion,String buildVersion, - String iso3166Codes, String identity, String credential, Class sync, Class async) { - return new RestContextSpec(provider, endpoint, apiVersion, buildVersion, iso3166Codes, identity, credential, sync, async); - } - - @SuppressWarnings( { "unchecked", "rawtypes" }) - public static RestContextSpec contextSpec(String provider, String endpoint, String apiVersion, - String buildVersion, String iso3166Codes, String identity, String credential, Class sync, - Class async, Iterable modules) { - return new RestContextSpec(provider, endpoint, apiVersion, buildVersion, iso3166Codes, identity, - credential, sync, async, PropertiesBuilder.class, (Class) RestContextBuilder.class, modules); - } - - private final static Properties NO_PROPERTIES = new Properties(); - private final Properties properties; - /** - * Initializes with the default properties built-in to jclouds. This is typically stored in the - * classpath resource {@code rest.properties} - * - * @see RestContextFactory#getPropertiesFromResource + * for porting old code to {@link ContextBuilder} */ public RestContextFactory() { - this("/rest.properties"); } /** - * Initializes with the default properties built-in to jclouds. This is typically stored in the - * classpath resource {@code filename} - * - * @param filename - * name of the properties file to initialize from - * @throws IOException - * if the default properties file cannot be loaded - * @see #getPropertiesFromResource + * for porting old code to {@link ContextBuilder} */ - public RestContextFactory(String filename) { - this(getPropertiesFromResource(filename)); - } - - /** - * Loads the default properties that define the {@code RestContext} objects.

    properties file - * format

    - * - * Two properties are needed per context: - *
      - *
    • tag.contextbuilder=classname extends RestContextBuilder
    • - *
    • tag.propertiesbuilder=classname extends HttpPropertiesBuilder
    • - *
    - * Ex. - * - *
    -    * azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureRestContextBuilder
    -    * azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder
    -    * 
    - * - * @param filename - * name of file to load from in the resource path - * @return properties object with these items loaded for each tag - */ - public static Properties getPropertiesFromResource(String filename) { - Properties properties = new Properties(); - try { - properties.load(RestContextFactory.class.getResourceAsStream(filename)); - } catch (IOException e) { - propagate(e); - } - properties.putAll(System.getProperties()); - return properties; - } - - /** - * Initializes the {@code RestContext} definitions from the specified properties. - */ - @Inject public RestContextFactory(Properties properties) { - this.properties = properties; - } - - public RestContextBuilder createContextBuilder(String provider, String identity, String credential) { - return createContextBuilder(provider, identity, credential, ImmutableSet. of(), NO_PROPERTIES); } /** - * @see RestContextFactory#createContextBuilder(String, Properties, Iterable, - * Properties) + * @see #createContext(String, String,String, Iterable, Properties) */ - public RestContextBuilder createContextBuilder(String provider, Properties overrides) { - return createContextBuilder(provider, null, null, ImmutableSet. of(), overrides); + public RestContext createContext(String providerOrApi, String identity, String credential) { + return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** - * @see RestContextFactory#createContextBuilder(String, Properties, Iterable, - * Properties) + * @see #createContext(String, String, String, Iterable, Properties) */ - public RestContextBuilder createContextBuilder(String provider, Iterable modules) { - return createContextBuilder(provider, null, null, modules, NO_PROPERTIES); + public RestContext createContext(String providerOrApi, Properties overrides) { + return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** - * - * Identity will be found by searching {@code jclouds.identity} failing that - * {@code provider.identity} where provider corresponds to the parameter. Same pattern is used - * for credential ({@code jclouds.credential} failing that {@code provider.credential}). - * - * @param - * Type of the provider specific client - * @param
    - * Type of the provide specific async client (same as above, yet all methods return - * {@code Future} results) - * @param provider - * name of the provider (ex. s3, bluelock, etc.) - * @param wiring - * defines how objects are bound to interfaces, pass in here to override this, or - * specify service implementations. - * @param overrides - * properties to pass to the context. + * @see #createContext(String, String,String, Iterable, Properties) */ - public RestContextBuilder createContextBuilder(String provider, Iterable wiring, + public RestContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { - return createContextBuilder(provider, null, null, wiring, overrides); - } - - @SuppressWarnings("unchecked") - public RestContextBuilder createContextBuilder(String provider, @Nullable String identity, - @Nullable String credential, Properties properties) { - return createContextBuilder(provider, identity, credential, EMPTY_LIST, properties); - } - - public RestContextBuilder createContextBuilder(String provider, @Nullable String identity, - @Nullable String credential, Iterable wiring) { - return createContextBuilder(provider, identity, credential, wiring, NO_PROPERTIES); + return createContext(providerOrApi, null, null, wiring, overrides); } /** - * Creates a new remote context. + * @see #createContext(String, String,String, Iterable, Properties) + */ + public RestContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Properties overrides) { + return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); + } + + /** + * @see createContext(String, String,String, Iterable, Properties) + */ + public RestContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Iterable wiring) { + return createContext(providerOrApi, identity, credential, wiring, new Properties()); + } + + /** + * for porting old code to {@link ContextBuilder} * - * @param provider + * @param providerOrApi * @param identity * nullable, if credentials are present in the overrides * @param credential * nullable, if credentials are present in the overrides * @param wiring - * Configuration you'd like to pass to the context. Ex. ImmutableSet.of(new - * ExecutorServiceModule(myexecutor)) + * Configuration you'd like to pass to the context. Ex. + * ImmutableSet.of(new ExecutorServiceModule(myexecutor)) * @param overrides * properties to override defaults with. * @return initialized context ready for use */ - public RestContextBuilder createContextBuilder(String providerName, @Nullable String identity, - @Nullable String credential, Iterable wiring, Properties _overrides) { - checkNotNull(wiring, "wiring"); - RestContextSpec contextSpec = createContextSpec(providerName, identity, credential, wiring, _overrides); - return createContextBuilder(contextSpec, _overrides); - } - - public static Properties toProperties(RestContextSpec contextSpec) { - checkNotNull(contextSpec, "contextSpec"); - - Properties props = new Properties(); - - props.setProperty(contextSpec.provider + ".endpoint", contextSpec.endpoint); - props.setProperty(contextSpec.provider + ".api-version", contextSpec.apiVersion); - props.setProperty(contextSpec.provider + ".build-version", contextSpec.buildVersion); - props.setProperty(contextSpec.provider + "." + LocationConstants.ISO3166_CODES, contextSpec.iso3166Codes); - props.setProperty(contextSpec.provider + ".identity", contextSpec.identity); - if (contextSpec.credential != null) - props.setProperty(contextSpec.provider + ".credential", contextSpec.credential); - if (contextSpec.sync != null) { - props.setProperty(contextSpec.provider + ".sync", contextSpec.sync.getName()); - props.setProperty(contextSpec.provider + ".async", checkNotNull(contextSpec.async, "contextSpec.async") - .getName()); - } else { - props.setProperty(contextSpec.provider + ".contextbuilder", - checkNotNull(contextSpec.contextBuilderClass, "contextSpec.contextBuilderClass").getName()); - - props.setProperty(contextSpec.provider + ".propertiesbuilder", - checkNotNull(contextSpec.propertiesBuilderClass, "contextSpec.propertiesBuilderClass").getName()); - } - if (size(contextSpec.modules) > 0) { - props.setProperty(contextSpec.provider + ".modules", - Joiner.on(',').join(transform(contextSpec.modules, new Function() { - - @Override - public String apply(Module from) { - return from.getClass().getName(); - } - - }))); - } - return props; - } - @SuppressWarnings("unchecked") - public RestContextSpec createContextSpec(String providerName, String identity, String credential, - Properties _overrides) { - return createContextSpec(providerName, identity, credential, EMPTY_LIST, _overrides); - } - - @SuppressWarnings("unchecked") - public RestContextSpec createContextSpec(String providerName, String identity, String credential, - Iterable wiring, Properties _overrides) { - checkNotNull(providerName, "providerName"); - checkNotNull(_overrides, "overrides"); - - Properties props = new Properties(); - props.putAll(this.properties); - props.putAll(_overrides); - - String endpoint = props.getProperty(providerName + "." + LocationConstants.ENDPOINT, null); - String iso3166Codes = props.getProperty(providerName + "." + LocationConstants.ISO3166_CODES, null); - String apiVersion = props.getProperty(providerName + ".api-version", null); - String buildVersion = props.getProperty(providerName + ".build-version", null); - identity = props.getProperty(providerName + ".identity", props.getProperty("jclouds.identity", identity)); - credential = loadCredentialOrDefault(props, providerName + ".credential", - loadCredentialOrDefault(props, "jclouds.credential", credential)); - String syncClassName = props.getProperty(providerName + ".sync", null); - String asyncClassName = props.getProperty(providerName + ".async", null); - Iterable modules = concat(Modules2.modulesForProviderInProperties(providerName, props), wiring); - - Class> contextBuilderClass; - Class propertiesBuilderClass; - Class sync; - Class async; - try { - contextBuilderClass = Providers.resolveContextBuilderClass(providerName, props); - propertiesBuilderClass = Providers.resolvePropertiesBuilderClass(providerName, props); - sync = (Class) (syncClassName != null ? ClassLoadingUtils.loadClass(getClass(), syncClassName) : null); - async = (Class) (asyncClassName != null ? ClassLoadingUtils.loadClass(getClass(), asyncClassName) : null); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException( - String.format( - "The specified provider \"%s\" is either not configured or supported. Currently configured providers are:%n %s%nCheck this list, as the provider name may have changed. If you are sure that provider name is correct, check that your project has a dependency on org.jclouds.provider/%s, or on org.jclouds/jclouds-all.", - providerName, Providers.getSupportedProviders(), providerName), e); - } catch (Exception e) { - propagate(e); - assert false : "exception should have propogated " + e; - return null; - } - RestContextSpec contextSpec = new RestContextSpec(providerName, endpoint, apiVersion, buildVersion, iso3166Codes, - identity, credential, sync, async, propertiesBuilderClass, contextBuilderClass, modules); - return contextSpec; - } - - static String loadCredentialOrDefault(Properties properties, String property, String credential) { - if (properties.containsKey(property)) - return properties.getProperty(property); - else if (properties.containsKey(property + ".resource")) - try { - return Strings2.toStringAndClose(RestContextFactory.class.getResourceAsStream(properties - .getProperty(property + ".resource"))); - } catch (IOException e) { - throw new RuntimeException("error reading resource: " + properties.getProperty(property + ".resource")); - } - else if (properties.containsKey(property + ".file")) - try { - return Files.toString(new File(properties.getProperty(property + ".file")), Charsets.UTF_8); - } catch (IOException e) { - throw new RuntimeException("error reading file: " + properties.getProperty(property + ".file")); - } - else - return credential; - } - - public static RestContextBuilder createContextBuilder(RestContextSpec contextSpec) { - return createContextBuilder(contextSpec, NO_PROPERTIES); - } - - @SuppressWarnings("unchecked") - public static RestContextBuilder createContextBuilder(RestContextSpec contextSpec, - Properties overrides) { - return createContextBuilder(contextSpec, EMPTY_LIST, overrides); - } - - public static RestContextBuilder createContextBuilder(RestContextSpec contextSpec, - Iterable modules) { - return createContextBuilder(contextSpec, modules, NO_PROPERTIES); - } - - public static RestContextBuilder createContextBuilder(RestContextSpec contextSpec, - Iterable modules, Properties overrides) { - try { - PropertiesBuilder builder = contextSpec.propertiesBuilderClass.getConstructor(Properties.class).newInstance( - overrides); - - builder.provider(contextSpec.provider); - if (contextSpec.apiVersion != null) - builder.apiVersion(contextSpec.apiVersion); - if (contextSpec.buildVersion != null) - builder.buildVersion(contextSpec.buildVersion); - if (contextSpec.iso3166Codes != null) - builder.iso3166Codes(Splitter.on('.').split(contextSpec.iso3166Codes)); - if (contextSpec.identity != null) - builder.credentials(contextSpec.identity, contextSpec.credential); - if (contextSpec.endpoint != null) - builder.endpoint(contextSpec.endpoint); - - RestContextBuilder contextBuilder = Providers.initContextBuilder(contextSpec.contextBuilderClass, - contextSpec.sync, contextSpec.async, builder.build()); - - contextBuilder.withModules(concat(modules, contextSpec.modules)); - - return contextBuilder; - } catch (Exception e) { - return propagateAuthorizationOrOriginalException(e); - } - } - - /** - * @see RestContextFactory#createContextBuilder(String, String, String) - */ - public RestContext createContext(String provider, String identity, String credential) { - RestContextBuilder builder = createContextBuilder(provider, identity, credential); - return buildContextUnwrappingExceptions(builder); - } - - public static RestContext buildContextUnwrappingExceptions(RestContextBuilder builder) { - try { - return builder.buildContext(); - } catch (Exception e) { - return propagateAuthorizationOrOriginalException(e); - } - } - - /** - * @see RestContextFactory#createContextBuilder(String, Properties) - */ - public RestContext createContext(String provider, Properties overrides) { - RestContextBuilder builder = createContextBuilder(provider, overrides); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, Iterable) - */ - public RestContext createContext(String provider, Iterable wiring, - Properties overrides) { - RestContextBuilder builder = createContextBuilder(provider, wiring, overrides); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, String,String, Properties) - */ - public RestContext createContext(String provider, @Nullable String identity, - @Nullable String credential, Properties properties) { - RestContextBuilder builder = createContextBuilder(provider, identity, credential, properties); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, String,String, Iterable) - */ - public RestContext createContext(String provider, @Nullable String identity, - @Nullable String credential, Iterable wiring) { - RestContextBuilder builder = createContextBuilder(provider, identity, credential, wiring); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, String,String, Iterable, Properties) - */ - public RestContext createContext(String provider, @Nullable String identity, + public RestContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - RestContextBuilder builder = createContextBuilder(provider, identity, credential, wiring, overrides); - return buildContextUnwrappingExceptions(builder); + ContextBuilder builder = null; + try { + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = ContextBuilder.newBuilder(pm); + } catch (NoSuchElementException e) { + builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); + } + builder.modules(Iterable.class.cast(wiring)); + builder.overrides(overrides); + if (identity != null) + builder.credentials(identity, credential); + Object context = builder.build(); + if (context instanceof RestContext) { + return RestContext.class.cast(context); + } else if (context instanceof BackedByRestContext) { + return BackedByRestContext.class.cast(context).getProviderSpecificContext(); + } else { + throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " + + context.getClass().getSimpleName()); + } + } - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec) - */ - public static RestContext createContext(RestContextSpec contextSpec) { - RestContextBuilder builder = createContextBuilder(contextSpec); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec, Properties) - */ - public static RestContext createContext(RestContextSpec contextSpec, Properties overrides) { - RestContextBuilder builder = createContextBuilder(contextSpec, overrides); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec, Iterable) - */ - public static RestContext createContext(RestContextSpec contextSpec, Iterable modules) { - RestContextBuilder builder = createContextBuilder(contextSpec, modules); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec, Iterable, Properties) - */ - public static RestContext createContext(RestContextSpec contextSpec, Iterable modules, - Properties overrides) { - RestContextBuilder builder = createContextBuilder(contextSpec, modules, overrides); - return buildContextUnwrappingExceptions(builder); - } } diff --git a/core/src/main/java/org/jclouds/rest/RestContextSpec.java b/core/src/main/java/org/jclouds/rest/RestContextSpec.java deleted file mode 100644 index 9cbea956e0..0000000000 --- a/core/src/main/java/org/jclouds/rest/RestContextSpec.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rest; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.Collections.EMPTY_LIST; - -import org.jclouds.PropertiesBuilder; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableList; -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -public class RestContextSpec { - protected final String provider; - protected final String endpoint; - protected final String apiVersion; - protected final String buildVersion; - protected final String iso3166Codes; - protected final String identity; - protected final String credential; - protected final Class sync; - protected final Class async; - protected final Class propertiesBuilderClass; - protected final Class> contextBuilderClass; - protected final Iterable modules; - - public RestContextSpec(String provider, String endpoint, String apiVersion, String buildVersion, String iso3166Codes, String identity, - String credential, Class sync, Class async, Class propertiesBuilderClass, - Class> contextBuilderClass, Iterable modules) { - this.provider = checkNotNull(provider, "provider"); - this.endpoint = endpoint; - this.apiVersion = apiVersion; - this.buildVersion = buildVersion; - this.identity = identity; - this.credential = credential; - this.iso3166Codes = iso3166Codes; - this.sync = sync; - this.async = async; - checkArgument(RestContextBuilder.class.isAssignableFrom(contextBuilderClass), contextBuilderClass.getName() - + " is not a subclass of " + RestContextBuilder.class.getName()); - checkArgument(PropertiesBuilder.class.isAssignableFrom(propertiesBuilderClass), propertiesBuilderClass.getName() - + " is not a subclass of " + PropertiesBuilder.class.getName()); - this.propertiesBuilderClass = propertiesBuilderClass; - this.contextBuilderClass = contextBuilderClass; - this.modules = ImmutableList.copyOf(modules); - } - - @SuppressWarnings( { "unchecked", "rawtypes" }) - public RestContextSpec(String provider, String endpoint, String apiVersion, String buildVersion, String iso3166Codes, String identity, - String credential, Class sync, Class async) { - this(provider, endpoint, apiVersion, buildVersion, iso3166Codes, identity, credential, sync, async, PropertiesBuilder.class, - (Class) RestContextBuilder.class, EMPTY_LIST); - } - - - @Override - public int hashCode() { - return Objects.hashCode(provider, endpoint, apiVersion, buildVersion, iso3166Codes, identity, credential, sync, async, - propertiesBuilderClass, contextBuilderClass, modules); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - return Objects.equal(this.toString(), that.toString()); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).add("provider", provider).add("endpoint", endpoint).add("apiVersion", - apiVersion).add("buildVersion", buildVersion).add("iso3166Codes", iso3166Codes) - .add("identity", identity).add("sync", sync).add("async", async).add("propertiesBuilderClass", - propertiesBuilderClass).add("contextBuilderClass", contextBuilderClass).add("modules", modules) - .toString(); - } - -} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java new file mode 100644 index 0000000000..bc0e52fef1 --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java @@ -0,0 +1,74 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.rest.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.rest.RestApiMetadata; +import org.jclouds.rest.RestContext; + +import com.google.common.annotations.Beta; + +/** + * Useful in creating rest clients. + * + * @author Adrian Cole + */ +@Beta +public class BaseRestApiMetadata, M extends RestApiMetadata> extends BaseApiMetadata + implements RestApiMetadata { + + @SuppressWarnings("unchecked") + @Override + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata((M) this); + } + + public BaseRestApiMetadata(Class client, Class asyncClient) { + super(new Builder(client, asyncClient)); + } + + protected BaseRestApiMetadata(Builder builder) { + super(builder); + } + + public static class Builder, M extends RestApiMetadata > extends + BaseApiMetadata.Builder implements RestApiMetadata.Builder { + + public Builder(Class client, Class asyncClient) { + checkNotNull(client, "client"); + checkNotNull(asyncClient, "asyncClient"); + javaApi(client, asyncClient); + } + + @SuppressWarnings("unchecked") + @Override + public M build() { + return (M) new BaseRestApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(M in) { + super.fromApiMetadata(in); + return this; + } + } + +} diff --git a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java b/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java new file mode 100644 index 0000000000..4224944ebe --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java @@ -0,0 +1,465 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.rest.internal; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Predicates.instanceOf; +import static com.google.common.collect.Iterables.addAll; +import static com.google.common.collect.Iterables.any; +import static com.google.inject.Scopes.SINGLETON; +import static com.google.inject.util.Types.newParameterizedType; +import static org.jclouds.Constants.PROPERTY_API; +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; +import static org.jclouds.Constants.PROPERTY_CREDENTIAL; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_IDENTITY; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.Constants.PROPERTY_PROVIDER; +import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; + +import java.io.Closeable; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.Apis; +import org.jclouds.concurrent.MoreExecutors; +import org.jclouds.concurrent.SingleThreaded; +import org.jclouds.concurrent.config.ConfiguresExecutorService; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.events.config.ConfiguresEventBus; +import org.jclouds.events.config.EventBusModule; +import org.jclouds.http.RequiresHttp; +import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.lifecycle.config.LifeCycleModule; +import org.jclouds.logging.config.LoggingModule; +import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.Providers; +import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.rest.ConfiguresCredentialStore; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.ConfiguresRestContext; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.config.BindPropertiesToAnnotations; +import org.jclouds.rest.config.CredentialStoreModule; +import org.jclouds.rest.config.RestClientModule; +import org.jclouds.rest.config.RestModule; +import org.nnsoft.guice.rocoto.Rocoto; +import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Joiner; +import com.google.common.base.Objects; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableMultimap.Builder; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.util.concurrent.ExecutionList; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.Module; +import com.google.inject.Stage; +import com.google.inject.TypeLiteral; + +/** + * Creates {@link RestContext} or {@link Injector} instances based on the most + * commonly requested arguments. + *

    + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. + *

    + *

    + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. + * + * @author Adrian Cole, Andrew Newdigate + * @see RestContext + */ +public class ContextBuilder> { + + /** + * looks up a provider or api with the given id + * + * @param providerOrApi + * id of the provider or api + * @return means to build a context to that provider + * @throws NoSuchElementException + * if the id was not configured. + */ + public static ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { + try { + try { + return ContextBuilder.newBuilder(Providers.withId(providerOrApi)); + } catch (NoSuchElementException e) { + return ContextBuilder.newBuilder(Apis.withId(providerOrApi)); + } + } catch (NoSuchElementException e) { + Builder builder = ImmutableMultimap. builder(); + builder.putAll("providers", Iterables.transform(Providers.all(), Providers.idFunction())); + builder.putAll("apis", Iterables.transform(Apis.all(), Apis.idFunction())); + throw new NoSuchElementException(String.format("key [%s] not in the list of providers or apis: %s", + providerOrApi, builder.build())); + } + } + + @SuppressWarnings("unchecked") + public static > ContextBuilder newBuilder( + ApiMetadata apiMetadata) { + try { + for (Constructor ctor : apiMetadata.getContextBuilder().getRawType().getConstructors()) { + if (ctor.getParameterTypes().length == 1 + && ctor.getParameterTypes()[0].isAssignableFrom(apiMetadata.getClass())) + return (ContextBuilder) ctor.newInstance(apiMetadata); + } + throw new IllegalArgumentException(String.format("class %s has no constructor that accepts %s", apiMetadata + .getContextBuilder().getRawType().getSimpleName(), apiMetadata.getClass().getSimpleName())); + } catch (Exception e) { + return propagateAuthorizationOrOriginalException(e); + } + } + + @SuppressWarnings("unchecked") + public static > ContextBuilder newBuilder( + ProviderMetadata providerMetadata) { + try { + Class contextBuilderClass = providerMetadata.getApiMetadata().getContextBuilder().getRawType(); + return (ContextBuilder) contextBuilderClass.getConstructor(ProviderMetadata.class).newInstance( + providerMetadata); + } catch (Exception e) { + return propagateAuthorizationOrOriginalException(e); + } + } + + protected ProviderMetadata providerMetadata; + protected String endpoint; + protected String identity; + protected String credential; + protected M apiMetadata; + protected String apiVersion; + protected String buildVersion; + protected Properties overrides = new Properties();; + protected List modules = new ArrayList(3); + + @Override + public String toString() { + return Objects.toStringHelper("").add("providerMetadata", providerMetadata).add("apiMetadata", apiMetadata) + .toString(); + } + + public ContextBuilder(ProviderMetadata providerMetadata) { + this(providerMetadata, providerMetadata.getApiMetadata()); + } + + protected ContextBuilder(@Nullable ProviderMetadata providerMetadata, M apiMetadata) { + this.apiMetadata = checkNotNull(apiMetadata, "apiMetadata"); + this.providerMetadata = providerMetadata; + if (providerMetadata != null) + this.endpoint = providerMetadata.getEndpoint(); + if (apiMetadata.getDefaultIdentity().isPresent()) + identity = apiMetadata.getDefaultIdentity().get(); + if (apiMetadata.getDefaultCredential().isPresent()) + credential = apiMetadata.getDefaultCredential().get(); + this.apiVersion = apiMetadata.getVersion(); + this.buildVersion = apiMetadata.getBuildVersion().or(""); + if (endpoint == null) + endpoint = apiMetadata.getDefaultEndpoint().orNull(); + } + + public ContextBuilder(M apiMetadata) { + this(null, apiMetadata); + } + + public ContextBuilder credentials(String identity, String credential) { + this.identity = identity; + this.credential = credential; + return this; + } + + public ContextBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + public ContextBuilder apiVersion(String apiVersion) { + this.apiVersion = checkNotNull(apiVersion, "apiVersion"); + return this; + } + + public ContextBuilder buildVersion(String buildVersion) { + this.buildVersion = checkNotNull(buildVersion, "buildVersion"); + return this; + } + + public ContextBuilder modules(Iterable modules) { + addAll(this.modules, modules); + return this; + } + + public ContextBuilder overrides(Properties overrides) { + this.overrides.putAll(overrides); + return this; + } + + /** + * + * @throws NoSuchElementException + */ + + public static String searchPropertiesForProviderScopedProperty(Properties overrides, String prov, String key, + String defaultVal) { + try { + return Iterables.find(Lists.newArrayList(overrides.getProperty(prov + "." + key), + overrides.getProperty("jclouds." + key), defaultVal), Predicates.notNull()); + } catch (NoSuchElementException e) { + throw new NoSuchElementException("no " + key + " configured for provider: " + prov); + } + } + + public Injector buildInjector() { + checkNotNull(modules, "modules"); + checkNotNull(overrides, "overrides"); + checkNotNull(apiMetadata, "api"); + + final Properties mutable = new Properties(); + mutable.putAll(apiMetadata.getDefaultProperties()); + String providerId; + if (providerMetadata != null) { + mutable.putAll(providerMetadata.getDefaultProperties()); + mutable.setProperty(PROPERTY_PROVIDER, providerId = providerMetadata.getId()); + mutable.setProperty(PROPERTY_ISO3166_CODES, Joiner.on(',').join(providerMetadata.getIso3166Codes())); + } else { + mutable.setProperty(PROPERTY_PROVIDER, providerId = apiMetadata.getId()); + } + mutable.putAll(checkNotNull(overrides, "overrides")); + mutable.putAll(propertiesPrefixedWithJcloudsApiOrProviderId(System.getProperties(), providerId)); + + mutable.setProperty(PROPERTY_ENDPOINT, + searchPropertiesForProviderScopedProperty(mutable, providerId, "endpoint", endpoint)); + mutable.setProperty(PROPERTY_API, + searchPropertiesForProviderScopedProperty(mutable, providerId, "api", apiMetadata.getName())); + mutable.setProperty(PROPERTY_API_VERSION, + searchPropertiesForProviderScopedProperty(mutable, providerId, "api-version", apiVersion)); + mutable.setProperty(PROPERTY_BUILD_VERSION, + searchPropertiesForProviderScopedProperty(mutable, providerId, "build-version", buildVersion)); + mutable.setProperty(PROPERTY_IDENTITY, + searchPropertiesForProviderScopedProperty(mutable, providerId, "identity", identity)); + try { + mutable.setProperty(PROPERTY_CREDENTIAL, + searchPropertiesForProviderScopedProperty(mutable, providerId, "credential", credential)); + } catch (NoSuchElementException e) { + if (apiMetadata.getCredentialName().isPresent()) + throw e; + } + if (providerMetadata == null) + providerMetadata = AnonymousProviderMetadata.forApiWithEndpoint(apiMetadata, + mutable.getProperty(PROPERTY_ENDPOINT)); + modules.add(Rocoto.expandVariables(new ConfigurationModule() { + + @Override + protected void bindConfigurations() { + bindProperties(mutable); + } + + })); + addContextModule(modules); + addClientModuleIfNotPresent(modules); + addLoggingModuleIfNotPresent(modules); + addHttpModuleIfNeededAndNotPresent(modules); + ifHttpConfigureRestOtherwiseGuiceClientFactory(modules); + addExecutorServiceIfNotPresent(modules); + addCredentialStoreIfNotPresent(modules); + modules.add(new LifeCycleModule()); + modules.add(new BindPropertiesToAnnotations()); + Injector returnVal = Guice.createInjector(Stage.PRODUCTION, modules); + returnVal.getInstance(ExecutionList.class).execute(); + return returnVal; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + Map propertiesPrefixedWithJcloudsApiOrProviderId(Properties properties, String providerId) { + return Maps.filterKeys((Map) System.getProperties(), + Predicates.containsPattern("^(jclouds|" + providerId + "|" + apiMetadata.getId() + ").*")); + } + + @VisibleForTesting + protected void addLoggingModuleIfNotPresent(List modules) { + if (!any(modules, instanceOf(LoggingModule.class))) + modules.add(new JDKLoggingModule()); + } + + @VisibleForTesting + void addHttpModuleIfNeededAndNotPresent(List modules) { + if (defaultOrAtLeastOneModuleRequiresHttp(modules) && nothingConfiguresAnHttpService(modules)) + modules.add(new JavaUrlHttpCommandExecutorServiceModule()); + } + + private boolean nothingConfiguresAnHttpService(List modules) { + return (!any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresHttpCommandExecutorService.class); + } + + })); + } + + @VisibleForTesting + protected void addContextModuleIfNotPresent(List modules) { + if (!any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresRestContext.class); + } + + })) { + addContextModule(modules); + } + } + + @VisibleForTesting + protected void addContextModule(List modules) { + modules.add(new AbstractModule() { + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + protected void configure() { + bind( + (TypeLiteral) TypeLiteral.get(newParameterizedType(RestContext.class, providerMetadata + .getApiMetadata().getApi(), apiMetadata.getAsyncApi()))).to( + TypeLiteral.get(newParameterizedType(RestContextImpl.class, apiMetadata.getApi(), + apiMetadata.getAsyncApi()))).in(SINGLETON); + } + + public String toString() { + return String.format("configure rest context %s->%s", apiMetadata.getApi().getSimpleName(), apiMetadata + .getAsyncApi().getSimpleName()); + } + + }); + } + + @VisibleForTesting + protected void ifHttpConfigureRestOtherwiseGuiceClientFactory(List modules) { + if (defaultOrAtLeastOneModuleRequiresHttp(modules)) { + modules.add(new RestModule()); + } + } + + private boolean defaultOrAtLeastOneModuleRequiresHttp(List modules) { + return atLeastOneModuleRequiresHttp(modules) || !restClientModulePresent(modules); + } + + private boolean atLeastOneModuleRequiresHttp(List modules) { + return any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(RequiresHttp.class); + } + }); + } + + @VisibleForTesting + protected void addClientModuleIfNotPresent(List modules) { + if (!restClientModulePresent(modules)) { + addClientModule(modules); + } + } + + private boolean restClientModulePresent(List modules) { + return any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresRestClient.class); + } + + }); + } + + protected void addClientModule(List modules) { + modules.add(new RestClientModule(apiMetadata.getApi(), providerMetadata.getApiMetadata().getAsyncApi())); + } + + @VisibleForTesting + protected void addEventBusIfNotPresent(List modules) { + if (!any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresEventBus.class); + } + } + + )) { + modules.add(new EventBusModule()); + } + } + + @VisibleForTesting + protected void addExecutorServiceIfNotPresent(List modules) { + if (!any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); + } + } + + )) { + if (any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(SingleThreaded.class); + } + })) { + modules.add(new ExecutorServiceModule(MoreExecutors.sameThreadExecutor(), MoreExecutors + .sameThreadExecutor())); + } else { + modules.add(new ExecutorServiceModule()); + } + } + } + + @VisibleForTesting + protected void addCredentialStoreIfNotPresent(List modules) { + if (!any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresCredentialStore.class); + } + } + + )) { + modules.add(new CredentialStoreModule()); + } + } + + @SuppressWarnings("unchecked") + public C build() { + return (C) buildInjector().getInstance(Key.get(TypeLiteral.get(apiMetadata.getContext().getType()))); + } + + public M getApiMetadata() { + return apiMetadata; + } +} diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index 81cf5fe62f..d46966ddcc 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -1,5 +1,3 @@ -byon.contextbuilder=org.jclouds.byon.BYONComputeServiceContextBuilder -byon.propertiesbuilder=org.jclouds.byon.BYONPropertiesBuilder azurequeue.contextbuilder=org.jclouds.azure.storage.AzureStorageContextBuilder azurequeue.sync=org.jclouds.azurequeue.AzureQueueClient @@ -37,9 +35,6 @@ aws-cloudwatch.propertiesbuilder=org.jclouds.aws.cloudwatch.AWSCloudWatchPropert aws-s3.contextbuilder=org.jclouds.aws.s3.AWSS3ContextBuilder aws-s3.propertiesbuilder=org.jclouds.aws.s3.AWSS3PropertiesBuilder -aws-ec2.contextbuilder=org.jclouds.aws.ec2.AWSEC2ContextBuilder -aws-ec2.propertiesbuilder=org.jclouds.aws.ec2.AWSEC2PropertiesBuilder - rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingPropertiesBuilder @@ -155,7 +150,6 @@ virtacore-publiccloud-lax.contextbuilder=org.jclouds.virtacore.publiccloud.Virta dunkel-vcd.propertiesbuilder=org.jclouds.dunkel.vcd.DunkelVCloudDirectorPropertiesBuilder dunkel-vcd.contextbuilder=org.jclouds.dunkel.vcd.DunkelVCloudDirectorContextBuilder -stub.contextbuilder=org.jclouds.compute.stub.StubComputeServiceContextBuilder # example of where to change your endpoint # bluelock.endpoint=https://express3.bluelock.com/api @@ -234,9 +228,6 @@ hosteurope-storage.propertiesbuilder=org.jclouds.hosteurope.storage.HostEuropeSt tiscali-storage.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder tiscali-storage.propertiesbuilder=org.jclouds.tiscali.storage.TiscaliStoragePropertiesBuilder -transient.contextbuilder=org.jclouds.blobstore.TransientBlobStoreContextBuilder -transient.propertiesbuilder=org.jclouds.blobstore.TransientBlobStorePropertiesBuilder - virtualbox.contextbuilder=org.jclouds.virtualbox.VirtualBoxContextBuilder virtualbox.propertiesbuilder=org.jclouds.virtualbox.VirtualBoxPropertiesBuilder diff --git a/core/src/test/java/org/jclouds/apis/ApisTest.java b/core/src/test/java/org/jclouds/apis/ApisTest.java index 9f945ed06c..ba6d2f5e35 100644 --- a/core/src/test/java/org/jclouds/apis/ApisTest.java +++ b/core/src/test/java/org/jclouds/apis/ApisTest.java @@ -33,14 +33,14 @@ import org.testng.annotations.Test; @Test(groups = "unit", testName = "ApisTest") public class ApisTest { - private final ApiMetadata testBlobstoreApi = new JcloudsTestBlobStoreApiMetadata(); - private final ApiMetadata testComputeApi = new JcloudsTestComputeApiMetadata(); - private final ApiMetadata testYetAnotherComputeApi = new JcloudsTestYetAnotherComputeApiMetadata(); + private final JcloudsTestBlobStoreApiMetadata testBlobstoreApi = new JcloudsTestBlobStoreApiMetadata(); + private final JcloudsTestComputeApiMetadata testComputeApi = new JcloudsTestComputeApiMetadata(); + private final JcloudsTestYetAnotherComputeApiMetadata testYetAnotherComputeApi = new JcloudsTestYetAnotherComputeApiMetadata(); @Test public void testWithId() { - ApiMetadata apiMetadata; + ApiMetadata apiMetadata; try { apiMetadata = Apis.withId("fake-id"); fail("Looking for a api with an id that doesn't exist should " + "throw an exceptoin."); @@ -55,15 +55,15 @@ public class ApisTest { @Test public void testOfType() { - Iterable apisMetadata = Apis.ofType(ApiType.BLOBSTORE); + Iterable> apisMetadata = Apis.ofType(ApiType.BLOBSTORE); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { assertEquals(testBlobstoreApi, apiMetadata); } apisMetadata = Apis.ofType(ApiType.COMPUTE); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { if (apiMetadata.getName().equals(testComputeApi.getName())) { assertEquals(testComputeApi, apiMetadata); } else { @@ -78,9 +78,9 @@ public class ApisTest { @Test public void testAll() { - Iterable apisMetadata = Apis.all(); + Iterable> apisMetadata = Apis.all(); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { if (apiMetadata.getName().equals(testBlobstoreApi.getName())) { assertEquals(testBlobstoreApi, apiMetadata); } else if (apiMetadata.getName().equals(testComputeApi.getName())) { diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java index 7f1cffa226..21d2c88e4a 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java @@ -20,44 +20,56 @@ package org.jclouds.apis; import java.net.URI; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.rest.RestContext; + /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock , Adrian Cole */ -public class JcloudsTestBlobStoreApiMetadata extends BaseApiMetadata { - - public JcloudsTestBlobStoreApiMetadata() { - this(builder() - .id("test-blobstore-api") - .type(ApiType.BLOBSTORE) - .name("Test Blobstore Api") - .identityName("user") - .credentialName("password") - .documentation(URI.create("http://jclouds.org/documentation"))); +public class JcloudsTestBlobStoreApiMetadata + extends + BaseApiMetadata, JcloudsTestBlobStoreApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected JcloudsTestBlobStoreApiMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromApiMetadata(this)); + } + + public JcloudsTestBlobStoreApiMetadata() { + super(builder()); + } + + protected JcloudsTestBlobStoreApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + public static class Builder + extends + BaseApiMetadata.Builder, JcloudsTestBlobStoreApiMetadata> { + + protected Builder(){ + id("test-blobstore-api") + .type(ApiType.BLOBSTORE) + .name("Test Blobstore Api") + .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) + .identityName("user") + .credentialName("password") + .documentation(URI.create("http://jclouds.org/documentation")); + } @Override public JcloudsTestBlobStoreApiMetadata build() { return new JcloudsTestBlobStoreApiMetadata(this); } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java index c21f86ccab..99addc6a57 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java @@ -20,44 +20,54 @@ package org.jclouds.apis; import java.net.URI; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.rest.RestContext; + /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock , Adrian Cole */ -public class JcloudsTestComputeApiMetadata extends BaseApiMetadata { - - public JcloudsTestComputeApiMetadata() { - this(builder() - .id("test-compute-api") - .type(ApiType.COMPUTE) - .name("Test Compute Api") - .identityName("user") - .credentialName("password") - .documentation(URI.create("http://jclouds.org/documentation"))); +public class JcloudsTestComputeApiMetadata extends BaseApiMetadata, JcloudsTestComputeApiMetadata>{ + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected JcloudsTestComputeApiMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromApiMetadata(this)); + } + + public JcloudsTestComputeApiMetadata() { + super(builder()); + } + + protected JcloudsTestComputeApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + public static class Builder + extends + BaseApiMetadata.Builder, JcloudsTestComputeApiMetadata> { + + protected Builder(){ + id("test-compute-api") + .type(ApiType.COMPUTE) + .name("Test Compute Api") + .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) + .identityName("user") + .credentialName("password") + .documentation(URI.create("http://jclouds.org/documentation")); + } @Override public JcloudsTestComputeApiMetadata build() { return new JcloudsTestComputeApiMetadata(this); } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java index eb7c35e985..ad36f40fe4 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java @@ -20,45 +20,54 @@ package org.jclouds.apis; import java.net.URI; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.rest.RestContext; + /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock */ -public class JcloudsTestYetAnotherComputeApiMetadata extends BaseApiMetadata { - - public JcloudsTestYetAnotherComputeApiMetadata() { - this(builder() - .id("test-yet-another-compute-api") - .type(ApiType.COMPUTE) - .name("Test Yet Another Compute Api") - .identityName("user") - .credentialName("password") - .documentation(URI.create("http://jclouds.org/documentation"))); +public class JcloudsTestYetAnotherComputeApiMetadata + extends + BaseApiMetadata, JcloudsTestYetAnotherComputeApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected JcloudsTestYetAnotherComputeApiMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromApiMetadata(this)); + } + + public JcloudsTestYetAnotherComputeApiMetadata() { + super(builder()); + } + + protected JcloudsTestYetAnotherComputeApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + public static class Builder extends BaseApiMetadata.Builder, JcloudsTestYetAnotherComputeApiMetadata> { + + protected Builder(){ + id("test-yet-another-compute-api") + .type(ApiType.COMPUTE) + .name("Test Yet Another Compute Api") + .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) + .identityName("user") + .credentialName("password") + .documentation(URI.create("http://jclouds.org/documentation")); + } @Override public JcloudsTestYetAnotherComputeApiMetadata build() { return new JcloudsTestYetAnotherComputeApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/apis/BaseApiMetadataTest.java b/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java similarity index 75% rename from core/src/test/java/org/jclouds/apis/BaseApiMetadataTest.java rename to core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java index dc46bf8cea..95addda38b 100644 --- a/core/src/test/java/org/jclouds/apis/BaseApiMetadataTest.java +++ b/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java @@ -16,23 +16,27 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.apis; +package org.jclouds.apis.internal; import static org.testng.Assert.assertEquals; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.Apis; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** * - * @author Jeremy Whitlock + * @author Adrian Cole */ +@SuppressWarnings("rawtypes") @Test(groups = "unit") public abstract class BaseApiMetadataTest { - private final ApiMetadata toTest; - private final ApiType expectedType; + protected final ApiMetadata toTest; + protected final ApiType expectedType; public BaseApiMetadataTest(ApiMetadata toTest, ApiType expectedType) { this.toTest = toTest; @@ -41,7 +45,7 @@ public abstract class BaseApiMetadataTest { @Test public void testWithId() { - ApiMetadata apiMetadata = Apis.withId(toTest.getId()); + ApiMetadata apiMetadata = Apis.withId(toTest.getId()); assertEquals(toTest, apiMetadata); } @@ -49,13 +53,13 @@ public abstract class BaseApiMetadataTest { // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) @Test public void testOfTypeContains() { - ImmutableSet ofType = ImmutableSet.copyOf(Apis.ofType(expectedType)); + ImmutableSet> ofType = ImmutableSet.copyOf(Apis.ofType(expectedType)); assert ofType.contains(toTest) : String.format("%s not found in %s", toTest, ofType); } @Test public void testAllContains() { - ImmutableSet all = ImmutableSet.copyOf(Apis.all()); + ImmutableSet> all = ImmutableSet.copyOf(Apis.all()); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } diff --git a/compute/src/test/java/org/jclouds/compute/ComputeServiceContextFactoryTest.java b/core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java similarity index 51% rename from compute/src/test/java/org/jclouds/compute/ComputeServiceContextFactoryTest.java rename to core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java index af977d5d29..a6a3bec92b 100644 --- a/compute/src/test/java/org/jclouds/compute/ComputeServiceContextFactoryTest.java +++ b/core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java @@ -16,36 +16,36 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.compute; +package org.jclouds.apis.internal; -import java.util.concurrent.ConcurrentMap; +import java.util.Set; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.stub.StubComputeServiceContextBuilder; -import org.jclouds.domain.Location; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.Apis; +import org.jclouds.rest.RestApiMetadata; +import org.jclouds.rest.RestContext; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; +import com.google.common.reflect.TypeToken; /** * * @author Adrian Cole - * */ @Test(groups = "unit") -public class ComputeServiceContextFactoryTest { +public abstract class BaseRestApiMetadataTest extends BaseApiMetadataTest { + + @SuppressWarnings("rawtypes") + public BaseRestApiMetadataTest(RestApiMetadata toTest, ApiType type) { + super(toTest, type); + } @Test - public void testStandalone() { - @SuppressWarnings("rawtypes") - ComputeServiceContext context = new ComputeServiceContextFactory() - .createContext(new StandaloneComputeServiceContextSpec( - "stub", "stub", "1", "", "", "identity", "credential", ConcurrentMap.class, - StubComputeServiceContextBuilder.class, ImmutableSet. of())); - - context.getComputeService().listNodes(); + public void testContextAssignableFromRestContext() { + Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(RestContext.class))); + assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } -} + +} \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index b5b3d5ae84..8a9c196027 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -26,8 +26,6 @@ import static com.google.common.io.ByteStreams.newInputStreamSupplier; import static com.google.common.io.ByteStreams.toByteArray; import static com.google.common.io.Closeables.closeQuietly; import static javax.ws.rs.core.HttpHeaders.CONTENT_LENGTH; -import static org.jclouds.rest.RestContextFactory.contextSpec; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -55,9 +53,9 @@ import org.eclipse.jetty.util.ssl.SslContextFactory; import org.jclouds.Constants; import org.jclouds.crypto.CryptoStreams; import org.jclouds.io.InputSuppliers; +import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextBuilder; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.util.Strings2; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; @@ -173,7 +171,7 @@ public abstract class BaseJettyTest { Properties properties = new Properties(); addConnectionProperties(properties); - context = newBuilder(testPort, properties, createConnectionModule()).buildContext(); + context = newBuilder(testPort, properties, createConnectionModule()).build(); client = context.getApi(); assert client != null; @@ -282,14 +280,16 @@ public abstract class BaseJettyTest { return temp; } - public static RestContextBuilder newBuilder(int testPort, - Properties properties, Module... connectionModules) { + public static ContextBuilder, ?> newBuilder( + int testPort, Properties properties, Module... connectionModules) { properties.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - RestContextSpec contextSpec = contextSpec("test", - "http://localhost:" + testPort, "1", "", "", "identity", null, IntegrationTestClient.class, - IntegrationTestAsyncClient.class, ImmutableSet. copyOf(connectionModules)); - return createContextBuilder(contextSpec, properties); + return ContextBuilder + .newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, + "http://localhost:" + testPort)) + .modules(ImmutableSet. copyOf(connectionModules)) + .overrides(properties); } @AfterTest diff --git a/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java b/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java index 3e59269162..1eed674207 100644 --- a/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java @@ -26,8 +26,9 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.net.ssl.SSLException; -import org.jclouds.rest.BaseRestClientExpectTest; -import org.jclouds.rest.BaseRestClientExpectTest.RegisterContext; +import org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.base.Function; @@ -40,7 +41,6 @@ import com.google.common.base.Function; */ @Test(groups = "unit", testName = "IntegrationTestClientExpectTest") // only needed as IntegrationTestClient is not registered in rest.properties -@RegisterContext(sync = IntegrationTestClient.class, async = IntegrationTestAsyncClient.class) public class IntegrationTestClientExpectTest extends BaseRestClientExpectTest { public void testRetryOnSSLExceptionClose() { @@ -87,4 +87,9 @@ public class IntegrationTestClientExpectTest extends BaseRestClientExpectTest createProviderMetadata() { + return new JcloudsTestBlobStoreProviderMetadata(); + } } diff --git a/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java b/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java index 707ef581fd..db921672db 100644 --- a/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java +++ b/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java @@ -32,8 +32,8 @@ import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.BaseRestClientTest.MockModule; import org.jclouds.rest.config.RestModule; +import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java index 265079b3de..c04305de97 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java @@ -21,6 +21,10 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestBlobStoreApiMetadata; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -29,38 +33,46 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestBlobStoreProviderMetadata extends BaseProviderMetadata { +public class JcloudsTestBlobStoreProviderMetadata + extends + BaseProviderMetadata, JcloudsTestBlobStoreApiMetadata> { - public JcloudsTestBlobStoreProviderMetadata() { - this(builder() - .api(new JcloudsTestBlobStoreApiMetadata()) - .id("test-blobstore-api") - .name("Test Blobstore Provider") - .homepage(URI.create("http://jclouds.org")) - .console(URI.create("http://jclouds.org/console")) - .iso3166Codes(ImmutableSet.of("US-VA", "US-CA", "US-FL"))); + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromProviderMetadata(this)); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected JcloudsTestBlobStoreProviderMetadata(ConcreteBuilder builder) { + public JcloudsTestBlobStoreProviderMetadata() { + super(builder()); + } + + public JcloudsTestBlobStoreProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + public static class Builder + extends + BaseProviderMetadata.Builder, JcloudsTestBlobStoreApiMetadata> { + + protected Builder(){ + id("test-blobstore-api") + .name("Test Blobstore Provider") + .endpoint("http://mock") + .homepage(URI.create("http://jclouds.org")) + .console(URI.create("http://jclouds.org/console")) + .iso3166Codes(ImmutableSet.of("US-VA", "US-CA", "US-FL")) + .apiMetadata(new JcloudsTestBlobStoreApiMetadata()); + } @Override public JcloudsTestBlobStoreProviderMetadata build() { return new JcloudsTestBlobStoreProviderMetadata(this); } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java index c7abbe46ce..60fc513520 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java @@ -21,6 +21,10 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestComputeApiMetadata; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -29,38 +33,46 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestComputeProviderMetadata extends BaseProviderMetadata { - - public JcloudsTestComputeProviderMetadata() { - this(builder() - .api(new JcloudsTestComputeApiMetadata()) - .id("test-compute-api") - .name("Test Compute Provider") - .homepage(URI.create("http://jclouds.org")) - .console(URI.create("http://jclouds.org/console")) - .iso3166Codes(ImmutableSet.of("US-VA", "US-CA"))); +public class JcloudsTestComputeProviderMetadata + extends + BaseProviderMetadata, JcloudsTestComputeApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected JcloudsTestComputeProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromProviderMetadata(this)); + } + + public JcloudsTestComputeProviderMetadata() { + super(builder()); + } + + public JcloudsTestComputeProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + public static class Builder + extends + BaseProviderMetadata.Builder, JcloudsTestComputeApiMetadata> { + + protected Builder(){ + id("test-compute-api") + .name("Test Compute Provider") + .endpoint("mem2") + .homepage(URI.create("http://jclouds.org")) + .console(URI.create("http://jclouds.org/console")) + .iso3166Codes(ImmutableSet.of("US-VA", "US-CA")) + .apiMetadata(new JcloudsTestComputeApiMetadata()); + } @Override public JcloudsTestComputeProviderMetadata build() { return new JcloudsTestComputeProviderMetadata(this); } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java index 3297b35840..388ebc9cc1 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java @@ -21,6 +21,10 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestComputeApiMetadata; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -29,38 +33,46 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestYetAnotherComputeProviderMetadata extends BaseProviderMetadata { - - public JcloudsTestYetAnotherComputeProviderMetadata() { - this(builder() - .api(new JcloudsTestComputeApiMetadata()) - .id("test-yet-another-compute-provider") - .name("Test Yet Another Compute Provider") - .homepage(URI.create("http://jclouds.org")) - .console(URI.create("http://jclouds.org/console")) - .iso3166Codes(ImmutableSet.of("JP-13"))); +public class JcloudsTestYetAnotherComputeProviderMetadata + extends + BaseProviderMetadata, JcloudsTestComputeApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected JcloudsTestYetAnotherComputeProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromProviderMetadata(this)); + } + + public JcloudsTestYetAnotherComputeProviderMetadata() { + super(builder()); + } + + public JcloudsTestYetAnotherComputeProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + public static class Builder + extends + BaseProviderMetadata.Builder, JcloudsTestComputeApiMetadata> { + + protected Builder(){ + id("test-yet-another-compute-provider") + .name("Test Yet Another Compute Provider") + .endpoint("mem3") + .homepage(URI.create("http://jclouds.org")) + .console(URI.create("http://jclouds.org/console")) + .iso3166Codes(ImmutableSet.of("JP-13")) + .apiMetadata(new JcloudsTestComputeApiMetadata()); + } @Override public JcloudsTestYetAnotherComputeProviderMetadata build() { return new JcloudsTestYetAnotherComputeProviderMetadata(this); } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/providers/ProvidersTest.java b/core/src/test/java/org/jclouds/providers/ProvidersTest.java index 0edf5d158f..5f6f841d75 100644 --- a/core/src/test/java/org/jclouds/providers/ProvidersTest.java +++ b/core/src/test/java/org/jclouds/providers/ProvidersTest.java @@ -19,6 +19,7 @@ package org.jclouds.providers; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.fail; import java.util.NoSuchElementException; @@ -36,13 +37,13 @@ import com.google.common.collect.Iterables; @Test(groups = "unit", testName = "ProvidersTest") public class ProvidersTest { - private final ProviderMetadata testBlobstoreProvider = new JcloudsTestBlobStoreProviderMetadata(); - private final ProviderMetadata testComputeProvider = new JcloudsTestComputeProviderMetadata(); - private final ProviderMetadata testYetAnotherComputeProvider = new JcloudsTestYetAnotherComputeProviderMetadata(); + private final JcloudsTestBlobStoreProviderMetadata testBlobstoreProvider = new JcloudsTestBlobStoreProviderMetadata(); + private final JcloudsTestComputeProviderMetadata testComputeProvider = new JcloudsTestComputeProviderMetadata(); + private final JcloudsTestYetAnotherComputeProviderMetadata testYetAnotherComputeProvider = new JcloudsTestYetAnotherComputeProviderMetadata(); @Test public void testWithId() { - ProviderMetadata providerMetadata; + ProviderMetadata providerMetadata; try { providerMetadata = Providers.withId("fake-id"); @@ -54,19 +55,21 @@ public class ProvidersTest { providerMetadata = Providers.withId(testBlobstoreProvider.getId()); assertEquals(testBlobstoreProvider, providerMetadata); + assertNotEquals(testBlobstoreProvider, testComputeProvider); + assertNotEquals(testBlobstoreProvider, testYetAnotherComputeProvider); } @Test public void testOfType() { - Iterable providersMetadata = Providers.ofType(ApiType.BLOBSTORE); + Iterable> providersMetadata = Providers.ofType(ApiType.BLOBSTORE); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { assertEquals(testBlobstoreProvider, providerMetadata); } providersMetadata = Providers.ofType(ApiType.COMPUTE); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { if (providerMetadata.getName().equals(testComputeProvider.getName())) { assertEquals(testComputeProvider, providerMetadata); } else { @@ -79,35 +82,11 @@ public class ProvidersTest { assertEquals(false, providersMetadata.iterator().hasNext()); } - @Test - @Deprecated - public void testOfTypeDeprecated() { - Iterable providersMetadata = Providers.ofType(ProviderMetadata.BLOBSTORE_TYPE); - - for (ProviderMetadata providerMetadata : providersMetadata) { - assertEquals(testBlobstoreProvider, providerMetadata); - } - - providersMetadata = Providers.ofType(ProviderMetadata.COMPUTE_TYPE); - - for (ProviderMetadata providerMetadata : providersMetadata) { - if (providerMetadata.getName().equals(testComputeProvider.getName())) { - assertEquals(testComputeProvider, providerMetadata); - } else { - assertEquals(testYetAnotherComputeProvider, providerMetadata); - } - } - - providersMetadata = Providers.ofType("fake-type"); - - assertEquals(false, providersMetadata.iterator().hasNext()); - } - @Test public void testAll() { - Iterable providersMetadata = Providers.all(); + Iterable> providersMetadata = Providers.all(); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { if (providerMetadata.getName().equals(testBlobstoreProvider.getName())) { assertEquals(testBlobstoreProvider, providerMetadata); } else if (providerMetadata.getName().equals(testComputeProvider.getName())) { @@ -142,6 +121,7 @@ public class ProvidersTest { @Test public void testCollocatedWith() { // Test filtering by collocation alone + assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider)), 0); assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider)), 1); assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider)), 1); assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider)), 0); @@ -155,44 +135,4 @@ public class ProvidersTest { assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.BLOBSTORE)), 0); } - @Test - @Deprecated - public void testBoundedByIso3166CodeDeprecated() { - // Test filtering by ISO 3166 code alone - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA")), 2); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL")), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US")), 2); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP-13")), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP")), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE")), 0); - - // Test filtering by ISO 3166 code and type - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ProviderMetadata.BLOBSTORE_TYPE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ProviderMetadata.COMPUTE_TYPE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ProviderMetadata.BLOBSTORE_TYPE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ProviderMetadata.COMPUTE_TYPE)), 0); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ProviderMetadata.BLOBSTORE_TYPE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ProviderMetadata.COMPUTE_TYPE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ProviderMetadata.BLOBSTORE_TYPE)), 0); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ProviderMetadata.COMPUTE_TYPE)), 0); - } - - @Test - @Deprecated - public void testCollocatedWithDeprecated() { - // Test filtering by collocation alone - assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider)), 1); - assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider)), 1); - assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider)), 0); - - // Test filtering by collocation and type - assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ProviderMetadata.BLOBSTORE_TYPE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ProviderMetadata.COMPUTE_TYPE)), 1); - assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ProviderMetadata.COMPUTE_TYPE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ProviderMetadata.BLOBSTORE_TYPE)), 1); - assertEquals( - Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ProviderMetadata.COMPUTE_TYPE)), 0); - assertEquals( - Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ProviderMetadata.BLOBSTORE_TYPE)), 0); - } } diff --git a/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java b/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java similarity index 80% rename from core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java rename to core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java index 9c27af317f..23ba372edf 100644 --- a/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java +++ b/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.providers; +package org.jclouds.providers.internal; import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; @@ -25,16 +25,20 @@ import java.util.logging.Logger; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.Providers; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.common.reflect.TypeToken; /** * * @author Jeremy Whitlock */ @Test(groups = "unit") +@SuppressWarnings("rawtypes") public abstract class BaseProviderMetadataTest { private final ProviderMetadata toTest; @@ -49,34 +53,35 @@ public abstract class BaseProviderMetadataTest { @Test public void testWithId() { - ProviderMetadata providerMetadata = Providers.withId(toTest.getId()); + ProviderMetadata providerMetadata = Providers.withId(toTest.getId()); assertEquals(toTest, providerMetadata); assert providerMetadata.getLinkedServices().contains(toTest.getId()); } - + @Test public void testOfApiContains() { if (expectedApi == null) Logger.getAnonymousLogger().warning("please update your test class"); - ImmutableSet ofApi = ImmutableSet.copyOf(Providers.ofApi(expectedApi)); + ImmutableSet> ofApi = ImmutableSet.copyOf(Providers.apiMetadataAssignableFrom(TypeToken.of(expectedApi.getClass()))); assert ofApi.contains(toTest) : String.format("%s not found in %s", toTest, ofApi); } // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) @Test public void testOfTypeContains() { - ImmutableSet ofType = ImmutableSet.copyOf(Providers.ofType(expectedType)); + ImmutableSet> ofType = ImmutableSet.copyOf(Providers.ofType(expectedType)); assert ofType.contains(toTest) : String.format("%s not found in %s", toTest, ofType); } @Test public void testAllContains() { - ImmutableSet all = ImmutableSet.copyOf(Providers.all()); + ImmutableSet> all = ImmutableSet.copyOf(Providers.all()); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } @Test + @Deprecated public void testInRestProperties() { Iterable providers = org.jclouds.rest.Providers.getSupportedProviders(); assert Iterables.contains(providers, toTest.getId()) : providers; diff --git a/core/src/test/java/org/jclouds/rest/BaseRestClientLiveTest.java b/core/src/test/java/org/jclouds/rest/BaseRestClientLiveTest.java deleted file mode 100644 index 4df6e584b0..0000000000 --- a/core/src/test/java/org/jclouds/rest/BaseRestClientLiveTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rest; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Strings.emptyToNull; - -import java.util.Properties; - -import org.jclouds.Constants; -import org.testng.annotations.BeforeClass; - -/** - * - * @author Adrian Cole - */ -public abstract class BaseRestClientLiveTest { - protected String prefix = System.getProperty("user.name"); - - protected String provider; - protected String identity; - protected String credential; - protected String endpoint; - protected String apiVersion; - protected String buildVersion; - - protected Properties setupRestProperties() { - return RestContextFactory.getPropertiesFromResource("/rest.properties"); - } - - protected Properties setupProperties() { - - if (emptyToNull(provider) == null) - throw new NullPointerException("provider must not be null or empty:" + provider); - if (emptyToNull(identity) == null) - throw new NullPointerException("identity must not be null or empty:" + provider); - - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - - overrides.setProperty(provider + ".identity", identity); - - if (credential != null) - overrides.setProperty(provider + ".credential", credential); - if (endpoint != null) - overrides.setProperty(provider + ".endpoint", endpoint); - if (apiVersion != null) - overrides.setProperty(provider + ".api-version", apiVersion); - if (buildVersion != null) - overrides.setProperty(provider + ".build-version", buildVersion); - - return overrides; - } - - @BeforeClass - protected void setupCredentials() { - identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); - credential = System.getProperty("test." + provider + ".credential"); - endpoint = System.getProperty("test." + provider + ".endpoint"); - apiVersion = System.getProperty("test." + provider + ".api-version"); - buildVersion = System.getProperty("test." + provider + ".build-version"); - } - -} diff --git a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java index 108f14ff45..2fc944b0ab 100644 --- a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java +++ b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java @@ -18,9 +18,6 @@ */ package org.jclouds.rest; -import static org.jclouds.rest.RestContextFactory.contextSpec; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; - import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; @@ -33,6 +30,7 @@ import org.jclouds.http.IntegrationTestClient; import org.jclouds.predicates.validators.AllLowerCaseValidator; import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.TestException; import org.testng.annotations.BeforeClass; @@ -139,12 +137,10 @@ public class InputParamValidatorTest { @BeforeClass void setupFactory() { - - RestContextSpec contextSpec = contextSpec("test", - "http://localhost:9999", "1", "", "", "userFoo", null, IntegrationTestClient.class, - IntegrationTestAsyncClient.class); - - injector = createContextBuilder(contextSpec).buildInjector(); + injector = ContextBuilder + .newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, + "http://localhost:9999")).buildInjector(); } diff --git a/core/src/test/java/org/jclouds/rest/RestContextFactoryTest.java b/core/src/test/java/org/jclouds/rest/RestContextFactoryTest.java deleted file mode 100644 index 3dcfdd8ce5..0000000000 --- a/core/src/test/java/org/jclouds/rest/RestContextFactoryTest.java +++ /dev/null @@ -1,292 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rest; - -import static org.jclouds.rest.RestContextFactory.contextSpec; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; -import static org.testng.Assert.assertEquals; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.config.RestClientModule; -import org.testng.annotations.Test; - -import com.google.common.base.Charsets; -import com.google.common.collect.Iterables; -import com.google.common.io.Files; -import com.google.inject.AbstractModule; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class RestContextFactoryTest { - - private static final String provider = "test"; - - public void testBuilder() { - RestContextSpec contextSpec = contextSpec(provider, - "http://localhost", "1", "", "", "dummy", null, IntegrationTestClient.class, - IntegrationTestAsyncClient.class); - - createContextBuilder(contextSpec); - } - - public void testBuilderPropertiesWithIso3166() { - RestContextSpec contextSpec = contextSpec(provider, - "http://localhost", "1", "build-foo", "US-CA", "dummy", null, IntegrationTestClient.class, - IntegrationTestAsyncClient.class); - - Properties props = RestContextFactory.toProperties(contextSpec); - assertEquals(props.getProperty("test.endpoint"), "http://localhost"); - assertEquals(props.getProperty("test.api-version"), "1"); - assertEquals(props.getProperty("test.build-version"), "build-foo"); - assertEquals(props.getProperty("test.identity"), "dummy"); - assertEquals(props.getProperty("test.iso3166-codes"), "US-CA"); - assertEquals(props.getProperty("test.credential"), null); - assertEquals(props.getProperty("test.sync"), IntegrationTestClient.class.getName()); - assertEquals(props.getProperty("test.async"), IntegrationTestAsyncClient.class.getName()); - assertEquals(props.getProperty("test.propertiesbuilder"), null); - assertEquals(props.getProperty("test.contextbuilder"), null); - assertEquals(props.getProperty("test.modules"), null); - - new RestContextFactory().createContext(provider, props); - } - - public void testBuilderPropertiesWithCredential() { - RestContextSpec contextSpec = contextSpec(provider, - "http://localhost", "1", "build-foo", "", "dummy", "credential", IntegrationTestClient.class, - IntegrationTestAsyncClient.class); - - Properties props = RestContextFactory.toProperties(contextSpec); - assertEquals(props.getProperty("test.endpoint"), "http://localhost"); - assertEquals(props.getProperty("test.api-version"), "1"); - assertEquals(props.getProperty("test.build-version"), "build-foo"); - assertEquals(props.getProperty("test.identity"), "dummy"); - assertEquals(props.getProperty("test.credential"), "credential"); - assertEquals(props.getProperty("test.sync"), IntegrationTestClient.class.getName()); - assertEquals(props.getProperty("test.async"), IntegrationTestAsyncClient.class.getName()); - assertEquals(props.getProperty("test.propertiesbuilder"), null); - assertEquals(props.getProperty("test.contextbuilder"), null); - assertEquals(props.getProperty("test.modules"), null); - - new RestContextFactory().createContext(provider, props); - } - - @SuppressWarnings("unchecked") - public void testBuilderPropertiesWithContextBuilder() { - @SuppressWarnings("rawtypes") - RestContextSpec contextSpec = contextSpec(provider, - "http://localhost", "1", "build-foo", "", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class, - (Class) IntegrationTestContextBuilder.class, Collections.EMPTY_LIST); - - Properties props = RestContextFactory.toProperties(contextSpec); - assertEquals(props.getProperty("test.endpoint"), "http://localhost"); - assertEquals(props.getProperty("test.api-version"), "1"); - assertEquals(props.getProperty("test.build-version"), "build-foo"); - assertEquals(props.getProperty("test.identity"), "dummy"); - assertEquals(props.getProperty("test.credential"), null); - assertEquals(props.getProperty("test.sync"), null); - assertEquals(props.getProperty("test.async"), null); - assertEquals(props.getProperty("test.propertiesbuilder"), PropertiesBuilder.class.getName()); - assertEquals(props.getProperty("test.contextbuilder"), IntegrationTestContextBuilder.class.getName()); - assertEquals(props.getProperty("test.modules"), null); - - new RestContextFactory().createContext(provider, props); - } - - @SuppressWarnings("unchecked") - public void testBuilderPropertiesWithModule() { - @SuppressWarnings("rawtypes") - RestContextSpec contextSpec = contextSpec(provider, - "http://localhost", "1", "build-foo", "", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class, - (Class) IntegrationTestContextBuilder.class, Collections. singleton(new A())); - - Properties props = RestContextFactory.toProperties(contextSpec); - assertEquals(props.getProperty("test.endpoint"), "http://localhost"); - assertEquals(props.getProperty("test.api-version"), "1"); - assertEquals(props.getProperty("test.build-version"), "build-foo"); - assertEquals(props.getProperty("test.identity"), "dummy"); - assertEquals(props.getProperty("test.credential"), null); - assertEquals(props.getProperty("test.sync"), null); - assertEquals(props.getProperty("test.async"), null); - assertEquals(props.getProperty("test.propertiesbuilder"), PropertiesBuilder.class.getName()); - assertEquals(props.getProperty("test.contextbuilder"), IntegrationTestContextBuilder.class.getName()); - assertEquals(props.getProperty("test.modules"), "org.jclouds.rest.RestContextFactoryTest$A"); - - new RestContextFactory().createContext(provider, props); - } - - @SuppressWarnings("unchecked") - public void testBuilderPropertiesWithModules() { - @SuppressWarnings("rawtypes") - RestContextSpec contextSpec = contextSpec(provider, - "http://localhost", "1", "build-foo", "", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class, - (Class) IntegrationTestContextBuilder.class, Arrays. asList(new A(), new B())); - - Properties props = RestContextFactory.toProperties(contextSpec); - assertEquals(props.getProperty("test.endpoint"), "http://localhost"); - assertEquals(props.getProperty("test.api-version"), "1"); - assertEquals(props.getProperty("test.build-version"), "build-foo"); - assertEquals(props.getProperty("test.identity"), "dummy"); - assertEquals(props.getProperty("test.credential"), null); - assertEquals(props.getProperty("test.sync"), null); - assertEquals(props.getProperty("test.async"), null); - assertEquals(props.getProperty("test.propertiesbuilder"), PropertiesBuilder.class.getName()); - assertEquals(props.getProperty("test.contextbuilder"), IntegrationTestContextBuilder.class.getName()); - assertEquals(props.getProperty("test.modules"), - "org.jclouds.rest.RestContextFactoryTest$A,org.jclouds.rest.RestContextFactoryTest$B"); - - new RestContextFactory().createContext(provider, props); - } - - public void testBuilderPropertiesJCloudsScope() { - Properties props = new Properties(); - props.setProperty("test.endpoint", "http://localhost"); - props.setProperty("test.api-version", "1"); - props.setProperty("test.build-version", "build-foo"); - props.setProperty("test.iso3166-codes", "US"); - props.setProperty("jclouds.identity", "foo"); - props.setProperty("jclouds.credential", "bar"); - - props.setProperty("test.propertiesbuilder", PropertiesBuilder.class.getName()); - props.setProperty("test.contextbuilder", IntegrationTestContextBuilder.class.getName()); - props.setProperty("jclouds.modules", - "org.jclouds.rest.RestContextFactoryTest$A,org.jclouds.rest.RestContextFactoryTest$B"); - - new RestContextFactory() { - - @SuppressWarnings("hiding") - @Override - public RestContextSpec createContextSpec(String providerName, String identity, String credential, - Iterable wiring, Properties _overrides) { - RestContextSpec spec = super - .createContextSpec(providerName, identity, credential, wiring, _overrides); - assertEquals(spec.iso3166Codes, "US"); - assertEquals(spec.identity, "foo"); - assertEquals(spec.credential, "bar"); - assertEquals(spec.apiVersion, "1"); - assertEquals(spec.buildVersion, "build-foo"); - assertEquals(Iterables.size(spec.modules), 2); - return spec; - } - - }.createContext(provider, props); - } - - public void testBuilderPropertiesJCloudsScopeWithProviderIdentityAndFileCredential() throws IOException { - - File file = File.createTempFile("foo", "bar"); - file.deleteOnExit(); - Files.write("bar", file, Charsets.UTF_8); - Properties props = new Properties(); - props.setProperty("test.endpoint", "http://localhost"); - props.setProperty("test.api-version", "1"); - props.setProperty("test.build-version", "build-foo"); - props.setProperty("test.iso3166-codes", "US"); - props.setProperty("test.identity", "foo"); - props.setProperty("test.credential.file", file.getAbsolutePath()); - - props.setProperty("test.propertiesbuilder", PropertiesBuilder.class.getName()); - props.setProperty("test.contextbuilder", IntegrationTestContextBuilder.class.getName()); - props.setProperty("jclouds.modules", - "org.jclouds.rest.RestContextFactoryTest$A,org.jclouds.rest.RestContextFactoryTest$B"); - - new RestContextFactory() { - - @SuppressWarnings("hiding") - @Override - public RestContextSpec createContextSpec(String providerName, String identity, String credential, - Iterable wiring, Properties _overrides) { - RestContextSpec spec = super - .createContextSpec(providerName, identity, credential, wiring, _overrides); - assertEquals(spec.iso3166Codes, "US"); - assertEquals(spec.identity, "foo"); - assertEquals(spec.credential, "bar"); - assertEquals(spec.apiVersion, "1"); - assertEquals(spec.buildVersion, "build-foo"); - assertEquals(Iterables.size(spec.modules), 2); - return spec; - } - - }.createContext(provider, props); - } - - public static class A extends AbstractModule { - - @Override - protected void configure() { - - } - - } - - public static class B extends AbstractModule { - - @Override - protected void configure() { - - } - - } - - @SuppressWarnings("unchecked") - @Test(expectedExceptions = IllegalArgumentException.class) - public void testBuilderPropertiesWithWrongConfig() { - @SuppressWarnings( { "unused", "rawtypes" }) - RestContextSpec contextSpec = contextSpec(provider, - "http://localhost", "1", "build-foo", "", "dummy", null, (Class) null, (Class) null, - (Class) IntegrationTestContextBuilder.class, (Class) PropertiesBuilder.class, Collections.EMPTY_LIST); - } - - @RequiresHttp - @ConfiguresRestClient - public static class IntegrationTestRestClientModule extends - RestClientModule { - - public IntegrationTestRestClientModule() { - super(IntegrationTestClient.class, IntegrationTestAsyncClient.class); - } - - } - - public static class IntegrationTestContextBuilder extends - RestContextBuilder { - - public IntegrationTestContextBuilder(Properties props) { - super(IntegrationTestClient.class, IntegrationTestAsyncClient.class, props); - } - - protected void addClientModule(List modules) { - modules.add(new IntegrationTestRestClientModule()); - } - - } -} diff --git a/core/src/test/java/org/jclouds/rest/RestClientTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java similarity index 60% rename from core/src/test/java/org/jclouds/rest/RestClientTest.java rename to core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java index f8124e7c81..712785970a 100644 --- a/core/src/test/java/org/jclouds/rest/RestClientTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java @@ -16,23 +16,24 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest; +package org.jclouds.rest.internal; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; +import static com.google.common.base.Preconditions.checkNotNull; import java.io.IOException; import java.util.Properties; +import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientExpectTest.RegisterContext; -import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; +import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.TypeLiteral; @@ -42,7 +43,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ @Test(groups = "unit") -public abstract class RestClientTest extends BaseRestClientTest { +public abstract class BaseAsyncClientTest extends BaseRestClientTest { protected RestAnnotationProcessor processor; @@ -50,8 +51,6 @@ public abstract class RestClientTest extends BaseRestClientTest { protected abstract void checkFilters(HttpRequest request); - abstract public RestContextSpec createContextSpec(); - protected Module createModule() { return new Module() { @@ -65,21 +64,39 @@ public abstract class RestClientTest extends BaseRestClientTest { @BeforeClass protected void setupFactory() throws IOException { - RestContextSpec contextSpec = createContextSpec(); - - injector = createContextBuilder(contextSpec, - ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule()), setupProperties()) - .buildInjector(); + injector = createInjector(); parserFactory = injector.getInstance(ParseSax.Factory.class); processor = injector.getInstance(Key.get(createTypeLiteral())); } - + + protected String identity = "identity"; + protected String credential = "credential"; + /** - * override this when the provider or api is not located in rest.properties and you are not using - * the {@link RegisterContext} annotation on your tests. + * @see org.jclouds.providers.Providers#withId */ - protected Properties setupRestProperties() { - return RestContextFactory.getPropertiesFromResource("/rest.properties"); + protected ProviderMetadata createProviderMetadata() { + return null; + } + + /** + * @see org.jclouds.apis.Apis#withId + */ + protected ApiMetadata createApiMetadata() { + return null; + } + + protected Injector createInjector() { + ProviderMetadata pm = createProviderMetadata(); + + @SuppressWarnings("unchecked") + ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder + .newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(), + "either createApiMetadata or createProviderMetadata must be overridden"))); + + return builder.credentials(identity, credential) + .modules(ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule())) + .overrides(setupProperties()).buildInjector(); } /** diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java new file mode 100644 index 0000000000..f28aa0bd87 --- /dev/null +++ b/core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java @@ -0,0 +1,143 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.rest.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.Closeable; +import java.util.NoSuchElementException; +import java.util.Properties; +import java.util.logging.Logger; + +import org.jclouds.Constants; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.Apis; +import org.jclouds.logging.LoggingModules; +import org.jclouds.logging.config.LoggingModule; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.Providers; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; + +import com.google.common.collect.ImmutableSet; +import com.google.common.io.Closeables; +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + */ +public abstract class BaseContextLiveTest { + protected String prefix = System.getProperty("user.name"); + protected String provider; + + protected volatile C context; + + protected Properties setupProperties() { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + setIfTestSystemPropertyPresent(overrides, provider + ".identity"); + setIfTestSystemPropertyPresent(overrides, provider + ".credential"); + setIfTestSystemPropertyPresent(overrides, provider + ".endpoint"); + setIfTestSystemPropertyPresent(overrides, provider + ".api-version"); + setIfTestSystemPropertyPresent(overrides, provider + ".build-version"); + return overrides; + } + + protected String setIfTestSystemPropertyPresent(Properties overrides, String key) { + if (System.getProperties().containsKey("test." + key)) { + String val = System.getProperty("test." + key); + overrides.setProperty(key, val); + } + return null; + } + + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + initializeContext(); + } + + protected void initializeContext() { + if (context != null) + Closeables.closeQuietly(context); + context = createContext(setupProperties(), setupModules()); + } + + protected Iterable setupModules() { + return ImmutableSet. of(getLoggingModule()); + } + + protected LoggingModule getLoggingModule() { + return LoggingModules.firstOrJDKLoggingModule(); + } + + /** + * @see org.jclouds.providers.Providers#withId + */ + @SuppressWarnings("unchecked") + protected ProviderMetadata createProviderMetadata() { + try { + return (ProviderMetadata) Providers.withId(provider); + } catch (NoSuchElementException e) { + return null; + } + } + + /** + * @see org.jclouds.apis.Apis#withId + */ + @SuppressWarnings("unchecked") + protected ApiMetadata createApiMetadata() { + try { + return (ApiMetadata) Apis.withId(provider); + } catch (NoSuchElementException e) { + return null; + } + } + + protected C createContext(Properties props, Iterable modules) { + return newBuilder().modules(modules).overrides(props).build(); + } + + @SuppressWarnings("unchecked") + protected ContextBuilder newBuilder() { + if (provider != null) + try { + return (ContextBuilder) ContextBuilder.newBuilder(provider); + } catch (NoSuchElementException e){ + Logger.getAnonymousLogger() + .warning("provider [" + + provider + + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata"); + } + + ProviderMetadata pm = createProviderMetadata(); + + ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder + .newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(), + "either createApiMetadata or createProviderMetadata must be overridden"))); + return builder; + } + + @AfterClass(groups = { "integration", "live" }) + protected void tearDownContext() { + Closeables.closeQuietly(context); + } +} diff --git a/core/src/test/java/org/jclouds/rest/BaseRestClientExpectTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java similarity index 90% rename from core/src/test/java/org/jclouds/rest/BaseRestClientExpectTest.java rename to core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java index 24583c4931..21c0f2e7c7 100644 --- a/core/src/test/java/org/jclouds/rest/BaseRestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java @@ -16,24 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest; +package org.jclouds.rest.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import static org.jclouds.rest.RestContextFactory.contextSpec; -import static org.jclouds.rest.RestContextFactory.createContext; import static org.testng.Assert.assertEquals; import java.io.IOException; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Map.Entry; import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Logger; import javax.inject.Inject; import javax.inject.Named; @@ -46,6 +42,7 @@ import org.custommonkey.xmlunit.DifferenceListener; import org.custommonkey.xmlunit.NodeDetail; import org.custommonkey.xmlunit.XMLUnit; import org.jclouds.Constants; +import org.jclouds.apis.ApiMetadata; import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.SingleThreaded; import org.jclouds.concurrent.config.ConfiguresExecutorService; @@ -62,6 +59,7 @@ import org.jclouds.http.internal.HttpWire; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.logging.config.NullLoggingModule; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.util.Strings2; import org.testng.annotations.Test; import org.w3c.dom.Node; @@ -78,6 +76,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.google.inject.AbstractModule; import com.google.inject.Binder; +import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; @@ -109,16 +108,6 @@ import com.google.inject.name.Names; @Test(groups = "unit") @Beta public abstract class BaseRestClientExpectTest { - /** - * only needed when the client is simple and not registered fn rest.properties - */ - @Target(TYPE) - @Retention(RUNTIME) - public static @interface RegisterContext { - Class sync(); - - Class async(); - } protected String provider = "mock"; @@ -500,38 +489,64 @@ public abstract class BaseRestClientExpectTest { } + @SuppressWarnings("unchecked") public S createClient(Function fn, Module module, Properties props) { - RestContextSpec contextSpec = makeContextSpec(); - - return createContext(contextSpec, - ImmutableSet. of(new ExpectModule(fn), new NullLoggingModule(), module), props).getApi(); + return (S) createInjector(fn, module, props).getInstance(api); } protected String identity = "identity"; protected String credential = "credential"; - - private RestContextSpec makeContextSpec() { - if (getClass().isAnnotationPresent(RegisterContext.class)) - return (RestContextSpec) contextSpec(provider, "http://mock", "1", "", "", "userfoo", null, getClass() - .getAnnotation(RegisterContext.class).sync(), - getClass().getAnnotation(RegisterContext.class).async(), ImmutableSet. of()); - else - return new RestContextFactory(setupRestProperties()).createContextSpec(provider, identity, credential, - new Properties()); - } + protected Class api; /** - * override this when the provider or api is not located in rest.properties and you are not using - * the {@link RegisterContext} annotation on your tests. + * @see org.jclouds.providers.Providers#withId */ - protected Properties setupRestProperties() { - return RestContextFactory.getPropertiesFromResource("/rest.properties"); + protected ProviderMetadata createProviderMetadata() { + return null; } + + /** + * @see org.jclouds.apis.Apis#withId + */ + protected ApiMetadata createApiMetadata() { + return null; + } + + @SuppressWarnings("unchecked") + protected Injector createInjector(Function fn, Module module, Properties props) { + ContextBuilder builder = null; + if (provider != null) + try { + builder = ContextBuilder.newBuilder(provider).credentials(identity, credential); + } catch (NoSuchElementException e){ + Logger.getAnonymousLogger() + .warning("provider [" + + provider + + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata"); + } + if (builder == null){ + ProviderMetadata pm = createProviderMetadata(); + ApiMetadata am = (pm != null) ? pm.getApiMetadata() : checkNotNull(createApiMetadata(), + "either createApiMetadata or createProviderMetadata must be overridden"); + + builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder + .newBuilder(ApiMetadata.class.cast(am)); + } + + this.api = builder.getApiMetadata().getApi(); + + return builder.credentials(identity, credential) + .modules(ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), module)) + .overrides(setupProperties()).buildInjector(); + } + /** * override this to supply context-specific parameters during tests. */ protected Properties setupProperties() { - return new Properties(); + Properties props = new Properties(); + props.put(Constants.PROPERTY_MAX_RETRIES, 1); + return props; } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/rest/BaseRestClientTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientTest.java similarity index 99% rename from core/src/test/java/org/jclouds/rest/BaseRestClientTest.java rename to core/src/test/java/org/jclouds/rest/internal/BaseRestClientTest.java index b6033a6673..cdee2c240b 100644 --- a/core/src/test/java/org/jclouds/rest/BaseRestClientTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest; +package org.jclouds.rest.internal; import static com.google.common.base.Throwables.propagate; import static com.google.inject.util.Types.newParameterizedType; diff --git a/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java b/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java similarity index 74% rename from core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java rename to core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java index 113be8c1cb..a2f6145493 100644 --- a/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java @@ -16,23 +16,26 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest; +package org.jclouds.rest.internal; import static org.testng.Assert.assertEquals; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Properties; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.events.config.EventBusModule; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; import org.jclouds.http.RequiresHttp; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.config.LoggingModule; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.CredentialStoreModule; import org.testng.annotations.Test; @@ -41,12 +44,12 @@ import com.google.inject.Binder; import com.google.inject.Module; /** - * Tests behavior of modules configured in RestContextBuilder + * Tests behavior of modules configured in ContextBuilder * * @author Adrian Cole */ -@Test(groups = "unit") -public class RestContextBuilderTest { +@Test(groups = "unit", testName="ContextBuilderTest") +public class ContextBuilderTest { @ConfiguresHttpCommandExecutorService static class HttpModule extends AbstractModule { @@ -57,13 +60,17 @@ public class RestContextBuilderTest { } } + private ContextBuilder testContextBuilder() { + return ContextBuilder.newBuilder(AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost")); + } + @Test public void testAddHttpModuleIfNotPresent() { List modules = new ArrayList(); HttpModule module = new HttpModule(); modules.add(module); - new RestContextBuilder(String.class, String.class, new Properties()) - .addHttpModuleIfNeededAndNotPresent(modules); + testContextBuilder().addHttpModuleIfNeededAndNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -73,8 +80,7 @@ public class RestContextBuilderTest { List modules = new ArrayList(); LoggingModule module = new NullLoggingModule(); modules.add(module); - new RestContextBuilder(String.class, String.class, new Properties()) - .addLoggingModuleIfNotPresent(modules); + testContextBuilder().addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -84,8 +90,7 @@ public class RestContextBuilderTest { List modules = new ArrayList(); EventBusModule module = new EventBusModule(); modules.add(module); - new RestContextBuilder(String.class, String.class, new Properties()) - .addEventBusIfNotPresent(modules); + testContextBuilder().addEventBusIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -95,8 +100,7 @@ public class RestContextBuilderTest { List modules = new ArrayList(); ExecutorServiceModule module = new ExecutorServiceModule(); modules.add(module); - new RestContextBuilder(String.class, String.class, new Properties()) - .addExecutorServiceIfNotPresent(modules); + testContextBuilder().addExecutorServiceIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -106,8 +110,7 @@ public class RestContextBuilderTest { List modules = new ArrayList(); CredentialStoreModule module = new CredentialStoreModule(); modules.add(module); - new RestContextBuilder(String.class, String.class, new Properties()) - .addCredentialStoreIfNotPresent(modules); + testContextBuilder().addCredentialStoreIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -119,8 +122,7 @@ public class RestContextBuilderTest { modules.add(loggingModule); HttpModule httpModule = new HttpModule(); modules.add(httpModule); - RestContextBuilder builder = new RestContextBuilder(String.class, String.class, - new Properties()); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); @@ -131,18 +133,17 @@ public class RestContextBuilderTest { @Test public void testAddBothWhenDoesntRequireHttp() { List modules = new ArrayList(); - modules.add(new ConfiguresRestClientModule()); - RestContextBuilder builder = new RestContextBuilder(String.class, String.class, - new Properties()); + modules.add(new ConfiguresClientModule()); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); - assert modules.remove(0) instanceof ConfiguresRestClientModule; + assert modules.remove(0) instanceof ConfiguresClientModule; assert modules.remove(0) instanceof JDKLoggingModule; } @ConfiguresRestClient - static class ConfiguresRestClientModule implements Module { + static class ConfiguresClientModule implements Module { public void configure(Binder arg0) { } @@ -152,8 +153,7 @@ public class RestContextBuilderTest { @Test public void testAddBothWhenDefault() { List modules = new ArrayList(); - RestContextBuilder builder = new RestContextBuilder(String.class, String.class, - new Properties()); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); @@ -173,8 +173,7 @@ public class RestContextBuilderTest { public void testAddBothWhenLive() { List modules = new ArrayList(); modules.add(new RequiresHttpModule()); - RestContextBuilder builder = new RestContextBuilder(String.class, String.class, - new Properties()); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 3); @@ -197,9 +196,8 @@ public class RestContextBuilderTest { protected void configure() { } }; - RestContextBuilder builder = new RestContextBuilder(String.class, String.class, - new Properties()); - builder.withModules(Arrays.asList(module1, module2)); + ContextBuilder builder = testContextBuilder(); + builder.modules(Arrays.asList(module1, module2)); } } diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index 52745c9e10..9432d41ef4 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.io.Payloads.calculateMD5; import static org.jclouds.io.Payloads.newInputStreamPayload; import static org.jclouds.io.Payloads.newStringPayload; -import static org.jclouds.rest.RestContextFactory.contextSpec; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; @@ -102,12 +100,11 @@ import org.jclouds.io.PayloadEnclosing; import org.jclouds.io.Payloads; import org.jclouds.javax.annotation.Nullable; import org.jclouds.logging.config.NullLoggingModule; +import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.AsyncClientFactory; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.BaseRestClientTest; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.InvocationContext; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Endpoint; @@ -422,21 +419,13 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { } private Injector injectorForCaller(HttpCommandExecutorService service, Module... modules) { - - RestContextSpec contextSpec = contextSpec( - "test", - "http://localhost:9999", - "1", - "", - "", - "userfoo", - null, - Caller.class, - AsyncCaller.class, - ImmutableSet. builder().add(new MockModule(service)).add(new NullLoggingModule()) - .add(new CallerModule()).addAll(ImmutableSet. copyOf(modules)).build()); - - return createContextBuilder(contextSpec).buildInjector(); + return ContextBuilder + .newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(Caller.class, AsyncCaller.class, + "http://localhost:9999")) + .modules( + ImmutableSet. builder().add(new MockModule(service)).add(new NullLoggingModule()) + .add(new CallerModule()).addAll(ImmutableSet. copyOf(modules)).build()).buildInjector(); } @@ -2543,9 +2532,11 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @BeforeClass void setupFactory() { - RestContextSpec contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "", - "userfoo", null, Callee.class, AsyncCallee.class, - ImmutableSet. of(new MockModule(), new NullLoggingModule(), new AbstractModule() { + injector = ContextBuilder + .newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(Callee.class, AsyncCallee.class, + "http://localhost:9999")) + .modules(ImmutableSet. of(new MockModule(), new NullLoggingModule(), new AbstractModule() { @Override protected void configure() { @@ -2565,9 +2556,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { throw new AuthorizationException(); } - })); - - injector = createContextBuilder(contextSpec).buildInjector(); + })).buildInjector(); parserFactory = injector.getInstance(ParseSax.Factory.class); crypto = injector.getInstance(Crypto.class); } diff --git a/core/src/test/java/org/jclouds/util/ProvidersTest.java b/core/src/test/java/org/jclouds/util/ProvidersTest.java index 07866964bf..81ee659d3f 100644 --- a/core/src/test/java/org/jclouds/util/ProvidersTest.java +++ b/core/src/test/java/org/jclouds/util/ProvidersTest.java @@ -20,7 +20,6 @@ package org.jclouds.util; import static org.testng.Assert.assertEquals; -import org.jclouds.rest.Providers; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -34,8 +33,9 @@ public class ProvidersTest { @Test public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assertEquals(Sets.newLinkedHashSet(providers), ImmutableSet. of()); + Iterable providers = org.jclouds.rest.Providers.getSupportedProviders(); + assertEquals(Sets.newLinkedHashSet(providers), ImmutableSet. of("test-blobstore-api", "test-compute-api", + "test-yet-another-compute-api", "test-yet-another-compute-provider")); } } diff --git a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java deleted file mode 100644 index f22894ab4e..0000000000 --- a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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 static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; -import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; -import static org.jclouds.aws.domain.Region.EU_WEST_1; -import static org.jclouds.aws.domain.Region.SA_EAST_1; -import static org.jclouds.aws.domain.Region.US_EAST_1; -import static org.jclouds.aws.domain.Region.US_WEST_1; -import static org.jclouds.aws.domain.Region.US_WEST_2; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; - -import java.util.Properties; - -import org.jclouds.aws.domain.Region; -import org.jclouds.elb.ELBAsyncClient; -import org.jclouds.elb.ELBPropertiesBuilder; - -/** - * Builds properties used in ELB Clients - * - * @author Adrian Cole - */ -public class AWSELBPropertiesBuilder extends ELBPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.putAll(Region.regionProperties()); - properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION); - properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", - "https://elasticloadbalancing.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint", - "https://elasticloadbalancing.us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_2 + ".endpoint", - "https://elasticloadbalancing.us-west-2.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + SA_EAST_1 + ".endpoint", - "https://elasticloadbalancing.sa-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint", - "https://elasticloadbalancing.eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint", - "https://elasticloadbalancing.ap-southeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint", - "https://elasticloadbalancing.ap-northeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); - return properties; - } - - public AWSELBPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java index 1c33e610a5..7878225240 100644 --- a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java +++ b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java @@ -18,10 +18,26 @@ */ package org.jclouds.aws.elb; -import java.net.URI; +import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; +import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; +import static org.jclouds.aws.domain.Region.EU_WEST_1; +import static org.jclouds.aws.domain.Region.SA_EAST_1; +import static org.jclouds.aws.domain.Region.US_EAST_1; +import static org.jclouds.aws.domain.Region.US_WEST_1; +import static org.jclouds.aws.domain.Region.US_WEST_2; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.aws.domain.Region; import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elb.ELBAsyncClient; +import org.jclouds.elb.ELBClient; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing @@ -29,40 +45,65 @@ import org.jclouds.providers.BaseProviderMetadata; * * @author Adrian Cole */ -public class AWSELBProviderMetadata extends BaseProviderMetadata { - - public AWSELBProviderMetadata() { - this(builder() - .id("aws-elb") - .name("Amazon Elastic Load Balancing") - .api(new ELBApiMetadata()) - .homepage(URI.create("http://aws.amazon.com/elasticloadbalancing")) - .console(URI.create("https://console.aws.amazon.com/ec2/home")) - .linkedServices("aws-ec2","aws-elb", "aws-elb", "aws-s3", "aws-simpledb") - .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13")); +public class AWSELBProviderMetadata extends BaseProviderMetadata, ELBApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AWSELBProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromProviderMetadata(this)); + } + + public AWSELBProviderMetadata() { + super(builder()); + } + + public AWSELBProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.putAll(Region.regionProperties()); + properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", + "https://elasticloadbalancing.us-east-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint", + "https://elasticloadbalancing.us-west-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + US_WEST_2 + ".endpoint", + "https://elasticloadbalancing.us-west-2.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + SA_EAST_1 + ".endpoint", + "https://elasticloadbalancing.sa-east-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint", + "https://elasticloadbalancing.eu-west-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint", + "https://elasticloadbalancing.ap-southeast-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint", + "https://elasticloadbalancing.ap-northeast-1.amazonaws.com"); + properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, ELBApiMetadata> { + + protected Builder(){ + id("aws-elb") + .name("Amazon Elastic Load Balancing") + .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com") + .homepage(URI.create("http://aws.amazon.com/elasticloadbalancing")) + .console(URI.create("https://console.aws.amazon.com/ec2/home")) + .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") + .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13") + .apiMetadata(new ELBApiMetadata()) + .defaultProperties(AWSELBProviderMetadata.defaultProperties()); + } @Override - public AWSELBProviderMetadata build() { - return new AWSELBProviderMetadata(this); + public Builder fromProviderMetadata( + ProviderMetadata, ELBApiMetadata> in) { + super.fromProviderMetadata(in); + return this; } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - } \ No newline at end of file diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java index 283c816719..d7d92addb9 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java @@ -24,6 +24,7 @@ import java.lang.reflect.Method; import org.jclouds.aws.domain.Region; import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBAsyncClientTest; +import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -35,15 +36,16 @@ import org.testng.annotations.Test; @Test(groups = "unit", testName = "AWSELBAsyncClientTest") public class AWSELBAsyncClientTest extends ELBAsyncClientTest { - public AWSELBAsyncClientTest() { - this.provider = "aws-elb"; - } - public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { Method method = ELBAsyncClient.class.getMethod("describeLoadBalancersInRegion", String.class, String[].class); for (String region : Region.DEFAULT_REGIONS) { processor.createRequest(method, region); } } + + @Override + public ProviderMetadata createProviderMetadata() { + return new AWSELBProviderMetadata(); + } } diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java index 25bc4e26af..29172ff5e9 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java @@ -19,6 +19,8 @@ package org.jclouds.aws.elb; import org.jclouds.aws.domain.Region; +import org.jclouds.elb.ELBAsyncClient; +import org.jclouds.elb.ELBClient; import org.jclouds.elb.ELBClientLiveTest; import org.testng.annotations.Test; @@ -28,7 +30,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AWSELBClientLiveTest") -public class AWSELBClientLiveTest extends ELBClientLiveTest { +public class AWSELBClientLiveTest extends ELBClientLiveTest { public AWSELBClientLiveTest() { provider = "aws-elb"; } diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java index 7c56d557ac..13a922b5d6 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java @@ -19,7 +19,9 @@ package org.jclouds.aws.elb; import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.elb.ELBAsyncClient; +import org.jclouds.elb.ELBClient; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** @@ -31,6 +33,6 @@ import org.testng.annotations.Test; public class AWSELBProviderTest extends BaseProviderMetadataTest { public AWSELBProviderTest() { - super(new AWSELBProviderMetadata(), new ELBApiMetadata()); + super(new AWSELBProviderMetadata(), new ELBApiMetadata()); } } \ No newline at end of file diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java index e758e4b40c..690cfec465 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.aws.elb.config; +import org.jclouds.elb.ELBAsyncClient; +import org.jclouds.elb.ELBClient; import org.jclouds.elb.loadbalancer.ELBLoadBalancerServiceLiveTest; import org.testng.annotations.Test; @@ -25,8 +27,8 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true, testName = "AWSELBLoadBalancerServiceLiveTest") -public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiveTest { +@Test(groups = "live", singleThreaded = true, testName = "AWSELBLoadBalancerServiceLiveTest") +public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiveTest { public AWSELBLoadBalancerServiceLiveTest() { provider = "aws-elb"; diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java index 39a3fd86ce..59fc2c56b9 100644 --- a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java +++ b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java @@ -19,11 +19,14 @@ package org.jclouds.carrenza.vcloud.director; import java.util.List; -import java.util.Properties; -import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorComputeServiceContextModule; import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorRestClientModule; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; import org.jclouds.vcloud.director.v1_5.VCloudDirectorContextBuilder; +import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; +import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import com.google.inject.Module; @@ -34,8 +37,13 @@ import com.google.inject.Module; */ public class CarrenzaVCloudDirectorContextBuilder extends VCloudDirectorContextBuilder { - public CarrenzaVCloudDirectorContextBuilder(Properties props) { - super(props); + public CarrenzaVCloudDirectorContextBuilder( + ProviderMetadata providerMetadata) { + super(providerMetadata); + } + + public CarrenzaVCloudDirectorContextBuilder(VCloudDirectorApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorPropertiesBuilder.java b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorPropertiesBuilder.java deleted file mode 100644 index 80a81e275a..0000000000 --- a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorPropertiesBuilder.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.carrenza.vcloud.director; - -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.vcloud.director.v1_5.VCloudDirectorPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class CarrenzaVCloudDirectorPropertiesBuilder extends VCloudDirectorPropertiesBuilder { - @Override - public Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "GB-LND"); - properties.setProperty(PROPERTY_ENDPOINT, "https://myvdc.carrenza.net/api"); - properties.setProperty(PROPERTY_BUILD_VERSION, "???"); //FIXME -// properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); FIXME: needed? - return properties; - } - - public CarrenzaVCloudDirectorPropertiesBuilder(Properties properties) { - super(properties); - } -} diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java index 0d28b88cfb..3c75135bd4 100644 --- a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java +++ b/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java @@ -18,49 +18,78 @@ */ package org.jclouds.carrenza.vcloud.director; -import java.net.URI; +import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; +import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; +import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Carrenza vCloud Director + * Implementation of {@link org.jclouds.types.ProviderMetadata} for StratoGen VMware hosting * - * @author dankov + * @author Adrian Cole */ -public class CarrenzaVCloudDirectorProviderMetadata extends BaseProviderMetadata { +public class CarrenzaVCloudDirectorProviderMetadata + extends + BaseProviderMetadata { - public CarrenzaVCloudDirectorProviderMetadata() { - this(builder() - .id("carrenza-vcloud-director") - .name("Carrenza vCloud Director") - .api(new VCloudDirectorApiMetadata()) - .homepage(URI.create("http://carrenza.com/")) - .console(URI.create("https://myvdc.carrenza.net/cloud/org/YOUR_ORG_HERE")) - .iso3166Codes("GB-LND")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CarrenzaVCloudDirectorProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CarrenzaVCloudDirectorProviderMetadata() { + super(builder()); + } + + public CarrenzaVCloudDirectorProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_BUILD_VERSION, "???"); //FIXME +// properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); FIXME: needed? + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder(){ + id("carrenza-vcloud-director") + .name("Carrenza vCloud Director") + .apiMetadata(new VCloudDirectorApiMetadata().toBuilder() + .buildVersion("1.5.0.464915") + .contextBuilder(TypeToken.of(CarrenzaVCloudDirectorContextBuilder.class)).build()) + .homepage(URI.create("http://carrenza.com/")) + .console(URI.create("https://myvdc.carrenza.net/cloud/org/YOUR_ORG_HERE")) + .iso3166Codes("GB-LND") + .endpoint("https://myvdc.carrenza.net/api") + .defaultProperties(CarrenzaVCloudDirectorProviderMetadata.defaultProperties()); + } @Override public CarrenzaVCloudDirectorProviderMetadata build() { return new CarrenzaVCloudDirectorProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - -} +} \ No newline at end of file diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java index d9468075ba..c1054103e3 100644 --- a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.carrenza.vcloud.director; -import org.jclouds.vcloud.director.v1_5.NonClientOperationsLiveTest; +import org.jclouds.vcloud.director.v1_5.HttpClientLiveTest; import org.testng.annotations.Test; /** @@ -27,7 +27,7 @@ import org.testng.annotations.Test; * @author danikov */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorNonClientOperationsLiveTest") -public class CarrenzaVCloudDirectorNonClientOperationsLiveTest extends NonClientOperationsLiveTest { +public class CarrenzaVCloudDirectorNonClientOperationsLiveTest extends HttpClientLiveTest { public CarrenzaVCloudDirectorNonClientOperationsLiveTest() { provider = "carrenza-vcloud-director"; diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java index d5774cb7e6..ed936665da 100644 --- a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.carrenza.vcloud.director; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; import org.testng.annotations.Test; diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java index 5295f9f3ea..dea42c7a04 100644 --- a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java +++ b/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java @@ -18,60 +18,48 @@ */ package org.jclouds.carrenza.vcloud.director.compute; -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Set; - -import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; - /** * * @author danikov */ @Test(groups = "live", testName = "CarrenzaVCloudDirectorTemplateBuilderLiveTest") -public class CarrenzaVCloudDirectorTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - public CarrenzaVCloudDirectorTemplateBuilderLiveTest() { - provider = "carrenza-vcloud-director"; - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { - - @Override - public boolean apply(OsFamilyVersion64Bit input) { - switch (input.family) { - case UBUNTU: - return !input.version.equals("") || !input.is64Bit; - default: - return true; - } - } - - }; - } - - @Override - public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("GB-LND"); - } +public class CarrenzaVCloudDirectorTemplateBuilderLiveTest { +// BaseTemplateBuilderLiveTest { +// +// public CarrenzaVCloudDirectorTemplateBuilderLiveTest() { +// provider = "carrenza-vcloud-director"; +// } +// +// @Override +// protected Predicate defineUnsupportedOperatingSystems() { +// return new Predicate() { +// +// @Override +// public boolean apply(OsFamilyVersion64Bit input) { +// switch (input.family) { +// case UBUNTU: +// return !input.version.equals("") || !input.is64Bit; +// default: +// return true; +// } +// } +// +// }; +// } +// +// @Override +// public void testDefaultTemplateBuilder() throws IOException { +// Template defaultTemplate = context.getComputeService().templateBuilder().build(); +// assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); +// assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); +// assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); +// assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); +// } +// +// @Override +// protected Set getIso3166Codes() { +// return ImmutableSet. of("GB-LND"); +// } } diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java index f0397a41a3..c0c9df2ecf 100644 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java +++ b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java @@ -18,50 +18,84 @@ */ package org.jclouds.elb; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for Amazon's Elastic Load Balancing api. + *

    note

    + *

    + * This class allows overriding of types {@code S}(client) and {@code A}(asyncClient), so that + * children can add additional methods not declared here, such as new features + * from AWS. + *

    + * + * This class is not setup to allow a different context than {@link LoadBalancerServiceContext} + * . By doing so, it reduces the type complexity. * * @author Adrian Cole */ -public class ELBApiMetadata extends BaseApiMetadata { +public class ELBApiMetadata extends + BaseLoadBalancerServiceApiMetadata, ELBApiMetadata> { + + @Override + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + } public ELBApiMetadata() { - this(builder() - .id("elb") - .type(ApiType.LOADBALANCER) - .name("Amazon Elastic Load Balancing Api") - .identityName("Access Key ID") - .credentialName("Secret Access Key") - .documentation(URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference"))); + this(new Builder(ELBClient.class, ELBAsyncClient.class)); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected ELBApiMetadata(ConcreteBuilder builder) { + protected ELBApiMetadata(Builder builder) { super(builder); } + + protected static Properties defaultProperties() { + Properties properties = BaseApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); + properties.setProperty(PROPERTY_HEADER_TAG, "amz"); + return properties; + } + + public static class Builder extends + BaseLoadBalancerServiceApiMetadata.Builder, ELBApiMetadata> { - private static class ConcreteBuilder extends Builder { + protected Builder(Class client, Class asyncClient) { + id("elb") + .name("Amazon Elastic Load Balancing Api") + .identityName("Access Key ID") + .credentialName("Secret Access Key") + .version(ELBAsyncClient.VERSION) + .defaultProperties(ELBApiMetadata.defaultProperties()) + .defaultEndpoint("https://elasticloadbalancing.us-east-1.amazonaws.com") + .documentation(URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference")) + .javaApi(client, asyncClient) + .contextBuilder(new TypeToken>(getClass()){ + private static final long serialVersionUID = 1L; + }); + } @Override - public ELBApiMetadata build() { - return new ELBApiMetadata(this); + public ELBApiMetadata build() { + return new ELBApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(ELBApiMetadata in) { + super.fromApiMetadata(in); + return this; } } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java b/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java index c8b6fdf7cf..256bd88f51 100644 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java +++ b/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java @@ -19,13 +19,14 @@ package org.jclouds.elb; import java.util.List; -import java.util.Properties; import org.jclouds.elb.config.ELBRestClientModule; import org.jclouds.elb.loadbalancer.config.ELBLoadBalancerContextModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Injector; import com.google.inject.Module; @@ -43,17 +44,22 @@ import com.google.inject.Module; * @author Adrian Cole * @see ELBContext */ -public class ELBContextBuilder extends LoadBalancerServiceContextBuilder { +public class ELBContextBuilder extends + LoadBalancerServiceContextBuilder, ELBApiMetadata> { + public ELBContextBuilder(ProviderMetadata, ELBApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public ELBContextBuilder(ELBApiMetadata apiMetadata) { + super(apiMetadata); + } + @Override protected void addContextModule(List modules) { modules.add(new ELBLoadBalancerContextModule()); } - public ELBContextBuilder(Properties props) { - super(ELBClient.class, ELBAsyncClient.class, props); - } - @Override protected void addClientModule(List modules) { modules.add(new ELBRestClientModule()); diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java index 011d2017a1..feb103b5b5 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.elb; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,10 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "ELBApiMetadataTest") -public class ELBApiMetadataTest extends BaseApiMetadataTest { +public class ELBApiMetadataTest extends BaseLoadBalancerServiceApiMetadataTest { + @SuppressWarnings("rawtypes") public ELBApiMetadataTest() { - super(new ELBApiMetadata(), ApiType.LOADBALANCER); + super(new ELBApiMetadata()); } } diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java index bf3fe21c41..dcb425dcb2 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java @@ -22,11 +22,11 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; -import java.util.Properties; import javax.inject.Named; import org.jclouds.Constants; +import org.jclouds.apis.ApiMetadata; import org.jclouds.aws.filters.FormSigner; import org.jclouds.date.DateService; import org.jclouds.elb.config.ELBRestClientModule; @@ -38,11 +38,9 @@ import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -56,7 +54,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "ELBAsyncClientTest") -public class ELBAsyncClientTest extends RestClientTest { +public class ELBAsyncClientTest extends BaseAsyncClientTest { public void testCreateLoadBalancerInRegion() throws SecurityException, NoSuchMethodException, IOException { Method method = ELBAsyncClient.class.getMethod("createLoadBalancerInRegion", String.class, String.class, @@ -176,14 +174,10 @@ public class ELBAsyncClientTest extends RestClientTest { protected Module createModule() { return new TestELBRestClientModule(); } - - protected String provider = "elb"; - - + @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "identity", "credential", - new Properties()); + public ApiMetadata createApiMetadata() { + return new ELBApiMetadata(); } @Override diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java index 24b963ca62..4ac5556e31 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java @@ -21,45 +21,35 @@ package org.jclouds.elb; import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertNotNull; -import java.util.Properties; import java.util.Set; import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.loadbalancer.LoadBalancerServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.BaseRestClientLiveTest; -import org.jclouds.rest.RestContext; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.rest.internal.BaseContextLiveTest; import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code ELBClient} * * @author Lili Nader */ @Test(groups = "live", singleThreaded = true, testName = "ELBClientLiveTest") -public class ELBClientLiveTest extends BaseRestClientLiveTest { +public class ELBClientLiveTest extends BaseContextLiveTest> { public ELBClientLiveTest() { provider = "elb"; } private ELBClient client; - private RestContext context; - protected String name = "TestLoadBalancer"; - @BeforeGroups(groups = "live") - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new LoadBalancerServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - client = context.getApi(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi(); } @Test diff --git a/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java index f218ca619f..4ef29b2ae8 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java @@ -29,6 +29,7 @@ import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBClient; import org.jclouds.elb.domain.LoadBalancer; import org.jclouds.loadbalancer.BaseLoadBalancerServiceLiveTest; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -38,7 +39,7 @@ import org.testng.annotations.Test; * @author Lili Nadar */ @Test(groups = "live", singleThreaded = true, testName = "ELBLoadBalancerServiceLiveTest") -public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest { +public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest> { public ELBLoadBalancerServiceLiveTest() { provider = "elb"; @@ -52,7 +53,7 @@ public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveT @Override protected void validateNodesInLoadBalancer() { - RestContext elbContext = context.getProviderSpecificContext(); + RestContext elbContext = context.getProviderSpecificContext(); // TODO create a LoadBalancer object and an appropriate list method so that this // does not have to be EC2 specific code ELBClient elbClient = elbContext.getApi(); diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java index be731d4992..bc06dbaf60 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java @@ -19,50 +19,71 @@ package org.jclouds.glesys; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for GleSYS API + * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class GleSYSApiMetadata extends BaseApiMetadata { +public class GleSYSApiMetadata + extends + BaseComputeServiceApiMetadata, GleSYSApiMetadata> { - public GleSYSApiMetadata() { - this(builder() - .id("glesys") - .type(ApiType.COMPUTE) - .name("GleSYS API") - .identityName("Username") - .credentialName("API Key") - .documentation(URI.create("https://customer.glesys.com/api.php"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected GleSYSApiMetadata(Builder builder) { + public GleSYSApiMetadata() { + this(new Builder()); + } + + protected GleSYSApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty("jclouds.ssh.max-retries", "5"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, GleSYSApiMetadata> { + + protected Builder() { + id("glesys") + .name("GleSYS API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("https://customer.glesys.com/api.php")) + .version("1") + .defaultEndpoint("https://api.glesys.com") + .defaultProperties(GleSYSApiMetadata.defaultProperties()) + .javaApi(GleSYSClient.class, GleSYSAsyncClient.class) + .contextBuilder(TypeToken.of(GleSYSContextBuilder.class)); + } @Override public GleSYSApiMetadata build() { return new GleSYSApiMetadata(this); } + + @Override + public Builder fromApiMetadata(GleSYSApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - -} \ No newline at end of file +} diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java index 1b093e8388..0f648dfe63 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java @@ -19,11 +19,12 @@ package org.jclouds.glesys; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.glesys.compute.config.GleSYSComputeServiceContextModule; import org.jclouds.glesys.config.GleSYSRestClientModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -31,10 +32,17 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class GleSYSContextBuilder extends ComputeServiceContextBuilder { +public class GleSYSContextBuilder + extends + ComputeServiceContextBuilder, GleSYSApiMetadata> { - public GleSYSContextBuilder(Properties props) { - super(GleSYSClient.class, GleSYSAsyncClient.class, props); + public GleSYSContextBuilder( + ProviderMetadata, GleSYSApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public GleSYSContextBuilder(GleSYSApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -42,7 +50,6 @@ public class GleSYSContextBuilder extends ComputeServiceContextBuilder modules) { modules.add(new GleSYSRestClientModule()); } diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSPropertiesBuilder.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSPropertiesBuilder.java deleted file mode 100644 index 31019e1973..0000000000 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSPropertiesBuilder.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.glesys; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.glesys.reference.GleSYSConstants.PROPERTY_GLESYS_DEFAULT_DC; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in GleSYS Clients - * - * @author Adrian Cole - * @author Adam Lowe - */ -public class GleSYSPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.glesys.com"); - properties.setProperty(PROPERTY_API_VERSION, "1"); - properties.setProperty(PROPERTY_ZONES, "Amsterdam,Falkenberg,New York City,Stockholm"); - properties.setProperty(PROPERTY_ISO3166_CODES, "NL-NH,SE-N,US-NY,SE-AB"); - properties.setProperty(PROPERTY_ZONE + ".Amsterdam." + ISO3166_CODES, "NL-NH"); - properties.setProperty(PROPERTY_ZONE + ".Falkenberg." + ISO3166_CODES, "SE-N"); - properties.setProperty(PROPERTY_ZONE + ".New York City." + ISO3166_CODES, "US-NY"); - properties.setProperty(PROPERTY_ZONE + ".Stockholm." + ISO3166_CODES, "SE-AB"); - properties.setProperty("jclouds.ssh.max-retries", "5"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - properties.setProperty(PROPERTY_GLESYS_DEFAULT_DC, "Falkenberg"); - return properties; - } - - public GleSYSPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java index 3d5da78f02..871fe47d79 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java @@ -18,48 +18,80 @@ */ package org.jclouds.glesys; -import java.net.URI; +import static org.jclouds.glesys.reference.GleSYSConstants.PROPERTY_GLESYS_DEFAULT_DC; +import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for GleSYS. - * * @author Adrian Cole */ -public class GleSYSProviderMetadata extends BaseProviderMetadata { +public class GleSYSProviderMetadata + extends + BaseProviderMetadata, GleSYSApiMetadata> { - public GleSYSProviderMetadata() { - this(builder() - .id("glesys") - .name("GleSYS") - .api(new GleSYSApiMetadata()) - .homepage(URI.create("http://www.glesys.com")) - .console(URI.create("https://customer.glesys.com/cloud.php")) - .iso3166Codes("NL-NH","SE-N","US-NY","SE-AB")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected GleSYSProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public GleSYSProviderMetadata() { + super(builder()); + } + + public GleSYSProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_ZONES, "Amsterdam,Falkenberg,New York City,Stockholm"); + properties.setProperty(PROPERTY_ZONE + ".Amsterdam." + ISO3166_CODES, "NL-NH"); + properties.setProperty(PROPERTY_ZONE + ".Falkenberg." + ISO3166_CODES, "SE-N"); + properties.setProperty(PROPERTY_ZONE + ".New York City." + ISO3166_CODES, "US-NY"); + properties.setProperty(PROPERTY_ZONE + ".Stockholm." + ISO3166_CODES, "SE-AB"); + properties.setProperty(PROPERTY_GLESYS_DEFAULT_DC, "Falkenberg"); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, GleSYSApiMetadata> { + + protected Builder() { + id("glesys") + .name("GleSYS") + .apiMetadata(new GleSYSApiMetadata()) + .homepage(URI.create("http://www.glesys.com")) + .console(URI.create("https://customer.glesys.com/cloud.php")) + .iso3166Codes("NL-NH","SE-N","US-NY","SE-AB") + .endpoint("https://api.glesys.com") + .defaultProperties(GleSYSProviderMetadata.defaultProperties()); + } @Override public GleSYSProviderMetadata build() { return new GleSYSProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, GleSYSApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - -} +} \ No newline at end of file diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/GleSYSProviderTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/GleSYSProviderTest.java index b8a5751814..eb41a8cab0 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/GleSYSProviderTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/GleSYSProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.glesys; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java index 70bdfb25f3..3ddec09ef4 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java @@ -18,12 +18,11 @@ */ package org.jclouds.glesys.compute; -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.glesys.GleSYSAsyncClient; import org.jclouds.glesys.GleSYSClient; -import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -37,7 +36,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class GleSYSComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class GleSYSComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public GleSYSComputeServiceLiveTest() { provider = "glesys"; // ensure hyphens work @@ -49,12 +51,6 @@ public class GleSYSComputeServiceLiveTest extends BaseComputeServiceLiveTest { return new SshjSshClientModule(); } - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = new ComputeServiceContextFactory().createContext( - provider, identity, credential).getProviderSpecificContext(); - } - // GleSYS does not support metadata @Override protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap userMetadata) { diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java index 1dc7ca53e4..34824b495f 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java @@ -33,7 +33,7 @@ public class GleSYSExperimentExpectTest extends BaseGleSYSComputeServiceExpectTe @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { context = computeContextForKnownArgumentsAndConstantPassword(); diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java index bd307e9229..357ad48039 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java @@ -20,39 +20,43 @@ package org.jclouds.glesys.compute; import static org.testng.Assert.assertEquals; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.glesys.GleSYSAsyncClient; +import org.jclouds.glesys.GleSYSClient; +import org.jclouds.glesys.GleSYSProviderMetadata; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; +import com.google.common.io.Closeables; /** * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "GleSYSExperimentLiveTest") -public class GleSYSExperimentLiveTest extends BaseVersionedServiceLiveTest { +public class GleSYSExperimentLiveTest + extends + BaseComputeServiceContextLiveTest> { + public GleSYSExperimentLiveTest() { provider = "glesys"; } @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = new ComputeServiceContextFactory().createContext(provider, identity, credential, ImmutableSet - . of(new Log4JLoggingModule(), new SshjSshClientModule())); + context = ComputeServiceContextBuilder + .newBuilder(new GleSYSProviderMetadata()) + .overrides(setupProperties()) + .modules(setupModules()).build(); assertEquals(context.getComputeService().listAssignableLocations().size(), 4); } finally { - if (context != null) - context.close(); + Closeables.closeQuietly(context); } } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java index 7e5edad7b2..55f19450e1 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java @@ -25,11 +25,14 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.glesys.GleSYSAsyncClient; +import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.compute.options.GleSYSTemplateOptions; import org.testng.annotations.Test; @@ -42,7 +45,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "GleSYSTemplateBuilderLiveTest") -public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class GleSYSTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public GleSYSTemplateBuilderLiveTest() { provider = "glesys"; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java index c27888934e..4e7ee5251e 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java @@ -22,19 +22,18 @@ import java.net.URI; import java.util.Map; import java.util.Properties; +import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.glesys.GleSYSApiMetadata; import org.jclouds.glesys.compute.config.GleSYSComputeServiceContextModule.PasswordProvider; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.Module; @@ -50,10 +49,14 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE provider = "glesys"; } + @Override + protected ApiMetadata createApiMetadata() { + return new GleSYSApiMetadata(); + } + @Override public ComputeService createClient(Function fn, Module module, Properties props) { - return new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, identity, credential, - ImmutableSet. of(new ExpectModule(fn), new NullLoggingModule(), module), props).getComputeService(); + return createInjector(fn, module, props).getInstance(ComputeService.class); } protected PasswordProvider passwordGenerator() { @@ -73,7 +76,7 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE return computeContextForKnownArgumentsAndConstantPassword(requestsResponses).utils().injector(); } - protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword( + protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword( Map requestsResponses) { return requestsSendResponses( ImmutableMap @@ -106,7 +109,7 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE }).getContext(); } - protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword() { + protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword() { return computeContextForKnownArgumentsAndConstantPassword(ImmutableMap. of()); } } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java index 48d9799e66..cd284e7c16 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java @@ -33,7 +33,7 @@ import org.jclouds.glesys.domain.ArchiveDetails; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientLiveTest.java index 8f50fb54de..e71ca77225 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientLiveTest.java @@ -28,7 +28,7 @@ import org.jclouds.glesys.domain.ArchiveAllowedArguments; import org.jclouds.glesys.domain.ArchiveDetails; import org.jclouds.glesys.internal.BaseGleSYSClientLiveTest; import org.jclouds.predicates.RetryablePredicate; -import org.testng.annotations.AfterGroups; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -43,11 +43,11 @@ import com.google.common.base.Predicate; public class ArchiveClientLiveTest extends BaseGleSYSClientLiveTest { @BeforeGroups(groups = {"live"}) - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); - client = context.getApi().getArchiveClient(); - archiveUser = context.getIdentity().toLowerCase() + "_jcloudstest9"; + client = gleContext.getApi().getArchiveClient(); + archiveUser = gleContext.getIdentity().toLowerCase() + "_jcloudstest9"; archiveCounter = new RetryablePredicate( new Predicate() { public boolean apply(Integer value){ @@ -56,13 +56,13 @@ public class ArchiveClientLiveTest extends BaseGleSYSClientLiveTest { }, 30, 1, TimeUnit.SECONDS); } - @AfterGroups(groups={"live"}) - public void tearDown() { + @AfterClass(groups = { "integration", "live" }) + protected void tearDownContext() { int before = client.listArchives().size(); client.deleteArchive(archiveUser); assertTrue(archiveCounter.apply(before - 1)); - super.tearDown(); + super.tearDownContext(); } private ArchiveClient client; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java index 60a9f448be..50de7966df 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java @@ -33,7 +33,7 @@ import org.jclouds.glesys.domain.DomainRecord; import org.jclouds.glesys.options.AddDomainOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientLiveTest.java index db3e2fed79..78ec75774a 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientLiveTest.java @@ -47,10 +47,10 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest { public final String testDomain = "glesystest.jclouds.org"; @BeforeGroups(groups = {"live"}) - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); - client = context.getApi().getDomainClient(); + client = gleContext.getApi().getDomainClient(); domainCounter = new RetryablePredicate( new Predicate() { public boolean apply(Integer value) { @@ -73,12 +73,12 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest { } @AfterGroups(groups = {"live"}) - public void tearDown() { + public void tearDownContext() { int before = client.listDomains().size(); client.deleteDomain(testDomain); assertTrue(domainCounter.apply(before - 1)); - super.tearDown(); + super.tearDownContext(); } private DomainClient client; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java index 73ac1459bb..17b3a01f73 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java @@ -36,7 +36,7 @@ import org.jclouds.glesys.domain.EmailOverviewSummary; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java index a0bad98256..6db98945fb 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java @@ -48,9 +48,9 @@ import com.google.common.base.Predicate; public class EmailClientLiveTest extends BaseGleSYSClientLiveTest { @BeforeGroups(groups = {"live"}) - public void setupClient() { - super.setupClient(); - client = context.getApi().getEmailClient(); + public void setupContext() { + super.setupContext(); + client = gleContext.getApi().getEmailClient(); serverId = createServer("test-email-jclouds").getServerId(); @@ -67,13 +67,13 @@ public class EmailClientLiveTest extends BaseGleSYSClientLiveTest { } @AfterGroups(groups = {"live"}) - public void tearDown() { + public void tearDownContext() { client.delete("test@" + testDomain); client.delete("test1@" + testDomain); assertTrue(emailAccountCounter.apply(0)); - context.getApi().getDomainClient().deleteDomain(testDomain); - context.getApi().getServerClient().destroyServer(serverId, DestroyServerOptions.Builder.discardIp()); - super.tearDown(); + gleContext.getApi().getDomainClient().deleteDomain(testDomain); + gleContext.getApi().getServerClient().destroyServer(serverId, DestroyServerOptions.Builder.discardIp()); + super.tearDownContext(); } private EmailClient client; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/IpClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/IpClientExpectTest.java index 743afb1e7e..6acb032cab 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/IpClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/IpClientExpectTest.java @@ -33,7 +33,7 @@ import org.jclouds.glesys.domain.IpDetails; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/IpClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/IpClientLiveTest.java index 60cbe675d7..0ba66e1ade 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/IpClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/IpClientLiveTest.java @@ -39,9 +39,9 @@ import org.testng.annotations.Test; public class IpClientLiveTest extends BaseGleSYSClientLiveTest { @BeforeGroups(groups = {"live"}) - public void setupClient() { - super.setupClient(); - client = context.getApi().getIpClient(); + public void setupContext() { + super.setupContext(); + client = gleContext.getApi().getIpClient(); } private IpClient client; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java index 32001b2894..53b2261dde 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java @@ -47,7 +47,7 @@ import org.jclouds.glesys.options.ServerStatusOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java index 999578762f..6ff5e39fed 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java @@ -58,20 +58,20 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest { public static final String testHostName2 = "jclouds-test2"; @BeforeGroups(groups = {"live"}) - public void setupClient() { - super.setupClient(); - client = context.getApi().getServerClient(); + public void setupContext() { + super.setupContext(); + client = gleContext.getApi().getServerClient(); serverStatusChecker = createServer(testHostName1); testServerId = serverStatusChecker.getServerId(); } @AfterGroups(groups = {"live"}) - public void tearDown() { + public void tearDownContext() { client.destroyServer(testServerId, DestroyServerOptions.Builder.discardIp()); if (testServerId2 != null) { client.destroyServer(testServerId2, DestroyServerOptions.Builder.discardIp()); } - super.tearDown(); + super.tearDownContext(); } private ServerClient client; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java index 9f84fb9acf..ae89a53dcc 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java @@ -20,20 +20,16 @@ package org.jclouds.glesys.internal; import static org.testng.Assert.assertEquals; -import java.util.Properties; - -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; +import org.jclouds.glesys.GleSYSProviderMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.BaseAsyncClientTest; /** * @author Adrian Cole */ -public abstract class BaseGleSYSAsyncClientTest extends RestClientTest { +public abstract class BaseGleSYSAsyncClientTest extends BaseAsyncClientTest { @Override protected void checkFilters(HttpRequest request) { @@ -42,8 +38,7 @@ public abstract class BaseGleSYSAsyncClientTest extends RestClientTest { } @Override - public RestContextSpec createContextSpec() { - Properties props = new Properties(); - return new RestContextFactory().createContextSpec("glesys", "username", "apiKey", props); + public ProviderMetadata createProviderMetadata() { + return new GleSYSProviderMetadata(); } } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java index 52ca98a804..753d78c6cb 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java @@ -26,9 +26,8 @@ import static org.testng.Assert.assertTrue; import java.util.UUID; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.glesys.GleSYSAsyncClient; import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.domain.Server; @@ -38,17 +37,12 @@ import org.jclouds.glesys.domain.ServerStatus; import org.jclouds.glesys.features.DomainClient; import org.jclouds.glesys.features.ServerClient; import org.jclouds.glesys.options.ServerStatusOptions; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; /** * Tests behavior of {@code GleSYSClient} @@ -56,33 +50,25 @@ import com.google.inject.Module; * @author Adrian Cole, Adam Lowe */ @Test(groups = "live") -public class BaseGleSYSClientLiveTest extends BaseVersionedServiceLiveTest { - protected ComputeServiceContext computeContext; - protected RestContext context; +public class BaseGleSYSClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + + protected RestContext gleContext; public BaseGleSYSClientLiveTest() { provider = "glesys"; } - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - - computeContext = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), setupProperties()); - context = computeContext.getProviderSpecificContext(); - } - - @AfterGroups(groups = "live") - protected void tearDown() { - if (context != null) { - context.close(); - context = null; - } + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + gleContext = context.getProviderSpecificContext(); } protected void createDomain(String domain) { - final DomainClient client = context.getApi().getDomainClient(); + final DomainClient client = gleContext.getApi().getDomainClient(); int before = client.listDomains().size(); client.addDomain(domain); RetryablePredicate result = new RetryablePredicate(new Predicate() { @@ -95,7 +81,7 @@ public class BaseGleSYSClientLiveTest extends BaseVersionedServiceLiveTest { } protected ServerStatusChecker createServer(String hostName) { - ServerClient client = context.getApi().getServerClient(); + ServerClient client = gleContext.getApi().getServerClient(); ServerDetails testServer = client.createServerWithHostnameAndRootPassword( ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 10.04 LTS 32-bit") diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java new file mode 100644 index 0000000000..b94c0faac3 --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java @@ -0,0 +1,88 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.opsource.servers; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; + +import com.google.common.reflect.TypeToken; + +/** + * Implementation of {@link ApiMetadata} for API + * + * @author Adrian Cole + */ +public class OpSourceServersApiMetadata + extends + BaseRestApiMetadata, OpSourceServersApiMetadata> { + + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); + } + + public OpSourceServersApiMetadata() { + this(new Builder()); + } + + protected OpSourceServersApiMetadata(Builder builder) { + super(builder); + } + + protected static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.Builder.defaultProperties(); + return properties; + } + + public static class Builder + extends + BaseRestApiMetadata.Builder, OpSourceServersApiMetadata> { + + protected Builder() { + super(OpSourceServersClient.class, OpSourceServersAsyncClient.class); + id("opsource-servers") + .name("OpSourceServers API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("http://www.opsource.net/Services/Cloud-Hosting/Open-API")) + .version("0.9") + .defaultEndpoint("https://api.opsourcecloud.net/oec/${jclouds.api-version}") + .type(ApiType.COMPUTE) + .contextBuilder(TypeToken.of(OpSourceServersContextBuilder.class)); + } + + @Override + public OpSourceServersApiMetadata build() { + return new OpSourceServersApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(OpSourceServersApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + + } + +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java index c174722015..ab7ef8b6e9 100644 --- a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java @@ -19,23 +19,36 @@ package org.jclouds.opsource.servers; import java.util.List; -import java.util.Properties; import org.jclouds.opsource.servers.config.OpSourceServersRestClientModule; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContextBuilder; import com.google.inject.Module; /** + * * @author Adrian Cole */ -public class OpSourceServersContextBuilder extends RestContextBuilder { +public class OpSourceServersContextBuilder + extends + RestContextBuilder, OpSourceServersApiMetadata> { - public OpSourceServersContextBuilder(Properties props) { - super(OpSourceServersClient.class, OpSourceServersAsyncClient.class, props); + public OpSourceServersContextBuilder( + ProviderMetadata, OpSourceServersApiMetadata> providerMetadata) { + super(providerMetadata); } - @Override + public OpSourceServersContextBuilder(OpSourceServersApiMetadata apiMetadata) { + super(apiMetadata); + } +// +// @Override +// protected void addContextModule(List modules) { +// modules.add(new OpSourceServersComputeServiceContextModule()); +// } + protected void addClientModule(List modules) { modules.add(new OpSourceServersRestClientModule()); } diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersPropertiesBuilder.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersPropertiesBuilder.java deleted file mode 100644 index 28cc359507..0000000000 --- a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersPropertiesBuilder.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.opsource.servers; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in OpSourceServers clients - * - * @author Adrian Cole - */ -public class OpSourceServersPropertiesBuilder extends PropertiesBuilder { - - @Override - public Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.opsourcecloud.net/oec/${jclouds.api-version}"); - properties.setProperty(PROPERTY_API_VERSION, "0.9"); - return properties; - } - - public OpSourceServersPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/opsource-servers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/opsource-servers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..24f893d882 --- /dev/null +++ b/labs/opsource-servers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.opsource.servers.OpSourceServersApiMetadata \ No newline at end of file diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/OpSourceServersClientExperimentLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/OpSourceServersClientExperimentLiveTest.java index 584a74709d..f21e36cae6 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/OpSourceServersClientExperimentLiveTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/OpSourceServersClientExperimentLiveTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; public class OpSourceServersClientExperimentLiveTest extends BaseOpSourceServersClientLiveTest { public void testImplicitSession() { - Account account = context.getApi().getAccountClient().getMyAccount(); + Account account = restContext.getApi().getAccountClient().getMyAccount(); assert account.getOrgId() != null; } diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientLiveTest.java index 6028ffcec6..c2fe4e8293 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientLiveTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientLiveTest.java @@ -32,14 +32,14 @@ import org.testng.annotations.Test; public class AccountClientLiveTest extends BaseOpSourceServersClientLiveTest { public void testGetMyAccount() { - Account account = context.getApi().getAccountClient().getMyAccount(); + Account account = restContext.getApi().getAccountClient().getMyAccount(); assert account.getOrgId() != null; } public void testGetDataCenterWithLimits() { - Account account = context.getApi().getAccountClient().getMyAccount(); + Account account = restContext.getApi().getAccountClient().getMyAccount(); assert account.getOrgId() != null; - DataCentersList dataCentersList = context.getApi().getAccountClient().getDataCentersWithLimits(account.getOrgId()); + DataCentersList dataCentersList = restContext.getApi().getAccountClient().getDataCentersWithLimits(account.getOrgId()); assert dataCentersList != null; } diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/ServerClientLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/ServerClientLiveTest.java index 672f1700d1..e31ddab658 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/ServerClientLiveTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/ServerClientLiveTest.java @@ -33,16 +33,16 @@ import org.testng.annotations.Test; public class ServerClientLiveTest extends BaseOpSourceServersClientLiveTest { public void testGetDeployedServers() { - Account account = context.getApi().getAccountClient().getMyAccount(); + Account account = restContext.getApi().getAccountClient().getMyAccount(); assert account.getOrgId() != null; - DeployedServersList deployedServersList = context.getApi().getServerClient().getDeployedServers(account.getOrgId()); + DeployedServersList deployedServersList = restContext.getApi().getServerClient().getDeployedServers(account.getOrgId()); assert deployedServersList != null; } public void testGetPendingDeployServers() { - Account account = context.getApi().getAccountClient().getMyAccount(); + Account account = restContext.getApi().getAccountClient().getMyAccount(); assert account.getOrgId() != null; - PendingDeployServersList pendingDeployServersList = context.getApi().getServerClient().getPendingDeployServers(account.getOrgId()); + PendingDeployServersList pendingDeployServersList = restContext.getApi().getServerClient().getPendingDeployServers(account.getOrgId()); assert pendingDeployServersList != null; } diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/ServerImageClientLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/ServerImageClientLiveTest.java index d55e155438..0430698758 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/ServerImageClientLiveTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/ServerImageClientLiveTest.java @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class ServerImageClientLiveTest extends BaseOpSourceServersClientLiveTest { public void testGetServerImages() { - ServerImagesList serverImagesList = context.getApi().getServerImageClient().getServerImages(); + ServerImagesList serverImagesList = restContext.getApi().getServerImageClient().getServerImages(); assert serverImagesList != null; } diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java index 9aba439acb..3d6ee073f0 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java @@ -18,21 +18,14 @@ */ package org.jclouds.opsource.servers.internal; -import java.util.Properties; - -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.opsource.servers.OpSourceServersAsyncClient; import org.jclouds.opsource.servers.OpSourceServersClient; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@link OpSourceServersClient} and acts as parent for other * client live tests. @@ -40,25 +33,21 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public abstract class BaseOpSourceServersClientLiveTest extends BaseVersionedServiceLiveTest { +public abstract class BaseOpSourceServersClientLiveTest + extends + BaseComputeServiceContextLiveTest> { protected BaseOpSourceServersClientLiveTest() { provider = "opsource-servers"; } - protected RestContext context; + protected RestContext restContext; - @BeforeClass(groups = { "live" }) + @BeforeGroups(groups = { "integration", "live" }) + @Override public void setupContext() { - setupCredentials(); - Properties overrides = setupProperties(); - - context = new RestContextFactory().createContext(provider, identity, credential, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); + super.setupContext(); + restContext = context.getProviderSpecificContext(); } - protected void tearDown() { - if (context != null) - context.close(); - } } diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java index c5720cd222..217fedf1e6 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java @@ -18,8 +18,10 @@ */ package org.jclouds.opsource.servers.internal; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.opsource.servers.OpSourceServersApiMetadata; import org.jclouds.opsource.servers.OpSourceServersClient; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; /** * Base class for writing OpSourceServersClient Expect tests @@ -34,4 +36,8 @@ public class BaseOpSourceServersRestClientExpectTest extends BaseRestClientExpec credential = "password"; } + @Override + protected ApiMetadata createApiMetadata() { + return new OpSourceServersApiMetadata(); + } } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCApiMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCApiMetadata.java deleted file mode 100644 index 718387b1af..0000000000 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCApiMetadata.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.jclouds.savvis.vpdc; - -import java.net.URI; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; - -/** - * Implementation of {@link ApiMetadata} for the Savvis Symphony VPDC API - * - * @author Adrian Cole - */ -public class SavvisSymphonyVPDCApiMetadata extends BaseApiMetadata { - - public SavvisSymphonyVPDCApiMetadata() { - this(builder() - .id("savvis-symphonyvpdc") - .type(ApiType.COMPUTE) - .name("Savvis Symphony VPDC API") - .identityName("Username") - .credentialName("Password") - .documentation(URI.create("https://api.savvis.net/doc/spec/api/index.html"))); - } - - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SavvisSymphonyVPDCApiMetadata(Builder builder) { - super(builder); - } - - private static class ConcreteBuilder extends Builder { - - @Override - public SavvisSymphonyVPDCApiMetadata build() { - return new SavvisSymphonyVPDCApiMetadata(this); - } - } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - -} \ No newline at end of file diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java deleted file mode 100644 index 35319e9195..0000000000 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.savvis.vpdc; - -import java.net.URI; - -import org.jclouds.providers.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Savvis Symphony VPDC services. - * - * @author Kedar Dave - */ -public class SavvisSymphonyVPDCProviderMetadata extends BaseProviderMetadata { - public SavvisSymphonyVPDCProviderMetadata() { - this(builder() - .id("savvis-symphonyvpdc") - .name("Savvis Symphony VPDC") - .api(new SavvisSymphonyVPDCApiMetadata()) - .homepage(URI.create("https://api.savvis.net/doc/spec/api/index.html")) - .console(URI.create("https://www.savvisstation.com")) - /** - * {@inheritDoc} - * list of data centers from savvisstation colocation guide - * https://www.savvisstation.com/DocumentViewer?GUID=a95f0387-cbfe-43eb-b25b-4f2b0f68498f&sessionid=SavvisCCC%3ac9a8984b9655b01916be587e5204b2cf - * Once we have confirmation from Savvis as to what data centers are used for vpdc deployments, - * iso codes for those will be entered here - * - * City Code - * Lithia Springs, GA AT1 - * Waltham, MA BO1 - * Waltham, MA BO2 - * Waltham, MA B03 - * Elk Grove Village, IL CH3 - * Chicago, IL CH4 - * Sterling, VA DC2 - * Sterling, VA DC3 - * Sterling, VA DC4 Phase I - * Sterling, VA DC4 Phase II - * Fort Worth, TX DL1 - * Fort Worth, TX DL2 - * El Segundo, CA LA1 - * Jersey City, NJ NJ1 - * Weehawken, NJ NJ2 - * Piscataway, NJ NJ3 - * Piscataway, NJ 2nd floor NJ3 - * Weehawken, NJ NJ2X - * Irvine, CA OC2 - * Santa Clara, CA SC4 - * Santa Clara, CA SC5 - * Santa Clara, CA SC8 - * Santa Clara, CA SC9 - * Tukwila, WA 1st floor SE2 - * Montreal, Canada MR1 - * Toronto, Canada TR1 - * Vancouver, Canada VC1 - */ - .iso3166Codes("US", "CA")); - } - - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SavvisSymphonyVPDCProviderMetadata(ConcreteBuilder builder) { - super(builder); - } - - private static class ConcreteBuilder extends Builder { - - @Override - public SavvisSymphonyVPDCProviderMetadata build() { - return new SavvisSymphonyVPDCProviderMetadata(this); - } - } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } -} \ No newline at end of file diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java new file mode 100644 index 0000000000..cf25f6862e --- /dev/null +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java @@ -0,0 +1,92 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.savvis.vpdc; + +import static org.jclouds.savvis.vpdc.reference.VPDCConstants.PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.apis.ApiType; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; + +/** + * Implementation of {@link org.jclouds.types.ApiMetadata} for Savvis Symphony VPDC services. + * + * @author Kedar Dave + */ +public class VPDCApiMetadata + extends + BaseComputeServiceApiMetadata, VPDCApiMetadata> { + + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); + } + + public VPDCApiMetadata() { + this(new Builder()); + } + + protected VPDCApiMetadata(Builder builder) { + super(builder); + } + + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED, 600l * 1000l + ""); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, VPDCApiMetadata> { + + protected Builder() { + id("savvis-symphonyvpdc") + .type(ApiType.COMPUTE) + .name("Savvis Symphony VPDC API") + .identityName("Username") + .credentialName("Password") + .documentation(URI.create("https://api.savvis.net/doc/spec/api/index.html")) + .version("1.0") + .buildVersion("2.3") + .defaultEndpoint("https://api.savvis.net/vpdc") + .defaultProperties(VPDCApiMetadata.defaultProperties()) + .javaApi(VPDCClient.class, VPDCAsyncClient.class) + .contextBuilder(TypeToken.of(VPDCContextBuilder.class)); + } + + @Override + public VPDCApiMetadata build() { + return new VPDCApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(VPDCApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + + } + +} diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java index a321f8c384..6934caea2e 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java @@ -19,9 +19,10 @@ package org.jclouds.savvis.vpdc; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.savvis.vpdc.compute.config.VPDCComputeServiceContextModule; import org.jclouds.savvis.vpdc.config.VPDCRestClientModule; @@ -31,14 +32,17 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class VPDCContextBuilder extends ComputeServiceContextBuilder { +public class VPDCContextBuilder + extends + ComputeServiceContextBuilder, VPDCApiMetadata> { - public VPDCContextBuilder(Properties props) { - super(VPDCClient.class, VPDCAsyncClient.class, props); + public VPDCContextBuilder( + ProviderMetadata, VPDCApiMetadata> providerMetadata) { + super(providerMetadata); } - protected void addClientModule(List modules) { - modules.add(new VPDCRestClientModule()); + public VPDCContextBuilder(VPDCApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -46,4 +50,8 @@ public class VPDCContextBuilder extends ComputeServiceContextBuilder modules) { + modules.add(new VPDCRestClientModule()); + } + } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java new file mode 100644 index 0000000000..31bbf4ccc7 --- /dev/null +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java @@ -0,0 +1,123 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.savvis.vpdc; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Savvis Symphony VPDC services. + * + * @author Kedar Dave + */ +public class VPDCProviderMetadata + extends + BaseProviderMetadata, VPDCApiMetadata> { + + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public VPDCProviderMetadata() { + super(builder()); + } + + public VPDCProviderMetadata(Builder builder) { + super(builder); + } + + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, VPDCApiMetadata> { + + protected Builder() { + id("savvis-symphonyvpdc") + .name("Savvis Symphony VPDC") + .apiMetadata(new VPDCApiMetadata()) + .homepage(URI.create("https://api.savvis.net/doc/spec/api/index.html")) + .console(URI.create("https://www.savvisstation.com")) + /** + * {@inheritDoc} + * list of data centers from savvisstation colocation guide + * https://www.savvisstation.com/DocumentViewer?GUID=a95f0387-cbfe-43eb-b25b-4f2b0f68498f&sessionid=SavvisCCC%3ac9a8984b9655b01916be587e5204b2cf + * Once we have confirmation from Savvis as to what data centers are used for vpdc deployments, + * iso codes for those will be entered here + * + * City Code + * Lithia Springs, GA AT1 +* Waltham, MA BO1 +* Waltham, MA BO2 +* Waltham, MA B03 +* Elk Grove Village, IL CH3 +* Chicago, IL CH4 +* Sterling, VA DC2 +* Sterling, VA DC3 +* Sterling, VA DC4 Phase I +* Sterling, VA DC4 Phase II +* Fort Worth, TX DL1 +* Fort Worth, TX DL2 +* El Segundo, CA LA1 +* Jersey City, NJ NJ1 +* Weehawken, NJ NJ2 +* Piscataway, NJ NJ3 +* Piscataway, NJ 2nd floor NJ3 +* Weehawken, NJ NJ2X +* Irvine, CA OC2 +* Santa Clara, CA SC4 +* Santa Clara, CA SC5 +* Santa Clara, CA SC8 +* Santa Clara, CA SC9 +* Tukwila, WA 1st floor SE2 +* Montreal, Canada MR1 +* Toronto, Canada TR1 +* Vancouver, Canada VC1 + */ + .iso3166Codes("US", "CA") + .endpoint("https://api.savvis.net/vpdc") + .defaultProperties(VPDCProviderMetadata.defaultProperties()); + } + + @Override + public VPDCProviderMetadata build() { + return new VPDCProviderMetadata(this); + } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, VPDCApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } + + } +} \ No newline at end of file diff --git a/labs/savvis-symphonyvpdc/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/savvis-symphonyvpdc/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata index ab54604528..04552f7f96 100644 --- a/labs/savvis-symphonyvpdc/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ b/labs/savvis-symphonyvpdc/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -1 +1 @@ -org.jclouds.savvis.vpdc.SavvisSymphonyVPDCProviderMetadata \ No newline at end of file +org.jclouds.savvis.vpdc.VPDCProviderMetadata \ No newline at end of file diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCProviderTest.java similarity index 66% rename from labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java rename to labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCProviderTest.java index 9bbca2f6a3..8e4972d44b 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCProviderTest.java @@ -18,19 +18,19 @@ */ package org.jclouds.savvis.vpdc; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** - * The SavvisSymphonyVPDCProviderTest tests the - * org.jclouds.savvis.vpdc.SavvisSymphonyVPDCProviderMetadata class. + * The VPDCProviderTest tests the + * org.jclouds.savvis.vpdc.VPDCProviderMetadata class. * * @author Kedar Dave */ -@Test(groups = "unit", testName = "SavvisSymphonyVPDCProviderTest") -public class SavvisSymphonyVPDCProviderTest extends BaseProviderMetadataTest { +@Test(groups = "unit", testName = "VPDCProviderTest") +public class VPDCProviderTest extends BaseProviderMetadataTest { - public SavvisSymphonyVPDCProviderTest() { - super(new SavvisSymphonyVPDCProviderMetadata(), new SavvisSymphonyVPDCApiMetadata()); + public VPDCProviderTest() { + super(new VPDCProviderMetadata(), new VPDCApiMetadata()); } } \ No newline at end of file diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java index d1bcf26dab..2c56d36d61 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java @@ -21,8 +21,11 @@ package org.jclouds.savvis.vpdc.compute; import java.util.Properties; import org.jclouds.Constants; -import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; +import org.jclouds.savvis.vpdc.VPDCAsyncClient; +import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -38,7 +41,9 @@ import com.google.inject.Module; * */ @Test(enabled = true, groups = "live") -public class VPDCComputeServiceLiveTestDisabled extends BaseComputeServiceLiveTest { +public class VPDCComputeServiceLiveTestDisabled + extends + BaseComputeServiceLiveTest> { public VPDCComputeServiceLiveTestDisabled() { provider = "savvis-symphonyvpdc"; diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java index ce763a95ea..f545316887 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java @@ -26,11 +26,14 @@ import java.io.IOException; import java.util.Properties; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.jclouds.domain.LocationScope; +import org.jclouds.savvis.vpdc.VPDCAsyncClient; +import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.savvis.vpdc.reference.VPDCConstants; import org.testng.annotations.Test; @@ -42,7 +45,8 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class VPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class VPDCTemplateBuilderLiveTest extends + BaseTemplateBuilderLiveTest> { public VPDCTemplateBuilderLiveTest() { provider = "savvis-symphonyvpdc"; diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java index 1e5c6c75b6..6d3674979e 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java @@ -29,12 +29,10 @@ import javax.inject.Named; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; -import org.jclouds.savvis.vpdc.VPDCAsyncClient; -import org.jclouds.savvis.vpdc.VPDCClient; +import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.savvis.vpdc.VPDCProviderMetadata; import org.jclouds.savvis.vpdc.config.VPDCRestClientModule; import org.jclouds.savvis.vpdc.domain.Resource; import org.jclouds.savvis.vpdc.domain.ResourceImpl; @@ -52,12 +50,11 @@ import com.google.inject.Module; /** * @author Adrian Cole */ -public abstract class BaseVPDCAsyncClientTest extends RestClientTest { +public abstract class BaseVPDCAsyncClientTest extends BaseAsyncClientTest { @Override - public RestContextSpec createContextSpec() { - Properties props = new Properties(); - return new RestContextFactory().createContextSpec("savvis-symphonyvpdc", "apiKey", "secretKey", props); + public ProviderMetadata createProviderMetadata() { + return new VPDCProviderMetadata(); } @Override diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java index be21aa3099..9219137347 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java @@ -23,47 +23,35 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Properties; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; import org.jclouds.savvis.vpdc.VPDCAsyncClient; import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.savvis.vpdc.predicates.TaskSuccess; import org.jclouds.savvis.vpdc.reference.VPDCConstants; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code VPDCClient} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "BaseVPDCClientLiveTest") -public class BaseVPDCClientLiveTest extends BaseVersionedServiceLiveTest { +public class BaseVPDCClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public BaseVPDCClientLiveTest() { provider = "savvis-symphonyvpdc"; } protected RestContext restContext; - protected ComputeServiceContext context; protected String email; protected RetryablePredicate taskTester; - @Override - protected void setupCredentials() { - super.setupCredentials(); - email = checkNotNull(System.getProperty("test." + VPDCConstants.PROPERTY_VPDC_VDC_EMAIL), "test." - + VPDCConstants.PROPERTY_VPDC_VDC_EMAIL); - } - @Override protected Properties setupProperties() { Properties overrides = super.setupProperties(); @@ -71,23 +59,16 @@ public class BaseVPDCClientLiveTest extends BaseVersionedServiceLiveTest { // unlimited timeouts overrides.setProperty("jclouds.connection-timeout", "0"); overrides.setProperty("jclouds.so-timeout", "0"); + email = checkNotNull(System.getProperty("test." + VPDCConstants.PROPERTY_VPDC_VDC_EMAIL), "test." + + VPDCConstants.PROPERTY_VPDC_VDC_EMAIL); return overrides; } - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), overrides); - restContext = context.getProviderSpecificContext(); + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); taskTester = new RetryablePredicate(new TaskSuccess(restContext.getApi()), 7200, 10, TimeUnit.SECONDS); } - @AfterGroups(groups = "live") - protected void tearDown() { - if (context != null) - context.close(); - } - } diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java index 4a1f020126..7b1b484793 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java @@ -49,8 +49,8 @@ public class BrowsingClientLiveTest extends BaseVPDCClientLiveTest { @Override @BeforeGroups(groups = { "live" }) - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); client = restContext.getApi().getBrowsingClient(); } diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java index 3cf8586404..0c8fcbe7b0 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java @@ -21,7 +21,6 @@ package org.jclouds.savvis.vpdc.features; import org.jclouds.savvis.vpdc.domain.FirewallRule; import org.jclouds.savvis.vpdc.domain.Resource; import org.jclouds.savvis.vpdc.domain.Task; -import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -36,8 +35,8 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest { @Override @BeforeGroups(groups = { "live" }) - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); client = restContext.getApi().getFirewallClient(); } @@ -110,10 +109,4 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest { assert this.taskTester.apply(task.getId()); } - - @AfterGroups(groups = "live") - protected void tearDown() { - //TODO cleanup resources - super.tearDown(); - } } \ No newline at end of file diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementClientLiveTest.java index 7dab3a5015..3565efb42c 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementClientLiveTest.java @@ -44,8 +44,8 @@ public class ServiceManagementClientLiveTest extends BaseVPDCClientLiveTest { @Override @BeforeGroups(groups = { "live" }) - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); client = restContext.getApi().getServiceManagementClient(); } diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java index 6ad7591f97..cb645f8346 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java @@ -63,8 +63,8 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { @Override @BeforeGroups(groups = { "live" }) - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); client = restContext.getApi().getVMClient(); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 130, 10, TimeUnit.SECONDS);// make } @@ -293,10 +293,10 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { } @AfterGroups(groups = "live") - protected void tearDown() { + protected void tearDownContext() { if (vm != null) { assert taskTester.apply(client.removeVMFromVDC(billingSiteId, vpdcId, vm.getId()).getId()) : vm; } - super.tearDown(); + super.tearDownContext(); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java index 62a837d3c8..b39f9298f6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java @@ -17,50 +17,95 @@ * under the License. */ package org.jclouds.vcloud.director.v1_5; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_VERSION_SCHEMA; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_XML_NAMESPACE; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_XML_SCHEMA; import java.net.URI; +import java.util.Properties; +import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; +import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for VCloud Director 1.5 API + * Implementation of {@link ApiMetadata} for VCloudDirector 1.0 API * * @author Adrian Cole */ -public class VCloudDirectorApiMetadata extends BaseApiMetadata { +public class VCloudDirectorApiMetadata + extends +// BaseComputeServiceApiMetadata { + BaseRestApiMetadata { - public VCloudDirectorApiMetadata() { - this(builder() - .id("vcloud-director") - .type(ApiType.COMPUTE) - .name("VCloud Director 1.5 API") - .identityName("User at Organization (user@org)") - .credentialName("Password") - .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected VCloudDirectorApiMetadata(ConcreteBuilder builder) { + public VCloudDirectorApiMetadata() { + this(new Builder()); + } + + public VCloudDirectorApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + /** FIXME this should not be the default */ + properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(30 * 60)); + + properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_XML_NAMESPACE, + String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_DIRECTOR_VERSION_SCHEMA)); + properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(8 * 60)); + properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_XML_SCHEMA, "${jclouds.endpoint}/v1.5/schema/master.xsd"); + + // TODO integrate these with the {@link ComputeTimeouts} instead of having a single timeout for everything. + properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(300)); + properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED, Long.toString(1200l * 1000l)); + + return properties; + } + + public static class Builder + extends +// BaseComputeServiceApiMetadata.Builder { + BaseRestApiMetadata.Builder { + + protected Builder() { + super(VCloudDirectorClient.class, VCloudDirectorAsyncClient.class); + id("vcloud") + .name("VCloud Director 1.5 API") + .type(ApiType.COMPUTE) + .identityName("User at Organization (user@org)") + .credentialName("Password") + .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) + .version("1.5") + .defaultEndpoint("https://vcloudbeta.bluelock.com/api") + .defaultProperties(VCloudDirectorApiMetadata.defaultProperties()) + .context(TypeToken.of(VCloudDirectorContext.class)) + .contextBuilder(TypeToken.of(VCloudDirectorContextBuilder.class)); + } @Override public VCloudDirectorApiMetadata build() { return new VCloudDirectorApiMetadata(this); } + + @Override + public Builder fromApiMetadata(VCloudDirectorApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } -} \ No newline at end of file +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java index dc0bd84bdd..cde539d05f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java @@ -19,33 +19,43 @@ package org.jclouds.vcloud.director.v1_5; import java.util.List; -import java.util.Properties; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.RestContextBuilder; import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; -import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorContextImpl; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import com.google.inject.Module; /** + * * @author Adrian Cole */ -public class VCloudDirectorContextBuilder extends RestContextBuilder { +public class VCloudDirectorContextBuilder + extends + // ComputeServiceContextBuilder { + RestContextBuilder { - public VCloudDirectorContextBuilder(Properties props) { - super(VCloudDirectorClient.class, VCloudDirectorAsyncClient.class, props); + public VCloudDirectorContextBuilder( + ProviderMetadata providerMetadata) { + super(providerMetadata); } - @Override + public VCloudDirectorContextBuilder(VCloudDirectorApiMetadata apiMetadata) { + super(apiMetadata); + } + + // TODO + // @Override + // protected void addContextModule(List modules) { + // modules.add(new VCloudDirectorComputeServiceContextModule()); + // } + protected void addClientModule(List modules) { modules.add(new VCloudDirectorRestClientModule()); } - - @SuppressWarnings("unchecked") - @Override - public VCloudDirectorContext buildContext() { - return buildInjector().getInstance(VCloudDirectorContextImpl.class); - } + } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java index 550c337e72..5f648123cb 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java @@ -51,8 +51,7 @@ public class HttpClientLiveTest extends BaseVCloudDirectorClientLiveTest { private SessionWithToken sessionWithToken; @Override - protected void setupRequiredClients() throws Exception { - setupCredentials(); + protected void setupRequiredClients() { } @Test(description = "POST /login") diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java index 5bd3bcd411..0b90278dca 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java @@ -19,7 +19,7 @@ package org.jclouds.vcloud.director.v1_5; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.apis.internal.BaseApiMetadataTest; import org.testng.annotations.Test; /** diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index 81c6df43e3..bb92d538d3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -79,7 +79,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { private Reference catalogRef; @Override - protected void setupRequiredClients() throws Exception { + protected void setupRequiredClients() { // TODO why do I need a guard clause here? if (adminCatalog != null) return; catalogClient = context.getApi().getCatalogClient(); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java index 74f40df635..03501d9110 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java @@ -26,7 +26,6 @@ import static org.testng.Assert.fail; import java.net.URI; import java.text.SimpleDateFormat; -import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.Properties; @@ -36,12 +35,14 @@ import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; -import org.jclouds.compute.BaseVersionedServiceLiveTest; +import org.jclouds.Constants; import org.jclouds.date.DateService; import org.jclouds.logging.Logger; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.vcloud.director.testng.FormatApiResultsListener; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient; @@ -76,7 +77,6 @@ import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -99,7 +99,7 @@ import com.google.inject.Guice; */ @Listeners(FormatApiResultsListener.class) @Test(groups = "live") -public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServiceLiveTest { +public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTest { @Resource protected Logger logger = Logger.CONSOLE; @@ -149,7 +149,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ } // NOTE Implement as required to populate xxxClient fields, or NOP - protected abstract void setupRequiredClients() throws Exception; + protected abstract void setupRequiredClients(); @Inject protected void initTaskSuccess(TaskSuccess taskSuccess) { @@ -160,18 +160,23 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ protected void initTaskSuccessLong(TaskSuccess taskSuccess) { retryTaskSuccessLong = new RetryablePredicate(taskSuccess, LONG_TASK_TIMEOUT_SECONDS * 1000L); } - - @BeforeSuite(alwaysRun = true) - protected void setupTestSession() { - setupCredentials(); - Properties overrides = setupProperties(); - testSession = VCloudDirectorTestSession.builder() - .identity(identity) - .credential(credential) - .provider(provider) - .overrides(overrides) - .endpoint(endpoint) - .build(); + //temporary until we marry up the test fixtures + + protected String identity; + protected String credential; + protected String endpoint; + + @Override + protected Properties setupProperties() { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + identity = setIfTestSystemPropertyPresent(overrides, provider + ".identity"); + credential = setIfTestSystemPropertyPresent(overrides, provider + ".credential"); + endpoint = setIfTestSystemPropertyPresent(overrides, provider + ".endpoint"); + setIfTestSystemPropertyPresent(overrides, provider + ".api-version"); + setIfTestSystemPropertyPresent(overrides, provider + ".build-version"); + return overrides; } @AfterSuite(alwaysRun = true) @@ -180,8 +185,8 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ } @BeforeClass(alwaysRun = true) - protected void setupContext() throws Exception { - setupCredentials(); + @Override + public void setupContext(){ context = testSession.getUserContext(); adminContext = testSession.getAdminContext(); @@ -495,4 +500,4 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ public static String name(String prefix) { return prefix + Integer.toString(random.nextInt(Integer.MAX_VALUE)); } -} \ No newline at end of file +} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java index d55ee72a6d..d620aacb2e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java @@ -25,10 +25,12 @@ import java.net.URI; import java.util.Properties; import org.jclouds.Constants; +import org.jclouds.apis.ApiMetadata; import org.jclouds.date.DateService; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.testng.annotations.BeforeGroups; @@ -250,4 +252,10 @@ public abstract class BaseVCloudDirectorExpectTest extends BaseRestClientExpe public URI toAdminUri(URI uri) { return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref(); } + + @Override + protected ApiMetadata createApiMetadata() { + return new VCloudDirectorApiMetadata(); + } + } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorAdminClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorAdminClientExpectTest.java index f713b33bf2..2f582f4b73 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorAdminClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorAdminClientExpectTest.java @@ -22,13 +22,10 @@ import java.util.Properties; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.RestContextFactory; import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -50,8 +47,7 @@ public abstract class VCloudDirectorAdminClientExpectTest extends } private VCloudDirectorContext createVCloudDirectorContext(Function fn, Module module, - Properties props) { - return VCloudDirectorContext.class.cast(new RestContextFactory(setupRestProperties()).createContext(provider, - identity, credential, ImmutableSet. of(new ExpectModule(fn), new NullLoggingModule(), module), props)); + Properties props) { + return createInjector(fn, module, props).getInstance(VCloudDirectorContext.class); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java index d905f77b5b..0a30ccd8c3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java @@ -22,10 +22,11 @@ import static org.testng.Assert.assertEquals; import java.net.URI; +import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.BaseRestClientExpectTest; -import org.jclouds.rest.BaseRestClientExpectTest.RegisterContext; +import org.jclouds.rest.AnonymousRestApiMetadata; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Session; @@ -40,9 +41,7 @@ import com.google.common.collect.ImmutableMultimap; * * @author Adrian Cole */ -@Test(groups = { "unit", "user" }, testName = "SessionClientExpectTest") -// only needed as SessionClient is not registered in rest.properties -@RegisterContext(sync = SessionClient.class, async = SessionAsyncClient.class) +@Test(groups = "unit", testName = "SessionClientExpectTest") public class SessionClientExpectTest extends BaseRestClientExpectTest { public static final String user = "adrian@jclouds.org"; public static final String org = "JClouds"; @@ -122,4 +121,10 @@ public class SessionClientExpectTest extends BaseRestClientExpectTest createApiMetadata() { + return AnonymousRestApiMetadata.forClientMappedToAsyncClient(SessionClient.class, SessionAsyncClient.class) + .toBuilder().defaultEndpoint("https://vcloudbeta.bluelock.com/api").build(); + } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java index c4c5c7f2ee..78ab4aff81 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java @@ -18,8 +18,6 @@ */ package org.jclouds.vcloud.director.v1_5.login; -import static org.jclouds.rest.RestContextFactory.contextSpec; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -27,20 +25,17 @@ import static org.testng.Assert.assertTrue; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.Constants; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.vcloud.director.testng.FormatApiResultsListener; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; -import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Listeners; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code SessionClient}. Note this class is tested completely independently of * VCloudClient as it is a dependency of the VCloud context working. @@ -48,32 +43,42 @@ import com.google.inject.Module; * @author Adrian Cole */ @Listeners(FormatApiResultsListener.class) -@Test(groups = { "live", "user" }, testName = "SessionClientLiveTest") -public class SessionClientLiveTest extends BaseVersionedServiceLiveTest { +@Test(groups = { "live", "user", "login" }, testName = "SessionClientLiveTest") +public class SessionClientLiveTest extends BaseContextLiveTest> { public SessionClientLiveTest() { provider = "vcloud-director"; } - private RestContext context; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - RestContextSpec contextSpec = contextSpec("vcloud-director", endpoint, - apiVersion, buildVersion, "", identity, credential, SessionClient.class, SessionAsyncClient.class); - - context = createContextBuilder(contextSpec, overrides).withModules( - ImmutableSet. of(new Log4JLoggingModule())).buildContext(); - + public void setupContext() { + super.setupContext(); // session client isn't typically exposed to the user, as it is implicit - client = context.utils().injector().getInstance(SessionClient.class); + client = context.getApi(); } private SessionClient client; private SessionWithToken sessionWithToken; - @Test(description = "POST /sessions") + //temporary until we marry up the test fixtures + + protected String identity; + protected String credential; + protected String endpoint; + + @Override + protected Properties setupProperties() { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + identity = setIfTestSystemPropertyPresent(overrides, provider + ".identity"); + credential = setIfTestSystemPropertyPresent(overrides, provider + ".credential"); + endpoint = setIfTestSystemPropertyPresent(overrides, provider + ".endpoint"); + setIfTestSystemPropertyPresent(overrides, provider + ".api-version"); + setIfTestSystemPropertyPresent(overrides, provider + ".build-version"); + return overrides; + } + + @Test(testName = "POST /sessions") public void testLogin() { String user = identity.substring(0, identity.lastIndexOf('@')); String org = identity.substring(identity.lastIndexOf('@') + 1); @@ -96,11 +101,9 @@ public class SessionClientLiveTest extends BaseVersionedServiceLiveTest { public void testLogout() { client.logoutSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken()); } - - @AfterGroups(groups = "live") - protected void tearDown() { - if (context != null) - context.close(); + + @Override + protected ApiMetadata, ?> createApiMetadata() { + return AnonymousRestApiMetadata.forClientMappedToAsyncClient(SessionClient.class, SessionAsyncClient.class); } - } diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java index 5c7a800a3c..dd9f02fada 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java @@ -18,50 +18,111 @@ */ package org.jclouds.virtualbox; +import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_AUTHENTICATE_SUDO; +import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_LOGIN_USER; +import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR; +import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR; +import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE; +import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_PRECONFIGURATION_URL; +import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR; + +import java.io.File; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.base.Supplier; +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for VirtualBox API * + *

    note

    + * + * This class is not setup to allow a subclasses to override the type of api, + * asyncapi, or context. This is an optimization for simplicity. + * * @author Adrian Cole */ -public class VirtualBoxApiMetadata extends BaseApiMetadata { +@SuppressWarnings("rawtypes") +public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata, VirtualBoxApiMetadata> { - public VirtualBoxApiMetadata() { - this(builder() - .id("virtualbox") - .type(ApiType.COMPUTE) - .name("VirtualBox API") - .identityName("User") - .credentialName("Password") - .documentation(URI.create("https://www.virtualbox.org/sdkref/index.html"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected VirtualBoxApiMetadata(ConcreteBuilder builder) { + public VirtualBoxApiMetadata() { + this(new Builder()); + } + + protected VirtualBoxApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + + properties.put(IMAGE_LOGIN_USER, "toor:password"); + properties.put(IMAGE_AUTHENTICATE_SUDO, "true"); + + + properties.put(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE, " " + + "/install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL " + + "debian-installer=en_US auto locale=en_US kbd-chooser/method=us " + "hostname=" + "HOSTNAME " + + "fb=false debconf/frontend=noninteractive " + + "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false " + + "initrd=/install/initrd.gz -- "); + + String workingDir = System.getProperty("test.virtualbox.workingDir", VIRTUALBOX_DEFAULT_DIR); + + properties.put(VIRTUALBOX_WORKINGDIR, workingDir); + + String yamlDescriptor = System.getProperty("test.virtualbox.image.descriptor.yaml", VIRTUALBOX_WORKINGDIR + + File.separator + "images.yaml"); + + properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor); + + properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:23232/preseed.cfg"); + return properties; + } + + public static class Builder extends BaseComputeServiceApiMetadata.Builder, VirtualBoxApiMetadata> { + + protected Builder() { + id("virtualbox") + .type(ApiType.COMPUTE) + .name("VirtualBox API") + .identityName("User") + .credentialName("Password") + .documentation(URI.create("https://www.virtualbox.org/sdkref/index.html")) + .defaultIdentity("administrator") + .defaultCredential("12345") + .defaultEndpoint("http://localhost:18083/") + .documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon")) + // later version not in maven, yet + .version("4.1.4") + .buildVersion("4.1.8r75467") + .defaultProperties(VirtualBoxApiMetadata.defaultProperties()) + .javaApi(Supplier.class, Supplier.class) + .contextBuilder(TypeToken.of(VirtualBoxContextBuilder.class)); + } @Override public VirtualBoxApiMetadata build() { return new VirtualBoxApiMetadata(this); } + + @Override + public Builder fromApiMetadata(VirtualBoxApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxContextBuilder.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxContextBuilder.java index d5668ec389..4a6aec5936 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxContextBuilder.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxContextBuilder.java @@ -21,12 +21,13 @@ package org.jclouds.virtualbox; import java.net.URI; import java.util.List; -import java.util.Properties; import org.jclouds.byon.Node; import org.jclouds.byon.config.CacheNodeStoreModule; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.StandaloneComputeServiceContextBuilder; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule; import com.google.common.base.Predicate; @@ -41,10 +42,15 @@ import com.google.inject.Module; * @author Mattias Holmqvist, Andrea Turli */ @SuppressWarnings("rawtypes") -public class VirtualBoxContextBuilder extends StandaloneComputeServiceContextBuilder { +public class VirtualBoxContextBuilder extends StandaloneComputeServiceContextBuilder, VirtualBoxApiMetadata> { - public VirtualBoxContextBuilder(Properties properties) { - super(Supplier.class, new VirtualBoxPropertiesBuilder(properties).defaultProperties()); + public VirtualBoxContextBuilder( + ProviderMetadata, VirtualBoxApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public VirtualBoxContextBuilder(VirtualBoxApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxPropertiesBuilder.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxPropertiesBuilder.java deleted file mode 100644 index 04218b0a5a..0000000000 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxPropertiesBuilder.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.virtualbox; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_AUTHENTICATE_SUDO; -import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_LOGIN_USER; -import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR; -import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR; -import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE; -import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_PRECONFIGURATION_URL; -import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR; - -import java.io.File; -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties for VirtualBox integration. - * - * @author Mattias Holmqvist - */ -public class VirtualBoxPropertiesBuilder extends PropertiesBuilder { - - public VirtualBoxPropertiesBuilder() { - super(); - } - - public VirtualBoxPropertiesBuilder(Properties properties) { - super(properties); - } - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.put(PROPERTY_ENDPOINT, "http://localhost:18083/"); - // later version not in maven, yet - properties.put(PROPERTY_API_VERSION, "4.1.4"); - - properties.put(PROPERTY_BUILD_VERSION, "4.1.8r75467"); - - properties.put(IMAGE_LOGIN_USER, "toor:password"); - properties.put(IMAGE_AUTHENTICATE_SUDO, "true"); - - - properties.put(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE, " " - + "/install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL " - + "debian-installer=en_US auto locale=en_US kbd-chooser/method=us " + "hostname=" + "HOSTNAME " - + "fb=false debconf/frontend=noninteractive " - + "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false " - + "initrd=/install/initrd.gz -- "); - - String workingDir = System.getProperty("test.virtualbox.workingDir", VIRTUALBOX_DEFAULT_DIR); - - properties.put(VIRTUALBOX_WORKINGDIR, workingDir); - - String yamlDescriptor = System.getProperty("test.virtualbox.image.descriptor.yaml", VIRTUALBOX_WORKINGDIR - + File.separator + "images.yaml"); - - properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor); - - properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:23232/preseed.cfg"); - - return properties; - } -} diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java index c6852e53d2..7882a130b6 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java @@ -34,13 +34,14 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; import org.eclipse.jetty.server.Server; +import org.jclouds.byon.BYONApiMetadata; import org.jclouds.byon.Node; import org.jclouds.byon.functions.NodeToNodeMetadata; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; @@ -169,11 +170,10 @@ public class VirtualBoxComputeServiceContextModule extends @Host @Singleton protected ComputeServiceContext provideHostController() { - String provider = "byon"; - String identity = ""; - String credential = ""; - return new ComputeServiceContextFactory().createContext(provider, identity, credential, - ImmutableSet. of(new SLF4JLoggingModule(), new SshjSshClientModule())); + return ComputeServiceContextBuilder.newBuilder(new BYONApiMetadata()) + .credentials("", "") + .modules(ImmutableSet. of(new SLF4JLoggingModule(), new SshjSshClientModule())) + .build(); } @Provides diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java index fc6ecf1811..6b22c1944b 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java @@ -25,24 +25,20 @@ import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTA import java.io.File; import java.util.Map; -import java.util.Properties; import java.util.concurrent.ExecutorService; import javax.inject.Inject; import javax.inject.Named; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.virtualbox.config.VirtualBoxConstants; import org.jclouds.virtualbox.domain.HardDisk; import org.jclouds.virtualbox.domain.IsoSpec; @@ -88,7 +84,8 @@ import com.google.inject.Module; * @author Adrian Cole, David Alves */ @Test(groups = "live", singleThreaded = true, testName = "BaseVirtualBoxClientLiveTest") -public class BaseVirtualBoxClientLiveTest extends BaseVersionedServiceLiveTest { +public class BaseVirtualBoxClientLiveTest extends + BaseComputeServiceContextLiveTest> { public static final String DONT_DESTROY_MASTER = "jclouds.virtualbox.keep-test-master"; @@ -96,8 +93,6 @@ public class BaseVirtualBoxClientLiveTest extends BaseVersionedServiceLiveTest { provider = "virtualbox"; } - protected ComputeServiceContext context; - @Inject protected MachineController machineController; @@ -129,30 +124,18 @@ public class BaseVirtualBoxClientLiveTest extends BaseVersionedServiceLiveTest { private final ExecutorService singleThreadExec = MoreExecutors.sameThreadExecutor(); private String masterVmName; + @Override - protected void setupCredentials() { - // default behavior is to bomb when no user is configured, but we know the - // default user of - // vbox - ensureIdentityPropertyIsSpecifiedOrTakeFromDefaults(); - super.setupCredentials(); + protected Iterable setupModules() { + return ImmutableSet. of(getLoggingModule(), credentialStoreModule, getSshModule(), new ExecutorServiceModule( + singleThreadExec, singleThreadExec)); } - - protected void ensureIdentityPropertyIsSpecifiedOrTakeFromDefaults() { - if (!System.getProperties().containsKey("test." + provider + ".identity")) - System.setProperty("test." + provider + ".identity", "administrator"); - } - - @BeforeClass(groups = "live") - public void setupClient() { - setupCredentials(); - Properties overrides = new VirtualBoxPropertiesBuilder(setupProperties()).build(); - - context = new ComputeServiceContextFactory().createContext(provider, identity, credential, ImmutableSet - . of(new SLF4JLoggingModule(), new SshjSshClientModule(), new ExecutorServiceModule( - singleThreadExec, singleThreadExec)), overrides); - + + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); context.utils().injector().injectMembers(this); YamlImage image = getDefaultImage(); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/PreseedCfgServerTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/PreseedCfgServerTest.java index 2dc1358f7d..1b383315db 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/PreseedCfgServerTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/PreseedCfgServerTest.java @@ -41,7 +41,7 @@ public class PreseedCfgServerTest { @Test public void testJettyServerServesPreseedFile() throws Exception { - Properties props = new VirtualBoxPropertiesBuilder().defaultProperties(); + Properties props = VirtualBoxApiMetadata.defaultProperties(); String preconfigurationUrl = props.getProperty(VirtualBoxConstants.VIRTUALBOX_PRECONFIGURATION_URL); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java index 4880ed4d7b..6aec98fb30 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java @@ -19,7 +19,7 @@ package org.jclouds.virtualbox; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadataTest; +import org.jclouds.apis.internal.BaseApiMetadataTest; import org.testng.annotations.Test; /** diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest.java index ed73ee4c54..8c8b1445ac 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest.java @@ -58,8 +58,8 @@ public class CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest exten @Override @BeforeClass(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); instanceName = VIRTUALBOX_IMAGE_PREFIX + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java index eb28872e36..d7c81dab49 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java @@ -119,8 +119,8 @@ public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest { @Override @BeforeClass(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); instanceName = VIRTUALBOX_IMAGE_PREFIX + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest.java index de5ae9c8a3..dafab24618 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest.java @@ -54,8 +54,8 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends B private String vmName = ""; @Override - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); ideControllerName = "IDE Controller"; mode = CleanupMode.Full; } diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java index da7617d484..e611e50848 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java @@ -70,8 +70,8 @@ public class GuestAdditionsInstallerLiveTest extends BaseVirtualBoxClientLiveTes @Override @BeforeClass(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); injector = context.utils().injector(); String instanceName = VIRTUALBOX_IMAGE_PREFIX diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java index 830053e18e..a1e2815b9d 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java @@ -62,8 +62,8 @@ public class IMachinePredicatesLiveTest extends BaseVirtualBoxClientLiveTest { @Override @BeforeClass(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); instanceName = VIRTUALBOX_IMAGE_PREFIX + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java index c1da4d7121..8d90ea2028 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java @@ -59,8 +59,8 @@ public class MachineControllerLiveTest extends BaseVirtualBoxClientLiveTest { @Override @BeforeClass(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); instanceName = VIRTUALBOX_IMAGE_PREFIX + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java index 007b169ff9..d5c9725f51 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java @@ -59,8 +59,8 @@ public class MachineUtilsLiveTest extends BaseVirtualBoxClientLiveTest { @Override @BeforeClass(groups = "live") - public void setupClient() { - super.setupClient(); + public void setupContext() { + super.setupContext(); instanceName = VIRTUALBOX_IMAGE_PREFIX + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()); diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java index bbc6a1a9f5..611fff821f 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java @@ -49,7 +49,7 @@ public interface LoadBalancerService { /** * @return a reference to the context that created this LoadBalancerService. */ - LoadBalancerServiceContext getContext(); + LoadBalancerServiceContext getContext(); /** * @param location diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java new file mode 100644 index 0000000000..32806f5163 --- /dev/null +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java @@ -0,0 +1,20 @@ +package org.jclouds.loadbalancer; + +import org.jclouds.apis.ApiMetadata; + +import com.google.common.annotations.Beta; + +/** + * + * @author Adrian Cole + * @since 1.5 + */ +@Beta +public interface LoadBalancerServiceApiMetadata, M extends LoadBalancerServiceApiMetadata> + extends ApiMetadata { + + public static interface Builder, M extends LoadBalancerServiceApiMetadata> + extends ApiMetadata.Builder { + } + +} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java index 4412d595d7..4f82ccce50 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java @@ -18,8 +18,10 @@ */ package org.jclouds.loadbalancer; +import java.io.Closeable; + import org.jclouds.loadbalancer.internal.LoadBalancerServiceContextImpl; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.BackedByRestContext; import org.jclouds.rest.Utils; import com.google.inject.ImplementedBy; @@ -32,14 +34,11 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(LoadBalancerServiceContextImpl.class) -public interface LoadBalancerServiceContext { +public interface LoadBalancerServiceContext extends Closeable, BackedByRestContext { LoadBalancerService getLoadBalancerService(); - RestContext getProviderSpecificContext(); - - Utils getUtils(); /** @@ -47,5 +46,6 @@ public interface LoadBalancerServiceContext { */ Utils utils(); + @Override void close(); } \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java index 2543f8e3f2..cd8bee81c7 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java @@ -18,33 +18,48 @@ */ package org.jclouds.loadbalancer; -import java.util.Properties; +import static com.google.common.base.Preconditions.checkArgument; -import org.jclouds.loadbalancer.internal.LoadBalancerServiceContextImpl; -import org.jclouds.rest.RestContextBuilder; +import java.util.NoSuchElementException; -import com.google.inject.Key; -import com.google.inject.util.Types; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.ContextBuilder; /** * @author Adrian Cole */ -public abstract class LoadBalancerServiceContextBuilder extends RestContextBuilder { - - public LoadBalancerServiceContextBuilder(Class syncClientType, Class asyncClientType) { - this(syncClientType, asyncClientType, new Properties()); +public abstract class LoadBalancerServiceContextBuilder, M extends LoadBalancerServiceApiMetadata> extends + ContextBuilder { + +// TODO: +// public static ContextBuilder forTests() { +// return ContextBuilder.newBuilder(new StubApiMetadata()); +// } + + /** + * looks up a provider or api with the given id + * + * @param providerOrApi + * id of the provider or api + * @return means to build a context to that provider + * @throws NoSuchElementException + * if the id was not configured. + * @throws IllegalArgumentException + * if the api or provider isn't assignable from LoadBalancerServiceContext + */ + public static LoadBalancerServiceContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { + ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); + checkArgument(builder instanceof LoadBalancerServiceContextBuilder, + "type of providerOrApi[%s] is not LoadBalancerServiceContextBuilder: %s", providerOrApi, builder); + return LoadBalancerServiceContextBuilder.class.cast(builder); + } + + public LoadBalancerServiceContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); } - public LoadBalancerServiceContextBuilder(Class syncClientType, Class asyncClientType, - Properties properties) { - super(syncClientType, asyncClientType, properties); - + public LoadBalancerServiceContextBuilder(M apiMetadata) { + super(apiMetadata); } - public LoadBalancerServiceContext buildLoadBalancerServiceContext() { - // need the generic type information - return (LoadBalancerServiceContext) buildInjector().getInstance( - Key.get(Types.newParameterizedType(LoadBalancerServiceContextImpl.class, syncClientType, - asyncClientType))); - } } \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java index 40ac3c05e1..d42cce256b 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java @@ -18,135 +18,114 @@ */ package org.jclouds.loadbalancer; -import static org.jclouds.rest.RestContextFactory.createContextBuilder; -import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; - +import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.Providers; +import org.jclouds.rest.internal.ContextBuilder; +import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** - * Helper class to instantiate {@code LoadBalancerServiceContext} instances. * + * @see ContextBuilder + * @see LoadBalancerServiceContextBuilder * @author Adrian Cole */ +@Deprecated public class LoadBalancerServiceContextFactory { - private final RestContextFactory contextFactory; - /** - * Initializes with the default properties built-in to jclouds. This is typically stored in the - * classpath resource {@code rest.properties} - * - * @see RestContextFactory#getPropertiesFromResource + * for porting old code to {@link ContextBuilder} */ public LoadBalancerServiceContextFactory() { - this(new RestContextFactory()); } /** - * Finds definitions in the specified properties. + * for porting old code to {@link ContextBuilder} */ public LoadBalancerServiceContextFactory(Properties properties) { - this(new RestContextFactory(properties)); } /** - * - * Uses the supplied RestContextFactory to create {@link LoadBalancerServiceContext}s + * @see #createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContextFactory(RestContextFactory restContextFactory) { - this.contextFactory = restContextFactory; - } - - public static LoadBalancerServiceContext buildContextUnwrappingExceptions( - LoadBalancerServiceContextBuilder builder) { - try { - return builder.buildLoadBalancerServiceContext(); - } catch (Exception e) { - return propagateAuthorizationOrOriginalException(e); - } + public LoadBalancerServiceContext createContext(String providerOrApi, String identity, String credential) { + return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** - * @see RestContextFactory#createContextBuilder(String, String, String) + * @see #createContext(String, String, String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String provider, String identity, String credential) { - LoadBalancerServiceContextBuilder builder = LoadBalancerServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, identity, credential)); - return buildContextUnwrappingExceptions(builder); + public LoadBalancerServiceContext createContext(String providerOrApi, Properties overrides) { + return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** - * @see RestContextFactory#createContextBuilder(String, Properties) + * @see #createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String provider, Properties overrides) { - LoadBalancerServiceContextBuilder builder = LoadBalancerServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, overrides)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, Iterable) - */ - public LoadBalancerServiceContext createContext(String provider, Iterable modules, Properties overrides) { - LoadBalancerServiceContextBuilder builder = LoadBalancerServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, modules, overrides)); - return buildContextUnwrappingExceptions(builder); - - } - - /** - * @see RestContextFactory#createContextBuilder(String, String,String, Iterable) - */ - public LoadBalancerServiceContext createContext(String provider, @Nullable String identity, @Nullable String credential, - Iterable modules) { - LoadBalancerServiceContextBuilder builder = LoadBalancerServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, identity, credential, modules)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(String, String,String, Iterable, Properties) - */ - public LoadBalancerServiceContext createContext(String provider, @Nullable String identity, @Nullable String credential, - Iterable modules, Properties overrides) { - LoadBalancerServiceContextBuilder builder = LoadBalancerServiceContextBuilder.class.cast(contextFactory - .createContextBuilder(provider, identity, credential, modules, overrides)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec) - */ - public LoadBalancerServiceContext createContext(RestContextSpec contextSpec) { - LoadBalancerServiceContextBuilder builder = LoadBalancerServiceContextBuilder.class - .cast(createContextBuilder(contextSpec)); - return buildContextUnwrappingExceptions(builder); - - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec, Properties) - */ - public LoadBalancerServiceContext createContext(RestContextSpec contextSpec, Properties overrides) { - LoadBalancerServiceContextBuilder builder = LoadBalancerServiceContextBuilder.class.cast(createContextBuilder( - contextSpec, overrides)); - return buildContextUnwrappingExceptions(builder); - } - - /** - * @see RestContextFactory#createContextBuilder(RestContextSpec, Iterable, Properties) - */ - public LoadBalancerServiceContext createContext(RestContextSpec contextSpec, Iterable modules, + public LoadBalancerServiceContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { - LoadBalancerServiceContextBuilder builder = LoadBalancerServiceContextBuilder.class.cast(createContextBuilder( - contextSpec, modules, overrides)); - return buildContextUnwrappingExceptions(builder); + return createContext(providerOrApi, null, null, wiring, overrides); } -} \ No newline at end of file + /** + * @see #createContext(String, String,String, Iterable, Properties) + */ + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Properties overrides) { + return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); + } + + /** + * @see createContext(String, String,String, Iterable, Properties) + */ + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Iterable wiring) { + return createContext(providerOrApi, identity, credential, wiring, new Properties()); + } + + /** + * for porting old code to {@link ContextBuilder} + * + * @param providerOrApi + * @param identity + * nullable, if credentials are present in the overrides + * @param credential + * nullable, if credentials are present in the overrides + * @param wiring + * Configuration you'd like to pass to the context. Ex. + * ImmutableSet.of(new ExecutorServiceModule(myexecutor)) + * @param overrides + * properties to override defaults with. + * @return initialized context ready for use + */ + @SuppressWarnings("unchecked") + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + @Nullable String credential, Iterable wiring, Properties overrides) { + ContextBuilder builder = null; + try { + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = LoadBalancerServiceContextBuilder.newBuilder(pm); + } catch (NoSuchElementException e) { + builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); + } + builder.modules(Iterable.class.cast(wiring)); + builder.overrides(overrides); + if (identity != null) + builder.credentials(identity, credential); + Object context = builder.build(); + if (context instanceof LoadBalancerServiceContext) { + return LoadBalancerServiceContext.class.cast(context); + } else { + throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " + + context.getClass().getSimpleName()); + } + + } + +} diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java index 1083898581..b0e32f723e 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java @@ -63,7 +63,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { protected Logger logger = Logger.NULL; protected final Supplier defaultLocationSupplier; - protected final LoadBalancerServiceContext context; + protected final LoadBalancerServiceContext context; protected final LoadBalanceNodesStrategy loadBalancerStrategy; protected final GetLoadBalancerMetadataStrategy getLoadBalancerMetadataStrategy; protected final DestroyLoadBalancerStrategy destroyLoadBalancerStrategy; @@ -71,7 +71,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { protected final Supplier> locations; @Inject - protected BaseLoadBalancerService(Supplier defaultLocationSupplier, LoadBalancerServiceContext context, + protected BaseLoadBalancerService(Supplier defaultLocationSupplier, @SuppressWarnings("rawtypes") LoadBalancerServiceContext context, LoadBalanceNodesStrategy loadBalancerStrategy, GetLoadBalancerMetadataStrategy getLoadBalancerMetadataStrategy, DestroyLoadBalancerStrategy destroyLoadBalancerStrategy, ListLoadBalancersStrategy listLoadBalancersStrategy, @@ -98,7 +98,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { * {@inheritDoc} */ @Override - public LoadBalancerServiceContext getContext() { + public LoadBalancerServiceContext getContext() { return context; } diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java new file mode 100644 index 0000000000..e4f7d3b383 --- /dev/null +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java @@ -0,0 +1,63 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.loadbalancer.internal; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; + +import com.google.common.annotations.Beta; +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; + +/** + * + * @author Adrian Cole + * @since 1.5 + */ +@Beta +public abstract class BaseLoadBalancerServiceApiMetadata, M extends LoadBalancerServiceApiMetadata> + extends BaseApiMetadata implements LoadBalancerServiceApiMetadata { + + public static class Builder, M extends LoadBalancerServiceApiMetadata> + extends BaseApiMetadata.Builder implements LoadBalancerServiceApiMetadata.Builder { + public Builder() { + type(ApiType.LOADBALANCER); + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("rawtypes") + protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { + return new TypeToken>() { + private static final long serialVersionUID = 1L; + }.where(new TypeParameter() { + }, clientToken).where(new TypeParameter() { + }, asyncClientToken); + } + } + + protected BaseLoadBalancerServiceApiMetadata(BaseLoadBalancerServiceApiMetadata.Builder builder) { + super(builder); + } + +} \ No newline at end of file diff --git a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ContextBuilder.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java similarity index 54% rename from providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ContextBuilder.java rename to loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java index 732f814597..a134d63a68 100644 --- a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ContextBuilder.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java @@ -16,29 +16,24 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.go2cloud; +package org.jclouds.loadbalancer.internal; -import java.util.List; -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackContextBuilder; -import org.jclouds.go2cloud.config.Go2CloudJohannesburg1ComputeServiceContextModule; - -import com.google.inject.Module; +import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.ContextBuilder; /** - * * @author Adrian Cole */ -public class Go2CloudJohannesburg1ContextBuilder extends ElasticStackContextBuilder { +public abstract class BaseLoadBalancerServiceContextBuilder, M extends LoadBalancerServiceApiMetadata> + extends ContextBuilder { - public Go2CloudJohannesburg1ContextBuilder(Properties props) { - super(props); + public BaseLoadBalancerServiceContextBuilder(ProviderMetadata providerMetadata) { + super(providerMetadata); } - - @Override - protected void addContextModule(List modules) { - modules.add(new Go2CloudJohannesburg1ComputeServiceContextModule()); + + public BaseLoadBalancerServiceContextBuilder(M apiMetadata) { + super(apiMetadata); } - -} +} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java index 9aeeaa8242..4353253c15 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java @@ -32,7 +32,7 @@ import org.jclouds.rest.Utils; * @author Adrian Cole */ @Singleton -public class LoadBalancerServiceContextImpl implements LoadBalancerServiceContext { +public class LoadBalancerServiceContextImpl implements LoadBalancerServiceContext { private final LoadBalancerService loadBalancerService; private final RestContext providerSpecificContext; private final Utils utils; @@ -46,10 +46,9 @@ public class LoadBalancerServiceContextImpl implements LoadBalancerService this.loadBalancerService = checkNotNull(loadBalancerService, "loadBalancerService"); } - @SuppressWarnings({ "unchecked", "hiding" }) @Override - public RestContext getProviderSpecificContext() { - return (RestContext) providerSpecificContext; + public RestContext getProviderSpecificContext() { + return providerSpecificContext; } @Override diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java index 9fa21cf636..9bbfdb8b9f 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java @@ -21,7 +21,6 @@ package org.jclouds.loadbalancer; import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertNotNull; -import java.io.IOException; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -30,24 +29,26 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jclouds.Constants; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; import org.jclouds.compute.predicates.NodePredicates; +import org.jclouds.domain.LoginCredentials; +import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; +import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.ssh.SshClient; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; import com.google.inject.Guice; import com.google.inject.Module; @@ -56,7 +57,39 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public abstract class BaseLoadBalancerServiceLiveTest extends BaseVersionedServiceLiveTest { +public abstract class BaseLoadBalancerServiceLiveTest> extends BaseContextLiveTest { + + protected String imageId; + protected String loginUser; + protected String authenticateSudo; + protected LoginCredentials loginCredentials = LoginCredentials.builder().user("root").build(); + + protected Properties setupComputeProperties() { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + computeProvider = setIfTestSystemPropertyPresent(overrides, provider + ".compute.provider"); + computeIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".compute.identity"); + computeCredential = setIfTestSystemPropertyPresent(overrides, provider + ".compute.credential"); + computeEndpoint = setIfTestSystemPropertyPresent(overrides, provider + ".compute.endpoint"); + computeApiversion = setIfTestSystemPropertyPresent(overrides, provider + ".compute.api-version"); + computeBuildversion = setIfTestSystemPropertyPresent(overrides, provider + ".compute.build-version"); + imageId = setIfTestSystemPropertyPresent(overrides, provider + ".compute.image-id"); + loginUser = setIfTestSystemPropertyPresent(overrides, provider + ".compute.image.login-user"); + authenticateSudo = setIfTestSystemPropertyPresent(overrides, provider + ".compute.image.authenticate-sudo"); + + if (loginUser != null) { + Iterable userPass = Splitter.on(':').split(loginUser); + Builder loginCredentialsBuilder = LoginCredentials.builder(); + loginCredentialsBuilder.user(Iterables.get(userPass, 0)); + if (Iterables.size(userPass) == 2) + loginCredentialsBuilder.password(Iterables.get(userPass, 1)); + if (authenticateSudo != null) + loginCredentialsBuilder.authenticateSudo(Boolean.valueOf(authenticateSudo)); + loginCredentials = loginCredentialsBuilder.build(); + } + return overrides; + } protected SshClient.Factory sshFactory; protected String group; @@ -67,7 +100,7 @@ public abstract class BaseLoadBalancerServiceLiveTest extends BaseVersionedServi protected Map keyPair; protected LoadBalancerMetadata loadbalancer; - protected LoadBalancerServiceContext context; + protected LoadBalancerServiceContext context; protected String computeProvider; protected String computeIdentity; @@ -75,44 +108,19 @@ public abstract class BaseLoadBalancerServiceLiveTest extends BaseVersionedServi protected String computeEndpoint; protected String computeApiversion; protected String computeBuildversion; - protected ComputeServiceContext computeContext; - - @Override - protected void setupCredentials() { - super.setupCredentials(); - computeProvider = checkNotNull(System.getProperty("test." + provider + ".compute.provider"), "test." + provider - + ".compute.provider"); - computeIdentity = checkNotNull(System.getProperty("test." + provider + ".compute.identity"), "test." + provider - + ".compute.identity"); - computeCredential = System.getProperty("test." + provider + ".compute.credential"); - computeEndpoint = System.getProperty("test." + provider + ".compute.endpoint"); - computeApiversion = System.getProperty("test." + provider + ".compute.api-version"); - computeBuildversion = System.getProperty("test." + provider + ".compute.build-version"); - } - - protected Properties setupComputeProperties() { - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - overrides.setProperty(computeProvider + ".identity", computeIdentity); - if (computeCredential != null) - overrides.setProperty(computeProvider + ".credential", computeCredential); - if (computeEndpoint != null) - overrides.setProperty(computeProvider + ".endpoint", computeEndpoint); - if (computeApiversion != null) - overrides.setProperty(computeProvider + ".api-version", computeApiversion); - if (computeBuildversion != null) - overrides.setProperty(computeProvider + ".build-version", computeBuildversion); - return overrides; - } + protected ComputeServiceContext computeContext; @BeforeGroups(groups = { "integration", "live" }) - public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { + @Override + public void setupContext() { setServiceDefaults(); if (group == null) group = checkNotNull(provider, "provider"); - setupCredentials(); - initializeContext(); + // groups need to work with hyphens in them, so let's make sure there is + // one! + if (group.indexOf('-') == -1) + group = group + "-"; + super.setupContext(); initializeComputeContext(); buildSocketTester(); } @@ -120,19 +128,12 @@ public abstract class BaseLoadBalancerServiceLiveTest extends BaseVersionedServi public void setServiceDefaults() { } - - private void initializeContext() throws IOException { - if (context != null) - context.close(); - context = new LoadBalancerServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet.of(new Log4JLoggingModule()), setupProperties()); - } - - private void initializeComputeContext() throws IOException { + + protected void initializeComputeContext() { if (computeContext != null) computeContext.close(); - computeContext = new ComputeServiceContextFactory(setupRestProperties()).createContext(computeProvider, - ImmutableSet.of(new Log4JLoggingModule(), getSshModule()), setupComputeProperties()); + computeContext = new ComputeServiceContextFactory().createContext(computeProvider, setupModules(), + setupComputeProperties()); } protected void buildSocketTester() { diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java new file mode 100644 index 0000000000..f55b210d32 --- /dev/null +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java @@ -0,0 +1,34 @@ +package org.jclouds.loadbalancer.internal; + +import java.util.Set; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.Apis; +import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public abstract class BaseLoadBalancerServiceApiMetadataTest extends BaseApiMetadataTest { + + @SuppressWarnings("rawtypes") + public BaseLoadBalancerServiceApiMetadataTest(LoadBalancerServiceApiMetadata toTest) { + super(toTest, ApiType.LOADBALANCER); + } + + @Test + public void testContextAssignableFromLoadBalancerServiceContext() { + Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(LoadBalancerServiceContext.class))); + assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); + } + +} \ No newline at end of file diff --git a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchPropertiesBuilder.java b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchPropertiesBuilder.java deleted file mode 100644 index a3e988789f..0000000000 --- a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchPropertiesBuilder.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudwatch; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; - -import java.util.Properties; - -import org.jclouds.aws.domain.Region; -import org.jclouds.cloudwatch.CloudWatchAsyncClient; -import org.jclouds.cloudwatch.CloudWatchPropertiesBuilder; - -/** - * Builds properties used in CloudWatch Clients - * - * @author Adrian Cole - */ -public class AWSCloudWatchPropertiesBuilder extends CloudWatchPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_HEADER_TAG, "amz"); - properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION); - properties.putAll(Region.regionProperties()); - properties.setProperty(PROPERTY_ENDPOINT, "https://monitoring.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", - "https://monitoring.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", - "https://monitoring.us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_2 + ".endpoint", - "https://monitoring.us-west-2.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.SA_EAST_1 + ".endpoint", - "https://monitoring.sa-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", - "https://monitoring.eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", - "https://monitoring.ap-southeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + Region.AP_NORTHEAST_1 + ".endpoint", - "https://monitoring.ap-northeast-1.amazonaws.com"); - return properties; - } - - public AWSCloudWatchPropertiesBuilder() { - super(); - } - - public AWSCloudWatchPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java index 32031a90fe..56d4a634dd 100644 --- a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java +++ b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java @@ -18,51 +18,91 @@ */ package org.jclouds.aws.cloudwatch; -import java.net.URI; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.aws.domain.Region; import org.jclouds.cloudwatch.CloudWatchApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.cloudwatch.CloudWatchAsyncClient; +import org.jclouds.cloudwatch.CloudWatchClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.rest.RestContext; /** * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's CloudWatch * provider. - * - * @author Adrian Cole - */ -public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata { - - public AWSCloudWatchProviderMetadata() { - this(builder() - .id("aws-cloudwatch") - .name("Amazon CloudWatch") - .api(new CloudWatchApiMetadata()) - .homepage(URI.create("http://aws.amazon.com/cloudwatch")) - .console(URI.create("https://console.aws.amazon.com/cloudwatch/home")) - .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") - .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13")); +* +* @author Adrian Cole +*/ +public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata, CloudWatchApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AWSCloudWatchProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public AWSCloudWatchProviderMetadata() { + super(builder()); + } + + public AWSCloudWatchProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.putAll(Region.regionProperties()); + properties.setProperty(PROPERTY_REGION + "." + Region.US_EAST_1 + ".endpoint", + "https://monitoring.us-east-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + ".endpoint", + "https://monitoring.us-west-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + Region.US_WEST_2 + ".endpoint", + "https://monitoring.us-west-2.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + Region.SA_EAST_1 + ".endpoint", + "https://monitoring.sa-east-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + Region.EU_WEST_1 + ".endpoint", + "https://monitoring.eu-west-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + ".endpoint", + "https://monitoring.ap-southeast-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + Region.AP_NORTHEAST_1 + ".endpoint", + "https://monitoring.ap-northeast-1.amazonaws.com"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, CloudWatchApiMetadata> { + + protected Builder(){ + id("aws-cloudwatch") + .name("Amazon CloudWatch") + .endpoint("https://monitoring.us-east-1.amazonaws.com") + .homepage(URI.create("http://aws.amazon.com/cloudwatch")) + .console(URI.create("https://console.aws.amazon.com/cloudwatch/home")) + .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") + .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13") + .apiMetadata( + new CloudWatchApiMetadata().toBuilder() + .version("2010-08-01").build()) + .defaultProperties(AWSCloudWatchProviderMetadata.defaultProperties()); + } @Override public AWSCloudWatchProviderMetadata build() { return new AWSCloudWatchProviderMetadata(this); } - } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudWatchApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - -} +} \ No newline at end of file diff --git a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java index 77882b1624..34e534042c 100644 --- a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java +++ b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java @@ -19,7 +19,9 @@ package org.jclouds.aws.cloudwatch; import org.jclouds.cloudwatch.CloudWatchApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.cloudwatch.CloudWatchAsyncClient; +import org.jclouds.cloudwatch.CloudWatchClient; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** @@ -31,6 +33,6 @@ import org.testng.annotations.Test; public class AWSCloudWatchProviderTest extends BaseProviderMetadataTest { public AWSCloudWatchProviderTest() { - super(new AWSCloudWatchProviderMetadata(), new CloudWatchApiMetadata()); + super(new AWSCloudWatchProviderMetadata(), new CloudWatchApiMetadata()); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java index 04cf5b3de4..8fec86622d 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java @@ -18,43 +18,70 @@ */ package org.jclouds.aws.ec2; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES; + +import java.util.Properties; + import org.jclouds.apis.ApiMetadata; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.ec2.EC2ApiMetadata; +import com.google.common.reflect.TypeToken; + /** * Implementation of {@link ApiMetadata} for the Amazon-specific EC2 API * * @author Adrian Cole */ -public class AWSEC2ApiMetadata extends EC2ApiMetadata { +public class AWSEC2ApiMetadata extends EC2ApiMetadata { + private static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } public AWSEC2ApiMetadata() { - this(builder().fromApiMetadata(new EC2ApiMetadata()) - .id("aws-ec2") - .name("Amazon-specific EC2 API")); + this(builder()); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AWSEC2ApiMetadata(ConcreteBuilder builder) { + protected AWSEC2ApiMetadata(Builder builder) { super(builder); } + + protected static Properties defaultProperties() { + Properties properties = EC2ApiMetadata.defaultProperties(); + // auth fail sometimes happens in EC2, as the rc.local script that injects the + // authorized key executes after ssh has started. + properties.setProperty("jclouds.ssh.max-retries", "7"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + properties.setProperty(PROPERTY_EC2_GENERATE_INSTANCE_NAMES, "true"); + return properties; + } - private static class ConcreteBuilder extends EC2ApiMetadataBuilder { - + public static class Builder extends EC2ApiMetadata.Builder { + protected Builder(){ + super(AWSEC2Client.class, AWSEC2AsyncClient.class); + id("aws-ec2") + .version(AWSEC2AsyncClient.VERSION) + .name("Amazon-specific EC2 API") + .context(TypeToken.of(AWSEC2ComputeServiceContext.class)) + .defaultProperties(AWSEC2ApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(AWSEC2ContextBuilder.class)); + } + @Override public AWSEC2ApiMetadata build() { return new AWSEC2ApiMetadata(this); } + + @Override + public Builder fromApiMetadata(AWSEC2ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } - private static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ContextBuilder.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ContextBuilder.java index 63bfd9e320..8a9c443933 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ContextBuilder.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ContextBuilder.java @@ -25,9 +25,11 @@ import java.util.List; import java.util.Properties; import java.util.logging.Logger; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.compute.config.AWSEC2ComputeServiceContextModule; import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; import org.jclouds.ec2.EC2ContextBuilder; +import org.jclouds.providers.ProviderMetadata; import com.google.common.annotations.VisibleForTesting; import com.google.inject.Module; @@ -36,19 +38,28 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class AWSEC2ContextBuilder extends EC2ContextBuilder { +public class AWSEC2ContextBuilder extends + EC2ContextBuilder { + public AWSEC2ContextBuilder() { + this(new AWSEC2ProviderMetadata()); + } - public AWSEC2ContextBuilder(Properties props) { - super(warnAndReplaceIfUsingOldImageKey(props)); + public AWSEC2ContextBuilder( + ProviderMetadata providerMetadata) { + super(providerMetadata); } - - @VisibleForTesting + + public AWSEC2ContextBuilder(AWSEC2ApiMetadata apiMetadata) { + super(apiMetadata); + } + @Override - public Properties getProperties(){ - return properties; + public AWSEC2ContextBuilder overrides(Properties overrides) { + super.overrides(warnAndReplaceIfUsingOldImageKey(overrides)); + return this; } - - //TODO: determine how to do conditional manipulation w/rocoto + + // TODO: determine how to do conditional manipulation w/rocoto static Properties warnAndReplaceIfUsingOldImageKey(Properties props) { if (props.containsKey(PROPERTY_EC2_AMI_OWNERS)) { StringBuilder query = new StringBuilder(); @@ -61,12 +72,12 @@ public class AWSEC2ContextBuilder extends EC2ContextBuilder { query = new StringBuilder(); props.setProperty(PROPERTY_EC2_AMI_QUERY, query.toString()); Logger.getAnonymousLogger().warning( - String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS, - PROPERTY_EC2_AMI_QUERY, query.toString())); + String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS, + PROPERTY_EC2_AMI_QUERY, query.toString())); } return props; } - + @Override protected void addClientModule(List modules) { modules.add(new AWSEC2RestClientModule()); @@ -77,4 +88,9 @@ public class AWSEC2ContextBuilder extends EC2ContextBuilder { modules.add(new AWSEC2ComputeServiceContextModule()); } + @VisibleForTesting + public Properties getOverrides() { + return overrides; + } + } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java deleted file mode 100644 index a79f049004..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ec2; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY; -import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY; -import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS; -import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; - -import java.util.Properties; - -import org.jclouds.aws.domain.Region; - -/** - * Builds properties used in EC2 Clients - * - * @author Adrian Cole - */ -public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, AWSEC2AsyncClient.VERSION); - // sometimes, like in ec2, stop takes a very long time, perhaps - // due to volume management. one example spent 2 minutes moving - // from stopping->stopped state on an ec2 micro - properties.setProperty(TIMEOUT_NODE_SUSPENDED, 120 * 1000 + ""); - // auth fail sometimes happens in EC2, as the rc.local script that injects the - // authorized key executes after ssh has started. - properties.setProperty("jclouds.ssh.max-retries", "7"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_EC2_GENERATE_INSTANCE_NAMES, "true"); - properties.putAll(Region.regionProperties()); - properties.remove(PROPERTY_EC2_AMI_OWNERS); - // amazon, alestic, canonical, and rightscale - properties.setProperty(PROPERTY_EC2_AMI_QUERY, - "owner-id=137112412989,063491364108,099720109477,411009282317;state=available;image-type=machine"); - // amis that work with the cluster instances - properties.setProperty(PROPERTY_EC2_CC_REGIONS, Region.US_EAST_1); - properties - .setProperty( - PROPERTY_EC2_CC_AMI_QUERY, - "virtualization-type=hvm;architecture=x86_64;owner-id=137112412989,099720109477;hypervisor=xen;state=available;image-type=machine;root-device-type=ebs"); - return properties; - } - - public AWSEC2PropertiesBuilder() { - super(); - } - - public AWSEC2PropertiesBuilder(Properties properties) { - super(properties); - } - - -} 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 945c4188a1..46a34a8212 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 @@ -18,50 +18,90 @@ */ package org.jclouds.aws.ec2; -import java.net.URI; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.aws.domain.Region; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Amazon's * Elastic Compute Cloud (EC2) provider. * - * @author Jeremy Whitlock + * @author Adrian Cole */ -public class AWSEC2ProviderMetadata extends BaseProviderMetadata { - - public AWSEC2ProviderMetadata() { - this(builder() - .id("aws-ec2") - .name("Amazon Elastic Compute Cloud (EC2)") - .api(new AWSEC2ApiMetadata()) - .homepage(URI.create("http://aws.amazon.com/ec2")) - .console(URI.create("https://console.aws.amazon.com/ec2/home")) - .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") - .iso3166Codes("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13")); +public class AWSEC2ProviderMetadata extends BaseProviderMetadata { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AWSEC2ProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public AWSEC2ProviderMetadata() { + super(builder()); + } + + public AWSEC2ProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + // sometimes, like in ec2, stop takes a very long time, perhaps + // due to volume management. one example spent 2 minutes moving + // from stopping->stopped state on an ec2 micro + properties.setProperty(TIMEOUT_NODE_SUSPENDED, 120 * 1000 + ""); + properties.putAll(Region.regionProperties()); + properties.remove(PROPERTY_EC2_AMI_OWNERS); + // amazon, alestic, canonical, and rightscale + properties.setProperty(PROPERTY_EC2_AMI_QUERY, + "owner-id=137112412989,063491364108,099720109477,411009282317;state=available;image-type=machine"); + // amis that work with the cluster instances + properties.setProperty(PROPERTY_EC2_CC_REGIONS, Region.US_EAST_1); + properties + .setProperty( + PROPERTY_EC2_CC_AMI_QUERY, + "virtualization-type=hvm;architecture=x86_64;owner-id=137112412989,099720109477;hypervisor=xen;state=available;image-type=machine;root-device-type=ebs"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder(){ + id("aws-ec2") + .name("Amazon Elastic Compute Cloud (EC2)") + .apiMetadata(new AWSEC2ApiMetadata()) + .endpoint("https://ec2.us-east-1.amazonaws.com") + .homepage(URI.create("http://aws.amazon.com/ec2")) + .console(URI.create("https://console.aws.amazon.com/ec2/home")) + .defaultProperties(AWSEC2ProviderMetadata.defaultProperties()) + .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") + .iso3166Codes("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13"); + } @Override public AWSEC2ProviderMetadata build() { return new AWSEC2ProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - } \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java index d54c7ed19d..758630b61c 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java @@ -92,7 +92,7 @@ public class AWSEC2ComputeService extends EC2ComputeService { private final boolean generateInstanceNames; @Inject - protected AWSEC2ComputeService(ComputeServiceContext context, Map credentialStore, + protected AWSEC2ComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichContextBuilder.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java similarity index 61% rename from providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichContextBuilder.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java index a62728d5a2..2b1642a084 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichContextBuilder.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java @@ -16,28 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.cloudsigma; +package org.jclouds.aws.ec2.compute; -import java.util.List; -import java.util.Properties; +import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.internal.AWSEC2ComputeServiceContextImpl; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; -import org.jclouds.cloudsigma.compute.config.CloudSigmaZurichComputeServiceContextModule; - -import com.google.inject.Module; +import com.google.inject.ImplementedBy; /** - * * @author Adrian Cole */ -public class CloudSigmaZurichContextBuilder extends CloudSigmaContextBuilder { - - public CloudSigmaZurichContextBuilder(Properties props) { - super(props); - } - +@ImplementedBy(AWSEC2ComputeServiceContextImpl.class) +public interface AWSEC2ComputeServiceContext extends EC2ComputeServiceContext { @Override - protected void addContextModule(List modules) { - modules.add(new CloudSigmaZurichComputeServiceContextModule()); - } - -} + AWSEC2ComputeService getComputeService(); +} \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java index a59b027789..c46cacd2ad 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java @@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicReference; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2PropertiesBuilder; import org.jclouds.aws.ec2.compute.AWSEC2TemplateBuilderImpl; import org.jclouds.aws.ec2.compute.functions.AWSRunningInstanceToNodeMetadata; import org.jclouds.aws.ec2.compute.predicates.AWSEC2InstancePresent; diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java index de2a4e3364..c123d18db4 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java @@ -73,6 +73,7 @@ import com.google.inject.name.Names; * @author Adrian Cole */ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDependenciesModule { + @SuppressWarnings("rawtypes") @Override protected void configure() { bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java new file mode 100644 index 0000000000..4ed9c3fba1 --- /dev/null +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java @@ -0,0 +1,51 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.ec2.compute.internal; + +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeService; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.compute.Utils; +import org.jclouds.domain.Credentials; +import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl; +import org.jclouds.rest.RestContext; + +/** + * @author Adrian Cole + */ +@Singleton +public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements AWSEC2ComputeServiceContext { + @Inject + public AWSEC2ComputeServiceContextImpl(AWSEC2ComputeService computeService, Map credentialStore, + Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { + super(computeService, credentialStore, utils, providerSpecificContext); + } + + @Override + public AWSEC2ComputeService getComputeService() { + return AWSEC2ComputeService.class.cast(super.getComputeService()); + } + +} diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java index 06c18c59d1..cd2d12c99a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java @@ -35,7 +35,7 @@ public class AWSEC2ContextBuilderTest { public void testConvertImageSyntax() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317"); - Properties props = new AWSEC2ContextBuilder(input).getProperties(); + Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), "owner-id=137112412989,063491364108,099720109477,411009282317;state=available;image-type=machine"); @@ -44,7 +44,7 @@ public class AWSEC2ContextBuilderTest { public void testConvertImageSyntaxWhenStar() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); - Properties props = new AWSEC2ContextBuilder(input).getProperties(); + Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), "state=available;image-type=machine"); } @@ -52,7 +52,7 @@ public class AWSEC2ContextBuilderTest { public void testConvertImageSyntaxWhenBlank() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, ""); - Properties props = new AWSEC2ContextBuilder(input).getProperties(); + Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), ""); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java index 5276ad391e..5a0c3d4bbb 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.aws.ec2; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index 20a35d7f6a..40e15c9b77 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -31,6 +31,8 @@ import java.util.Date; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata; +import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.MonitoringState; @@ -55,7 +57,7 @@ import org.jclouds.ec2.services.InstanceClient; import org.jclouds.ec2.services.KeyPairClient; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; +import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.scriptbuilder.domain.Statements; import org.testng.annotations.Test; @@ -73,7 +75,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AWSEC2ComputeServiceLiveTest") -public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { +public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public AWSEC2ComputeServiceLiveTest() { provider = "aws-ec2"; @@ -165,9 +167,9 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { // stop the spinner future.cancel(true); - RestContext monitoringContext = new RestContextFactory() - .createContext("aws-cloudwatch", identity, credential, ImmutableSet - . of(new Log4JLoggingModule())); + RestContext monitoringContext = ContextBuilder + .newBuilder(new AWSCloudWatchProviderMetadata()) + .modules(ImmutableSet. of(new Log4JLoggingModule())).build(); try { Set datapoints = monitoringContext.getApi().getMetricStatisticsInRegion(instance.getRegion(), diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index f2e28c3776..f32ff4875e 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -28,9 +28,10 @@ import java.util.Properties; import java.util.Set; import org.jclouds.aws.domain.Region; +import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.reference.AWSEC2Constants; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -59,7 +60,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { +public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { public AWSEC2TemplateBuilderLiveTest() { provider = "aws-ec2"; @@ -96,8 +97,8 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { public void testTemplateBuilderM1MEDIUMWithNegativeLookaroundDoesntMatchTestImages() { Template template = context.getComputeService().templateBuilder().hardwareId(InstanceType.M1_MEDIUM) - // need to select versions with double-digits so that lexicographic - // doesn't end up prefering 9.x vs 11.x + // need to select versions with double-digits so that lexicographic + // doesn't end up prefering 9.x vs 11.x .osVersionMatches("1[012].[10][04]") // negative lookahead for daily and testing, but ensure match // ubuntu-images @@ -238,15 +239,14 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testTemplateBuilderWithNoOwnersParsesImageOnDemand() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set owners to nothing overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, ""); overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, ""); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); + context = createContext(overrides, setupModules()); assertEquals(context.getComputeService().listImages().size(), 0); @@ -273,15 +273,14 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testTemplateBuilderWithNoOwnersParsesImageOnDemandDeprecated() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set owners to nothing overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, ""); overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, ""); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); + context = createContext(overrides, setupModules()); assertEquals(context.getComputeService().listImages().size(), 0); @@ -308,7 +307,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testTemplateBuilderWithLessRegions() throws IOException, SecurityException, NoSuchMethodException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set regions to only 1 @@ -318,11 +317,14 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, ""); final List commandsInvoked = Lists.newArrayList(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked)), - overrides); + + context = createContext( + overrides, + ImmutableSet. of(new Log4JLoggingModule(), + TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked))); - assert context.getComputeService().listAssignableLocations().size() < this.context.getComputeService().listAssignableLocations().size(); + assert context.getComputeService().listAssignableLocations().size() < this.context.getComputeService() + .listAssignableLocations().size(); assertOnlyOneRegionQueriedForAvailabilityZone(commandsInvoked); @@ -346,20 +348,22 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { } private static void assertOnlyOneRegionQueriedForAvailabilityZone(List commandsInvoked) - throws NoSuchMethodException { + throws NoSuchMethodException { assert commandsInvoked.size() == 2 : commandsInvoked; - assertEquals(getJavaMethodForRequestAtIndex(commandsInvoked, 0), AvailabilityZoneAndRegionAsyncClient.class - .getMethod("describeRegions", DescribeRegionsOptions[].class)); - assertEquals(getJavaMethodForRequestAtIndex(commandsInvoked, 1), AvailabilityZoneAndRegionAsyncClient.class - .getMethod("describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class)); + assertEquals(getJavaMethodForRequestAtIndex(commandsInvoked, 0), + AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", DescribeRegionsOptions[].class)); + assertEquals(getJavaMethodForRequestAtIndex(commandsInvoked, 1), + AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", String.class, + DescribeAvailabilityZonesOptions[].class)); } @Test public void testTemplateBuilderCanUseImageIdFromNonDefaultOwner() { - // This is the id of a public image, not owned by one of the four default owners + // This is the id of a public image, not owned by one of the four default + // owners String imageId = "us-east-1/ami-44d02f2d"; Template defaultTemplate = context.getComputeService().templateBuilder().imageId(imageId) - .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build(); + .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build(); assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate; assertEquals(defaultTemplate.getImage().getId(), imageId); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java index 2c9ecfbf96..fd7ece9fa4 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java @@ -26,20 +26,18 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import java.util.Iterator; -import java.util.Properties; import java.util.Set; import org.jclouds.aws.domain.Region; -import org.jclouds.compute.BaseVersionedServiceLiveTest; +import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.predicates.ImagePredicates; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.Image.ImageType; @@ -48,10 +46,8 @@ import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.services.AMIClient; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Predicates; @@ -60,7 +56,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; -import com.google.inject.Module; /** * Tests behavior of {@code AMIClient} @@ -68,7 +63,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AMIClientLiveTest extends BaseVersionedServiceLiveTest { +public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { public AMIClientLiveTest() { provider = "aws-ec2"; // TODO: parameterize this. @@ -78,20 +73,15 @@ public class AMIClientLiveTest extends BaseVersionedServiceLiveTest { private AMIClient client; private static final String DEFAULT_MANIFEST = "adrianimages/image.manifest.xml"; private static final String DEFAULT_SNAPSHOT = "TODO"; - private RestContext context; private Set imagesToDeregister = Sets.newHashSet(); private Set snapshotsToDelete = Sets.newHashSet(); - private ComputeServiceContext jcloudsContext; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - jcloudsContext = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet.of(new Log4JLoggingModule()), overrides); - context = jcloudsContext.getProviderSpecificContext(); - client = context.getApi().getAMIServices(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getAMIServices(); } public void testDescribeImageNotExists() { @@ -104,7 +94,7 @@ public class AMIClientLiveTest extends BaseVersionedServiceLiveTest { } public void testDescribeImages() { - for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : context.getProviderSpecificContext().getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set allResults = client.describeImagesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); @@ -165,7 +155,7 @@ public class AMIClientLiveTest extends BaseVersionedServiceLiveTest { @Test public void testNewlyRegisteredImageCanBeListed() throws Exception { - ComputeService computeService = jcloudsContext.getComputeService(); + ComputeService computeService = context.getComputeService(); Snapshot snapshot = createSnapshot(computeService); // List of images before... @@ -196,10 +186,10 @@ public class AMIClientLiveTest extends BaseVersionedServiceLiveTest { Set nodes = computeService.createNodesInGroup("jcloudstest", 1, options); try { String instanceId = Iterables.getOnlyElement(nodes).getProviderId(); - Reservation reservation = Iterables.getOnlyElement(context.getApi().getInstanceServices().describeInstancesInRegion(null, instanceId)); + Reservation reservation = Iterables.getOnlyElement(context.getProviderSpecificContext().getApi().getInstanceServices().describeInstancesInRegion(null, instanceId)); RunningInstance instance = Iterables.getOnlyElement(reservation); BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1"); - Snapshot snapshot = context.getApi().getElasticBlockStoreServices().createSnapshotInRegion(null, device.getVolumeId()); + Snapshot snapshot = context.getProviderSpecificContext().getApi().getElasticBlockStoreServices().createSnapshotInRegion(null, device.getVolumeId()); snapshotsToDelete.add(snapshot.getId()); return snapshot; } finally { @@ -281,6 +271,7 @@ public class AMIClientLiveTest extends BaseVersionedServiceLiveTest { for (String imageId : imagesToDeregister) client.deregisterImageInRegion(null, imageId); for (String snapshotId : snapshotsToDelete) - context.getApi().getElasticBlockStoreServices().deleteSnapshotInRegion(null, snapshotId); + context.getProviderSpecificContext().getApi().getElasticBlockStoreServices().deleteSnapshotInRegion(null, snapshotId); } + } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java index 4c536fd7a0..8e2d7d25d7 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java @@ -25,27 +25,22 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import java.util.Iterator; -import java.util.Properties; import java.util.Set; import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.RootDeviceType; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; -import com.google.inject.Module; /** * Tests behavior of {@code AWSAMIClient} @@ -53,7 +48,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AWSAMIClientLiveTest") -public class AWSAMIClientLiveTest extends BaseVersionedServiceLiveTest { +public class AWSAMIClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSAMIClientLiveTest() { provider = "aws-ec2"; // TODO: parameterize this. @@ -63,17 +58,14 @@ public class AWSAMIClientLiveTest extends BaseVersionedServiceLiveTest { private AWSAMIClient client; private static final String DEFAULT_MANIFEST = "adrianimages/image.manifest.xml"; private static final String DEFAULT_SNAPSHOT = "TODO"; - private RestContext context; private Set imagesToDeregister = Sets.newHashSet(); - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - client = context.getApi().getAMIServices(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getAMIServices(); } public void testDescribeImageNotExists() { @@ -86,7 +78,7 @@ public class AWSAMIClientLiveTest extends BaseVersionedServiceLiveTest { } public void testDescribeImages() { - for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : context.getProviderSpecificContext().getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java index 5554a5b55f..068e7dec17 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java @@ -20,31 +20,24 @@ package org.jclouds.aws.ec2.services; import static org.testng.Assert.assertNotNull; -import java.util.Properties; import java.util.Set; import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code EC2Client} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSInstanceClientLiveTest extends BaseVersionedServiceLiveTest { +public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSInstanceClientLiveTest() { provider = "aws-ec2"; } @@ -52,29 +45,21 @@ public class AWSInstanceClientLiveTest extends BaseVersionedServiceLiveTest { public static final String PREFIX = System.getProperty("user.name") + "-ec2"; private AWSInstanceClient client; - private RestContext context; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - client = context.getApi().getInstanceServices(); - + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getInstanceServices(); } @Test void testDescribeInstances() { - for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : context.getProviderSpecificContext().getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set> allResults = client.describeInstancesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 0 : allResults.size(); } } - @AfterTest - public void shutdown() { - context.close(); - } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java index efe34ee9c9..5a915fb7aa 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java @@ -31,29 +31,25 @@ import static org.testng.Assert.assertNotNull; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.SortedSet; import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.aws.ec2.domain.AWSRunningInstance; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeTestUtils; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.LoginCredentials; import org.jclouds.ec2.domain.KeyPair; import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -65,43 +61,36 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSKeyPairClientLiveTest extends BaseVersionedServiceLiveTest { +public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSKeyPairClientLiveTest() { provider = "aws-ec2"; } private AWSKeyPairClient client; - private RestContext context; - - private ComputeServiceContext computeContext; - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - computeContext = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), overrides); - context = computeContext.getProviderSpecificContext(); - client = context.getApi().getKeyPairServices(); + + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getKeyPairServices(); } public void testNoSsh() throws Exception { Map keyPair = ComputeTestUtils.setupKeyPair(); - AWSInstanceClient instanceClient = AWSEC2Client.class.cast(context.getApi()).getInstanceServices(); + AWSInstanceClient instanceClient = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()).getInstanceServices(); String group = PREFIX + "unssh"; - computeContext.getComputeService().destroyNodesMatching(inGroup(group)); + context.getComputeService().destroyNodesMatching(inGroup(group)); - TemplateOptions options = computeContext.getComputeService().templateOptions(); + TemplateOptions options = context.getComputeService().templateOptions(); options.authorizePublicKey(keyPair.get("public")).as(AWSEC2TemplateOptions.class); - ComputeServiceContext noSshContext = null; + ComputeServiceContext noSshContext = null; try { - noSshContext = new ComputeServiceContextFactory().createContext(provider, ImmutableSet - .of(new Log4JLoggingModule()), setupProperties()); + noSshContext = createContext(setupProperties(), ImmutableSet. of(new Log4JLoggingModule())); Set nodes = noSshContext.getComputeService().createNodesInGroup(group, 1, options); @@ -116,7 +105,7 @@ public class AWSKeyPairClientLiveTest extends BaseVersionedServiceLiveTest { assertEquals(instance.getKeyName(), "jclouds#" + group); - Map responses = computeContext.getComputeService() + Map responses = context.getComputeService() .runScriptOnNodesMatching( runningInGroup(group), exec("echo hello"), @@ -129,7 +118,7 @@ public class AWSKeyPairClientLiveTest extends BaseVersionedServiceLiveTest { } finally { noSshContext.close(); - computeContext.getComputeService().destroyNodesMatching(inGroup(group)); + context.getComputeService().destroyNodesMatching(inGroup(group)); } } @@ -213,9 +202,5 @@ public class AWSKeyPairClientLiveTest extends BaseVersionedServiceLiveTest { protected AWSRunningInstance getInstance(AWSInstanceClient instanceClient, String id) { return getOnlyElement(getOnlyElement(instanceClient.describeInstancesInRegion(null, id))); } - - @AfterTest - public void shutdown() { - context.close(); - } + } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java index 7c86695f43..fc3b2a0966 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java @@ -23,6 +23,9 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; +import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.ec2.domain.IpPermission; import org.jclouds.ec2.domain.IpProtocol; import org.jclouds.ec2.domain.SecurityGroup; @@ -38,7 +41,7 @@ import com.google.common.collect.ImmutableMultimap; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { +public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { public AWSSecurityGroupClientLiveTest() { provider = "aws-ec2"; } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java index 50295fe64b..3e184ba397 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java @@ -24,12 +24,12 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Properties; import java.util.Set; import javax.inject.Singleton; import org.jclouds.aws.domain.Region; +import org.jclouds.aws.ec2.AWSEC2ProviderMetadata; import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; import org.jclouds.aws.filters.FormSigner; import org.jclouds.compute.domain.Image; @@ -41,9 +41,7 @@ import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.util.Suppliers2; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -61,7 +59,7 @@ import com.google.inject.Provides; * @author Adrian Cole */ @Test(groups = "unit") -public abstract class BaseAWSEC2AsyncClientTest extends RestClientTest { +public abstract class BaseAWSEC2AsyncClientTest extends BaseAsyncClientTest { @RequiresHttp @ConfiguresRestClient @@ -134,8 +132,8 @@ public abstract class BaseAWSEC2AsyncClientTest extends RestClientTest { protected String provider = "aws-ec2"; @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties()); + public AWSEC2ProviderMetadata createProviderMetadata(){ + return new AWSEC2ProviderMetadata(); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java index 4cd81c9fbc..a1333fa1bb 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java @@ -21,44 +21,35 @@ package org.jclouds.aws.ec2.services; import static org.testng.Assert.assertEquals; import java.util.Map; -import java.util.Properties; import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.domain.MonitoringState; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.testng.annotations.BeforeGroups; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code MonitoringClient} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class MonitoringClientLiveTest extends BaseVersionedServiceLiveTest { +public class MonitoringClientLiveTest extends BaseComputeServiceContextLiveTest { public MonitoringClientLiveTest() { provider = "aws-ec2"; } private MonitoringClient client; private static final String DEFAULT_INSTANCE = "i-TODO"; - private RestContext context; - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - client = context.getApi().getMonitoringServices(); + + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getMonitoringServices(); } @Test(enabled = false) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index a39c976178..0899b6ce28 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -24,41 +24,34 @@ import static com.google.common.collect.Sets.newTreeSet; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Properties; import java.util.Set; import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; +import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.aws.ec2.domain.PlacementGroup.State; import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable; import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.ec2.domain.InstanceType; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.scriptbuilder.statements.java.InstallJDK; import org.jclouds.scriptbuilder.statements.login.AdminAccess; -import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; /** * Tests behavior of {@code PlacementGroupClient} @@ -66,25 +59,21 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "PlacementGroupClientLiveTest") -public class PlacementGroupClientLiveTest extends BaseVersionedServiceLiveTest { +public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest { public PlacementGroupClientLiveTest() { provider = "aws-ec2"; } private AWSEC2Client client; - private ComputeServiceContext context; private RetryablePredicate availableTester; private RetryablePredicate deletedTester; private PlacementGroup group; - - @BeforeGroups(groups = { "live" }) - public void setupClient() throws FileNotFoundException, IOException { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); - - client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()); + + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi(); availableTester = new RetryablePredicate(new PlacementGroupAvailable(client), 60, 1, TimeUnit.SECONDS); @@ -179,6 +168,5 @@ public class PlacementGroupClientLiveTest extends BaseVersionedServiceLiveTest { client.getPlacementGroupServices().deletePlacementGroupInRegion(group.getRegion(), group.getName()); assert deletedTester.apply(group) : group; } - context.close(); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java index 8908d7e48a..32c895b320 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java @@ -25,35 +25,29 @@ import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.la import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.io.FileNotFoundException; -import java.io.IOException; import java.util.Date; -import java.util.Properties; import java.util.Set; import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; +import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.LaunchSpecification; import org.jclouds.aws.ec2.domain.Spot; import org.jclouds.aws.ec2.domain.SpotInstanceRequest; import org.jclouds.aws.ec2.predicates.SpotInstanceRequestActive; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.domain.InstanceType; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; -import com.google.inject.Module; /** * Tests behavior of {@code SpotInstanceClient} @@ -61,27 +55,23 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class SpotInstanceClientLiveTest extends BaseVersionedServiceLiveTest { +public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { public SpotInstanceClientLiveTest() { provider = "aws-ec2"; } private static final int SPOT_DELAY_SECONDS = 600; private AWSEC2Client client; - private ComputeServiceContext context; private RetryablePredicate activeTester; private Set requests; private AWSRunningInstance instance; private long start; - @BeforeGroups(groups = { "live" }) - public void setupClient() throws FileNotFoundException, IOException { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), overrides); - - client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi(); activeTester = new RetryablePredicate(new SpotInstanceRequestActive(client), SPOT_DELAY_SECONDS, 1, 1, TimeUnit.SECONDS); } @@ -181,6 +171,5 @@ public class SpotInstanceClientLiveTest extends BaseVersionedServiceLiveTest { if (instance != null) { client.getInstanceServices().terminateInstancesInRegion(instance.getRegion(), instance.getId()); } - context.close(); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java index 901b52d23f..3f554f7f34 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java @@ -22,31 +22,23 @@ import static com.google.common.collect.Iterables.getOnlyElement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.util.Properties; import java.util.Set; import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.Tag; import org.jclouds.aws.ec2.util.TagFilters; import org.jclouds.aws.ec2.util.TagFilters.ResourceType; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.testng.annotations.AfterGroups; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.inject.Module; /** * Tests live behavior of {@code TagClient} @@ -54,40 +46,34 @@ import com.google.inject.Module; * @author grkvlt@apache.org */ @Test(groups = "live", singleThreaded = true) -public class TagClientLiveTest extends BaseVersionedServiceLiveTest { +public class TagClientLiveTest extends BaseComputeServiceContextLiveTest { public TagClientLiveTest() { provider = "aws-ec2"; } private TagClient client; - private RestContext context; - protected String testGroup; - private ComputeServiceContext computeContext; - - @BeforeGroups(groups = { "live" }) - public void setupClientAndSecurityGroup() { - setupCredentials(); - Properties overrides = setupProperties(); - computeContext = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), overrides); - context = computeContext.getProviderSpecificContext(); - client = context.getApi().getTagServices(); + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + client = context.getProviderSpecificContext().getApi().getTagServices(); + try { - testGroup = context.getApi().getSecurityGroupServices().createSecurityGroupInRegionAndReturnId(null, + testGroup = context.getProviderSpecificContext().getApi().getSecurityGroupServices().createSecurityGroupInRegionAndReturnId(null, "test-group", "test-group"); } catch (IllegalStateException e) { // already exists testGroup = Iterables.get( - context.getApi().getSecurityGroupServices().describeSecurityGroupsInRegion(null, "test-group"), 0) + context.getProviderSpecificContext().getApi().getSecurityGroupServices().describeSecurityGroupsInRegion(null, "test-group"), 0) .getId(); } } @AfterGroups(groups = { "live" }) public void deleteSecurityGroup() { - context.getApi().getSecurityGroupServices().deleteSecurityGroupInRegionById(null, testGroup); + context.getProviderSpecificContext().getApi().getSecurityGroupServices().deleteSecurityGroupInRegionById(null, testGroup); } public static final String PREFIX = System.getProperty("user.name") + "-ec2"; @@ -129,9 +115,4 @@ public class TagClientLiveTest extends BaseVersionedServiceLiveTest { protected AWSRunningInstance getInstance(AWSInstanceClient instanceClient, String id) { return getOnlyElement(getOnlyElement(instanceClient.describeInstancesInRegion(null, id))); } - - @AfterTest - public void shutdown() { - context.close(); - } } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java index 0b53e4bea9..708e2ef9cc 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java @@ -18,43 +18,62 @@ */ package org.jclouds.aws.s3; +import java.util.Properties; + import org.jclouds.apis.ApiMetadata; +import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; import org.jclouds.s3.S3ApiMetadata; +import com.google.common.reflect.TypeToken; + /** * Implementation of {@link ApiMetadata} for the Amazon-specific S3 API * * @author Adrian Cole */ -public class AWSS3ApiMetadata extends S3ApiMetadata { +public class AWSS3ApiMetadata extends S3ApiMetadata { + private static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } public AWSS3ApiMetadata() { - this(builder().fromApiMetadata(new S3ApiMetadata()) - .id("aws-s3") - .name("Amazon-specific S3 API")); + this(builder()); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AWSS3ApiMetadata(ConcreteBuilder builder) { + protected AWSS3ApiMetadata(Builder builder) { super(builder); } + + protected static Properties defaultProperties() { + Properties properties = S3ApiMetadata.defaultProperties(); + return properties; + } - private static class ConcreteBuilder extends S3ApiMetadataBuilder { - + public static class Builder extends S3ApiMetadata.Builder { + protected Builder(){ + super(AWSS3Client.class, AWSS3AsyncClient.class); + id("aws-s3") + .name("Amazon-specific S3 API") + .defaultProperties(AWSS3ApiMetadata.defaultProperties()) + .context(TypeToken.of(AWSS3BlobStoreContext.class)) + .contextBuilder(TypeToken.of(AWSS3ContextBuilder.class)); + } + @Override public AWSS3ApiMetadata build() { return new AWSS3ApiMetadata(this); } + + @Override + public Builder fromApiMetadata(AWSS3ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } - private static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } } \ No newline at end of file diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ContextBuilder.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ContextBuilder.java index 435933bb18..a2065d0c8c 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ContextBuilder.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ContextBuilder.java @@ -19,10 +19,11 @@ package org.jclouds.aws.s3; import java.util.List; -import java.util.Properties; +import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; import org.jclouds.aws.s3.blobstore.config.AWSS3BlobStoreContextModule; import org.jclouds.aws.s3.config.AWSS3RestClientModule; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.s3.S3ContextBuilder; import com.google.inject.Module; @@ -31,10 +32,19 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class AWSS3ContextBuilder extends S3ContextBuilder { +public class AWSS3ContextBuilder extends + S3ContextBuilder { + public AWSS3ContextBuilder() { + this(new AWSS3ProviderMetadata()); + } - public AWSS3ContextBuilder(Properties props) { - super(props); + public AWSS3ContextBuilder( + ProviderMetadata providerMetadata) { + super(providerMetadata); + } + + public AWSS3ContextBuilder(AWSS3ApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3PropertiesBuilder.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3PropertiesBuilder.java deleted file mode 100644 index 37f07d74d6..0000000000 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3PropertiesBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.s3; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; -import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; -import static org.jclouds.aws.domain.Region.SA_EAST_1; -import static org.jclouds.aws.domain.Region.US_STANDARD; -import static org.jclouds.aws.domain.Region.US_WEST_1; -import static org.jclouds.aws.domain.Region.US_WEST_2; -import static org.jclouds.location.reference.LocationConstants.ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; - -import java.util.Properties; - -import org.jclouds.aws.domain.Region; - -/** - * Builds properties used in S3 Clients - * - * @author Adrian Cole - */ -public class AWSS3PropertiesBuilder extends org.jclouds.s3.S3PropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.putAll(Region.regionPropertiesS3()); - properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ENDPOINT, "https://s3-us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_2 + "." + ENDPOINT, "https://s3-us-west-2.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + SA_EAST_1 + "." + ENDPOINT, "https://s3-sa-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ENDPOINT, "https://s3-eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ENDPOINT, - "https://s3-ap-southeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ENDPOINT, - "https://s3-ap-northeast-1.amazonaws.com"); - return properties; - } - - public AWSS3PropertiesBuilder() { - super(); - } - - public AWSS3PropertiesBuilder(Properties properties) { - super(properties); - } - -} 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 a6b758bd36..7dafc9d487 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 @@ -18,9 +18,23 @@ */ package org.jclouds.aws.s3; -import java.net.URI; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; +import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; +import static org.jclouds.aws.domain.Region.SA_EAST_1; +import static org.jclouds.aws.domain.Region.US_STANDARD; +import static org.jclouds.aws.domain.Region.US_WEST_1; +import static org.jclouds.aws.domain.Region.US_WEST_2; +import static org.jclouds.location.reference.LocationConstants.ENDPOINT; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.aws.domain.Region; +import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.providers.ProviderMetadata} for Amazon's Simple Storage Service @@ -28,40 +42,64 @@ import org.jclouds.providers.BaseProviderMetadata; * * @author Adrian Cole */ -public class AWSS3ProviderMetadata extends BaseProviderMetadata { - - public AWSS3ProviderMetadata() { - this(builder() - .id("aws-s3") - .name("Amazon Simple Storage Service (S3)") - .api(new AWSS3ApiMetadata()) - .homepage(URI.create("http://aws.amazon.com/s3")) - .console(URI.create("https://console.aws.amazon.com/s3/home")) - .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") - .iso3166Codes("US", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13")); +public class AWSS3ProviderMetadata extends BaseProviderMetadata { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AWSS3ProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public AWSS3ProviderMetadata() { + super(builder()); + } + + public AWSS3ProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.putAll(Region.regionPropertiesS3()); + properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ENDPOINT, "https://s3.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ENDPOINT, "https://s3-us-west-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + US_WEST_2 + "." + ENDPOINT, "https://s3-us-west-2.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + SA_EAST_1 + "." + ENDPOINT, "https://s3-sa-east-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + "EU" + "." + ENDPOINT, "https://s3-eu-west-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ENDPOINT, + "https://s3-ap-southeast-1.amazonaws.com"); + properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ENDPOINT, + "https://s3-ap-northeast-1.amazonaws.com"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder(){ + id("aws-s3") + .name("Amazon Simple Storage Service (S3)") + .apiMetadata(new AWSS3ApiMetadata()) + .homepage(URI.create("http://aws.amazon.com/s3")) + .console(URI.create("https://console.aws.amazon.com/s3/home")) + .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") + .iso3166Codes("US", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13") + .defaultProperties(AWSS3ProviderMetadata.defaultProperties()); + } @Override public AWSS3ProviderMetadata build() { return new AWSS3ProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - } \ No newline at end of file diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java index bc5e5b15f6..7f8476d7c8 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java @@ -69,7 +69,7 @@ public class AWSS3AsyncBlobStore extends S3AsyncBlobStore { private final BlobToObject blob2Object; @Inject - public AWSS3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + public AWSS3AsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AWSS3AsyncClient async, AWSS3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java index ba641fcc04..8fc842687d 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java @@ -65,7 +65,7 @@ public class AWSS3BlobStore extends S3BlobStore { private final BlobToObject blob2Object; @Inject - AWSS3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AWSS3BlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AWSS3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob, diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java similarity index 60% rename from apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java rename to providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java index 2de913c0d2..a95e175ab0 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java @@ -16,19 +16,24 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.cloudfiles.blobstore.integration; +package org.jclouds.aws.s3.blobstore; -import org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer; +import org.jclouds.aws.s3.AWSS3AsyncClient; +import org.jclouds.aws.s3.AWSS3Client; +import org.jclouds.aws.s3.blobstore.internal.AWSS3BlobStoreContextImpl; +import org.jclouds.s3.blobstore.S3BlobStoreContext; + +import com.google.inject.ImplementedBy; /** - * * @author Adrian Cole */ -public class CloudFilesTestInitializer extends SwiftTestInitializer { - - public CloudFilesTestInitializer() { - provider = "cloudfiles"; - } +@ImplementedBy(AWSS3BlobStoreContextImpl.class) +public interface AWSS3BlobStoreContext extends S3BlobStoreContext { + @Override + AWSS3BlobStore getBlobStore(); + @Override + AWSS3AsyncBlobStore getAsyncBlobStore(); } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java new file mode 100644 index 0000000000..640f7431d1 --- /dev/null +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java @@ -0,0 +1,62 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.s3.blobstore.internal; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.aws.s3.AWSS3AsyncClient; +import org.jclouds.aws.s3.AWSS3Client; +import org.jclouds.aws.s3.blobstore.AWSS3AsyncBlobStore; +import org.jclouds.aws.s3.blobstore.AWSS3BlobStore; +import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.InputStreamMap; +import org.jclouds.blobstore.attr.ConsistencyModel; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.Utils; +import org.jclouds.s3.blobstore.internal.S3BlobStoreContextImpl; + +/** + * @author Adrian Cole + */ +@Singleton +public class AWSS3BlobStoreContextImpl extends S3BlobStoreContextImpl implements + AWSS3BlobStoreContext { + + @Inject + public AWSS3BlobStoreContextImpl(BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, + InputStreamMap.Factory inputStreamMapFactory, AWSS3AsyncBlobStore ablobStore, AWSS3BlobStore blobStore, + @SuppressWarnings("rawtypes") RestContext providerSpecificContext, BlobRequestSigner blobRequestSigner) { + super(blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, blobStore, providerSpecificContext, + blobRequestSigner); + } + + @Override + public AWSS3BlobStore getBlobStore() { + return AWSS3BlobStore.class.cast(super.getBlobStore()); + } + + @Override + public AWSS3AsyncBlobStore getAsyncBlobStore() { + return AWSS3AsyncBlobStore.class.cast(super.getAsyncBlobStore()); + } + +} diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java index a56a0f2c6f..f003e5c57d 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java @@ -90,11 +90,10 @@ public class AWSS3RestClientModule extends S3RestClientModule */ - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) @Singleton @Provides - RestContext - provideBaseContext(RestContext in) { + RestContext provideBaseContext(RestContext in) { return (RestContext) in; } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java index da375f3532..70020caa99 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java @@ -21,7 +21,6 @@ package org.jclouds.aws.s3; import java.io.IOException; import java.lang.reflect.Method; import java.util.Map; -import java.util.Properties; import java.util.concurrent.ConcurrentMap; import org.jclouds.aws.s3.config.AWSS3RestClientModule; @@ -38,8 +37,6 @@ import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; @@ -66,10 +63,6 @@ import com.google.inject.TypeLiteral; @Test(groups = "unit", testName = "AWSS3AsyncClientTest") public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest { - public AWSS3AsyncClientTest() { - this.provider = "aws-s3"; - } - public void testGetBucketLocationEU() throws SecurityException, NoSuchMethodException, IOException { Method method = AWSS3AsyncClient.class.getMethod("getBucketLocation", String.class); HttpRequest request = processor.createRequest(method, "eubucket"); @@ -282,10 +275,9 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest createContextSpec() { - Properties props = new Properties(); - return new RestContextFactory().createContextSpec(provider, "identity", "credential", props); + public AWSS3ProviderMetadata createProviderMetadata() { + return new AWSS3ProviderMetadata(); } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientExpectTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientExpectTest.java index 746c3d0ac8..020ba759ff 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientExpectTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientExpectTest.java @@ -24,6 +24,7 @@ import java.net.URI; import org.jclouds.aws.s3.internal.BaseAWSS3ClientExpectTest; import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.domain.BlobBuilder; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.io.payloads.StringPayload; @@ -31,7 +32,10 @@ import org.jclouds.s3.blobstore.functions.BlobToObject; import org.jclouds.s3.domain.ObjectMetadata.StorageClass; import org.testng.annotations.Test; +import com.google.common.base.Functions; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; +import com.google.inject.Injector; /** * @author Andrei Savu @@ -41,6 +45,11 @@ public class AWSS3ClientExpectTest extends BaseAWSS3ClientExpectTest { @Test public void testPutWithReducedRedundancy() { + Injector injector = createInjector(Functions.forMap(ImmutableMap.of()), createModule(), setupProperties()); + + Blob blob = injector.getInstance(BlobBuilder.class).name("test").payload("content").build(); + BlobToObject blobToObject = injector.getInstance(BlobToObject.class); + AWSS3Client client = requestSendsResponse( HttpRequest.builder() .method("PUT") @@ -65,14 +74,7 @@ public class AWSS3ClientExpectTest extends BaseAWSS3ClientExpectTest { .build() ); - Blob blob = blobStore.blobBuilder("test").payload("content").build(); - BlobToObject blobToObject = getInstance(BlobToObject.class); - client.putObject("test", blobToObject.apply(blob), storageClass(StorageClass.REDUCED_REDUNDANCY)); } - - public T getInstance(Class klass) { - return blobStoreContext.utils().injector().getInstance(klass); - } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java index 6769524ae9..61ca9cb57b 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java @@ -60,8 +60,11 @@ import com.google.common.io.InputSupplier; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true, testName = "AWSS3ClientLiveTest") +@Test(groups = "live", singleThreaded = true, testName = "AWSS3ClientLiveTest") public class AWSS3ClientLiveTest extends S3ClientLiveTest { + public AWSS3ClientLiveTest() { + provider = "aws-s3"; + } private InputSupplier oneHundredOneConstitutions; private byte[] oneHundredOneConstitutionsMD5; private static long oneHundredOneConstitutionsLength; diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java index a4fb7bf309..e34f58f74a 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.aws.s3; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobIntegrationLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobIntegrationLiveTest.java index 5de31901a5..73b1e042fd 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobIntegrationLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "AWSS3BlobIntegrationLiveTest") public class AWSS3BlobIntegrationLiveTest extends S3BlobIntegrationLiveTest { - + public AWSS3BlobIntegrationLiveTest() { + provider = "aws-s3"; + } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobLiveTest.java index d38a2d6744..806eba2a7b 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "AWSS3BlobLiveTest") public class AWSS3BlobLiveTest extends S3BlobLiveTest { - + public AWSS3BlobLiveTest() { + provider = "aws-s3"; + } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobMapIntegrationLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobMapIntegrationLiveTest.java index 2aa3f41440..42a9a34384 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobMapIntegrationLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "AWSS3BlobMapIntegrationLiveTest") public class AWSS3BlobMapIntegrationLiveTest extends S3BlobMapIntegrationLiveTest { - + public AWSS3BlobMapIntegrationLiveTest() { + provider = "aws-s3"; + } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobSignerLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobSignerLiveTest.java index c18e7f7046..2ef6e68634 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobSignerLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobSignerLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "AWSS3BlobSignerLiveTest") public class AWSS3BlobSignerLiveTest extends S3BlobSignerLiveTest { - + public AWSS3BlobSignerLiveTest() { + provider = "aws-s3"; + } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ContainerIntegrationLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ContainerIntegrationLiveTest.java index fce28d2d48..04d94b5e67 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ContainerIntegrationLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ContainerIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "AWSS3ContainerIntegrationLiveTest") public class AWSS3ContainerIntegrationLiveTest extends S3ContainerIntegrationLiveTest { - + public AWSS3ContainerIntegrationLiveTest() { + provider = "aws-s3"; + } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ContainerLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ContainerLiveTest.java index 799c21721e..27b952bd65 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ContainerLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ContainerLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "AWSS3ContainerLiveTest") public class AWSS3ContainerLiveTest extends S3ContainerLiveTest { - + public AWSS3ContainerLiveTest() { + provider = "aws-s3"; + } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3InputStreamMapIntegrationLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3InputStreamMapIntegrationLiveTest.java index 9a07c4de7e..8b83a0d6a7 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3InputStreamMapIntegrationLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3InputStreamMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "AWSS3InputStreamMapIntegrationLiveTest") public class AWSS3InputStreamMapIntegrationLiveTest extends S3InputStreamMapIntegrationLiveTest { - + public AWSS3InputStreamMapIntegrationLiveTest() { + provider = "aws-s3"; + } } diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ServiceIntegrationLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ServiceIntegrationLiveTest.java index 9736063dd3..caadb04705 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ServiceIntegrationLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3ServiceIntegrationLiveTest.java @@ -30,6 +30,10 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live", testName = "AWSS3ServiceIntegrationLiveTest") public class AWSS3ServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest { + public AWSS3ServiceIntegrationLiveTest() { + provider = "aws-s3"; + } + @Override protected Set getIso3166Codes() { return ImmutableSet. of("US", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13"); diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3TestInitializer.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3TestInitializer.java deleted file mode 100644 index 5ba408bd22..0000000000 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3TestInitializer.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.s3.blobstore.integration; - -import java.io.IOException; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer; -import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; -import org.jclouds.enterprise.config.EnterpriseConfigurationModule; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class AWSS3TestInitializer extends TransientBlobStoreTestInitializer { - - public AWSS3TestInitializer() { - provider = "aws-s3"; - BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true; - } - - @Override - protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiVersion, - String buildVersion, String app, String identity, String credential) throws IOException { - return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule, - new Log4JLoggingModule(), new EnterpriseConfigurationModule()), setupProperties(endpoint, apiVersion, - buildVersion, identity, credential)); - } - -} diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyTest.java index 2ef31b4819..deeea20e38 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategyTest.java @@ -54,6 +54,7 @@ import com.google.common.collect.Maps; @Test(groups = "unit") public class SequentialMultipartUploadStrategyTest { + @SuppressWarnings("unchecked") @Test public void testWithTwoParts() { AWSS3BlobStore ablobStore = createMock(AWSS3BlobStore.class); @@ -64,8 +65,8 @@ public class SequentialMultipartUploadStrategyTest { MutableBlobMetadata blobMeta = createMock(MutableBlobMetadata.class); Payload payload = createMock(Payload.class); MutableContentMetadata contentMeta = createMock(MutableContentMetadata.class); + @SuppressWarnings("rawtypes") BlobStoreContext context = createMock(BlobStoreContext.class); - @SuppressWarnings("unchecked") RestContext psc = createMock(RestContextImpl.class); AWSS3Client client = createMock(AWSS3Client.class); ObjectMetadata ometa = createMock(ObjectMetadata.class); @@ -117,6 +118,7 @@ public class SequentialMultipartUploadStrategyTest { verify(ometa); } + @SuppressWarnings("unchecked") @Test public void testWithTimeout() { AWSS3BlobStore ablobStore = createMock(AWSS3BlobStore.class); @@ -127,8 +129,8 @@ public class SequentialMultipartUploadStrategyTest { MutableBlobMetadata blobMeta = createMock(MutableBlobMetadata.class); Payload payload = createMock(Payload.class); MutableContentMetadata contentMeta = createMock(MutableContentMetadata.class); + @SuppressWarnings("rawtypes") BlobStoreContext context = createMock(BlobStoreContext.class); - @SuppressWarnings("unchecked") RestContext psc = createMock(RestContextImpl.class); AWSS3Client client = createMock(AWSS3Client.class); ObjectMetadata ometa = createMock(ObjectMetadata.class); diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java index c049a12d77..671c1712b8 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java @@ -18,24 +18,16 @@ */ package org.jclouds.aws.s3.internal; -import java.util.Properties; - import org.jclouds.aws.s3.AWSS3Client; +import org.jclouds.aws.s3.AWSS3ProviderMetadata; import org.jclouds.aws.s3.config.AWSS3RestClientModule; -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.date.TimeStamp; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; import org.jclouds.http.RequiresHttp; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.internal.BaseRestClientExpectTest; -import com.google.common.base.Function; import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -46,13 +38,16 @@ import com.google.inject.Module; public class BaseAWSS3ClientExpectTest extends BaseRestClientExpectTest { protected static final String CONSTANT_DATE = "2009-11-08T15:54:08.897Z"; - - protected BlobStoreContext blobStoreContext; - protected BlobStore blobStore; + public BaseAWSS3ClientExpectTest() { provider = "aws-s3"; } + + @Override + public ProviderMetadata createProviderMetadata() { + return new AWSS3ProviderMetadata(); + } @RequiresHttp @ConfiguresRestClient @@ -68,17 +63,4 @@ public class BaseAWSS3ClientExpectTest extends BaseRestClientExpectTest fn, Module module, Properties props) { - return clientFrom(BlobStoreContext.class.cast(new BlobStoreContextFactory(setupRestProperties()) - .createContext(provider, "identity", "credential", ImmutableSet.of(new ExpectModule(fn), - new NullLoggingModule(), module), props))); - } - - protected AWSS3Client clientFrom(BlobStoreContext context) { - blobStoreContext = context; - blobStore = context.getBlobStore(); - return AWSS3Client.class.cast(context.getProviderSpecificContext().getApi()); - } - } diff --git a/providers/azureblob/pom.xml b/providers/azureblob/pom.xml index d06fd0a561..73f56cc972 100644 --- a/providers/azureblob/pom.xml +++ b/providers/azureblob/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.azureblob.blobstore.integration.AzureBlobTestInitializer https://${jclouds.identity}.blob.core.windows.net 2009-09-19 @@ -99,7 +98,6 @@ ${test.azureblob.build-version} ${test.azureblob.identity} ${test.azureblob.credential} - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5}
    diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java index 3c2e3bd5f2..e0d21bee2a 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java @@ -18,51 +18,72 @@ */ package org.jclouds.azureblob; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for Microsoft Azure Blob Service API * * @author Adrian Cole */ -public class AzureBlobApiMetadata extends BaseApiMetadata { +public class AzureBlobApiMetadata + extends + BaseBlobStoreApiMetadata, AzureBlobApiMetadata> { + private static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } public AzureBlobApiMetadata() { - this(builder() - .id("azureblob") - .type(ApiType.BLOBSTORE) + this(builder()); + } + + protected AzureBlobApiMetadata(Builder builder) { + super(builder); + } + + protected static Properties defaultProperties() { + Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-ms-meta-"); + return properties; + } + + public static class Builder extends BaseBlobStoreApiMetadata.Builder, AzureBlobApiMetadata> { + protected Builder(){ + id("azureblob") .name("Microsoft Azure Blob Service API") .identityName("Account Name") .credentialName("Access Key") - .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx"))); - } - - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AzureBlobApiMetadata(Builder builder) { - super(builder); - } - - private static class ConcreteBuilder extends Builder { - + .version("2009-09-19") + .defaultEndpoint("https://${jclouds.identity}.blob.core.windows.net") + .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx")) + .contextBuilder(TypeToken.of(AzureBlobContextBuilder.class)) + .javaApi(AzureBlobClient.class, AzureBlobAsyncClient.class) + .defaultProperties(AzureBlobApiMetadata.defaultProperties()); + } + @Override public AzureBlobApiMetadata build() { return new AzureBlobApiMetadata(this); } + + @Override + public Builder fromApiMetadata(AzureBlobApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - -} \ No newline at end of file +} diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java index e36811c2be..e3492de627 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java @@ -19,35 +19,49 @@ package org.jclouds.azureblob; import java.util.List; -import java.util.Properties; import org.jclouds.azureblob.blobstore.config.AzureBlobStoreContextModule; import org.jclouds.azureblob.config.AzureBlobRestClientModule; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link AzureBlobStoreContext} or {@link Injector} instances based on the most commonly - * requested arguments. + * Creates {@link AzureBlobStoreContext} or {@link Injector} instances based on + * the most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole, Andrew Newdigate * @see AzureBlobStoreContext */ -public class AzureBlobContextBuilder extends - BlobStoreContextBuilder { +public class AzureBlobContextBuilder + extends + BlobStoreContextBuilder, AzureBlobApiMetadata> { + + public AzureBlobContextBuilder() { + this(new AzureBlobProviderMetadata()); + } - public AzureBlobContextBuilder(Properties props) { - super(AzureBlobClient.class, AzureBlobAsyncClient.class, props); + public AzureBlobContextBuilder( + ProviderMetadata, AzureBlobApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public AzureBlobContextBuilder(AzureBlobApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobPropertiesBuilder.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobPropertiesBuilder.java deleted file mode 100644 index 5fae25ea68..0000000000 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobPropertiesBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.azureblob; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in AzureBlob Connections - * - * @author Adrian Cole - */ -public class AzureBlobPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-ms-meta-"); - properties.setProperty(PROPERTY_API_VERSION, "2009-09-19"); - properties.setProperty(PROPERTY_ENDPOINT, "https://${jclouds.identity}.blob.core.windows.net"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-TX,US-IL,IE-D,SG,NL-NH,HK"); - return properties; - } - - public AzureBlobPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java index c57e8beb53..446b44aabb 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java @@ -19,46 +19,64 @@ package org.jclouds.azureblob; import java.net.URI; +import java.util.Properties; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Microsoft Azure Blob Service. * * @author Adrian Cole */ -public class AzureBlobProviderMetadata extends BaseProviderMetadata { - public AzureBlobProviderMetadata() { - this(builder() - .id("azureblob") - .name("Microsoft Azure Blob Service") - .api(new AzureBlobApiMetadata()) - .homepage(URI.create("http://www.microsoft.com/windowsazure/storage/")) - .console(URI.create("https://windows.azure.com/default.aspx")) - .linkedServices("azureblob", "azurequeue", "azuretable") - .iso3166Codes("US-TX","US-IL","IE-D","SG","NL-NH","HK")); +public class AzureBlobProviderMetadata extends BaseProviderMetadata, AzureBlobApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected AzureBlobProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public AzureBlobProviderMetadata() { + super(builder()); + } + + public AzureBlobProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + public static class Builder extends BaseProviderMetadata.Builder, AzureBlobApiMetadata> { + + protected Builder(){ + id("azureblob") + .name("Microsoft Azure Blob Service") + .apiMetadata(new AzureBlobApiMetadata()) + .endpoint("https://${jclouds.identity}.blob.core.windows.net") + .homepage(URI.create("http://www.microsoft.com/windowsazure/storage/")) + .console(URI.create("https://windows.azure.com/default.aspx")) + .linkedServices("azureblob", "azurequeue", "azuretable") + .iso3166Codes("US-TX","US-IL","IE-D","SG","NL-NH","HK") + .defaultProperties(AzureBlobProviderMetadata.defaultProperties()); + } @Override public AzureBlobProviderMetadata build() { return new AzureBlobProviderMetadata(this); } - } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, AzureBlobApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java index dc8980bae4..10adc18057 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java @@ -80,7 +80,7 @@ public class AzureAsyncBlobStore extends BaseAsyncBlobStore { private final BlobToHttpGetOptions blob2ObjectGetOptions; @Inject - AzureAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + AzureAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AzureBlobAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java index 629f176ca7..bc51aa5b22 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java @@ -72,7 +72,7 @@ public class AzureBlobStore extends BaseBlobStore { private final BlobToHttpGetOptions blob2ObjectGetOptions; @Inject - AzureBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AzureBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AzureBlobClient sync, ContainerToResourceMetadata container2ResourceMd, ListOptionsToListBlobsOptions blobStore2AzureContainerListOptions, diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java index b497828c03..72cf44c2b8 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java @@ -25,7 +25,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; import java.util.Map; -import java.util.Properties; import org.jclouds.azure.storage.filters.SharedKeyLiteAuthentication; import org.jclouds.azure.storage.options.ListOptions; @@ -46,10 +45,8 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.ReturnTrueOn404; import org.jclouds.http.options.GetOptions; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -64,7 +61,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AzureBlobAsyncClientTest") -public class AzureBlobAsyncClientTest extends RestClientTest { +public class AzureBlobAsyncClientTest extends BaseAsyncClientTest { public void testListContainers() throws SecurityException, NoSuchMethodException, IOException { Method method = AzureBlobAsyncClient.class.getMethod("listContainers", ListOptions[].class); @@ -293,7 +290,7 @@ public class AzureBlobAsyncClientTest extends RestClientTest createContextSpec() { - return new RestContextFactory().createContextSpec("azureblob", "identity", "credential", new Properties()); + public AzureBlobProviderMetadata createProviderMetadata() { + return new AzureBlobProviderMetadata(); } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java index dc84cf6044..cded63bf98 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java @@ -28,7 +28,6 @@ import java.io.ByteArrayInputStream; import java.lang.reflect.UndeclaredThrowableException; import java.net.URI; import java.security.SecureRandom; -import java.util.Properties; import java.util.Set; import org.jclouds.azure.storage.AzureStorageResponseException; @@ -40,25 +39,19 @@ import org.jclouds.azureblob.domain.ContainerProperties; import org.jclouds.azureblob.domain.ListBlobsResponse; import org.jclouds.azureblob.domain.PublicAccess; import org.jclouds.azureblob.options.ListBlobsOptions; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.blobstore.ContainerNotFoundException; +import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.crypto.CryptoStreams; import org.jclouds.http.HttpResponseException; import org.jclouds.http.options.GetOptions; import org.jclouds.io.Payloads; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.BaseRestClientLiveTest; import org.jclouds.util.Strings2; import org.jclouds.util.Throwables2; -import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.inject.Module; /** * Tests behavior of {@code AzureBlobClient} @@ -66,26 +59,18 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { +public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { public AzureBlobClientLiveTest() { provider = "azureblob"; } - protected AzureBlobClient client; - private BlobStoreContext context; - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new BlobStoreContextFactory().createContext(provider, ImmutableSet - . of(new Log4JLoggingModule()), overrides); - client = (AzureBlobClient) context.getProviderSpecificContext().getApi(); + public AzureBlobClient getApi() { + return (AzureBlobClient) context.getProviderSpecificContext().getApi(); } @Test public void testListContainers() throws Exception { - Set response = client.listContainers(); + Set response = getApi().listContainers(); assert null != response; long initialContainerCount = response.size(); assertTrue(initialContainerCount >= 0); @@ -101,7 +86,7 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { while (!created) { privateContainer = prefix + new SecureRandom().nextInt(); try { - created = client.createContainer(privateContainer, withMetadata(ImmutableMultimap.of("foo", "bar"))); + created = getApi().createContainer(privateContainer, withMetadata(ImmutableMultimap.of("foo", "bar"))); } catch (UndeclaredThrowableException e) { HttpResponseException htpe = (HttpResponseException) e.getCause().getCause(); if (htpe.getResponse().getStatusCode() == 409) @@ -109,13 +94,13 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { throw e; } } - Set response = client.listContainers(includeMetadata()); + Set response = getApi().listContainers(includeMetadata()); assert null != response; long containerCount = response.size(); assertTrue(containerCount >= 1); - ListBlobsResponse list = client.listBlobs(privateContainer); - assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/%s", identity, - privateContainer))); + ListBlobsResponse list = getApi().listBlobs(privateContainer); + assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/%s", context + .getProviderSpecificContext().getIdentity(), privateContainer))); // TODO .. check to see the container actually exists } @@ -125,7 +110,7 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { while (!created) { publicContainer = prefix + new SecureRandom().nextInt(); try { - created = client.createContainer(publicContainer, withPublicAccess(PublicAccess.BLOB)); + created = getApi().createContainer(publicContainer, withPublicAccess(PublicAccess.BLOB)); } catch (UndeclaredThrowableException e) { HttpResponseException htpe = (HttpResponseException) e.getCause().getCause(); if (htpe.getResponse().getStatusCode() == 409) @@ -134,7 +119,8 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { } } // TODO - // URL url = new URL(String.format("http://%s.blob.core.windows.net/%s", identity, + // URL url = new URL(String.format("http://%s.blob.core.windows.net/%s", + // identity, // publicContainer)); // Utils.toStringAndClose(url.openStream()); } @@ -142,11 +128,12 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { @Test(timeOut = 5 * 60 * 1000) public void testCreatePublicRootContainer() throws Exception { try { - client.deleteRootContainer(); + getApi().deleteRootContainer(); } catch (ContainerNotFoundException e) { Thread.sleep(5000); } catch (AzureStorageResponseException htpe) { - if (htpe.getResponse().getStatusCode() == 409) {// TODO look for specific message + if (htpe.getResponse().getStatusCode() == 409) {// TODO look for + // specific message Thread.sleep(5000); } else { throw htpe; @@ -156,9 +143,10 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { boolean created = false; while (!created) { try { - created = client.createRootContainer(); + created = getApi().createRootContainer(); } catch (AzureStorageResponseException htpe) { - if (htpe.getResponse().getStatusCode() == 409) {// TODO look for specific message + if (htpe.getResponse().getStatusCode() == 409) {// TODO look for + // specific message Thread.sleep(5000); continue; } else { @@ -166,15 +154,16 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { } } } - ListBlobsResponse list = client.listBlobs(); - assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/$root", identity))); + ListBlobsResponse list = getApi().listBlobs(); + assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/$root", context + .getProviderSpecificContext().getIdentity()))); } @Test public void testListContainersWithOptions() throws Exception { - BoundedSet response = client.listContainers(ListOptions.Builder.prefix(privateContainer) - .maxResults(1).includeMetadata()); + BoundedSet response = getApi().listContainers( + ListOptions.Builder.prefix(privateContainer).maxResults(1).includeMetadata()); assert null != response; long initialContainerCount = response.size(); assertTrue(initialContainerCount >= 0); @@ -184,7 +173,7 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testCreatePublicRootContainer" }) public void testDeleteRootContainer() throws Exception { - client.deleteRootContainer(); + getApi().deleteRootContainer(); // TODO loop for up to 30 seconds checking if they are really gone } @@ -192,18 +181,20 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { public void testListOwnedContainers() throws Exception { // Test default listing - Set response = client.listContainers(); - // assertEquals(response.size(), initialContainerCount + 2);// if the containers already + Set response = getApi().listContainers(); + // assertEquals(response.size(), initialContainerCount + 2);// if the + // containers already // exist, this will fail // Test listing with options - response = client.listContainers(ListOptions.Builder.prefix( - privateContainer.substring(0, privateContainer.length() - 1)).maxResults(1).includeMetadata()); + response = getApi().listContainers( + ListOptions.Builder.prefix(privateContainer.substring(0, privateContainer.length() - 1)).maxResults(1) + .includeMetadata()); assertEquals(response.size(), 1); assertEquals(Iterables.getOnlyElement(response).getName(), privateContainer); assertEquals(Iterables.getOnlyElement(response).getMetadata(), ImmutableMap.of("foo", "bar")); - response = client.listContainers(ListOptions.Builder.prefix(publicContainer).maxResults(1)); + response = getApi().listContainers(ListOptions.Builder.prefix(publicContainer).maxResults(1)); assertEquals(response.size(), 1); assertEquals(Iterables.getOnlyElement(response).getName(), publicContainer); @@ -211,13 +202,13 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { @Test public void testDeleteOneContainer() throws Exception { - client.deleteContainer("does-not-exist"); + getApi().deleteContainer("does-not-exist"); } @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testListOwnedContainers", "testObjectOperations" }) public void testDeleteContainer() throws Exception { - client.deleteContainer(privateContainer); - client.deleteContainer(publicContainer); + getApi().deleteContainer(privateContainer); + getApi().deleteContainer(publicContainer); // TODO loop for up to 30 seconds checking if they are really gone } @@ -226,33 +217,37 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { String data = "Here is my data"; // Test PUT with string data, ETag hash, and a piece of metadata - AzureBlob object = client.newBlob(); + AzureBlob object = getApi().newBlob(); object.getProperties().setName("object"); object.setPayload(data); Payloads.calculateMD5(object); object.getProperties().getContentMetadata().setContentType("text/plain"); object.getProperties().getMetadata().put("mykey", "metadata-value"); byte[] md5 = object.getProperties().getContentMetadata().getContentMD5(); - String newEtag = client.putBlob(privateContainer, object); - assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(object.getProperties().getContentMetadata() - .getContentMD5())); + String newEtag = getApi().putBlob(privateContainer, object); + assertEquals(CryptoStreams.hex(md5), + CryptoStreams.hex(object.getProperties().getContentMetadata().getContentMD5())); // Test HEAD of missing object - assert client.getBlobProperties(privateContainer, "non-existent-object") == null; + assert getApi().getBlobProperties(privateContainer, "non-existent-object") == null; // Test HEAD of object - BlobProperties metadata = client.getBlobProperties(privateContainer, object.getProperties().getName()); - // TODO assertEquals(metadata.getName(), object.getProperties().getName()); - // we can't check this while hacking around lack of content-md5, as GET of the first byte will - // show incorrect length 1, the returned size, as opposed to the real length. This is an ok - // tradeoff, as a container list will contain the correct size of the objects in an + BlobProperties metadata = getApi().getBlobProperties(privateContainer, object.getProperties().getName()); + // TODO assertEquals(metadata.getName(), + // object.getProperties().getName()); + // we can't check this while hacking around lack of content-md5, as GET of + // the first byte will + // show incorrect length 1, the returned size, as opposed to the real + // length. This is an ok + // tradeoff, as a container list will contain the correct size of the + // objects in an // inexpensive fashion // http://code.google.com/p/jclouds/issues/detail?id=92 // assertEquals(metadata.getSize(), data.length()); assertEquals(metadata.getContentMetadata().getContentType(), "text/plain"); // Azure doesn't return the Content-MD5 on head request.. - assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(object.getProperties().getContentMetadata() - .getContentMD5())); + assertEquals(CryptoStreams.hex(md5), + CryptoStreams.hex(object.getProperties().getContentMetadata().getContentMD5())); assertEquals(metadata.getETag(), newEtag); assertEquals(metadata.getMetadata().entrySet().size(), 1); assertEquals(metadata.getMetadata().get("mykey"), "metadata-value"); @@ -261,23 +256,25 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { // Multimap userMetadata = LinkedHashMultimap.create(); // userMetadata.put("New-Metadata-1", "value-1"); // userMetadata.put("New-Metadata-2", "value-2"); - // assertTrue(client.setBlobProperties(privateContainer, object.getProperties().getName(), + // assertTrue(getApi().setBlobProperties(privateContainer, + // object.getProperties().getName(), // userMetadata)); // Test GET of missing object - assert client.getBlob(privateContainer, "non-existent-object") == null; + assert getApi().getBlob(privateContainer, "non-existent-object") == null; // Test GET of object (including updated metadata) - AzureBlob getBlob = client.getBlob(privateContainer, object.getProperties().getName()); + AzureBlob getBlob = getApi().getBlob(privateContainer, object.getProperties().getName()); assertEquals(Strings2.toStringAndClose(getBlob.getPayload().getInput()), data); // TODO assertEquals(getBlob.getName(), object.getProperties().getName()); assertEquals(getBlob.getPayload().getContentMetadata().getContentLength(), new Long(data.length())); assertEquals(getBlob.getProperties().getContentMetadata().getContentType(), "text/plain"); - assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(getBlob.getProperties().getContentMetadata() - .getContentMD5())); + assertEquals(CryptoStreams.hex(md5), + CryptoStreams.hex(getBlob.getProperties().getContentMetadata().getContentMD5())); assertEquals(newEtag, getBlob.getProperties().getETag()); // wait until we can update metadata - // assertEquals(getBlob.getProperties().getMetadata().entries().size(), 2); + // assertEquals(getBlob.getProperties().getMetadata().entries().size(), + // 2); // assertEquals( // Iterables.getLast(getBlob.getProperties().getMetadata().get("New-Metadata-1")), // "value-1"); @@ -288,38 +285,41 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { assertEquals(metadata.getMetadata().get("mykey"), "metadata-value"); // test listing - ListBlobsResponse response = client.listBlobs(privateContainer, ListBlobsOptions.Builder.prefix( - object.getProperties().getName().substring(0, object.getProperties().getName().length() - 1)) - .maxResults(1).includeMetadata()); + ListBlobsResponse response = getApi().listBlobs( + privateContainer, + ListBlobsOptions.Builder + .prefix(object.getProperties().getName().substring(0, object.getProperties().getName().length() - 1)) + .maxResults(1).includeMetadata()); assertEquals(response.size(), 1); assertEquals(Iterables.getOnlyElement(response).getName(), object.getProperties().getName()); assertEquals(Iterables.getOnlyElement(response).getMetadata(), ImmutableMap.of("mykey", "metadata-value")); - // Test PUT with invalid ETag (as if object's data was corrupted in transit) + // Test PUT with invalid ETag (as if object's data was corrupted in + // transit) String correctEtag = newEtag; String incorrectEtag = "0" + correctEtag.substring(1); object.getProperties().setETag(incorrectEtag); try { - client.putBlob(privateContainer, object); + getApi().putBlob(privateContainer, object); } catch (Throwable e) { assertEquals(e.getCause().getClass(), HttpResponseException.class); assertEquals(((HttpResponseException) e.getCause()).getResponse().getStatusCode(), 422); } ByteArrayInputStream bais = new ByteArrayInputStream(data.getBytes("UTF-8")); - object = client.newBlob(); + object = getApi().newBlob(); object.getProperties().setName("chunked-object"); object.setPayload(bais); object.getPayload().getContentMetadata().setContentLength(new Long(data.getBytes().length)); - newEtag = client.putBlob(privateContainer, object); - assertEquals(CryptoStreams.hex(md5), CryptoStreams.hex(getBlob.getProperties().getContentMetadata() - .getContentMD5())); + newEtag = getApi().putBlob(privateContainer, object); + assertEquals(CryptoStreams.hex(md5), + CryptoStreams.hex(getBlob.getProperties().getContentMetadata().getContentMD5())); // Test GET with options // Non-matching ETag try { - client.getBlob(privateContainer, object.getProperties().getName(), GetOptions.Builder - .ifETagDoesntMatch(newEtag)); + getApi().getBlob(privateContainer, object.getProperties().getName(), + GetOptions.Builder.ifETagDoesntMatch(newEtag)); } catch (Exception e) { HttpResponseException httpEx = Throwables2.getFirstThrowableOfType(e, HttpResponseException.class); assert (httpEx != null) : "expected http exception, not " + e; @@ -328,8 +328,8 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { // Matching ETag TODO this shouldn't fail!!! try { - getBlob = client.getBlob(privateContainer, object.getProperties().getName(), GetOptions.Builder - .ifETagMatches(newEtag)); + getBlob = getApi().getBlob(privateContainer, object.getProperties().getName(), + GetOptions.Builder.ifETagMatches(newEtag)); assertEquals(getBlob.getProperties().getETag(), newEtag); } catch (HttpResponseException e) { assertEquals(e.getResponse().getStatusCode(), 412); @@ -338,13 +338,14 @@ public class AzureBlobClientLiveTest extends BaseRestClientLiveTest { // Range // doesn't work per // http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/479fa63f-51df-4b66-96b5-33ae362747b6 - // getBlob = client + // getBlob = getApi() // .getBlob(privateContainer, object.getProperties().getName(), // GetOptions.Builder.startAt(8)).get(120, // TimeUnit.SECONDS); - // assertEquals(Utils.toStringAndClose((InputStream) getBlob.getData()), data.substring(8)); + // assertEquals(Utils.toStringAndClose((InputStream) getBlob.getData()), + // data.substring(8)); - client.deleteBlob(privateContainer, "object"); - client.deleteBlob(privateContainer, "chunked-object"); + getApi().deleteBlob(privateContainer, "object"); + getApi().deleteBlob(privateContainer, "chunked-object"); } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java index d37a651909..81ddbaac09 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.azureblob; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequestTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequestTest.java index 57fce98969..a2424d3a16 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequestTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequestTest.java @@ -22,18 +22,16 @@ import static org.testng.Assert.assertEquals; import java.io.File; import java.net.URI; -import java.util.Properties; import javax.ws.rs.HttpMethod; import org.jclouds.azureblob.AzureBlobAsyncClient; +import org.jclouds.azureblob.AzureBlobProviderMetadata; import org.jclouds.azureblob.domain.AzureBlob; import org.jclouds.http.HttpRequest; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; @@ -48,7 +46,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BindAzureBlobMetadataToRequestTest") -public class BindAzureBlobMetadataToRequestTest extends RestClientTest { +public class BindAzureBlobMetadataToRequestTest extends BaseAsyncClientTest { @Test public void testPassWithMinimumDetailsAndPayload64MB() { @@ -147,7 +145,7 @@ public class BindAzureBlobMetadataToRequestTest extends RestClientTest createContextSpec() { - return new RestContextFactory().createContextSpec("azureblob", "identity", "credential", new Properties()); + public AzureBlobProviderMetadata createProviderMetadata() { + return new AzureBlobProviderMetadata(); } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java index ace0f360c2..d8d54451b8 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java @@ -21,9 +21,9 @@ package org.jclouds.azureblob.blobstore; import static org.testng.Assert.assertEquals; import java.io.IOException; -import java.util.Properties; import org.jclouds.azureblob.AzureBlobAsyncClient; +import org.jclouds.azureblob.AzureBlobProviderMetadata; import org.jclouds.azureblob.config.AzureBlobRestClientModule; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.domain.Blob; @@ -32,9 +32,7 @@ import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -50,7 +48,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AzureBlobRequestSignerTest") -public class AzureBlobRequestSignerTest extends RestClientTest { +public class AzureBlobRequestSignerTest extends BaseAsyncClientTest { private BlobRequestSigner signer; private Factory blobFactory; @@ -138,8 +136,7 @@ public class AzureBlobRequestSignerTest extends RestClientTest createContextSpec() { - return new RestContextFactory().createContextSpec("azureblob", "identity", "credential", new Properties()); + public AzureBlobProviderMetadata createProviderMetadata() { + return new AzureBlobProviderMetadata(); } - } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreModuleTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreModuleTest.java index be2cd4eb41..a4ad4e0722 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreModuleTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreModuleTest.java @@ -20,18 +20,13 @@ package org.jclouds.azureblob.blobstore.config; import static org.testng.Assert.assertEquals; +import org.jclouds.azureblob.AzureBlobProviderMetadata; import org.jclouds.azureblob.blobstore.strategy.FindMD5InBlobProperties; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientTest.MockModule; -import org.jclouds.rest.RestContextFactory; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.inject.Injector; -import com.google.inject.Module; /** * @author Adrian Cole @@ -39,20 +34,14 @@ import com.google.inject.Module; @Test(groups = "unit") public class AzureBlobStoreModuleTest { - Injector createInjector() { - return new RestContextFactory().createContextBuilder("azureblob", "uid", "key", - ImmutableSet. of(new MockModule(), new NullLoggingModule())).buildInjector(); - } - @Test void testContextImpl() { - Injector injector = createInjector(); - BlobStoreContext handler = injector.getInstance(BlobStoreContext.class); - assertEquals(handler.getClass(), BlobStoreContextImpl.class); - ContainsValueInListStrategy valueList = injector - .getInstance(ContainsValueInListStrategy.class); + Injector injector = BlobStoreContextBuilder.newBuilder(new AzureBlobProviderMetadata()).credentials("foo", "bar") + .buildInjector(); + ContainsValueInListStrategy valueList = injector.getInstance(ContainsValueInListStrategy.class); assertEquals(valueList.getClass(), FindMD5InBlobProperties.class); } + } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerIntegrationLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerIntegrationLiveTest.java index 9fb7ce01cd..dc73426d51 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerIntegrationLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerIntegrationLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class AzureBlobContainerIntegrationLiveTest extends BaseContainerIntegrationTest { - + public AzureBlobContainerIntegrationLiveTest() { + provider = "azureblob"; + } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerLiveTest.java index 1e000777a1..8b484bdd62 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobContainerLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class AzureBlobContainerLiveTest extends BaseContainerLiveTest { - + public AzureBlobContainerLiveTest() { + provider = "azureblob"; + } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobInputStreamMapIntegrationLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobInputStreamMapIntegrationLiveTest.java index 46080d53ef..42dd9b61d5 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobInputStreamMapIntegrationLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobInputStreamMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class AzureBlobInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest { - + public AzureBlobInputStreamMapIntegrationLiveTest() { + provider = "azureblob"; + } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java index ce345013da..e22bebd58a 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobIntegrationLiveTest.java @@ -31,7 +31,9 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class AzureBlobIntegrationLiveTest extends BaseBlobIntegrationTest { - + public AzureBlobIntegrationLiveTest() { + provider = "azureblob"; + } @Override public void testGetIfMatch() throws InterruptedException { // this currently fails diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobLiveTest.java index 708385b08b..405a1f060b 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class AzureBlobLiveTest extends BaseBlobLiveTest { - + public AzureBlobLiveTest() { + provider = "azureblob"; + } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobMapIntegrationLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobMapIntegrationLiveTest.java index b3d2829a11..27a948afbe 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobMapIntegrationLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class AzureBlobMapIntegrationLiveTest extends BaseBlobMapIntegrationTest { - + public AzureBlobMapIntegrationLiveTest() { + provider = "azureblob"; + } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobServiceIntegrationLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobServiceIntegrationLiveTest.java index e1cc463b93..9517b59fce 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobServiceIntegrationLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobServiceIntegrationLiveTest.java @@ -30,6 +30,9 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live") public class AzureBlobServiceIntegrationLiveTest extends BaseServiceIntegrationTest { + public AzureBlobServiceIntegrationLiveTest() { + provider = "azureblob"; + } @Override protected Set getIso3166Codes() { return ImmutableSet. of("US-TX", "US-IL", "IE-D", "SG", "NL-NH", "HK"); diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobSignerLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobSignerLiveTest.java index 9f1358051a..04eb532b85 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobSignerLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobSignerLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class AzureBlobSignerLiveTest extends BaseBlobSignerLiveTest { - + public AzureBlobSignerLiveTest() { + provider = "azureblob"; + } } diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobTestInitializer.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobTestInitializer.java deleted file mode 100644 index 5dfcd0a1d0..0000000000 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/integration/AzureBlobTestInitializer.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.azureblob.blobstore.integration; - -import java.io.IOException; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class AzureBlobTestInitializer extends TransientBlobStoreTestInitializer { - - public AzureBlobTestInitializer() { - provider = "azureblob"; - } - - @Override - protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiVersion, - String buildVersion, String app, String identity, String credential) throws IOException { - return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule, - new Log4JLoggingModule()), setupProperties(endpoint, apiVersion, buildVersion, identity, credential)); - } - -} diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ContextBuilder.java b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ContextBuilder.java index 31881dcb78..c65d72fba9 100644 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ContextBuilder.java +++ b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ContextBuilder.java @@ -19,11 +19,15 @@ package org.jclouds.bluelock.vcloud.zone01; import java.util.List; -import java.util.Properties; import org.jclouds.bluelock.vcloud.zone01.config.BluelockVCloudZone01RestClientModule; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.vcloud.VCloudApiMetadata; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudContextBuilder; import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; @@ -31,21 +35,28 @@ import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link BlueLockVCloudComputeServiceContext} or {@link Injector} instances based on the - * most commonly requested arguments. + * Creates {@link BlueLockVCloudComputeServiceContext} or {@link Injector} + * instances based on the most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole */ public class BluelockVCloudZone01ContextBuilder extends VCloudContextBuilder { + public BluelockVCloudZone01ContextBuilder( + ProviderMetadata, VCloudApiMetadata> providerMetadata) { + super(providerMetadata); + } - public BluelockVCloudZone01ContextBuilder(Properties props) { - super(props); + public BluelockVCloudZone01ContextBuilder(VCloudApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01PropertiesBuilder.java b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01PropertiesBuilder.java deleted file mode 100644 index f7a089870f..0000000000 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01PropertiesBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.bluelock.vcloud.zone01; - -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; - -import java.util.Properties; - -import org.jclouds.vcloud.VCloudPropertiesBuilder; - -/** - * Builds properties used in bluelock VCloud Clients - * - * @author Adrian Cole - */ -public class BluelockVCloudZone01PropertiesBuilder extends VCloudPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-IN"); - properties.setProperty(PROPERTY_ENDPOINT, "https://zone01.bluelock.com/api"); - properties.setProperty(PROPERTY_BUILD_VERSION, "1.5.0.464915"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01-.*"); - return properties; - } - - public BluelockVCloudZone01PropertiesBuilder(Properties properties) { - super(properties); - } -} diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java index ad88c48042..eca1705bbf 100644 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java +++ b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java @@ -18,49 +18,78 @@ */ package org.jclouds.bluelock.vcloud.zone01; -import java.net.URI; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.VCloudApiMetadata; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Bluelock vCloud Zone 1. * * @author Adrian Cole */ -public class BluelockVCloudZone01ProviderMetadata extends BaseProviderMetadata { +public class BluelockVCloudZone01ProviderMetadata + extends + BaseProviderMetadata, VCloudApiMetadata> { - public BluelockVCloudZone01ProviderMetadata() { - this(builder() - .id("bluelock-vcloud-zone01") - .name("Bluelock vCloud Zone 1") - .api(new VCloudApiMetadata()) - .homepage(URI.create("http://www.bluelock.com/bluelock-cloud-hosting")) - .console(URI.create("https://zone01.bluelock.com/cloud/org/YOUR_ORG_HERE")) - .iso3166Codes("US-IN")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected BluelockVCloudZone01ProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public BluelockVCloudZone01ProviderMetadata() { + super(builder()); + } + + public BluelockVCloudZone01ProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01-.*"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + + protected Builder(){ + id("bluelock-vcloud-zone01") + .name("Bluelock vCloud Zone 1") + .apiMetadata( + new VCloudApiMetadata().toBuilder() + .buildVersion("1.5.0.464915") + .contextBuilder(TypeToken.of(BluelockVCloudZone01ContextBuilder.class)).build()) + .homepage(URI.create("http://www.bluelock.com/bluelock-cloud-hosting")) + .console(URI.create("https://zone01.bluelock.com/cloud/org/YOUR_ORG_HERE")) + .iso3166Codes("US-IN") + .endpoint("https://zone01.bluelock.com/api") + .defaultProperties(BluelockVCloudZone01ProviderMetadata.defaultProperties()); + } @Override public BluelockVCloudZone01ProviderMetadata build() { return new BluelockVCloudZone01ProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, VCloudApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - -} +} \ No newline at end of file diff --git a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderTest.java b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderTest.java index 589c13500e..6ff2a9c476 100644 --- a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderTest.java +++ b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.bluelock.vcloud.zone01; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.jclouds.vcloud.VCloudApiMetadata; import org.testng.annotations.Test; diff --git a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java index f53ad7a320..ce95f91059 100644 --- a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java +++ b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "BluelockVCloudZone01TemplateBuilderLiveTest") -public class BluelockVCloudZone01TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class BluelockVCloudZone01TemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public BluelockVCloudZone01TemplateBuilderLiveTest() { provider = "bluelock-vcloud-zone01"; @@ -51,14 +56,14 @@ public class BluelockVCloudZone01TemplateBuilderLiveTest extends BaseTemplateBui @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { - case UBUNTU: - return !input.version.equals("") || !input.is64Bit; - case RHEL: - return !input.version.equals(""); - case WINDOWS: - return !input.version.equals(""); - default: - return true; + case UBUNTU: + return !input.version.equals("") || !input.is64Bit; + case RHEL: + return !input.version.equals(""); + case WINDOWS: + return !input.version.equals(""); + default: + return true; } } diff --git a/providers/cloudfiles-uk/pom.xml b/providers/cloudfiles-uk/pom.xml index bd14deabdf..d53054cffd 100644 --- a/providers/cloudfiles-uk/pom.xml +++ b/providers/cloudfiles-uk/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.rackspace.cloudfiles.blobstore.integration.CloudFilesUKTestInitializer https://lon.auth.api.rackspacecloud.com 1.0 @@ -114,7 +113,6 @@ ${test.cloudfiles-uk.build-version} ${test.cloudfiles-uk.identity} ${test.cloudfiles-uk.credential} - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} diff --git a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKPropertiesBuilder.java b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKPropertiesBuilder.java deleted file mode 100644 index 8ca6198225..0000000000 --- a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rackspace.cloudfiles; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.cloudfiles.CloudFilesPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class CloudFilesUKPropertiesBuilder extends CloudFilesPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_REGIONS, "UK"); - properties.setProperty(PROPERTY_ENDPOINT, "https://lon.auth.api.rackspacecloud.com"); - properties.setProperty(PROPERTY_ISO3166_CODES, "GB-SLG"); - return properties; - } - - public CloudFilesUKPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java index f50f10a9cc..53be4911e0 100644 --- a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java +++ b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java @@ -18,50 +18,70 @@ */ package org.jclouds.rackspace.cloudfiles; -import java.net.URI; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.cloudfiles.CloudFilesApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.cloudfiles.CloudFilesAsyncClient; +import org.jclouds.cloudfiles.CloudFilesClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files in UK. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files UK. * * @author Adrian Cole */ -public class CloudFilesUKProviderMetadata extends BaseProviderMetadata { - - public CloudFilesUKProviderMetadata() { - this(builder() - .id("cloudfiles-uk") - .name("Rackspace Cloud Files UK") - .api(new CloudFilesApiMetadata()) - .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-files")) - .console(URI.create("https://lon.manage.rackspacecloud.com")) - .linkedServices("cloudfiles-uk", "cloudservers-uk", "cloudloadbalancers-uk") - .iso3166Codes("GB-SLG")); +public class CloudFilesUKProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudFilesUKProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudFilesUKProviderMetadata() { + super(builder()); + } + + public CloudFilesUKProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, "UK"); + return properties; + } + public static class Builder extends BaseProviderMetadata.Builder, CloudFilesApiMetadata> { + + protected Builder(){ + id("cloudfiles-uk") + .name("Rackspace Cloud Files UK") + .apiMetadata(new CloudFilesApiMetadata()) + .endpoint("https://lon.auth.api.rackspacecloud.com") + .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-files")) + .console(URI.create("https://lon.manage.rackspacecloud.com")) + .linkedServices("cloudfiles-uk", "cloudservers-uk", "cloudloadbalancers-uk") + .iso3166Codes("GB-SLG"); + } @Override public CloudFilesUKProviderMetadata build() { return new CloudFilesUKProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudFilesApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - } \ No newline at end of file diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java index 0772eb26fc..703c3a3d00 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java @@ -21,7 +21,7 @@ package org.jclouds.rackspace.cloudfiles; import static org.testng.Assert.assertEquals; import org.jclouds.cloudfiles.CloudFilesClient; -import org.jclouds.openstack.swift.CommonSwiftClientLiveTest; +import org.jclouds.cloudfiles.CloudFilesClientLiveTest; import org.jclouds.openstack.swift.domain.SwiftObject; import org.testng.annotations.Test; @@ -31,7 +31,11 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudFilesUKClientLiveTest") -public class CloudFilesUKClientLiveTest extends CommonSwiftClientLiveTest { +public class CloudFilesUKClientLiveTest extends CloudFilesClientLiveTest { + public CloudFilesUKClientLiveTest() { + provider = "cloudfiles-uk"; + } + // NOTE cloudfilesuk doesn't have cdn @Override diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java index b8b2b83f11..f6ceef8a78 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.rackspace.cloudfiles; import org.jclouds.cloudfiles.CloudFilesApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobIntegrationLiveTest.java index a8f3004331..4a71ced142 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobIntegrationLiveTest.java @@ -26,6 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUKBlobIntegrationLiveTest") public class CloudFilesUKBlobIntegrationLiveTest extends CloudFilesBlobIntegrationLiveTest { - + public CloudFilesUKBlobIntegrationLiveTest() { + provider = "cloudfiles-uk"; + } } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobLiveTest.java index e1ea7f06f2..3fdbf7f74c 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUKBlobLiveTest") public class CloudFilesUKBlobLiveTest extends CloudFilesBlobLiveTest { + public CloudFilesUKBlobLiveTest() { + provider = "cloudfiles-uk"; + } } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobMapIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobMapIntegrationLiveTest.java index 22a106e789..baddc4135e 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobMapIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobMapIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUKBlobMapIntegrationLiveTest") public class CloudFilesUKBlobMapIntegrationLiveTest extends CloudFilesBlobMapIntegrationLiveTest { + public CloudFilesUKBlobMapIntegrationLiveTest() { + provider = "cloudfiles-uk"; + } } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobSignerLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobSignerLiveTest.java index 0334d52a8f..c1db27fcef 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobSignerLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKBlobSignerLiveTest.java @@ -27,5 +27,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUKBlobSignerLiveTest") public class CloudFilesUKBlobSignerLiveTest extends CloudFilesBlobSignerLiveTest { + public CloudFilesUKBlobSignerLiveTest() { + provider = "cloudfiles-uk"; + } } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerIntegrationLiveTest.java index 34c40ca166..5a86298313 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUKContainerIntegrationLiveTest") public class CloudFilesUKContainerIntegrationLiveTest extends CloudFilesContainerIntegrationLiveTest { + public CloudFilesUKContainerIntegrationLiveTest() { + provider = "cloudfiles-uk"; + } } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerLiveTest.java index e6be46a521..be4b310fac 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKContainerLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUKContainerLiveTest") public class CloudFilesUKContainerLiveTest extends CloudFilesContainerLiveTest { + public CloudFilesUKContainerLiveTest() { + provider = "cloudfiles-uk"; + } } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKInputStreamMapIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKInputStreamMapIntegrationLiveTest.java index 2991ed8983..cd559bcbf9 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKInputStreamMapIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKInputStreamMapIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUKInputStreamMapIntegrationLiveTest") public class CloudFilesUKInputStreamMapIntegrationLiveTest extends CloudFilesInputStreamMapIntegrationLiveTest { + public CloudFilesUKInputStreamMapIntegrationLiveTest() { + provider = "cloudfiles-uk"; + } } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKServiceIntegrationLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKServiceIntegrationLiveTest.java index bf0f7fcab7..2d2246f71f 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKServiceIntegrationLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKServiceIntegrationLiveTest.java @@ -30,6 +30,10 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live", testName = "CloudFilesUKServiceIntegrationLiveTest") public class CloudFilesUKServiceIntegrationLiveTest extends CloudFilesServiceIntegrationLiveTest { + public CloudFilesUKServiceIntegrationLiveTest() { + provider = "cloudfiles-uk"; + } + @Override protected Set getIso3166Codes() { return ImmutableSet. of("GB-SLG"); diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKTestInitializer.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKTestInitializer.java deleted file mode 100644 index 7f0747519f..0000000000 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUKTestInitializer.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rackspace.cloudfiles.blobstore.integration; - -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer; - -/** - * - * @author Adrian Cole - */ -public class CloudFilesUKTestInitializer extends CloudFilesTestInitializer { - - public CloudFilesUKTestInitializer() { - provider = "cloudfiles-uk"; - } -} diff --git a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSPropertiesBuilder.java b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSPropertiesBuilder.java deleted file mode 100644 index fff5bc1d09..0000000000 --- a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rackspace.cloudfiles; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.cloudfiles.CloudFilesPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class CloudFilesUSPropertiesBuilder extends CloudFilesPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_REGIONS, "US"); - properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-IL,US-TX"); - return properties; - } - - public CloudFilesUSPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java index c30dad5cdb..2b5c581e9a 100644 --- a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java +++ b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java @@ -18,50 +18,71 @@ */ package org.jclouds.rackspace.cloudfiles; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + import java.net.URI; +import java.util.Properties; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.cloudfiles.CloudFilesApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; - +import org.jclouds.cloudfiles.CloudFilesAsyncClient; +import org.jclouds.cloudfiles.CloudFilesClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files in US. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files US. * * @author Adrian Cole */ -public class CloudFilesUSProviderMetadata extends BaseProviderMetadata { - - public CloudFilesUSProviderMetadata() { - this(builder() - .id("cloudfiles-us") - .name("Rackspace Cloud Files US") - .api(new CloudFilesApiMetadata()) - .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/files")) - .console(URI.create("https://manage.rackspacecloud.com")) - .linkedServices("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us") - .iso3166Codes("US-IL","US-TX")); +public class CloudFilesUSProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudFilesUSProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudFilesUSProviderMetadata() { + super(builder()); + } + + public CloudFilesUSProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, "US"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, CloudFilesApiMetadata> { + + protected Builder(){ + id("cloudfiles-us") + .name("Rackspace Cloud Files US") + .apiMetadata(new CloudFilesApiMetadata()) + .endpoint("https://auth.api.rackspacecloud.com") + .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/files")) + .console(URI.create("https://manage.rackspacecloud.com")) + .linkedServices("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us") + .iso3166Codes("US-IL","US-TX"); + } @Override public CloudFilesUSProviderMetadata build() { return new CloudFilesUSProviderMetadata(this); } - } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudFilesApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSClientLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSClientLiveTest.java index 30cff58d55..165deaf1d4 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSClientLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSClientLiveTest.java @@ -28,5 +28,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", sequential = true, testName = "CloudFilesUSClientLiveTest") public class CloudFilesUSClientLiveTest extends CloudFilesClientLiveTest { - + public CloudFilesUSClientLiveTest() { + provider = "cloudfiles-us"; + } } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java index 54c8da6584..3d4b976ff1 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.rackspace.cloudfiles; import org.jclouds.cloudfiles.CloudFilesApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobIntegrationLiveTest.java index 7f1655b522..f7c7b02c45 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobIntegrationLiveTest.java @@ -26,6 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUSBlobIntegrationLiveTest") public class CloudFilesUSBlobIntegrationLiveTest extends CloudFilesBlobIntegrationLiveTest { - - + public CloudFilesUSBlobIntegrationLiveTest() { + provider = "cloudfiles-us"; + } } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobLiveTest.java index 8b5320ce07..1852d8feb4 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUSBlobLiveTest") public class CloudFilesUSBlobLiveTest extends CloudFilesBlobLiveTest { - + public CloudFilesUSBlobLiveTest() { + provider = "cloudfiles-us"; + } } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobMapIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobMapIntegrationLiveTest.java index c5e41d195f..eecc7b0703 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobMapIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUSBlobMapIntegrationLiveTest") public class CloudFilesUSBlobMapIntegrationLiveTest extends CloudFilesBlobMapIntegrationLiveTest { - + public CloudFilesUSBlobMapIntegrationLiveTest() { + provider = "cloudfiles-us"; + } } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobSignerLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobSignerLiveTest.java index 8e20eb85bb..1122d5ca58 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobSignerLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSBlobSignerLiveTest.java @@ -27,5 +27,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUSBlobSignerLiveTest") public class CloudFilesUSBlobSignerLiveTest extends CloudFilesBlobSignerLiveTest { - + public CloudFilesUSBlobSignerLiveTest() { + provider = "cloudfiles-us"; + } } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerIntegrationLiveTest.java index aab3274f63..86658faf92 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUSContainerIntegrationLiveTest") public class CloudFilesUSContainerIntegrationLiveTest extends CloudFilesContainerIntegrationLiveTest { - + public CloudFilesUSContainerIntegrationLiveTest() { + provider = "cloudfiles-us"; + } } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerLiveTest.java index 16e72e0ac6..2d003cceb5 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSContainerLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUSContainerLiveTest") public class CloudFilesUSContainerLiveTest extends CloudFilesContainerLiveTest { - + public CloudFilesUSContainerLiveTest() { + provider = "cloudfiles-us"; + } } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSInputStreamMapIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSInputStreamMapIntegrationLiveTest.java index c816f1eb3c..c982cb2890 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSInputStreamMapIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSInputStreamMapIntegrationLiveTest.java @@ -26,5 +26,7 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudFilesUSInputStreamMapIntegrationLiveTest") public class CloudFilesUSInputStreamMapIntegrationLiveTest extends CloudFilesInputStreamMapIntegrationLiveTest { - + public CloudFilesUSInputStreamMapIntegrationLiveTest() { + provider = "cloudfiles-us"; + } } diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSServiceIntegrationLiveTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSServiceIntegrationLiveTest.java index 0165ed8a51..3dfed3356f 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSServiceIntegrationLiveTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSServiceIntegrationLiveTest.java @@ -30,6 +30,9 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live", testName = "CloudFilesUSServiceIntegrationLiveTest") public class CloudFilesUSServiceIntegrationLiveTest extends CloudFilesServiceIntegrationLiveTest { + public CloudFilesUSServiceIntegrationLiveTest() { + provider = "cloudfiles-us"; + } @Override protected Set getIso3166Codes() { return ImmutableSet. of("US-IL", "US-TX"); diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSTestInitializer.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSTestInitializer.java deleted file mode 100644 index a9d667830d..0000000000 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesUSTestInitializer.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rackspace.cloudfiles.blobstore.integration; - -import org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer; - -/** - * - * @author Adrian Cole - */ -public class CloudFilesUSTestInitializer extends CloudFilesTestInitializer { - - public CloudFilesUSTestInitializer() { - provider = "cloudfiles-us"; - } -} diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java deleted file mode 100644 index f40db05837..0000000000 --- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rackspace.cloudloadbalancers; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.cloudloadbalancers.reference.Region.LON; -import static org.jclouds.location.reference.LocationConstants.ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.cloudloadbalancers.CloudLoadBalancersPropertiesBuilder; - -import com.google.common.base.Joiner; - -/** - * Builds properties used inRackspace Cloud Load Balancers Clients - * - * @author Dan Lo Bianco - */ -public class CloudLoadBalancersUKPropertiesBuilder extends CloudLoadBalancersPropertiesBuilder { - public static final String[] REGIONS = {LON}; - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(REGIONS)); - properties.setProperty(PROPERTY_ENDPOINT, "https://lon.auth.api.rackspacecloud.com"); - properties.setProperty(PROPERTY_ISO3166_CODES, "GB-SLG"); - - properties.setProperty(PROPERTY_REGION + "." + LON + "." + ISO3166_CODES, "GB-SLG"); - properties.setProperty(PROPERTY_REGION + "." + LON + "." + ENDPOINT, - String.format("https://lon.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION)); - - return properties; - } - - public CloudLoadBalancersUKPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java index 6069979007..f211ad45c8 100644 --- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java +++ b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java @@ -18,49 +18,82 @@ */ package org.jclouds.rackspace.cloudloadbalancers; +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.cloudloadbalancers.reference.Region.LON; +import static org.jclouds.location.reference.LocationConstants.ENDPOINT; +import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + import java.net.URI; +import java.util.Properties; import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers in UK. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers UK. * - * @author Dan Lo Bianco + * @author Adrian Cole */ -public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata { - - public CloudLoadBalancersUKProviderMetadata() { - this(builder() - .id("cloudloadbalancers-uk") - .name("Rackspace Cloud Load Balancers UK") - .api(new CloudLoadBalancersApiMetadata()) - .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-load-balancers")) - .console(URI.create("https://lon.manage.rackspacecloud.com")) - .linkedServices("cloudloadbalancers-uk", "cloudservers-uk", "cloudfiles-uk") - .iso3166Codes("GB-SLG")); +public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudLoadBalancersUKProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudLoadBalancersUKProviderMetadata() { + super(builder()); + } + + public CloudLoadBalancersUKProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, LON); + properties.setProperty(PROPERTY_ENDPOINT, "https://lon.auth.api.rackspacecloud.com"); + properties.setProperty(PROPERTY_ISO3166_CODES, "GB-SLG"); + properties.setProperty(PROPERTY_REGION + "." + LON + "." + ISO3166_CODES, "GB-SLG"); + properties.setProperty(PROPERTY_REGION + "." + LON + "." + ENDPOINT, + String.format("https://lon.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION)); + return properties; + } + public static class Builder extends BaseProviderMetadata.Builder, CloudLoadBalancersApiMetadata> { + + protected Builder(){ + id("cloudloadbalancers-uk") + .name("Rackspace Cloud Load Balancers UK") + .apiMetadata(new CloudLoadBalancersApiMetadata()) + .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-load-balancers")) + .console(URI.create("https://lon.manage.rackspacecloud.com")) + .linkedServices("cloudloadbalancers-uk", "cloudservers-uk", "cloudfiles-uk") + .iso3166Codes("GB-SLG") + .endpoint("https://lon.auth.api.rackspacecloud.com"); + } @Override public CloudLoadBalancersUKProviderMetadata build() { return new CloudLoadBalancersUKProviderMetadata(this); } - } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudLoadBalancersApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java index 3ef8cfc4f6..8f2f6d2892 100644 --- a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java +++ b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java @@ -29,6 +29,6 @@ import org.testng.annotations.Test; public class CloudLoadBalancersUKLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest { public CloudLoadBalancersUKLoadBalancerClientLiveTest() { provider = "cloudloadbalancers-uk"; - regions = CloudLoadBalancersUKPropertiesBuilder.REGIONS; + regions = new String[] { "LON" }; } } diff --git a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderTest.java b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderTest.java index ec189cfdd6..74a50dd55f 100644 --- a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderTest.java +++ b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.rackspace.cloudloadbalancers; import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java deleted file mode 100644 index 50e8e35515..0000000000 --- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rackspace.cloudloadbalancers; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.cloudloadbalancers.reference.Region.DFW; -import static org.jclouds.cloudloadbalancers.reference.Region.ORD; -import static org.jclouds.location.reference.LocationConstants.ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.cloudloadbalancers.CloudLoadBalancersPropertiesBuilder; - -import com.google.common.base.Joiner; - -/** - * Builds properties used inRackspace Cloud Load Balancers Clients - * - * @author Adrian Cole - */ -public class CloudLoadBalancersUSPropertiesBuilder extends CloudLoadBalancersPropertiesBuilder { - public static final String[] REGIONS = {ORD, DFW}; - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com"); - properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(REGIONS)); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-IL,US-TX"); - - properties.setProperty(PROPERTY_REGION + "." + ORD + "." + ISO3166_CODES, "US-IL"); - properties.setProperty(PROPERTY_REGION + "." + ORD + "." + ENDPOINT, String - .format("https://ord.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION)); - - properties.setProperty(PROPERTY_REGION + "." + DFW + "." + ISO3166_CODES, "US-TX"); - properties.setProperty(PROPERTY_REGION + "." + DFW + "." + ENDPOINT, String - .format("https://dfw.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION)); - return properties; - } - - public CloudLoadBalancersUSPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java index 4249495ec9..04f2018d5e 100644 --- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java +++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java @@ -18,49 +18,92 @@ */ package org.jclouds.rackspace.cloudloadbalancers; +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.cloudloadbalancers.reference.Region.DFW; +import static org.jclouds.cloudloadbalancers.reference.Region.ORD; +import static org.jclouds.location.reference.LocationConstants.ENDPOINT; +import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + import java.net.URI; +import java.util.Properties; import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; +import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +import com.google.common.base.Joiner; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers in US. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers US. * * @author Adrian Cole */ -public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata { - - public CloudLoadBalancersUSProviderMetadata() { - this(builder() - .id("cloudloadbalancers-us") - .name("Rackspace Cloud Load Balancers US") - .api(new CloudLoadBalancersApiMetadata()) - .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/loadbalancers")) - .console(URI.create("https://manage.rackspacecloud.com")) - .linkedServices("cloudloadbalancers-us", "cloudservers-us", "cloudfiles-us") - .iso3166Codes("US-IL","US-TX")); +public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudLoadBalancersUSProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudLoadBalancersUSProviderMetadata() { + super(builder()); + } + + public CloudLoadBalancersUSProviderMetadata(Builder builder) { super(builder); } + public static final String[] REGIONS = {ORD, DFW}; - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com"); + properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(REGIONS)); + properties.setProperty(PROPERTY_ISO3166_CODES, "US-IL,US-TX"); + + properties.setProperty(PROPERTY_REGION + "." + ORD + "." + ISO3166_CODES, "US-IL"); + properties.setProperty(PROPERTY_REGION + "." + ORD + "." + ENDPOINT, String + .format("https://ord.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION)); + + properties.setProperty(PROPERTY_REGION + "." + DFW + "." + ISO3166_CODES, "US-TX"); + properties.setProperty(PROPERTY_REGION + "." + DFW + "." + ENDPOINT, String + .format("https://dfw.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION)); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, CloudLoadBalancersApiMetadata> { + + protected Builder(){ + id("cloudloadbalancers-us") + .name("Rackspace Cloud Load Balancers US") + .apiMetadata(new CloudLoadBalancersApiMetadata()) + .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/loadbalancers")) + .console(URI.create("https://manage.rackspacecloud.com")) + .linkedServices("cloudloadbalancers-us", "cloudservers-us", "cloudfiles-us") + .iso3166Codes("US-IL","US-TX") + .endpoint("https://auth.api.rackspacecloud.com"); + } @Override public CloudLoadBalancersUSProviderMetadata build() { return new CloudLoadBalancersUSProviderMetadata(this); } - } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudLoadBalancersApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java index 0d471943be..31c17ffd8a 100644 --- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java +++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java @@ -29,6 +29,6 @@ import org.testng.annotations.Test; public class CloudLoadBalancersUSLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest { public CloudLoadBalancersUSLoadBalancerClientLiveTest() { provider = "cloudloadbalancers-us"; - regions = CloudLoadBalancersUSPropertiesBuilder.REGIONS; + regions = CloudLoadBalancersUSProviderMetadata.REGIONS; } } diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java index 7fdf7435f4..544d8ca23e 100644 --- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java +++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.rackspace.cloudloadbalancers; import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudonestorage/pom.xml b/providers/cloudonestorage/pom.xml index 73ff163f5a..8390b7c257 100644 --- a/providers/cloudonestorage/pom.xml +++ b/providers/cloudonestorage/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.cloudonestorage.blobstore.integration.CloudOneStorageTestInitializer https://cloudonestorage.peer1.com 1.3.0 @@ -107,7 +106,6 @@ ${test.cloudonestorage.build-version} ${test.cloudonestorage.identity} ${test.cloudonestorage.credential} - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} diff --git a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStoragePropertiesBuilder.java b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStoragePropertiesBuilder.java deleted file mode 100644 index 7941563395..0000000000 --- a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStoragePropertiesBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudonestorage; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Atmos Clients - * - * @author Adrian Cole - */ -public class CloudOneStoragePropertiesBuilder extends PropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "https://cloudonestorage.peer1.com"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-GA,US-TX"); - properties.setProperty(PROPERTY_API_VERSION, "1.3.0"); - return properties; - } - - public CloudOneStoragePropertiesBuilder() { - super(); - } - - public CloudOneStoragePropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java index 01c6e552ea..55e5452be9 100644 --- a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java +++ b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java @@ -19,9 +19,14 @@ package org.jclouds.cloudonestorage; import java.net.URI; +import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.atmos.AtmosAsyncClient; +import org.jclouds.atmos.AtmosClient; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@ link org.jclouds.types.ProviderMetadata} for PEER1's @@ -29,38 +34,53 @@ import org.jclouds.providers.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class CloudOneStorageProviderMetadata extends BaseProviderMetadata { - - public CloudOneStorageProviderMetadata() { - this(builder() - .id("cloudonestorage") - .name("PEER1 CloudOne Storage") - .api(new AtmosApiMetadata()) - .homepage(URI.create("http://www.peer1.com/hosting/cloudone-storage.php")) - .console(URI.create("https://mypeer1.com/")) - .iso3166Codes("US-GA", "US-TX")); +public class CloudOneStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudOneStorageProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudOneStorageProviderMetadata() { + super(builder()); + } + + public CloudOneStorageProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, AtmosApiMetadata> { + + protected Builder(){ + id("cloudonestorage") + .name("PEER1 CloudOne Storage") + .apiMetadata(new AtmosApiMetadata()) + .homepage(URI.create("http://www.peer1.com/hosting/cloudone-storage.php")) + .console(URI.create("https://mypeer1.com/")) + .iso3166Codes("US-GA", "US-TX") + .endpoint("https://cloudonestorage.peer1.com") + .defaultProperties(CloudOneStorageProviderMetadata.defaultProperties()); + } @Override public CloudOneStorageProviderMetadata build() { return new CloudOneStorageProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, AtmosApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } -} +} \ No newline at end of file diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/CloudOneStorageProviderTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/CloudOneStorageProviderTest.java index 0b1a45be58..92fa334aff 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/CloudOneStorageProviderTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/CloudOneStorageProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.cloudonestorage; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobIntegrationLiveTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobIntegrationLiveTest.java index e2aa681b32..fc3fe7380d 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobIntegrationLiveTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudOneStorageBlobIntegrationLiveTest") public class CloudOneStorageBlobIntegrationLiveTest extends AtmosIntegrationLiveTest { + public CloudOneStorageBlobIntegrationLiveTest() { + provider = "cloudonestorage"; + } } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobLiveTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobLiveTest.java index 29402bfc2b..240730065d 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobLiveTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudOneStorageBlobLiveTest") public class CloudOneStorageBlobLiveTest extends AtmosLiveTest { + public CloudOneStorageBlobLiveTest() { + provider = "cloudonestorage"; + } } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobMapIntegrationLiveTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobMapIntegrationLiveTest.java index 64ca7503ab..0026347e73 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobMapIntegrationLiveTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobMapIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudOneStorageBlobMapIntegrationLiveTest") public class CloudOneStorageBlobMapIntegrationLiveTest extends AtmosMapIntegrationLiveTest { + public CloudOneStorageBlobMapIntegrationLiveTest() { + provider = "cloudonestorage"; + } } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobSignerLiveTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobSignerLiveTest.java index 6391cd1733..10c4ddeeff 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobSignerLiveTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageBlobSignerLiveTest.java @@ -27,5 +27,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudOneStorageBlobSignerLiveTest") public class CloudOneStorageBlobSignerLiveTest extends AtmosBlobSignerLiveTest { + public CloudOneStorageBlobSignerLiveTest() { + provider = "cloudonestorage"; + } } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageContainerIntegrationLiveTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageContainerIntegrationLiveTest.java index fb7145b820..68f69e8614 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageContainerIntegrationLiveTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageContainerIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudOneStorageContainerIntegrationLiveTest") public class CloudOneStorageContainerIntegrationLiveTest extends AtmosContainerIntegrationLiveTest { + public CloudOneStorageContainerIntegrationLiveTest() { + provider = "cloudonestorage"; + } } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageContainerLiveTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageContainerLiveTest.java index bda2c12a73..440d023390 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageContainerLiveTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageContainerLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudOneStorageContainerLiveTest") public class CloudOneStorageContainerLiveTest extends AtmosContainerLiveTest { + public CloudOneStorageContainerLiveTest() { + provider = "cloudonestorage"; + } } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageInputStreamMapIntegrationLiveTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageInputStreamMapIntegrationLiveTest.java index da25e36a2d..37d9a9e3e5 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageInputStreamMapIntegrationLiveTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageInputStreamMapIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "CloudOneStorageInputStreamMapIntegrationLiveTest") public class CloudOneStorageInputStreamMapIntegrationLiveTest extends AtmosInputStreamMapIntegrationLiveTest { + public CloudOneStorageInputStreamMapIntegrationLiveTest() { + provider = "cloudonestorage"; + } } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageServiceIntegrationLiveTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageServiceIntegrationLiveTest.java index 6827693883..0ff05f0ad6 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageServiceIntegrationLiveTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/blobstore/integration/CloudOneStorageServiceIntegrationLiveTest.java @@ -30,6 +30,10 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live", testName = "CloudOneStorageServiceIntegrationLiveTest") public class CloudOneStorageServiceIntegrationLiveTest extends AtmosServiceIntegrationLiveTest { + public CloudOneStorageServiceIntegrationLiveTest() { + provider = "cloudonestorage"; + } + @Override protected Set getIso3166Codes() { return ImmutableSet. of("US-GA", "US-TX"); diff --git a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKPropertiesBuilder.java b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKPropertiesBuilder.java deleted file mode 100644 index 248e503514..0000000000 --- a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKPropertiesBuilder.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rackspace.cloudservers; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.cloudservers.CloudServersPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class CloudServersUKPropertiesBuilder extends CloudServersPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "GB-SLG"); - properties.setProperty(PROPERTY_ENDPOINT, "https://lon.auth.api.rackspacecloud.com"); - return properties; - } - - public CloudServersUKPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java index a2dee8abc8..0bed8a3b5d 100644 --- a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java +++ b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java @@ -18,50 +18,69 @@ */ package org.jclouds.rackspace.cloudservers; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + import java.net.URI; +import java.util.Properties; import org.jclouds.cloudservers.CloudServersApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.cloudservers.CloudServersAsyncClient; +import org.jclouds.cloudservers.CloudServersClient; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers in UK. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers UK. * * @author Adrian Cole */ -public class CloudServersUKProviderMetadata extends BaseProviderMetadata { - - public CloudServersUKProviderMetadata() { - this(builder() - .id("cloudservers-uk") - .name("Rackspace Cloud Servers UK") - .api(new CloudServersApiMetadata()) - .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-servers")) - .console(URI.create("https://lon.manage.rackspacecloud.com")) - .linkedServices("cloudloadbalancers-uk", "cloudservers-uk", "cloudfiles-uk") - .iso3166Codes("GB-SLG")); +public class CloudServersUKProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudServersUKProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudServersUKProviderMetadata() { + super(builder()); + } + + public CloudServersUKProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, "UK"); + return properties; + } + public static class Builder extends BaseProviderMetadata.Builder, CloudServersApiMetadata> { + + protected Builder(){ + id("cloudservers-uk") + .name("Rackspace Cloud Servers UK") + .apiMetadata(new CloudServersApiMetadata()) + .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-servers")) + .console(URI.create("https://lon.manage.rackspacecloud.com")) + .linkedServices("cloudloadbalancers-uk", "cloudservers-uk", "cloudfiles-uk") + .iso3166Codes("GB-SLG"); + } @Override public CloudServersUKProviderMetadata build() { return new CloudServersUKProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudServersApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - } \ No newline at end of file diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java index e0011cc6e1..3c394e4feb 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java @@ -36,7 +36,7 @@ package org.jclouds.rackspace.cloudservers; import org.jclouds.cloudservers.CloudServersApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index 8865fc8c29..da6f4a3450 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.cloudservers.CloudServersAsyncClient; +import org.jclouds.cloudservers.CloudServersClient; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class CloudServersUKTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public CloudServersUKTemplateBuilderLiveTest() { provider = "cloudservers-uk"; diff --git a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSPropertiesBuilder.java b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSPropertiesBuilder.java deleted file mode 100644 index 76c0ac294d..0000000000 --- a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSPropertiesBuilder.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rackspace.cloudservers; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.cloudservers.CloudServersPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class CloudServersUSPropertiesBuilder extends CloudServersPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-IL,US-TX"); - properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com"); - return properties; - } - - public CloudServersUSPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java index 698f96f954..16f85b88ae 100644 --- a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java +++ b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java @@ -18,50 +18,70 @@ */ package org.jclouds.rackspace.cloudservers; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + import java.net.URI; +import java.util.Properties; import org.jclouds.cloudservers.CloudServersApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; - +import org.jclouds.cloudservers.CloudServersAsyncClient; +import org.jclouds.cloudservers.CloudServersClient; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers in US. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers US. * * @author Adrian Cole */ -public class CloudServersUSProviderMetadata extends BaseProviderMetadata { - - public CloudServersUSProviderMetadata() { - this(builder() - .id("cloudservers-us") - .name("Rackspace Cloud Servers US") - .api(new CloudServersApiMetadata()) - .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/servers")) - .console(URI.create("https://manage.rackspacecloud.com")) - .linkedServices("cloudloadbalancers-us", "cloudservers-us", "cloudfiles-us") - .iso3166Codes("US-IL", "US-TX")); +public class CloudServersUSProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudServersUSProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudServersUSProviderMetadata() { + super(builder()); + } + + public CloudServersUSProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, "US"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, CloudServersApiMetadata> { + + protected Builder(){ + id("cloudservers-us") + .name("Rackspace Cloud Servers US") + .apiMetadata(new CloudServersApiMetadata()) + .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/servers")) + .console(URI.create("https://manage.rackspacecloud.com")) + .linkedServices("cloudloadbalancers-us", "cloudservers-us", "cloudfiles-us") + .iso3166Codes("US-IL", "US-TX"); + } @Override public CloudServersUSProviderMetadata build() { return new CloudServersUSProviderMetadata(this); } - } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudServersApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java index 6f4ec86df6..433f0ea55f 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java @@ -36,7 +36,7 @@ package org.jclouds.rackspace.cloudservers; import org.jclouds.cloudservers.CloudServersApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java index 7d73a29c44..1dc74d846f 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.cloudservers.CloudServersAsyncClient; +import org.jclouds.cloudservers.CloudServersClient; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class CloudServersUSTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public CloudServersUSTemplateBuilderLiveTest() { provider = "cloudservers-us"; diff --git a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasPropertiesBuilder.java b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasPropertiesBuilder.java deleted file mode 100644 index 5565b5b921..0000000000 --- a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasPropertiesBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudsigma; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -/** - * Builds properties used in CloudSigma Clients - * - * @author Adrian Cole - */ -public class CloudSigmaLasVegasPropertiesBuilder extends CloudSigmaPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-NV"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.lvs.cloudsigma.com"); - return properties; - } - - public CloudSigmaLasVegasPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java index 12970c054d..83ada1c0b4 100644 --- a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java +++ b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java @@ -19,46 +19,70 @@ package org.jclouds.cloudsigma; import java.net.URI; +import java.util.Properties; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for CloudSigma Las Vegas. - * + + * * @author Adrian Cole */ -public class CloudSigmaLasVegasProviderMetadata extends BaseProviderMetadata { +public class CloudSigmaLasVegasProviderMetadata + extends + BaseProviderMetadata, CloudSigmaApiMetadata> { - public CloudSigmaLasVegasProviderMetadata() { - this(builder() - .id("cloudsigma-lvs") - .name("CloudSigma Las Vegas") - .api(new CloudSigmaApiMetadata()) - .homepage(URI.create("http://www.cloudsigma.com/en/our-cloud/features")) - .console(URI.create("https://gui.lvs.cloudsigma.com/")) - .iso3166Codes("US-NV")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudSigmaLasVegasProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudSigmaLasVegasProviderMetadata() { + super(builder()); + } + + public CloudSigmaLasVegasProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, CloudSigmaApiMetadata> { + + protected Builder() { + id("cloudsigma-lvs") + .name("CloudSigma Las Vegas") + .apiMetadata(new CloudSigmaApiMetadata()) + .homepage(URI.create("http://www.cloudsigma.com/en/our-cloud/features")) + .console(URI.create("https://gui.lvs.cloudsigma.com/")) + .iso3166Codes("US-NV") + .endpoint("https://api.lvs.cloudsigma.com") + .defaultProperties(CloudSigmaLasVegasProviderMetadata.defaultProperties()); + } @Override public CloudSigmaLasVegasProviderMetadata build() { return new CloudSigmaLasVegasProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudSigmaApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } -} +} \ No newline at end of file diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java index 0afe6d819f..5bfac827b6 100644 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java +++ b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.cloudsigma; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java index d365b692bb..ada7600380 100644 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.cloudsigma.CloudSigmaAsyncClient; +import org.jclouds.cloudsigma.CloudSigmaClient; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "CloudSigmaLasVegasTemplateBuilderLiveTest") -public class CloudSigmaLasVegasTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class CloudSigmaLasVegasTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public CloudSigmaLasVegasTemplateBuilderLiveTest() { provider = "cloudsigma-lvs"; diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichPropertiesBuilder.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichPropertiesBuilder.java deleted file mode 100644 index 7900f4beaa..0000000000 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichPropertiesBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudsigma; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -/** - * Builds properties used in CloudSigma Clients - * - * @author Adrian Cole - */ -public class CloudSigmaZurichPropertiesBuilder extends CloudSigmaPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "CH-ZH"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.zrh.cloudsigma.com"); - return properties; - } - - public CloudSigmaZurichPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java index 483f22eabd..7f18af9aa2 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java @@ -19,46 +19,70 @@ package org.jclouds.cloudsigma; import java.net.URI; +import java.util.Properties; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for CloudSigma Zurich. - * + + * * @author Adrian Cole */ -public class CloudSigmaZurichProviderMetadata extends BaseProviderMetadata { +public class CloudSigmaZurichProviderMetadata + extends + BaseProviderMetadata, CloudSigmaApiMetadata> { - public CloudSigmaZurichProviderMetadata() { - this(builder() - .id("cloudsigma-zrh") - .name("CloudSigma Zurich") - .api(new CloudSigmaApiMetadata()) - .homepage(URI.create("http://www.cloudsigma.com/en/our-cloud/features")) - .console(URI.create("https://gui.zrh.cloudsigma.com/")) - .iso3166Codes("CH-ZH")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected CloudSigmaZurichProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudSigmaZurichProviderMetadata() { + super(builder()); + } + + public CloudSigmaZurichProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, CloudSigmaApiMetadata> { + + protected Builder() { + id("cloudsigma-zrh") + .name("CloudSigma Zurich") + .apiMetadata(new CloudSigmaApiMetadata()) + .homepage(URI.create("http://www.cloudsigma.com/en/our-cloud/features")) + .console(URI.create("https://gui.zrh.cloudsigma.com/")) + .iso3166Codes("CH-ZH") + .endpoint("https://api.zrh.cloudsigma.com") + .defaultProperties(CloudSigmaZurichProviderMetadata.defaultProperties()); + } @Override public CloudSigmaZurichProviderMetadata build() { return new CloudSigmaZurichProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, CloudSigmaApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } -} +} \ No newline at end of file diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java index 2e9d1d8180..6ff78f4fda 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.cloudsigma; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java index a46f237689..b85002b3b9 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.cloudsigma.CloudSigmaAsyncClient; +import org.jclouds.cloudsigma.CloudSigmaClient; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudSigmaZurichTemplateBuilderLiveTest") -public class CloudSigmaZurichTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class CloudSigmaZurichTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public CloudSigmaZurichTemplateBuilderLiveTest() { provider = "cloudsigma-zrh"; diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesPropertiesBuilder.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesPropertiesBuilder.java deleted file mode 100644 index 3a34dab879..0000000000 --- a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elastichosts; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class ElasticHostsPeer1LosAngelesPropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.lax-p.elastichosts.com"); - properties.setProperty(PROPERTY_API_VERSION, "2.0"); - return properties; - } - - public ElasticHostsPeer1LosAngelesPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java index ec5cdd1a42..3082c24b96 100644 --- a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java +++ b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java @@ -19,47 +19,73 @@ package org.jclouds.elastichosts; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Los Angeles Peer 1. - * + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts LA Peer1. + + * * @author Adrian Cole */ -public class ElasticHostsPeer1LosAngelesProviderMetadata extends BaseProviderMetadata { +public class ElasticHostsPeer1LosAngelesProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public ElasticHostsPeer1LosAngelesProviderMetadata() { - this(builder() - .id("elastichosts-lax-p") - .name("ElasticHosts Los Angeles Peer 1") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("https://lax-p.elastichosts.com")) - .console(URI.create("https://lax-p.elastichosts.com/accounts")) - .iso3166Codes("US-CA")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected ElasticHostsPeer1LosAngelesProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsPeer1LosAngelesProviderMetadata() { + super(builder()); + } + + public ElasticHostsPeer1LosAngelesProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("elastichosts-lax-p") + .name("ElasticHosts Los Angeles Peer 1") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://lax-p.elastichosts.com")) + .console(URI.create("https://lax-p.elastichosts.com/accounts")) + .iso3166Codes("US-CA") + .endpoint("https://api.lax-p.elastichosts.com") + .defaultProperties(ElasticHostsPeer1LosAngelesProviderMetadata.defaultProperties()); + } @Override public ElasticHostsPeer1LosAngelesProviderMetadata build() { return new ElasticHostsPeer1LosAngelesProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } -} +} \ No newline at end of file diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java index bc8e76310a..b7da04ee1e 100644 --- a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.elastichosts; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java index b147769ba1..ca8d2a2d37 100644 --- a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest() { provider = "elastichosts-lax-p"; diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java deleted file mode 100644 index 2bb4317db6..0000000000 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elastichosts; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class ElasticHostsBlueSquareLondonPropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "GB-LND"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.lon-b.elastichosts.com"); - properties.setProperty(PROPERTY_API_VERSION, "2.0"); - return properties; - } - - public ElasticHostsBlueSquareLondonPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java index dcf1e4a97f..337650cc65 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java @@ -19,48 +19,71 @@ package org.jclouds.elastichosts; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London BlueSquare. - * * @author Adrian Cole */ -public class ElasticHostsBlueSquareLondonProviderMetadata extends BaseProviderMetadata { +public class ElasticHostsBlueSquareLondonProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public ElasticHostsBlueSquareLondonProviderMetadata() { - this(builder() - .id("elastichosts-lon-b") - .name("ElasticHosts Los Angeles BlueSquare") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("https://lon-b.elastichosts.com")) - .console(URI.create("https://lon-b.elastichosts.com/accounts")) - .iso3166Codes("GB-LND")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected ElasticHostsBlueSquareLondonProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsBlueSquareLondonProviderMetadata() { + super(builder()); + } + + public ElasticHostsBlueSquareLondonProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("elastichosts-lon-b") + .name("ElasticHosts Los Angeles BlueSquare") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://lon-b.elastichosts.com")) + .console(URI.create("https://lon-b.elastichosts.com/accounts")) + .iso3166Codes("GB-LND") + .endpoint("https://api.lon-b.elastichosts.com") + .defaultProperties(ElasticHostsBlueSquareLondonProviderMetadata.defaultProperties()); + } @Override public ElasticHostsBlueSquareLondonProviderMetadata build() { return new ElasticHostsBlueSquareLondonProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - -} +} \ No newline at end of file diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java index b339d08d62..f063b94e1e 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.elastichosts; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java index d6c32b5ab8..c530f30205 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public ElasticHostsBlueSquareLondonTemplateBuilderLiveTest() { provider = "elastichosts-lon-b"; diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonPropertiesBuilder.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonPropertiesBuilder.java deleted file mode 100644 index 7bd46cd68c..0000000000 --- a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elastichosts; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class ElasticHostsPeer1LondonPropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "GB-LND"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.lon-p.elastichosts.com"); - properties.setProperty(PROPERTY_API_VERSION, "2.0"); - return properties; - } - - public ElasticHostsPeer1LondonPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java index c68185e919..2987ee2cab 100644 --- a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java +++ b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java @@ -19,48 +19,72 @@ package org.jclouds.elastichosts; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London Peer 1. - * + * * @author Adrian Cole */ -public class ElasticHostsPeer1LondonProviderMetadata extends BaseProviderMetadata { +public class ElasticHostsPeer1LondonProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public ElasticHostsPeer1LondonProviderMetadata() { - this(builder() - .id("elastichosts-lon-p") - .name("ElasticHosts Los Angeles Peer 1") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("https://lon-p.elastichosts.com")) - .console(URI.create("https://lon-p.elastichosts.com/accounts")) - .iso3166Codes("GB-LND")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected ElasticHostsPeer1LondonProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsPeer1LondonProviderMetadata() { + super(builder()); + } + + public ElasticHostsPeer1LondonProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("elastichosts-lon-p") + .name("ElasticHosts London Peer 1") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://lon-p.elastichosts.com")) + .console(URI.create("https://lon-p.elastichosts.com/accounts")) + .iso3166Codes("GB-LND") + .endpoint("https://api.lon-p.elastichosts.com") + .defaultProperties(ElasticHostsPeer1LondonProviderMetadata.defaultProperties()); + } @Override public ElasticHostsPeer1LondonProviderMetadata build() { return new ElasticHostsPeer1LondonProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - -} +} \ No newline at end of file diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java index 7763951a1e..3120e1c5e4 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.elastichosts; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java index 184cf3b590..32dbc5fcc4 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1LondonTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class ElasticHostsPeer1LondonTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public ElasticHostsPeer1LondonTemplateBuilderLiveTest() { provider = "elastichosts-lon-p"; diff --git a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioPropertiesBuilder.java b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioPropertiesBuilder.java deleted file mode 100644 index b6e2ad94e9..0000000000 --- a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elastichosts; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class ElasticHostsPeer1SanAntonioPropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-TX"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.sat-p.elastichosts.com"); - properties.setProperty(PROPERTY_API_VERSION, "2.0"); - return properties; - } - - public ElasticHostsPeer1SanAntonioPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java index 3643598ebf..b79332d3f0 100644 --- a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java +++ b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java @@ -1,6 +1,6 @@ /** * Licensed to jclouds, Inc. (jclouds) under one or more - * contribusat license agreements. See the NOTICE file + * contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. jclouds licenses this file * to you under the Apache License, Version 2.0 (the @@ -19,47 +19,72 @@ package org.jclouds.elastichosts; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts San Antonio Peer 1. - * + * * @author Adrian Cole */ -public class ElasticHostsPeer1SanAntonioProviderMetadata extends BaseProviderMetadata { +public class ElasticHostsPeer1SanAntonioProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public ElasticHostsPeer1SanAntonioProviderMetadata() { - this(builder() - .id("elastichosts-sat-p") - .name("ElasticHosts San Antonio Peer 1") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("https://sat-p.elastichosts.com")) - .console(URI.create("https://sat-p.elastichosts.com/accounts")) - .iso3166Codes("US-TX")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected ElasticHostsPeer1SanAntonioProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsPeer1SanAntonioProviderMetadata() { + super(builder()); + } + + public ElasticHostsPeer1SanAntonioProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("elastichosts-sat-p") + .name("ElasticHosts San Antonio Peer 1") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://sat-p.elastichosts.com")) + .console(URI.create("https://sat-p.elastichosts.com/accounts")) + .iso3166Codes("US-TX") + .endpoint("https://api.sat-p.elastichosts.com") + .defaultProperties(ElasticHostsPeer1SanAntonioProviderMetadata.defaultProperties()); + } @Override public ElasticHostsPeer1SanAntonioProviderMetadata build() { return new ElasticHostsPeer1SanAntonioProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java index 9c6cae4531..58a7ed0880 100644 --- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.elastichosts; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java index 5a0030fca4..a33e8475ce 100644 --- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest() { provider = "elastichosts-sat-p"; diff --git a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoPropertiesBuilder.java b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoPropertiesBuilder.java deleted file mode 100644 index a9f8b0f74c..0000000000 --- a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elastichosts; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class ElasticHostsPeer1TorontoPropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "CA-ON"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.tor-p.elastichosts.com"); - properties.setProperty(PROPERTY_API_VERSION, "2.0"); - return properties; - } - - public ElasticHostsPeer1TorontoPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java index 921c42f40d..e857445271 100644 --- a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java +++ b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java @@ -19,47 +19,72 @@ package org.jclouds.elastichosts; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Toronto Peer 1. - * + * * @author Adrian Cole */ -public class ElasticHostsPeer1TorontoProviderMetadata extends BaseProviderMetadata { +public class ElasticHostsPeer1TorontoProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public ElasticHostsPeer1TorontoProviderMetadata() { - this(builder() - .id("elastichosts-tor-p") - .name("ElasticHosts Toronto Peer 1") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("https://tor-p.elastichosts.com")) - .console(URI.create("https://tor-p.elastichosts.com/accounts")) - .iso3166Codes("CA-ON")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected ElasticHostsPeer1TorontoProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsPeer1TorontoProviderMetadata() { + super(builder()); + } + + public ElasticHostsPeer1TorontoProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("elastichosts-tor-p") + .name("ElasticHosts Toronto Peer 1") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://tor-p.elastichosts.com")) + .console(URI.create("https://tor-p.elastichosts.com/accounts")) + .iso3166Codes("CA-ON") + .endpoint("https://api.tor-p.elastichosts.com") + .defaultProperties(ElasticHostsPeer1TorontoProviderMetadata.defaultProperties()); + } @Override public ElasticHostsPeer1TorontoProviderMetadata build() { return new ElasticHostsPeer1TorontoProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderTest.java index 9164406b60..a6ba3ec342 100644 --- a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderTest.java +++ b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.elastichosts; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java index 103b0ec4ef..f98bb35b5d 100644 --- a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java +++ b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1TorontoTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class ElasticHostsPeer1TorontoTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public ElasticHostsPeer1TorontoTemplateBuilderLiveTest() { provider = "elastichosts-tor-p"; diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java index 8b129e06c8..97b22136f1 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java @@ -19,10 +19,14 @@ package org.jclouds.epc; import java.util.List; -import java.util.Properties; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.EC2ContextBuilder; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.epc.config.EucalyptusPartnerCloudComputeServiceContextModule; +import org.jclouds.eucalyptus.EucalyptusApiMetadata; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -30,10 +34,14 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class EucalyptusPartnerCloudContextBuilder extends EC2ContextBuilder { +public class EucalyptusPartnerCloudContextBuilder extends EC2ContextBuilder, EucalyptusApiMetadata> { - public EucalyptusPartnerCloudContextBuilder(Properties props) { - super(props); + public EucalyptusPartnerCloudContextBuilder(ProviderMetadata, EucalyptusApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public EucalyptusPartnerCloudContextBuilder(EucalyptusApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java index ebac17f28f..1f9b118e77 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java @@ -18,51 +18,80 @@ */ package org.jclouds.epc; -import java.net.URI; +import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.eucalyptus.EucalyptusApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Eucalpytus' - * Partner Cloud EC2 provider. + * Implementation of {@link org.jclouds.providers.ProviderMetadata} for Eucalyptus Partner Cloud EC2. * - * @author Jeremy Whitlock + * @author Adrian Cole */ -public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetadata { - - public EucalyptusPartnerCloudEC2ProviderMetadata() { - this(builder() - .id("eucalyptus-partnercloud-ec2") - .name("Eucalyptus Partner Cloud (EC2)") - .api(new EucalyptusApiMetadata()) - .homepage(URI.create("http://www.eucalyptus.com/partners")) - .console(URI.create("https://partnercloud.eucalyptus.com:8443")) - .linkedServices("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3") - .iso3166Codes("US-CA")); +public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetadata, EucalyptusApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected EucalyptusPartnerCloudEC2ProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public EucalyptusPartnerCloudEC2ProviderMetadata() { + super(builder()); + } + + public EucalyptusPartnerCloudEC2ProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, "Eucalyptus"); + properties.setProperty(PROPERTY_REGION + ".Eucalyptus." + ISO3166_CODES, "US-CA"); + properties.setProperty("eucalyptus-partnercloud-ec2.virtualization-type", "kvm"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, EucalyptusApiMetadata> { + + protected Builder(){ + id("eucalyptus-partnercloud-ec2") + .name("Eucalyptus Partner Cloud (EC2)") + .apiMetadata( + new EucalyptusApiMetadata().toBuilder() + .contextBuilder(TypeToken.of(EucalyptusPartnerCloudContextBuilder.class)).build()) + .homepage(URI.create("http://www.eucalyptus.com/partners")) + .console(URI.create("https://partnercloud.eucalyptus.com:8443")) + .linkedServices("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3") + .iso3166Codes("US-CA") + .endpoint("http://partnercloud.eucalyptus.com:8773/services/Eucalyptus") + .defaultProperties(EucalyptusPartnerCloudEC2ProviderMetadata.defaultProperties()); + } @Override public EucalyptusPartnerCloudEC2ProviderMetadata build() { return new EucalyptusPartnerCloudEC2ProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, EucalyptusApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - -} +} \ No newline at end of file diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudPropertiesBuilder.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudPropertiesBuilder.java deleted file mode 100644 index dfccfef7a5..0000000000 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudPropertiesBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.epc; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.eucalyptus.EucalyptusPropertiesBuilder; - -/** - * Builds properties used in EucalyptusPartnerCloudEucalyptus Clients - * - * @author Adrian Cole - */ -public class EucalyptusPartnerCloudPropertiesBuilder extends EucalyptusPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_REGIONS, "Eucalyptus"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); - properties.setProperty(PROPERTY_REGION + ".Eucalyptus." + ISO3166_CODES, "US-CA"); - properties.setProperty("eucalyptus-partnercloud-ec2.virtualization-type", "kvm"); - properties.setProperty(PROPERTY_ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Eucalyptus"); - return properties; - } - - public EucalyptusPartnerCloudPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java index 54292a806b..a4c754a2a9 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.epc; import org.jclouds.eucalyptus.EucalyptusApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java index af0f11b69b..8dc7b80f28 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java @@ -25,11 +25,14 @@ import java.io.IOException; import java.util.Set; import org.jclouds.aws.util.AWSUtils; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.jclouds.domain.LocationScope; -import org.jclouds.ec2.compute.EC2TemplateBuilderLiveTest; +import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.util.EC2ComputeUtils; import org.testng.annotations.Test; @@ -42,7 +45,8 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { +public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends + BaseTemplateBuilderLiveTest> { public EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest() { provider = "eucalyptus-partnercloud-ec2"; diff --git a/providers/eucalyptus-partnercloud-s3/pom.xml b/providers/eucalyptus-partnercloud-s3/pom.xml index 0fa8f0d78c..543407cc2b 100644 --- a/providers/eucalyptus-partnercloud-s3/pom.xml +++ b/providers/eucalyptus-partnercloud-s3/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.epc.blobstore.EucalyptusPartnerCloudWalrusTestInitializer http://partnercloud.eucalyptus.com:8773/services/Walrus 2006-03-01 @@ -115,7 +114,6 @@ ${test.eucalyptus-partnercloud-s3.build-version} ${test.eucalyptus-partnercloud-s3.identity} ${test.eucalyptus-partnercloud-s3.credential} - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} ${test.blobstore.container-count} diff --git a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java index 9afe679fd5..5664afa0b5 100644 --- a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java @@ -18,51 +18,79 @@ */ package org.jclouds.epc; -import java.net.URI; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.ENDPOINT; +import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.s3.S3AsyncClient; +import org.jclouds.s3.S3Client; +import org.jclouds.s3.blobstore.S3BlobStoreContext; import org.jclouds.walrus.WalrusApiMetadata; /** - * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Eucalpytus' - * Partner Cloud S3 provider. + * Implementation of {@link org.jclouds.providers.ProviderMetadata} for Eucalyptus Partner Cloud S3. * - * @author Jeremy Whitlock + * @author Adrian Cole */ -public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetadata { - - public EucalyptusPartnerCloudS3ProviderMetadata() { - this(builder() - .id("eucalyptus-partnercloud-s3") - .name("Eucalyptus Partner Cloud (S3)") - .api(new WalrusApiMetadata()) - .homepage(URI.create("http://www.eucalyptus.com/partners")) - .console(URI.create("https://partnercloud.eucalyptus.com:8443")) - .linkedServices("eucalyptus-partnercloud-s3", "eucalyptus-partnercloud-s3") - .iso3166Codes("US-CA")); +public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetadata, WalrusApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected EucalyptusPartnerCloudS3ProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public EucalyptusPartnerCloudS3ProviderMetadata() { + super(builder()); + } + + public EucalyptusPartnerCloudS3ProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_REGIONS, "Walrus"); + properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); + properties.setProperty(PROPERTY_REGION + ".Walrus." + ISO3166_CODES, "US-CA"); + properties.setProperty(PROPERTY_REGION + "." + "Walrus" + "." + ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Walrus"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, WalrusApiMetadata> { + + protected Builder(){ + id("eucalyptus-partnercloud-s3") + .name("Eucalyptus Partner Cloud (S3)") + .apiMetadata(new WalrusApiMetadata()) + .homepage(URI.create("http://www.eucalyptus.com/partners")) + .console(URI.create("https://partnercloud.eucalyptus.com:8443")) + .linkedServices("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3") + .iso3166Codes("US-CA") + .endpoint("http://partnercloud.eucalyptus.com:8773/services/Walrus") + .defaultProperties(EucalyptusPartnerCloudS3ProviderMetadata.defaultProperties()); + } @Override public EucalyptusPartnerCloudS3ProviderMetadata build() { return new EucalyptusPartnerCloudS3ProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, WalrusApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - -} +} \ No newline at end of file diff --git a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudWalrusPropertiesBuilder.java b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudWalrusPropertiesBuilder.java deleted file mode 100644 index b89f95ba0e..0000000000 --- a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudWalrusPropertiesBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.epc; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Properties; - -import org.jclouds.walrus.WalrusPropertiesBuilder; - -/** - * Builds properties used in EucalyptusPartnerCloudWalrus Clients - * - * @author Adrian Cole - */ -public class EucalyptusPartnerCloudWalrusPropertiesBuilder extends WalrusPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_REGIONS, "Walrus"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); - properties.setProperty(PROPERTY_REGION + ".Walrus." + ISO3166_CODES, "US-CA"); - properties.setProperty(PROPERTY_ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Walrus"); - properties.setProperty(PROPERTY_REGION + "." + "Walrus" + "." + ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Walrus"); - return properties; - } - - public EucalyptusPartnerCloudWalrusPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java index cfdabb7d1c..9dcce9d453 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.epc; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.jclouds.walrus.WalrusApiMetadata; import org.testng.annotations.Test; diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudWalrusAsyncClientTestDisabled.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudWalrusAsyncClientTestDisabled.java deleted file mode 100644 index f3fb38e4d4..0000000000 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudWalrusAsyncClientTestDisabled.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.epc; - -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(enabled = false, groups = "unit", testName = "EucalyptusPartnerCloudWalrusAsyncClientTest") -public class EucalyptusPartnerCloudWalrusAsyncClientTestDisabled extends org.jclouds.walrus.WalrusAsyncClientTestDisabled { - - public EucalyptusPartnerCloudWalrusAsyncClientTestDisabled() { - this.provider = "eucalyptus-partnercloud-s3"; - this.url = "https://partnercloud.eucalyptus.com:8773/services/Walrus"; - } - - // TODO parameterize this test so that it can pass -} diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest.java index 543858aef1..7f502e279e 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest") public class EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest extends WalrusBlobIntegrationLiveTest { + public EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest() { + provider = "eucalyptus-partnercloud-s3"; + } } diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobLiveTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobLiveTest.java index 719a911d21..aa3660d613 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobLiveTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobLiveTest.java @@ -24,7 +24,10 @@ import org.testng.annotations.Test; /** * @author Adrian Cole */ -@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobLiveTest") +@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobLiveTest") public class EucalyptusPartnerCloudWalrusBlobLiveTest extends WalrusBlobLiveTest { + public EucalyptusPartnerCloudWalrusBlobLiveTest() { + provider = "eucalyptus-partnercloud-s3"; + } } diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest.java index ca4cdcc542..5ad504c3ef 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest.java @@ -24,6 +24,10 @@ import org.testng.annotations.Test; /** * @author Adrian Cole */ -@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest") +@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest") public class EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest extends WalrusBlobMapIntegrationLiveTest { + + public EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest() { + provider = "eucalyptus-partnercloud-s3"; + } } diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobSignerLiveTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobSignerLiveTest.java index c4a536a59f..4e239593a7 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobSignerLiveTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusBlobSignerLiveTest.java @@ -25,7 +25,10 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobSignerLiveTest") +@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobSignerLiveTest") public class EucalyptusPartnerCloudWalrusBlobSignerLiveTest extends WalrusBlobSignerLiveTest { + public EucalyptusPartnerCloudWalrusBlobSignerLiveTest() { + provider = "eucalyptus-partnercloud-s3"; + } } diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest.java index ec6ae4d24b..8e42392236 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest.java @@ -24,7 +24,10 @@ import org.testng.annotations.Test; /** * @author Adrian Cole */ -@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest") +@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest") public class EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest extends WalrusContainerIntegrationLiveTest { + public EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest() { + provider = "eucalyptus-partnercloud-s3"; + } } diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusContainerLiveTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusContainerLiveTest.java index 941b7c49a0..32e13bfc34 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusContainerLiveTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusContainerLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusContainerLiveTest") public class EucalyptusPartnerCloudWalrusContainerLiveTest extends WalrusContainerLiveTest { + public EucalyptusPartnerCloudWalrusContainerLiveTest() { + provider = "eucalyptus-partnercloud-s3"; + } } diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest.java index f81da68f87..f2b060cf28 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest.java @@ -24,7 +24,11 @@ import org.testng.annotations.Test; /** * @author Adrian Cole */ -@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest") -public class EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest extends WalrusInputStreamMapIntegrationLiveTest { +@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest") +public class EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest extends + WalrusInputStreamMapIntegrationLiveTest { + public EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest() { + provider = "eucalyptus-partnercloud-s3"; + } } diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest.java index e0f71a4153..37ec64a88a 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest.java @@ -30,6 +30,11 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest") public class EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest extends WalrusServiceIntegrationLiveTest { + + public EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest() { + provider = "eucalyptus-partnercloud-s3"; + } + @Override protected Set getIso3166Codes() { return ImmutableSet. of("US-CA"); diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusTestInitializer.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusTestInitializer.java deleted file mode 100644 index caae25fb9e..0000000000 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/blobstore/EucalyptusPartnerCloudWalrusTestInitializer.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.epc.blobstore; - -import org.jclouds.walrus.blobstore.WalrusTestInitializer; - - -/** - * - * @author Adrian Cole - */ -public class EucalyptusPartnerCloudWalrusTestInitializer extends WalrusTestInitializer { - - public EucalyptusPartnerCloudWalrusTestInitializer() { - provider = "eucalyptus-partnercloud-s3"; - } - - -} diff --git a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1PropertiesBuilder.java b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1PropertiesBuilder.java deleted file mode 100644 index 505d431393..0000000000 --- a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1PropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.go2cloud; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class Go2CloudJohannesburg1PropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "ZA-GP"); - properties.setProperty(PROPERTY_ENDPOINT, "http://api.jhb1.go2cloud.co.za"); - properties.setProperty(PROPERTY_API_VERSION, "2.0"); - return properties; - } - - public Go2CloudJohannesburg1PropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java index 90e28f6e3c..9b3afed0b6 100644 --- a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java +++ b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java @@ -19,49 +19,73 @@ package org.jclouds.go2cloud; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Go2Cloud's * Johannesburg1 provider. - * + * * @author Adrian Cole */ -public class Go2CloudJohannesburg1ProviderMetadata extends BaseProviderMetadata { +public class Go2CloudJohannesburg1ProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public Go2CloudJohannesburg1ProviderMetadata() { - this(builder() - .id("go2cloud-jhb1") - .name("Go2Cloud Johannesburg1") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("https://jhb1.go2cloud.co.za")) - .console(URI.create("https://jhb1.go2cloud.co.za/accounts")) - .iso3166Codes("ZA-GP")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected Go2CloudJohannesburg1ProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public Go2CloudJohannesburg1ProviderMetadata() { + super(builder()); + } + + public Go2CloudJohannesburg1ProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("go2cloud-jhb1") + .name("Go2Cloud Johannesburg1") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://jhb1.go2cloud.co.za")) + .console(URI.create("https://jhb1.go2cloud.co.za/accounts")) + .iso3166Codes("ZA-GP") + .endpoint("https://api.jhb1.go2cloud.co.za") + .defaultProperties(Go2CloudJohannesburg1ProviderMetadata.defaultProperties()); + } @Override public Go2CloudJohannesburg1ProviderMetadata build() { return new Go2CloudJohannesburg1ProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - -} +} \ No newline at end of file diff --git a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/config/Go2CloudJohannesburg1ComputeServiceContextModule.java b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/config/Go2CloudJohannesburg1ComputeServiceContextModule.java deleted file mode 100644 index c13dc45cbb..0000000000 --- a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/config/Go2CloudJohannesburg1ComputeServiceContextModule.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.go2cloud.config; - -import static org.jclouds.compute.domain.OsFamily.UBUNTU; - -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule; - -import com.google.inject.Injector; - -/** - * - * @author Adrian Cole - */ -public class Go2CloudJohannesburg1ComputeServiceContextModule extends ElasticStackComputeServiceContextModule { - - @Override - protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).osVersionMatches("10.10").os64Bit(true); - } -} diff --git a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderTest.java b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderTest.java index 22a49cb308..cd2a00543f 100644 --- a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderTest.java +++ b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.go2cloud; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java index fc46ea9edd..65175537f3 100644 --- a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java +++ b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class Go2CloudJohannesburg1TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class Go2CloudJohannesburg1TemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public Go2CloudJohannesburg1TemplateBuilderLiveTest() { provider = "go2cloud-jhb1"; @@ -52,14 +57,14 @@ public class Go2CloudJohannesburg1TemplateBuilderLiveTest extends BaseTemplateBu @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { - case UBUNTU: - return (input.version.equals("") || input.version.equals("10.10")) && input.is64Bit; - case DEBIAN: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; - case WINDOWS: - return input.version.equals("") && input.is64Bit; - default: - return false; + case UBUNTU: + return (input.version.equals("") || input.version.equals("10.10")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + case WINDOWS: + return input.version.equals("") && input.is64Bit; + default: + return false; } } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java index e209e90e5d..7733c419de 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java @@ -19,50 +19,70 @@ package org.jclouds.gogrid; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for the GoGrid API + * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class GoGridApiMetadata extends BaseApiMetadata { +public class GoGridApiMetadata + extends + BaseComputeServiceApiMetadata, GoGridApiMetadata> { - public GoGridApiMetadata() { - this(builder() - .id("gogrid") - .type(ApiType.COMPUTE) - .name("GoGrid API") - .identityName("API Key") - .credentialName("Shared Secret") - .documentation(URI.create("https://wiki.gogrid.com/wiki/index.php/API"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected GoGridApiMetadata(Builder builder) { + public GoGridApiMetadata() { + this(new Builder()); + } + + protected GoGridApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty("jclouds.ssh.max-retries", "5"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, GoGridApiMetadata> { + + protected Builder() { + id("gogrid") + .name("GoGrid API") + .identityName("API Key") + .credentialName("Shared Secret") + .documentation(URI.create("https://wiki.gogrid.com/wiki/index.php/API")) + .version(GoGridAsyncClient.VERSION) + .defaultEndpoint("https://api.gogrid.com/api") + .javaApi(GoGridClient.class, GoGridAsyncClient.class) + .contextBuilder(TypeToken.of(GoGridContextBuilder.class)); + } @Override public GoGridApiMetadata build() { return new GoGridApiMetadata(this); } + + @Override + public Builder fromApiMetadata(GoGridApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - -} \ No newline at end of file +} diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java index d0c16ce5e9..0318c28952 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java @@ -19,31 +19,30 @@ package org.jclouds.gogrid; import java.util.List; -import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule; import org.jclouds.gogrid.config.GoGridRestClientModule; +import org.jclouds.providers.ProviderMetadata; -import com.google.inject.Key; import com.google.inject.Module; -import com.google.inject.TypeLiteral; /** * * @author Adrian Cole */ -public class GoGridContextBuilder extends - ComputeServiceContextBuilder { +public class GoGridContextBuilder + extends + ComputeServiceContextBuilder, GoGridApiMetadata> { - public GoGridContextBuilder(Properties props) { - super(GoGridClient.class, GoGridAsyncClient.class, props); + public GoGridContextBuilder( + ProviderMetadata, GoGridApiMetadata> providerMetadata) { + super(providerMetadata); } - protected void addClientModule(List modules) { - modules.add(new GoGridRestClientModule()); + public GoGridContextBuilder(GoGridApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -51,13 +50,8 @@ public class GoGridContextBuilder extends modules.add(new GoGridComputeServiceContextModule()); } - @Override - public ComputeServiceContext buildComputeServiceContext() { - return this - .buildInjector() - .getInstance( - Key - .get(new TypeLiteral>() { - })); + protected void addClientModule(List modules) { + modules.add(new GoGridRestClientModule()); } + } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridPropertiesBuilder.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridPropertiesBuilder.java deleted file mode 100644 index 6bb3362ce6..0000000000 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridPropertiesBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.gogrid; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.gogrid.reference.GoGridConstants.PROPERTY_GOGRID_DEFAULT_DC; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in GoGrid Clients - * - * @author Adrian Cole - * @author Oleksiy Yarmula - * - */ -public class GoGridPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ZONES, "1,2,3"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA,US-VA,NL-NH"); - properties.setProperty(PROPERTY_ZONE + ".1." + ISO3166_CODES, "US-CA"); - properties.setProperty(PROPERTY_ZONE + ".2." + ISO3166_CODES, "US-VA"); - properties.setProperty(PROPERTY_ZONE + ".3." + ISO3166_CODES, "NL-NH"); - properties.setProperty(PROPERTY_API_VERSION, GoGridAsyncClient.VERSION); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.gogrid.com/api"); - properties.setProperty(PROPERTY_GOGRID_DEFAULT_DC, "1"); - return properties; - } - - public GoGridPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java index 8221241ea5..c78a719162 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java @@ -18,47 +18,81 @@ */ package org.jclouds.gogrid; -import java.net.URI; +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.gogrid.reference.GoGridConstants.PROPERTY_GOGRID_DEFAULT_DC; +import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for GoGrid. - * * @author Adrian Cole */ -public class GoGridProviderMetadata extends BaseProviderMetadata { - public GoGridProviderMetadata() { - this(builder() - .id("gogrid") - .name("GoGrid") - .api(new GoGridApiMetadata()) - .homepage(URI.create("http://www.gogrid.com")) - .console(URI.create("https://my.gogrid.com/gogrid")) - .iso3166Codes("US-CA", "US-VA", "BR-SP")); +public class GoGridProviderMetadata + extends + BaseProviderMetadata, GoGridApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected GoGridProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public GoGridProviderMetadata() { + super(builder()); + } + + public GoGridProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_ZONES, "1,2,3"); + properties.setProperty(PROPERTY_ZONE + ".1." + ISO3166_CODES, "US-CA"); + properties.setProperty(PROPERTY_ZONE + ".2." + ISO3166_CODES, "US-VA"); + properties.setProperty(PROPERTY_ZONE + ".3." + ISO3166_CODES, "NL-NH"); + properties.setProperty(PROPERTY_API_VERSION, GoGridAsyncClient.VERSION); + properties.setProperty(PROPERTY_GOGRID_DEFAULT_DC, "1"); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, GoGridApiMetadata> { + + protected Builder() { + id("gogrid") + .name("GoGrid") + .apiMetadata(new GoGridApiMetadata()) + .homepage(URI.create("http://www.gogrid.com")) + .console(URI.create("https://my.gogrid.com/gogrid")) + .iso3166Codes("US-CA", "US-VA", "BR-SP") + .endpoint("https://api.gogrid.com/api") + .defaultProperties(GoGridProviderMetadata.defaultProperties()); + } @Override public GoGridProviderMetadata build() { return new GoGridProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, GoGridApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - } \ No newline at end of file diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java index b03aadf71d..879880a23d 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java @@ -62,7 +62,7 @@ import com.google.common.base.Supplier; @Singleton public class GoGridComputeService extends BaseComputeService { @Inject - protected GoGridComputeService(ComputeServiceContext context, Map credentialStore, + protected GoGridComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java index 7c3cc171cf..31017c0ebe 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java @@ -31,12 +31,11 @@ import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.Credentials; import org.jclouds.gogrid.domain.Ip; import org.jclouds.gogrid.domain.IpPortPair; @@ -54,7 +53,6 @@ import org.jclouds.gogrid.options.GetImageListOptions; import org.jclouds.gogrid.predicates.LoadBalancerLatestJobCompleted; import org.jclouds.gogrid.predicates.ServerLatestJobCompleted; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; @@ -67,9 +65,7 @@ import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.inject.Module; /** * End to end live test for GoGrid @@ -79,7 +75,10 @@ import com.google.inject.Module; * @author Oleksiy Yarmula */ @Test(enabled = false, groups = "live", singleThreaded = true, testName = "GoGridLiveTestDisabled") -public class GoGridLiveTestDisabled extends BaseVersionedServiceLiveTest { +public class GoGridLiveTestDisabled + extends + BaseComputeServiceContextLiveTest> { + public GoGridLiveTestDisabled() { provider = "gogrid"; } @@ -94,16 +93,15 @@ public class GoGridLiveTestDisabled extends BaseVersionedServiceLiveTest { private List serversToDeleteAfterTheTests = new ArrayList(); private List loadBalancersToDeleteAfterTest = new ArrayList(); - private RestContext context; + private RestContext gocontext; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides).getProviderSpecificContext(); + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + gocontext = context.getProviderSpecificContext(); - client = context.getApi(); + client = gocontext.getApi(); serverLatestJobCompleted = new RetryablePredicate(new ServerLatestJobCompleted(client.getJobServices()), 800, 20, TimeUnit.SECONDS); loadBalancerLatestJobCompleted = new RetryablePredicate(new LoadBalancerLatestJobCompleted(client @@ -352,7 +350,7 @@ public class GoGridLiveTestDisabled extends BaseVersionedServiceLiveTest { socketOpen.apply(socket); - SshClient sshClient = context.utils().injector().getInstance(SshClient.Factory.class).create(socket, instanceCredentials); + SshClient sshClient = gocontext.utils().injector().getInstance(SshClient.Factory.class).create(socket, instanceCredentials); sshClient.connect(); String output = sshClient.exec("df").getOutput(); assertTrue(output.contains("Filesystem"), diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java index 2fb9140c3a..3debe01ada 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.gogrid; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java index 3c8352ac4a..c2359cb42f 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java @@ -25,9 +25,10 @@ import static org.testng.Assert.assertNotNull; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.gogrid.GoGridAsyncClient; import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.domain.Server; @@ -47,7 +48,10 @@ import com.google.inject.Module; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "live", singleThreaded = true, testName = "GoGridComputeServiceLiveTest") -public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class GoGridComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public GoGridComputeServiceLiveTest() { provider = "gogrid"; } @@ -70,7 +74,7 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { public void testResizeRam() throws Exception { String group = this.group + "ram"; - RestContext providerContext = client.getContext().getProviderSpecificContext(); + RestContext providerContext = context.getProviderSpecificContext(); try { client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java index 9d917a2174..1773206435 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.gogrid.GoGridAsyncClient; +import org.jclouds.gogrid.GoGridClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -40,7 +43,9 @@ import com.google.common.collect.ImmutableSet; */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "live", singleThreaded = true, testName = "GoGridTemplateBuilderLiveTest") -public class GoGridTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class GoGridTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public GoGridTemplateBuilderLiveTest() { provider = "gogrid"; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java index fb890afdbf..ef95d93eb5 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java @@ -20,17 +20,15 @@ package org.jclouds.gogrid.services; import static org.testng.Assert.assertEquals; -import java.util.Properties; - import org.jclouds.date.TimeStamp; +import org.jclouds.gogrid.GoGridProviderMetadata; import org.jclouds.gogrid.config.GoGridRestClientModule; import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -41,7 +39,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "unit") -public abstract class BaseGoGridAsyncClientTest extends RestClientTest { +public abstract class BaseGoGridAsyncClientTest extends BaseAsyncClientTest { @Override protected void checkFilters(HttpRequest request) { assertEquals(request.getFilters().size(), 1); @@ -68,8 +66,8 @@ public abstract class BaseGoGridAsyncClientTest extends RestClientTest { } @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec("gogrid", "foo", "bar", new Properties()); + public ProviderMetadata createProviderMetadata() { + return new GoGridProviderMetadata(); } } \ No newline at end of file diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java index 9ca9e9b599..e070cc5571 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java @@ -18,50 +18,36 @@ */ package org.jclouds.gogrid.services; -import java.util.Properties; - -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.gogrid.GoGridAsyncClient; import org.jclouds.gogrid.GoGridClient; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code GoGridClient} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "BaseGoGridClientLiveTest") -public class BaseGoGridClientLiveTest extends BaseVersionedServiceLiveTest { +public class BaseGoGridClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public BaseGoGridClientLiveTest() { provider = "gogrid"; } protected RestContext restContext; - protected ComputeServiceContext context; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), overrides); + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); restContext = context.getProviderSpecificContext(); } - @AfterGroups(groups = "live") - protected void tearDown() { - if (context != null) - context.close(); - } } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java index 3da872721a..25fd8a968f 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java @@ -4,7 +4,7 @@ import org.jclouds.date.TimeStamp; import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.config.GoGridRestClientModule; import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ConfiguresRestClient; import com.google.common.base.Supplier; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java index 0999997979..a6eb0f94b4 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java @@ -67,7 +67,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest, VCloudApiMetadata> providerMetadata) { + super(providerMetadata); + } - public GreenHouseDataElementVCloudContextBuilder(Properties props) { - super(props); + public GreenHouseDataElementVCloudContextBuilder(VCloudApiMetadata apiMetadata) { + super(apiMetadata); } @Override protected void addContextModule(List modules) { - modules.add(new GreenHouseDataElementVCloudComputeServiceContextModule()); + modules.add(new VCloudComputeServiceContextModule()); } @Override diff --git a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java deleted file mode 100644 index 2e832511bd..0000000000 --- a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.greenhousedata.element.vcloud; - -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; - -import java.util.Properties; - -import org.jclouds.vcloud.VCloudPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class GreenHouseDataElementVCloudPropertiesBuilder extends VCloudPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-WY"); - properties.setProperty(PROPERTY_ENDPOINT, "https://mycloud.greenhousedata.com/api"); - properties.setProperty(PROPERTY_BUILD_VERSION, "1.5.0.464915"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); - return properties; - } - - public GreenHouseDataElementVCloudPropertiesBuilder(Properties properties) { - super(properties); - } -} diff --git a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java index a06f740ecc..0bf19f4964 100644 --- a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java +++ b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java @@ -18,49 +18,78 @@ */ package org.jclouds.greenhousedata.element.vcloud; -import java.net.URI; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.VCloudApiMetadata; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Green House Data Element vCloud * * @author Adrian Cole */ -public class GreenHouseDataElementVCloudProviderMetadata extends BaseProviderMetadata { +public class GreenHouseDataElementVCloudProviderMetadata + extends + BaseProviderMetadata, VCloudApiMetadata> { - public GreenHouseDataElementVCloudProviderMetadata() { - this(builder() - .id("greenhousedata-element-vcloud") - .name("Green House Data Element vCloud") - .api(new VCloudApiMetadata()) - .homepage(URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/")) - .console(URI.create("https://mycloud.greenhousedata.com/cloud/org/YOUR_ORG_HERE")) - .iso3166Codes("US-WY")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected GreenHouseDataElementVCloudProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public GreenHouseDataElementVCloudProviderMetadata() { + super(builder()); + } + + public GreenHouseDataElementVCloudProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + + protected Builder(){ + id("greenhousedata-element-vcloud") + .name("Green House Data Element vCloud") + .apiMetadata( + new VCloudApiMetadata().toBuilder() + .buildVersion("1.5.0.464915") + .contextBuilder(TypeToken.of(GreenHouseDataElementVCloudContextBuilder.class)).build()) + .homepage(URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/")) + .console(URI.create("https://mycloud.greenhousedata.com/cloud/org/YOUR_ORG_HERE")) + .iso3166Codes("US-WY") + .endpoint("https://mycloud.greenhousedata.com/api") + .defaultProperties(GreenHouseDataElementVCloudProviderMetadata.defaultProperties()); + } @Override public GreenHouseDataElementVCloudProviderMetadata build() { return new GreenHouseDataElementVCloudProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, VCloudApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - -} +} \ No newline at end of file diff --git a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java index b72914a0dc..61b93c25f9 100644 --- a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java +++ b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.greenhousedata.element.vcloud; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.jclouds.vcloud.VCloudApiMetadata; import org.testng.annotations.Test; diff --git a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java index ff3c504c18..efb4394359 100644 --- a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java +++ b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "GreenHouseDataElementVCloudTemplateBuilderLiveTest") -public class GreenHouseDataElementVCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class GreenHouseDataElementVCloudTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public GreenHouseDataElementVCloudTemplateBuilderLiveTest() { provider = "greenhousedata-element-vcloud"; diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeApiMetadata.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeApiMetadata.java deleted file mode 100644 index 05596e2e9e..0000000000 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeApiMetadata.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.hpcloud.compute; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; - -/** - * Implementation of {@link ApiMetadata} for the Amazon-specific Nova API - * - * @author Adrian Cole - */ -public class HPCloudComputeApiMetadata extends NovaApiMetadata { - - public HPCloudComputeApiMetadata() { - this(builder().fromApiMetadata(new NovaApiMetadata()) - .identityName("tenantId:accessKey") - .credentialName("secretKey")); - } - - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected HPCloudComputeApiMetadata(ConcreteBuilder builder) { - super(builder); - } - - private static class ConcreteBuilder extends NovaApiMetadataBuilder { - - @Override - public HPCloudComputeApiMetadata build() { - return new HPCloudComputeApiMetadata(this); - } - } - - private static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } -} \ No newline at end of file diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java index d0ad203eff..cdaccddb03 100644 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java +++ b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java @@ -19,10 +19,14 @@ package org.jclouds.hpcloud.compute; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.hpcloud.compute.config.HPCloudComputeServiceContextModule; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; +import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; +import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.NovaContextBuilder; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Module; @@ -32,12 +36,18 @@ import com.google.inject.Module; */ public class HPCloudComputeContextBuilder extends NovaContextBuilder { - public HPCloudComputeContextBuilder(Properties props) { - super(props); + public HPCloudComputeContextBuilder( + ProviderMetadata, NovaApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public HPCloudComputeContextBuilder(NovaApiMetadata apiMetadata) { + super(apiMetadata); } @Override protected void addContextModule(List modules) { modules.add(new HPCloudComputeServiceContextModule()); } + } diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputePropertiesBuilder.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputePropertiesBuilder.java deleted file mode 100644 index ca824c1744..0000000000 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputePropertiesBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not computee 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.hpcloud.compute; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; -import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; - -import java.util.Properties; - -import org.jclouds.openstack.nova.v1_1.NovaPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class HPCloudComputePropertiesBuilder extends NovaPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-NV"); - properties.setProperty(PROPERTY_ENDPOINT, "https://region-a.geo-1.identity.hpcloudsvc.com:35357"); - - // deallocating ip addresses can take a while - properties.setProperty(TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); - - properties.setProperty(CREDENTIAL_TYPE, "apiAccessKeyCredentials"); - properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "true"); - properties.setProperty(AUTO_GENERATE_KEYPAIRS, "true"); - return properties; - } - - public HPCloudComputePropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java index 5287499f88..44e48865a9 100644 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java +++ b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java @@ -4,7 +4,7 @@ * distributed with this work for additional information * regarding copyright ownership. jclouds licenses this file * to you under the Apache License, Version 2.0 (the - * "License"); you may not computee this file except in compliance + * "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 @@ -18,49 +18,86 @@ */ package org.jclouds.hpcloud.compute; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; +import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; + import java.net.URI; +import java.util.Properties; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; +import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; +import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; +import com.google.common.reflect.TypeToken; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for HP Cloud Compute Services. * * @author Adrian Cole */ -public class HPCloudComputeProviderMetadata extends BaseProviderMetadata { +public class HPCloudComputeProviderMetadata + extends + BaseProviderMetadata, NovaApiMetadata> { - public HPCloudComputeProviderMetadata() { - this(builder() - .id("hpcloud-compute") - .name("HP Cloud Compute Services") - .api(new HPCloudComputeApiMetadata()) - .homepage(URI.create("http://hpcloud.com")) - .console(URI.create("https://manage.hpcloud.com/compute")) - .linkedServices("hpcloud-compute", "hpcloud-objectstorage") - .iso3166Codes("US-NV")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected HPCloudComputeProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public HPCloudComputeProviderMetadata() { + super(builder()); + } + + public HPCloudComputeProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + // deallocating ip addresses can take a while + properties.setProperty(TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); + + properties.setProperty(CREDENTIAL_TYPE, "apiAccessKeyCredentials"); + properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "true"); + properties.setProperty(AUTO_GENERATE_KEYPAIRS, "true"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, NovaApiMetadata> { + + protected Builder(){ + id("hpcloud-compute") + .name("HP Cloud Compute Services") + .apiMetadata(new NovaApiMetadata().toBuilder().identityName("tenantId:accessKey") + .credentialName("secretKey") + .contextBuilder(TypeToken.of(HPCloudComputeContextBuilder.class)).build()) + .homepage(URI.create("http://hpcloud.com")) + .console(URI.create("https://manage.hpcloud.com/compute")) + .linkedServices("hpcloud-compute", "hpcloud-objectstorage") + .iso3166Codes("US-NV") + .endpoint("https://region-a.geo-1.identity.hpcloudsvc.com:35357") + .defaultProperties(HPCloudComputeProviderMetadata.defaultProperties()); + } @Override public HPCloudComputeProviderMetadata build() { return new HPCloudComputeProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, NovaApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } -} +} \ No newline at end of file diff --git a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderTest.java b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderTest.java index 670349b9ae..f752ac991a 100644 --- a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderTest.java +++ b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderTest.java @@ -35,7 +35,8 @@ */ package org.jclouds.hpcloud.compute; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** @@ -46,6 +47,6 @@ import org.testng.annotations.Test; public class HPCloudComputeProviderTest extends BaseProviderMetadataTest { public HPCloudComputeProviderTest() { - super(new HPCloudComputeProviderMetadata(), new HPCloudComputeApiMetadata()); + super(new HPCloudComputeProviderMetadata(), new NovaApiMetadata()); } } diff --git a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java index 676e2808e1..29664b45f4 100644 --- a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java +++ b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; +import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.compute.options.NovaTemplateOptions; import org.testng.annotations.Test; @@ -39,7 +42,8 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "HPCloudComputeTemplateBuilderLiveTest") -public class HPCloudComputeTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class HPCloudComputeTemplateBuilderLiveTest extends + BaseTemplateBuilderLiveTest> { public HPCloudComputeTemplateBuilderLiveTest() { provider = "hpcloud-compute"; diff --git a/providers/hpcloud-objectstorage/pom.xml b/providers/hpcloud-objectstorage/pom.xml index db3d4d7b55..360b992e40 100644 --- a/providers/hpcloud-objectstorage/pom.xml +++ b/providers/hpcloud-objectstorage/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.hpcloud.objectstorage.blobstore.integration.HPCloudObjectStorageTestInitializer https://region-a.geo-1.identity.hpcloudsvc.com:35357 1.0 @@ -127,10 +126,6 @@ test.hpcloud-objectstorage.credential ${test.hpcloud-objectstorage.credential} - - test.initializer - ${test.initializer} - jclouds.blobstore.httpstream.url ${jclouds.blobstore.httpstream.url} diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java index 2278c43d1d..8ff3b49aad 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java @@ -1,49 +1,95 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.hpcloud.objectstorage; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; + import java.net.URI; +import java.util.Properties; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.services.ServiceType; +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for HP Cloud Object Storage API + * Implementation of {@link org.jclouds.providers.ProviderMetadata} for HP Cloud Services Object Storage * - * @author Adrian Cole + * @author Jeremy Daggett */ -public class HPCloudObjectStorageApiMetadata extends BaseApiMetadata { +public class HPCloudObjectStorageApiMetadata + extends + BaseBlobStoreApiMetadata, HPCloudObjectStorageApiMetadata> { - public HPCloudObjectStorageApiMetadata() { - this(builder() - .id("hpcloud-objectstorage") - .type(ApiType.BLOBSTORE) - .name("HP Cloud Services Object Storage API") - .identityName("tenantId:accessKey") - .credentialName("secretKey") - .documentation(URI.create("https://build.hpcloud.com/object-storage/api"))); + private static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected HPCloudObjectStorageApiMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } + + public HPCloudObjectStorageApiMetadata() { + this(builder()); + } + + protected HPCloudObjectStorageApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); + // TODO: this doesn't actually do anything yet. + properties.setProperty(KeystoneProperties.VERSION, "2.0"); + properties.setProperty(CREDENTIAL_TYPE, "apiAccessKeyCredentials"); + return properties; + } + + public static class Builder + extends + BaseBlobStoreApiMetadata.Builder, HPCloudObjectStorageApiMetadata> { + + protected Builder() { + id("hpcloud-objectstorage") + .name("HP Cloud Services Object Storage API") + .identityName("tenantId:accessKey") + .credentialName("secretKey") + .version("1.0") + .documentation(URI.create("https://build.hpcloud.com/object-storage/api")) + .javaApi(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class) + .contextBuilder(TypeToken.of(HPCloudObjectStorageContextBuilder.class)) + .defaultProperties(HPCloudObjectStorageApiMetadata.defaultProperties()); + } @Override public HPCloudObjectStorageApiMetadata build() { return new HPCloudObjectStorageApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); + @Override + public Builder fromApiMetadata(HPCloudObjectStorageApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } -} \ No newline at end of file +} diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java index 5653544c81..f51bc37aae 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java @@ -19,35 +19,45 @@ package org.jclouds.hpcloud.objectstorage; import java.util.List; -import java.util.Properties; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.hpcloud.objectstorage.blobstore.HPCloudObjectStorageBlobStore; import org.jclouds.hpcloud.objectstorage.blobstore.config.HPCloudObjectStorageBlobStoreContextModule; import org.jclouds.hpcloud.objectstorage.config.HPCloudObjectStorageRestClientModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link HPCloudObjectStorageBlobStore} or {@link Injector} instances based on the most - * commonly requested arguments. + * Creates {@link HPCloudObjectStorageStoreContext} or {@link Injector} instances based on + * the most commonly requested arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or + * Context provided. *

    *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * If no Modules are specified, the default + * {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be + * installed. * * @author Adrian Cole, Andrew Newdigate - * @see HPCloudObjectStorageBlobStore + * @see HPCloudObjectStorageStoreContext */ -public class HPCloudObjectStorageContextBuilder extends BlobStoreContextBuilder { +public class HPCloudObjectStorageContextBuilder + extends + BlobStoreContextBuilder, HPCloudObjectStorageApiMetadata> { - public HPCloudObjectStorageContextBuilder(Properties props) { - super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class, props); + public HPCloudObjectStorageContextBuilder( + ProviderMetadata, HPCloudObjectStorageApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public HPCloudObjectStorageContextBuilder(HPCloudObjectStorageApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -59,4 +69,4 @@ public class HPCloudObjectStorageContextBuilder extends BlobStoreContextBuilder< protected void addClientModule(List modules) { modules.add(new HPCloudObjectStorageRestClientModule()); } -} +} \ No newline at end of file diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStoragePropertiesBuilder.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStoragePropertiesBuilder.java deleted file mode 100644 index 95bb9d2ecd..0000000000 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStoragePropertiesBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.hpcloud.objectstorage; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; - -import java.util.Properties; - -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; -import org.jclouds.openstack.services.ServiceType; -import org.jclouds.openstack.swift.SwiftPropertiesBuilder; - -/** - * @author Jeremy Daggett - */ -public class HPCloudObjectStoragePropertiesBuilder extends SwiftPropertiesBuilder { - - public HPCloudObjectStoragePropertiesBuilder(Properties properties) { - super(properties); - } - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-NV"); - properties.setProperty(PROPERTY_ENDPOINT, "https://region-a.geo-1.identity.hpcloudsvc.com:35357"); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - - properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); - // TODO: this doesn't actually do anything yet. - properties.setProperty(KeystoneProperties.VERSION, "2.0"); - - properties.setProperty(CREDENTIAL_TYPE, "apiAccessKeyCredentials"); - - return properties; - } - -} diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java index a41c592de8..65dea7c5a8 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java @@ -18,49 +18,72 @@ */ package org.jclouds.hpcloud.objectstorage; -import java.net.URI; +import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.providers.ProviderMetadata} for HP Cloud Services Object Storage + * Implementation of {@link org.jclouds.types.ProviderMetadata} for StratoGen VMware hosting * - * @author Jeremy Daggett + * @author Adrian Cole */ -public class HPCloudObjectStorageProviderMetadata extends BaseProviderMetadata { +public class HPCloudObjectStorageProviderMetadata + extends + BaseProviderMetadata, HPCloudObjectStorageApiMetadata> { - public HPCloudObjectStorageProviderMetadata() { - this(builder() - .id("hpcloud-objectstorage") - .name("HP Cloud Services Object Storage") - .api(new HPCloudObjectStorageApiMetadata()) - .homepage(URI.create("http://hpcloud.com")) - .console(URI.create("https://manage.hpcloud.com/objects/us-west")) - .linkedServices("hpcloud-compute", "hpcloud-objectstorage") - .iso3166Codes("US-NV")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected HPCloudObjectStorageProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public HPCloudObjectStorageProviderMetadata() { + super(builder()); + } + + public HPCloudObjectStorageProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_BUILD_VERSION, "???"); //FIXME +// properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); FIXME: needed? + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, HPCloudObjectStorageApiMetadata> { + + protected Builder(){ + id("hpcloud-objectstorage") + .name("HP Cloud Services Object Storage") + .apiMetadata(new HPCloudObjectStorageApiMetadata()) + .homepage(URI.create("http://hpcloud.com")) + .console(URI.create("https://manage.hpcloud.com/objects/us-west")) + .linkedServices("hpcloud-compute", "hpcloud-objectstorage") + .iso3166Codes("US-NV") + .endpoint("https://region-a.geo-1.identity.hpcloudsvc.com:35357") + .defaultProperties(HPCloudObjectStorageProviderMetadata.defaultProperties()); + } @Override public HPCloudObjectStorageProviderMetadata build() { return new HPCloudObjectStorageProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, HPCloudObjectStorageApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - } \ No newline at end of file diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java index ed305371de..a9516d6f9c 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java @@ -59,7 +59,7 @@ public class HPCloudObjectStorageAsyncBlobStore extends SwiftAsyncBlobStore { private final EnableCDNAndCache enableCDNAndCache; @Inject - protected HPCloudObjectStorageAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, + protected HPCloudObjectStorageAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, HPCloudObjectStorageClient sync, HPCloudObjectStorageAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java index e05119ed8c..fc9acef141 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java @@ -53,7 +53,7 @@ public class HPCloudObjectStorageBlobStore extends SwiftBlobStore { private EnableCDNAndCache enableCDNAndCache; @Inject - protected HPCloudObjectStorageBlobStore(BlobStoreContext context, BlobUtils blobUtils, + protected HPCloudObjectStorageBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, HPCloudObjectStorageClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java index 7deac56ea9..bda812354e 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java @@ -36,7 +36,11 @@ import org.testng.annotations.Test; */ @Test(groups = "live", testName = "HPCloudObjectStorageClientLiveTest") public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTest { - + + public HPCloudObjectStorageClientLiveTest(){ + provider = "hpcloud-objectstorage"; + } + @Override public HPCloudObjectStorageClient getApi() { return (HPCloudObjectStorageClient) context.getProviderSpecificContext().getApi(); diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java index 2ec0636ca6..d6855a61f3 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.hpcloud.objectstorage; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobIntegrationLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobIntegrationLiveTest.java index d500d58aa0..0fc06482d6 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobIntegrationLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobIntegrationLiveTest.java @@ -27,6 +27,10 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class HPCloudObjectStorageBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest { + public HPCloudObjectStorageBlobIntegrationLiveTest() { + provider = "hpcloud-objectstorage"; + } + @Override protected void checkContentDisposition(Blob blob, String contentDisposition) { assert blob.getPayload().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobLiveTest.java index d56de82499..2fd8425097 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class HPCloudObjectStorageBlobLiveTest extends SwiftBlobLiveTest { + public HPCloudObjectStorageBlobLiveTest() { + provider = "hpcloud-objectstorage"; + } } diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobMapIntegrationLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobMapIntegrationLiveTest.java index 88a67ddae6..a9e36cb5cc 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobMapIntegrationLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobMapIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class HPCloudObjectStorageBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest { + public HPCloudObjectStorageBlobMapIntegrationLiveTest() { + provider = "hpcloud-objectstorage"; + } } diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobSignerLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobSignerLiveTest.java index 21b6e07f56..f78fa2436b 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobSignerLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobSignerLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class HPCloudObjectStorageBlobSignerLiveTest extends SwiftBlobSignerLiveTest { + public HPCloudObjectStorageBlobSignerLiveTest() { + provider = "hpcloud-objectstorage"; + } } diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerIntegrationLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerIntegrationLiveTest.java index 73e717d4a3..207dc09cc2 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerIntegrationLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class HPCloudObjectStorageContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest { + public HPCloudObjectStorageContainerIntegrationLiveTest() { + provider = "hpcloud-objectstorage"; + } } diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerLiveTest.java index 44e70e3159..91d500d9b8 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerLiveTest.java @@ -29,6 +29,9 @@ import org.testng.annotations.Test; */ @Test(groups = { "live" }) public class HPCloudObjectStorageContainerLiveTest extends BaseContainerLiveTest { + public HPCloudObjectStorageContainerLiveTest() { + provider = "hpcloud-objectstorage"; + } @Test(enabled = false) //@Test(expectedExceptions=UnsupportedOperationException.class) diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageInputStreamMapIntegrationLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageInputStreamMapIntegrationLiveTest.java index 34907f3417..e3bd2f6061 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageInputStreamMapIntegrationLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageInputStreamMapIntegrationLiveTest.java @@ -26,5 +26,8 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class HPCloudObjectStorageInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest { + public HPCloudObjectStorageInputStreamMapIntegrationLiveTest() { + provider = "hpcloud-objectstorage"; + } } diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageServiceIntegrationLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageServiceIntegrationLiveTest.java index 5b28ee5c55..329156d7b6 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageServiceIntegrationLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageServiceIntegrationLiveTest.java @@ -30,6 +30,10 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live") public class HPCloudObjectStorageServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest { + public HPCloudObjectStorageServiceIntegrationLiveTest() { + provider = "hpcloud-objectstorage"; + } + @Override protected Set getIso3166Codes() { return ImmutableSet. of("US-NV"); diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageTestInitializer.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageTestInitializer.java deleted file mode 100644 index 03e5cf2487..0000000000 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageTestInitializer.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.hpcloud.objectstorage.blobstore.integration; - -import org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer; - -/** - * @author Jeremy Daggett - */ -public class HPCloudObjectStorageTestInitializer extends SwiftTestInitializer { - - public HPCloudObjectStorageTestInitializer() { - provider = "hpcloud-objectstorage"; - } - -} diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java index 2c7bde84d1..0e0b6fa748 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java @@ -8,17 +8,16 @@ import java.util.Properties; import java.util.Set; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.domain.Location; +import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageProviderMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.BaseRestClientExpectTest; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @Test(groups = "unit", testName = "HPCloudObjectStorageExpectTest") @@ -42,12 +41,6 @@ public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest fn, Module module, Properties props) { - return new BlobStoreContextFactory(setupRestProperties()) - .createContext(provider, identity, credential, ImmutableSet.of(new ExpectModule(fn), - new NullLoggingModule(), module), props) - .getBlobStore(); - } public void testListObjectsWhenResponseIs2xx() throws Exception { Map requestResponseMap = ImmutableMap. builder().put( @@ -60,4 +53,13 @@ public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest fn, Module module, Properties props) { + return createInjector(fn, module, props).getInstance(BlobStore.class); + } + + @Override public ProviderMetadata createProviderMetadata(){ + return new HPCloudObjectStorageProviderMetadata(); + } } diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/KeystoneFixture.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/KeystoneFixture.java index 45a5f393f8..01153ca070 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/KeystoneFixture.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/KeystoneFixture.java @@ -19,7 +19,7 @@ package org.jclouds.hpcloud.objectstorage.internal; import static java.lang.String.format; -import static org.jclouds.rest.BaseRestClientExpectTest.payloadFromStringWithContentType; +import static org.jclouds.rest.internal.BaseRestClientExpectTest.payloadFromStringWithContentType; import java.io.IOException; import java.net.URI; diff --git a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeContextBuilder.java b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeContextBuilder.java deleted file mode 100644 index 7309483ee9..0000000000 --- a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeContextBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ninefold.compute; - -import java.util.List; -import java.util.Properties; - -import org.jclouds.cloudstack.CloudStackContextBuilder; -import org.jclouds.ninefold.compute.config.NinefoldComputeServiceContextModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class NinefoldComputeContextBuilder extends CloudStackContextBuilder { - - public NinefoldComputeContextBuilder(Properties props) { - super(props); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new NinefoldComputeServiceContextModule()); - } - -} diff --git a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputePropertiesBuilder.java b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputePropertiesBuilder.java deleted file mode 100644 index f9ba9e888e..0000000000 --- a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputePropertiesBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ninefold.compute; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.cloudstack.CloudStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class NinefoldComputePropertiesBuilder extends CloudStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "AU-NSW"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.ninefold.com/compute/v1.0/"); - properties.setProperty(PROPERTY_API_VERSION, "2.2.12"); - properties.setProperty("ninefold-compute.image-id", "1215"); - properties.setProperty("ninefold-compute.image.login-user", "user:Password01"); - properties.setProperty("ninefold-compute.image.authenticate-sudo", "true"); - return properties; - } - - public NinefoldComputePropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java index 06b8a77b71..46da1fbdeb 100644 --- a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java +++ b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java @@ -1,66 +1,75 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ninefold.compute; import java.net.URI; +import java.util.Properties; import org.jclouds.cloudstack.CloudStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.cloudstack.CloudStackAsyncClient; +import org.jclouds.cloudstack.CloudStackClient; +import org.jclouds.cloudstack.CloudStackContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Ninefold - * Compute. - * + * Compute. * @author Adrian Cole */ -public class NinefoldComputeProviderMetadata extends BaseProviderMetadata { +public class NinefoldComputeProviderMetadata + extends + BaseProviderMetadata { - public NinefoldComputeProviderMetadata() { - this(builder() - .id("ninefold-compute") - .name("Ninefold Compute") - .api(new CloudStackApiMetadata()) - .homepage(URI.create("http://ninefold.com/virtual-servers/")) - .console(URI.create("https://ninefold.com/portal/portal/login")) - .iso3166Codes("AU-NSW")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected NinefoldComputeProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public NinefoldComputeProviderMetadata() { + super(builder()); + } + + public NinefoldComputeProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty("ninefold-compute.image-id", "1215"); + properties.setProperty("ninefold-compute.image.login-user", "user:Password01"); + properties.setProperty("ninefold-compute.image.authenticate-sudo", "true"); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder { + + protected Builder() { + id("ninefold-compute") + .name("Ninefold Compute") + .apiMetadata(new CloudStackApiMetadata().toBuilder().version("2.2.12").build()) + .homepage(URI.create("http://ninefold.com/virtual-servers/")) + .console(URI.create("https://ninefold.com/portal/portal/login")) + .iso3166Codes("AU-NSW") + .endpoint("https://api.ninefold.com/compute/v1.0/") + .defaultProperties(NinefoldComputeProviderMetadata.defaultProperties()); + } @Override public NinefoldComputeProviderMetadata build() { return new NinefoldComputeProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } -} +} \ No newline at end of file diff --git a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/config/NinefoldComputeServiceContextModule.java b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/config/NinefoldComputeServiceContextModule.java deleted file mode 100644 index e7551e4c30..0000000000 --- a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/config/NinefoldComputeServiceContextModule.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ninefold.compute.config; - -import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule; - -/** - * - * @author Adrian Cole - */ -public class NinefoldComputeServiceContextModule extends CloudStackComputeServiceContextModule { - -} diff --git a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/NinefoldComputeProviderTest.java b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/NinefoldComputeProviderTest.java index 0aec023a22..50fc82e0fe 100644 --- a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/NinefoldComputeProviderTest.java +++ b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/NinefoldComputeProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.ninefold.compute; import org.jclouds.cloudstack.CloudStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java index 71d3fb66d0..5368814810 100644 --- a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java +++ b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.cloudstack.CloudStackAsyncClient; +import org.jclouds.cloudstack.CloudStackClient; +import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class NinefoldComputeTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class NinefoldComputeTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest { public NinefoldComputeTemplateBuilderLiveTest() { provider = "ninefold-compute"; diff --git a/providers/ninefold-storage/pom.xml b/providers/ninefold-storage/pom.xml index 746355dd38..a25d2ae2b8 100644 --- a/providers/ninefold-storage/pom.xml +++ b/providers/ninefold-storage/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.ninefold.storage.blobstore.integration.NinefoldStorageTestInitializer http://onlinestorage.ninefold.com 1.4.0 @@ -106,7 +105,6 @@ ${test.ninefold-storage.build-version} ${test.ninefold-storage.identity} ${test.ninefold-storage.credential} - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} diff --git a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStoragePropertiesBuilder.java b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStoragePropertiesBuilder.java deleted file mode 100644 index 871c043251..0000000000 --- a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStoragePropertiesBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ninefold.storage; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Ninefold Storage - * - * @author Adrian Cole - */ -public class NinefoldStoragePropertiesBuilder extends PropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "http://onlinestorage.ninefold.com"); - properties.setProperty(PROPERTY_ISO3166_CODES, "AU-NSW"); - properties.setProperty(PROPERTY_API_VERSION, "1.4.0"); - return properties; - } - - public NinefoldStoragePropertiesBuilder() { - super(); - } - - public NinefoldStoragePropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java index 14e40a6f8f..152c46df77 100644 --- a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java +++ b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java @@ -19,9 +19,14 @@ package org.jclouds.ninefold.storage; import java.net.URI; +import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.atmos.AtmosAsyncClient; +import org.jclouds.atmos.AtmosClient; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Ninefold's @@ -29,38 +34,53 @@ import org.jclouds.providers.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class NinefoldStorageProviderMetadata extends BaseProviderMetadata { - - public NinefoldStorageProviderMetadata() { - this(builder() - .id("ninefold-storage") - .name("Ninefold Storage") - .api(new AtmosApiMetadata()) - .homepage(URI.create("http://ninefold.com/cloud-storage/")) - .console(URI.create("https://ninefold.com/portal/")) - .iso3166Codes("AU-NSW")); +public class NinefoldStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected NinefoldStorageProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public NinefoldStorageProviderMetadata() { + super(builder()); + } + + public NinefoldStorageProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, AtmosApiMetadata> { + + protected Builder(){ + id("ninefold-storage") + .name("Ninefold Storage") + .apiMetadata(new AtmosApiMetadata()) + .homepage(URI.create("http://ninefold.com/cloud-storage/")) + .console(URI.create("https://ninefold.com/portal/")) + .iso3166Codes("AU-NSW") + .endpoint("http://onlinestorage.ninefold.com") + .defaultProperties(NinefoldStorageProviderMetadata.defaultProperties()); + } @Override public NinefoldStorageProviderMetadata build() { return new NinefoldStorageProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, AtmosApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } -} +} \ No newline at end of file diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java index 499648c11b..ccd275f809 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.ninefold.storage; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobIntegrationLiveTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobIntegrationLiveTest.java index fa45cf29f0..85459aed79 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobIntegrationLiveTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "NinefoldStorageBlobIntegrationLiveTest") public class NinefoldStorageBlobIntegrationLiveTest extends AtmosIntegrationLiveTest { + public NinefoldStorageBlobIntegrationLiveTest() { + provider = "ninefold-storage"; + } } diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobLiveTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobLiveTest.java index de886df4ad..1e726acd69 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobLiveTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "NinefoldStorageBlobLiveTest") public class NinefoldStorageBlobLiveTest extends AtmosLiveTest { + public NinefoldStorageBlobLiveTest() { + provider = "ninefold-storage"; + } } diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobMapIntegrationLiveTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobMapIntegrationLiveTest.java index ab1d17221c..5028fa6261 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobMapIntegrationLiveTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobMapIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "NinefoldStorageBlobMapIntegrationLiveTest") public class NinefoldStorageBlobMapIntegrationLiveTest extends AtmosMapIntegrationLiveTest { + public NinefoldStorageBlobMapIntegrationLiveTest() { + provider = "ninefold-storage"; + } } diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobSignerLiveTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobSignerLiveTest.java index 81051acf30..c46e66c640 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobSignerLiveTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageBlobSignerLiveTest.java @@ -28,4 +28,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "NinefoldStorageBlobSignerLiveTest") public class NinefoldStorageBlobSignerLiveTest extends AtmosBlobSignerLiveTest { + public NinefoldStorageBlobSignerLiveTest() { + provider = "ninefold-storage"; + } } diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageContainerIntegrationLiveTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageContainerIntegrationLiveTest.java index c9ef0fb263..50eb0c0801 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageContainerIntegrationLiveTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageContainerIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "NinefoldStorageContainerIntegrationLiveTest") public class NinefoldStorageContainerIntegrationLiveTest extends AtmosContainerIntegrationLiveTest { + public NinefoldStorageContainerIntegrationLiveTest() { + provider = "ninefold-storage"; + } } diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageContainerLiveTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageContainerLiveTest.java index c9f9c803f5..fb3267b3e5 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageContainerLiveTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageContainerLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "NinefoldStorageContainerLiveTest") public class NinefoldStorageContainerLiveTest extends AtmosContainerLiveTest { + public NinefoldStorageContainerLiveTest() { + provider = "ninefold-storage"; + } } diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageInputStreamMapIntegrationLiveTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageInputStreamMapIntegrationLiveTest.java index 0cc55b3731..b7524ba753 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageInputStreamMapIntegrationLiveTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageInputStreamMapIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "NinefoldStorageInputStreamMapIntegrationLiveTest") public class NinefoldStorageInputStreamMapIntegrationLiveTest extends AtmosInputStreamMapIntegrationLiveTest { + public NinefoldStorageInputStreamMapIntegrationLiveTest() { + provider = "ninefold-storage"; + } } diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageServiceIntegrationLiveTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageServiceIntegrationLiveTest.java index 206f6a85f7..2bdec426ec 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageServiceIntegrationLiveTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageServiceIntegrationLiveTest.java @@ -30,6 +30,11 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live", testName = "NinefoldStorageServiceIntegrationLiveTest") public class NinefoldStorageServiceIntegrationLiveTest extends AtmosServiceIntegrationLiveTest { + + public NinefoldStorageServiceIntegrationLiveTest() { + provider = "ninefold-storage"; + } + @Override protected Set getIso3166Codes() { return ImmutableSet. of("AU-NSW"); diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageTestInitializer.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageTestInitializer.java deleted file mode 100644 index b9d7d37603..0000000000 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/blobstore/integration/NinefoldStorageTestInitializer.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ninefold.storage.blobstore.integration; - -import org.jclouds.atmos.blobstore.integration.AtmosTestInitializer; - -/** - * - * @author Adrian Cole - */ -public class NinefoldStorageTestInitializer extends AtmosTestInitializer { - - public NinefoldStorageTestInitializer() { - provider = "ninefold-storage"; - } - -} diff --git a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ContextBuilder.java b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ContextBuilder.java deleted file mode 100644 index 5a55f81ddf..0000000000 --- a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ContextBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openhosting; - -import java.util.List; -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackContextBuilder; -import org.jclouds.openhosting.config.OpenHostingEast1ComputeServiceContextModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class OpenHostingEast1ContextBuilder extends ElasticStackContextBuilder { - - public OpenHostingEast1ContextBuilder(Properties props) { - super(props); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new OpenHostingEast1ComputeServiceContextModule()); - } - -} diff --git a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1PropertiesBuilder.java b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1PropertiesBuilder.java deleted file mode 100644 index 01c05710fd..0000000000 --- a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1PropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openhosting; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class OpenHostingEast1PropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-FL"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.east1.openhosting.com"); - properties.setProperty(PROPERTY_API_VERSION, "2.0"); - return properties; - } - - public OpenHostingEast1PropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java index 6944d07aff..b1e33c13ca 100644 --- a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java +++ b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java @@ -19,48 +19,72 @@ package org.jclouds.openhosting; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London Peer 1. - * + * Implementation of {@link org.jclouds.types.ProviderMetadata} for OpenHosting East1. + * * @author Adrian Cole */ -public class OpenHostingEast1ProviderMetadata extends BaseProviderMetadata { +public class OpenHostingEast1ProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public OpenHostingEast1ProviderMetadata() { - this(builder() - .id("openhosting-east1") - .name("OpenHosting East1") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("https://east1.openhosting.com")) - .console(URI.create("https://east1.openhosting.com/accounts")) - .iso3166Codes("US-VA")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected OpenHostingEast1ProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public OpenHostingEast1ProviderMetadata() { + super(builder()); + } + + public OpenHostingEast1ProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("openhosting-east1") + .name("OpenHosting East1") + .apiMetadata(new ElasticStackApiMetadata()) + .homepage(URI.create("https://east1.openhosting.com")) + .console(URI.create("https://east1.openhosting.com/accounts")) + .iso3166Codes("US-VA") + .endpoint("https://api.east1.openhosting.com") + .defaultProperties(OpenHostingEast1ProviderMetadata.defaultProperties()); + } @Override public OpenHostingEast1ProviderMetadata build() { return new OpenHostingEast1ProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - -} +} \ No newline at end of file diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java index 7caa1d9564..a40c09c9a0 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.openhosting; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java index 96e00c3b5b..50a86d8a3a 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class OpenHostingEast1TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class OpenHostingEast1TemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public OpenHostingEast1TemplateBuilderLiveTest() { provider = "openhosting-east1"; @@ -52,16 +57,16 @@ public class OpenHostingEast1TemplateBuilderLiveTest extends BaseTemplateBuilder @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { - case WINDOWS: - return (input.version.equals("") || input.version.equals("2008 R2")) && input.is64Bit; - case UBUNTU: - return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; - case DEBIAN: - return (input.version.equals("") || input.version.matches("[56].0")) && input.is64Bit; - case CENTOS: - return (input.version.equals("") || input.version.matches("5.[567]")) && input.is64Bit; - default: - return false; + case WINDOWS: + return (input.version.equals("") || input.version.equals("2008 R2")) && input.is64Bit; + case UBUNTU: + return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.matches("[56].0")) && input.is64Bit; + case CENTOS: + return (input.version.equals("") || input.version.matches("5.[567]")) && input.is64Bit; + default: + return false; } } diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java index 795afc54ab..1ea439a161 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java @@ -18,50 +18,80 @@ */ package org.jclouds.rimuhosting.miro; +import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT; +import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.config.ComputeServiceProperties; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.concurrent.Timeout; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for RimuHosting API * * @author Adrian Cole */ -public class RimuHostingApiMetadata extends BaseApiMetadata { +public class RimuHostingApiMetadata + extends + BaseComputeServiceApiMetadata, RimuHostingApiMetadata> { - public RimuHostingApiMetadata() { - this(builder() - .id("rimuhosting") - .type(ApiType.COMPUTE) - .name("RimuHosting API") - .identityName("API Key") - .documentation(URI.create("http://apidocs.rimuhosting.com"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected RimuHostingApiMetadata(Builder builder) { + public RimuHostingApiMetadata() { + this(new Builder()); + } + + protected RimuHostingApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + Timeout timeout = RimuHostingClient.class.getAnnotation(Timeout.class); + long timeoutMillis = timeout.timeUnit().toMillis(timeout.duration()); + properties.setProperty(PROPERTY_SO_TIMEOUT, timeoutMillis + ""); + properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, timeoutMillis + ""); + properties.setProperty(ComputeServiceProperties.TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, RimuHostingApiMetadata> { + + protected Builder() { + id("rimuhosting") + .type(ApiType.COMPUTE) + .name("RimuHosting API") + .identityName("API Key") + .documentation(URI.create("http://apidocs.rimuhosting.com")) + .version("1") + .defaultEndpoint("https://api.rimuhosting.com/r") + .javaApi(RimuHostingClient.class, RimuHostingAsyncClient.class) + .contextBuilder(TypeToken.of(RimuHostingContextBuilder.class)); + } @Override public RimuHostingApiMetadata build() { return new RimuHostingApiMetadata(this); } + + @Override + public Builder fromApiMetadata(RimuHostingApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - -} \ No newline at end of file +} diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java index 68f3f2971d..e01c11d97b 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java @@ -19,38 +19,30 @@ package org.jclouds.rimuhosting.miro; import java.util.List; -import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rimuhosting.miro.compute.config.RimuHostingComputeServiceContextModule; import org.jclouds.rimuhosting.miro.config.RimuHostingRestClientModule; -import com.google.inject.Injector; -import com.google.inject.Key; import com.google.inject.Module; -import com.google.inject.TypeLiteral; /** - * Creates {@link RimuHostingComputeServiceContext} or {@link Injector} instances based on the most - * commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

    - *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. * * @author Adrian Cole - * @see RimuHostingComputeServiceContext */ -public class RimuHostingContextBuilder extends ComputeServiceContextBuilder { +public class RimuHostingContextBuilder + extends + ComputeServiceContextBuilder, RimuHostingApiMetadata> { - public RimuHostingContextBuilder(Properties props) { - super(RimuHostingClient.class, RimuHostingAsyncClient.class, props); + public RimuHostingContextBuilder( + ProviderMetadata, RimuHostingApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public RimuHostingContextBuilder(RimuHostingApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -58,16 +50,8 @@ public class RimuHostingContextBuilder extends ComputeServiceContextBuilder>() { - })); - } - - @Override protected void addClientModule(List modules) { modules.add(new RimuHostingRestClientModule()); } + } diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java deleted file mode 100644 index ea3562fcfa..0000000000 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rimuhosting.miro; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; -import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPERTY_RIMUHOSTING_DEFAULT_DC; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.concurrent.Timeout; - -/** - * Builds properties used in RimuHosting Clients - * - * @author Adrian Cole - */ -public class RimuHostingPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ZONES, "DCAUCKLAND,DCLONDON,DCDALLAS,DCSYDNEY"); - properties.setProperty(PROPERTY_ISO3166_CODES, "NZ-AUK,US-TX,AU-NSW,GB-LND"); - properties.setProperty(PROPERTY_ZONE + ".DCAUCKLAND." + ISO3166_CODES, "NZ-AUK"); - properties.setProperty(PROPERTY_ZONE + ".DCLONDON." + ISO3166_CODES, "GB-LND"); - properties.setProperty(PROPERTY_ZONE + ".DCDALLAS." + ISO3166_CODES, "US-TX"); - properties.setProperty(PROPERTY_ZONE + ".DCSYDNEY." + ISO3166_CODES, "AU-NSW"); - properties.setProperty(PROPERTY_API_VERSION, "TODO"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.rimuhosting.com/r"); - properties.setProperty(PROPERTY_RIMUHOSTING_DEFAULT_DC, "DCDALLAS"); - Timeout timeout = RimuHostingClient.class.getAnnotation(Timeout.class); - long timeoutMillis = timeout.timeUnit().toMillis(timeout.duration()); - properties.setProperty(PROPERTY_SO_TIMEOUT, timeoutMillis + ""); - properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, timeoutMillis + ""); - properties.setProperty(ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); - return properties; - } - - public RimuHostingPropertiesBuilder(Properties properties) { - super(properties); - } -} diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java index b037c50830..5d32459a2f 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java @@ -18,47 +18,80 @@ */ package org.jclouds.rimuhosting.miro; -import java.net.URI; +import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE; +import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; +import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPERTY_RIMUHOSTING_DEFAULT_DC; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for RimuHosting. - * * @author Adrian Cole */ -public class RimuHostingProviderMetadata extends BaseProviderMetadata { - public RimuHostingProviderMetadata() { - this(builder() - .id("rimuhosting") - .name("RimuHosting") - .api(new RimuHostingApiMetadata()) - .homepage(URI.create("http://www.rimuhosting.com")) - .console(URI.create("https://rimuhosting.com/cp")) - .iso3166Codes("NZ-AUK", "US-TX", "AU-NSW", "GB-LND")); +public class RimuHostingProviderMetadata + extends + BaseProviderMetadata, RimuHostingApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected RimuHostingProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public RimuHostingProviderMetadata() { + super(builder()); + } + + public RimuHostingProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_ZONES, "DCAUCKLAND,DCLONDON,DCDALLAS,DCSYDNEY"); + properties.setProperty(PROPERTY_ZONE + ".DCAUCKLAND." + ISO3166_CODES, "NZ-AUK"); + properties.setProperty(PROPERTY_ZONE + ".DCLONDON." + ISO3166_CODES, "GB-LND"); + properties.setProperty(PROPERTY_ZONE + ".DCDALLAS." + ISO3166_CODES, "US-TX"); + properties.setProperty(PROPERTY_ZONE + ".DCSYDNEY." + ISO3166_CODES, "AU-NSW"); + properties.setProperty(PROPERTY_RIMUHOSTING_DEFAULT_DC, "DCDALLAS"); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, RimuHostingApiMetadata> { + + protected Builder() { + id("rimuhosting") + .name("RimuHosting") + .apiMetadata(new RimuHostingApiMetadata()) + .homepage(URI.create("http://www.rimuhosting.com")) + .console(URI.create("https://rimuhosting.com/cp")) + .iso3166Codes("NZ-AUK", "US-TX", "AU-NSW", "GB-LND") + .endpoint("https://api.rimuhosting.com/r") + .defaultProperties(RimuHostingProviderMetadata.defaultProperties()); + } @Override public RimuHostingProviderMetadata build() { return new RimuHostingProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, RimuHostingApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - -} +} \ No newline at end of file diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java index ff388b638d..8e08b5b83a 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java @@ -22,13 +22,11 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; -import java.util.Properties; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rimuhosting.miro.binder.CreateServerOptions; @@ -46,7 +44,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "RimuHostingAsyncClientTest") -public class RimuHostingAsyncClientTest extends RestClientTest { +public class RimuHostingAsyncClientTest extends BaseAsyncClientTest { public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException { Method method = RimuHostingAsyncClient.class.getMethod("createServer", String.class, String.class, String.class, @@ -96,7 +94,7 @@ public class RimuHostingAsyncClientTest extends RestClientTest createContextSpec() { - return new RestContextFactory().createContextSpec("rimuhosting", "apikey", "null", new Properties()); + public ProviderMetadata createProviderMetadata() { + return new RimuHostingProviderMetadata(); } } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java index e63a41255e..22fd52dc70 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java @@ -22,13 +22,11 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -import java.util.Properties; import java.util.Set; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; import org.jclouds.rimuhosting.miro.domain.Image; import org.jclouds.rimuhosting.miro.domain.NewServerResponse; import org.jclouds.rimuhosting.miro.domain.PricingPlan; @@ -38,31 +36,29 @@ import org.jclouds.rimuhosting.miro.domain.internal.RunningState; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * Tests behavior of {@code RimuHostingClient} * * @author Ivan Meredith */ @Test(groups = "live", singleThreaded = true, testName = "RimuHostingClientLiveTest") -public class RimuHostingClientLiveTest extends BaseVersionedServiceLiveTest { +public class RimuHostingClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public RimuHostingClientLiveTest() { provider = "rimuhosting"; } private RimuHostingClient connection; - private RestContext context; + private RestContext restContext; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - - this.context = new RestContextFactory().createContext(provider, ImmutableSet - . of(new Log4JLoggingModule()), overrides); - this.connection = context.getApi(); + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + restContext = context.getProviderSpecificContext(); + this.connection = restContext.getApi(); } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java index de1ad2dd48..2c43f53516 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.rimuhosting.miro; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java index 0c8bbb88ae..e03c5759e1 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java @@ -18,8 +18,11 @@ */ package org.jclouds.rimuhosting.miro.compute; -import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; +import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; +import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -30,7 +33,10 @@ import com.google.common.collect.ImmutableMap; * @author Ivan Meredith */ @Test(groups = "live", sequential = true) -public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class RimuHostingComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public RimuHostingComputeServiceLiveTest() { provider = "rimuhosting"; } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java index a3041fad41..b67a5acc72 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; +import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -37,7 +40,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class RimuHostingTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class RimuHostingTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public RimuHostingTemplateBuilderLiveTest() { provider = "rimuhosting"; diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterContextBuilder.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterContextBuilder.java deleted file mode 100644 index e2ae42d1b0..0000000000 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterContextBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.serverlove; - -import java.util.List; -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackContextBuilder; -import org.jclouds.serverlove.config.ServerloveManchesterComputeServiceContextModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class ServerloveManchesterContextBuilder extends ElasticStackContextBuilder { - - public ServerloveManchesterContextBuilder(Properties props) { - super(props); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new ServerloveManchesterComputeServiceContextModule()); - } - -} diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterPropertiesBuilder.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterPropertiesBuilder.java deleted file mode 100644 index a708b496ab..0000000000 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.serverlove; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class ServerloveManchesterPropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "GB-MAN"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.z1-man.serverlove.com"); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - return properties; - } - - public ServerloveManchesterPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java index d1b2230206..f360e54b53 100644 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java @@ -19,47 +19,72 @@ package org.jclouds.serverlove; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Serverlove Manchester. - * + * * @author Adrian Cole */ -public class ServerloveManchesterProviderMetadata extends BaseProviderMetadata { +public class ServerloveManchesterProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public ServerloveManchesterProviderMetadata() { - this(builder() - .id("serverlove-z1-man") - .name("Serverlove Manchester") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("http://www.serverlove.com")) - .console(URI.create("http://www.serverlove.com/accounts")) - .iso3166Codes("GB-MAN")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected ServerloveManchesterProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ServerloveManchesterProviderMetadata() { + super(builder()); + } + + public ServerloveManchesterProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("serverlove-z1-man") + .name("Serverlove Manchester") + .apiMetadata(new ElasticStackApiMetadata()) + .homepage(URI.create("http://www.serverlove.com")) + .console(URI.create("http://www.serverlove.com/accounts")) + .iso3166Codes("GB-MAN") + .endpoint("https://api.z1-man.serverlove.com") + .defaultProperties(ServerloveManchesterProviderMetadata.defaultProperties()); + } @Override public ServerloveManchesterProviderMetadata build() { return new ServerloveManchesterProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } -} +} \ No newline at end of file diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/config/ServerloveManchesterComputeServiceContextModule.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/config/ServerloveManchesterComputeServiceContextModule.java deleted file mode 100644 index d84c5921df..0000000000 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/config/ServerloveManchesterComputeServiceContextModule.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.serverlove.config; - -import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule; - -/** - * - * @author Adrian Cole - */ -public class ServerloveManchesterComputeServiceContextModule extends ElasticStackComputeServiceContextModule { - -} diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java index 9ad8d824e2..4e757bfcdc 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.serverlove; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java index bfcf037e9e..a2bc867767 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -38,7 +41,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class ServerloveManchesterTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public ServerloveManchesterTemplateBuilderLiveTest() { provider = "serverlove-z1-man"; @@ -51,16 +56,16 @@ public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBui @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { - case UBUNTU: - return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; - case DEBIAN: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; - case CENTOS: - return (input.version.equals("") || input.version.equals("5.7")) && input.is64Bit; - case WINDOWS: - return (input.version.equals("") || input.version.equals("2008 R2")) && input.is64Bit; - default: - return false; + case UBUNTU: + return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + case CENTOS: + return (input.version.equals("") || input.version.equals("5.7")) && input.is64Bit; + case WINDOWS: + return (input.version.equals("") || input.version.equals("2008 R2")) && input.is64Bit; + default: + return false; } } diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaContextBuilder.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaContextBuilder.java deleted file mode 100644 index d3bdb84431..0000000000 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaContextBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.skalicloud; - -import java.util.List; -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackContextBuilder; -import org.jclouds.skalicloud.config.SkaliCloudMalaysiaComputeServiceContextModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class SkaliCloudMalaysiaContextBuilder extends ElasticStackContextBuilder { - - public SkaliCloudMalaysiaContextBuilder(Properties props) { - super(props); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new SkaliCloudMalaysiaComputeServiceContextModule()); - } - -} diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaPropertiesBuilder.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaPropertiesBuilder.java deleted file mode 100644 index c8fcad1ff0..0000000000 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaPropertiesBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.skalicloud; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class SkaliCloudMalaysiaPropertiesBuilder extends ElasticStackPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "MY-10"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.sdg-my.skalicloud.com"); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - return properties; - } - - public SkaliCloudMalaysiaPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java index d6a80aaee3..ba9e4c69c3 100644 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java +++ b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java @@ -19,48 +19,72 @@ package org.jclouds.skalicloud; import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for SkaliCloud Malaysia. - * + * * @author Adrian Cole */ -public class SkaliCloudMalaysiaProviderMetadata extends BaseProviderMetadata { +public class SkaliCloudMalaysiaProviderMetadata + extends + BaseProviderMetadata, ElasticStackApiMetadata> { - public SkaliCloudMalaysiaProviderMetadata() { - this(builder() - .id("skalicloud-sdg-my") - .name("SkaliCloud Malaysia") - .api(new ElasticStackApiMetadata()) - .homepage(URI.create("http://sdg-my.skalicloud.com")) - .console(URI.create("http://sdg-my.skalicloud.com/accounts")) - .iso3166Codes("MY-10")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SkaliCloudMalaysiaProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public SkaliCloudMalaysiaProviderMetadata() { + super(builder()); + } + + public SkaliCloudMalaysiaProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + + protected Builder() { + id("skalicloud-sdg-my") + .name("SkaliCloud Malaysia") + .apiMetadata(new ElasticStackApiMetadata()) + .homepage(URI.create("https://sdg-my.skalicloud.com")) + .console(URI.create("https://api.sdg-my.skalicloud.com/accounts")) + .iso3166Codes("MY-10") + .endpoint("https://api.sdg-my.skalicloud.com") + .defaultProperties(SkaliCloudMalaysiaProviderMetadata.defaultProperties()); + } @Override public SkaliCloudMalaysiaProviderMetadata build() { return new SkaliCloudMalaysiaProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, ElasticStackApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - -} +} \ No newline at end of file diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/config/SkaliCloudMalaysiaComputeServiceContextModule.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/config/SkaliCloudMalaysiaComputeServiceContextModule.java deleted file mode 100644 index 0e3219d94b..0000000000 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/config/SkaliCloudMalaysiaComputeServiceContextModule.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.skalicloud.config; - -import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule; - -/** - * - * @author Adrian Cole - */ -public class SkaliCloudMalaysiaComputeServiceContextModule extends ElasticStackComputeServiceContextModule { - -} \ No newline at end of file diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java index a45034b500..6ce1d3640b 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.skalicloud; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java index 72b92aa344..a35ea5fe04 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.elasticstack.ElasticStackAsyncClient; +import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class SkaliCloudMalaysiaTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class SkaliCloudMalaysiaTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public SkaliCloudMalaysiaTemplateBuilderLiveTest() { provider = "skalicloud-sdg-my"; diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java index 7193e51134..8d9edb2b04 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java @@ -19,49 +19,71 @@ package org.jclouds.slicehost; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for Slicehost API + * Implementation of {@link ApiMetadata} for Slicehost 1.0 API * * @author Adrian Cole */ -public class SlicehostApiMetadata extends BaseApiMetadata { +public class SlicehostApiMetadata + extends + BaseComputeServiceApiMetadata, SlicehostApiMetadata> { - public SlicehostApiMetadata() { - this(builder() - .id("slicehost") - .type(ApiType.COMPUTE) - .name("Slicehost API") - .identityName("API password") - .documentation(URI.create("http://articles.slicehost.com/api"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SlicehostApiMetadata(Builder builder) { + public SlicehostApiMetadata() { + this(new Builder()); + } + + protected SlicehostApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty("jclouds.ssh.max-retries", "8"); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, SlicehostApiMetadata> { + + protected Builder() { + id("slicehost") + .type(ApiType.COMPUTE) + .name("Slicehost API") + .identityName("API password") + .documentation(URI.create("http://articles.slicehost.com/api")) + .version("https://api.slicehost.com") + .defaultEndpoint("https://api.slicehost.com") + .javaApi(SlicehostClient.class, SlicehostAsyncClient.class) + .defaultProperties(SlicehostApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(SlicehostContextBuilder.class)); + } @Override public SlicehostApiMetadata build() { return new SlicehostApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromApiMetadata(SlicehostApiMetadata in) { + super.fromApiMetadata(in); + return this; + } - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java index fcd4edecd2..57cdaf2a38 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java @@ -19,35 +19,30 @@ package org.jclouds.slicehost; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.slicehost.compute.config.SlicehostComputeServiceContextModule; import org.jclouds.slicehost.config.SlicehostRestClientModule; -import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link SlicehostComputeServiceContext} or {@link Injector} instances based on the most - * commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

    - *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. * * @author Adrian Cole - * @see SlicehostComputeServiceContext */ -public class SlicehostContextBuilder extends - ComputeServiceContextBuilder { +public class SlicehostContextBuilder + extends + ComputeServiceContextBuilder, SlicehostApiMetadata> { - public SlicehostContextBuilder(Properties props) { - super(SlicehostClient.class, SlicehostAsyncClient.class, props); + public SlicehostContextBuilder( + ProviderMetadata, SlicehostApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public SlicehostContextBuilder(SlicehostApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -55,9 +50,8 @@ public class SlicehostContextBuilder extends modules.add(new SlicehostComputeServiceContextModule()); } - @Override protected void addClientModule(List modules) { modules.add(new SlicehostRestClientModule()); } -} +} \ No newline at end of file diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostPropertiesBuilder.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostPropertiesBuilder.java deleted file mode 100644 index 9c5fa000aa..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostPropertiesBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.slicehost; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Slicehost Connections - * - * @author Adrian Cole - */ -public class SlicehostPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-IL,US-TX,US-MO"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.slicehost.com"); - properties.setProperty(PROPERTY_API_VERSION, "1.4.1.1"); - properties.setProperty("jclouds.ssh.max-retries", "8"); - return properties; - } - - public SlicehostPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java index e315e8af3f..b0aba661e7 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java @@ -1,63 +1,62 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.slicehost; import java.net.URI; +import java.util.Properties; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Slicehost * * @author Adrian Cole */ -public class SlicehostProviderMetadata extends BaseProviderMetadata { - public SlicehostProviderMetadata() { - this(builder() - .id("slicehost") - .name("Slicehost") - .api(new SlicehostApiMetadata()) - .homepage(URI.create("http://www.slicehost.com")) - .console(URI.create("https://manage.slicehost.com/")) - .iso3166Codes("US-IL", "US-TX", "US-MO")); +public class SlicehostProviderMetadata extends BaseProviderMetadata, SlicehostApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SlicehostProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public SlicehostProviderMetadata() { + super(builder()); + } + + public SlicehostProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, SlicehostApiMetadata> { + + protected Builder(){ + id("slicehost") + .name("Slicehost") + .apiMetadata(new SlicehostApiMetadata()) + .homepage(URI.create("http://www.slicehost.com")) + .console(URI.create("https://manage.slicehost.com/")) + .iso3166Codes("US-IL", "US-TX", "US-MO"); + } @Override public SlicehostProviderMetadata build() { return new SlicehostProviderMetadata(this); } - } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, SlicehostApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java index f1ef8c2e55..692b324ca5 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java @@ -22,17 +22,15 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; -import java.util.Properties; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.slicehost.filters.SlicehostBasic; import org.jclouds.slicehost.xml.FlavorHandler; @@ -52,7 +50,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SlicehostAsyncClientTest") -public class SlicehostAsyncClientTest extends RestClientTest { +public class SlicehostAsyncClientTest extends BaseAsyncClientTest { public void testCreateSlice() throws IOException, SecurityException, NoSuchMethodException { Method method = SlicehostAsyncClient.class.getMethod("createSlice", String.class, int.class, int.class); @@ -253,8 +251,8 @@ public class SlicehostAsyncClientTest extends RestClientTest createContextSpec() { - return new RestContextFactory().createContextSpec("slicehost", "apikey", null, new Properties()); + public ProviderMetadata createProviderMetadata() { + return new SlicehostProviderMetadata(); } } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java index b15f7fb7a8..6d0b9e3480 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java @@ -25,34 +25,29 @@ import static org.testng.Assert.assertTrue; import java.io.IOException; import java.lang.reflect.UndeclaredThrowableException; import java.security.SecureRandom; -import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.BaseVersionedServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpResponseException; import org.jclouds.io.Payloads; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; -import org.jclouds.rest.RestContextFactory; import org.jclouds.slicehost.domain.Flavor; import org.jclouds.slicehost.domain.Image; import org.jclouds.slicehost.domain.Slice; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; -import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Injector; -import com.google.inject.Module; /** * Tests behavior of {@code SlicehostClient} @@ -60,7 +55,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "SlicehostClientLiveTest") -public class SlicehostClientLiveTest extends BaseVersionedServiceLiveTest { +public class SlicehostClientLiveTest + extends + BaseComputeServiceContextLiveTest> { + public SlicehostClientLiveTest() { provider = "slicehost"; } @@ -69,14 +67,12 @@ public class SlicehostClientLiveTest extends BaseVersionedServiceLiveTest { protected SshClient.Factory sshFactory; private Predicate socketTester; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - - Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides).buildInjector(); - + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + Injector injector = context.utils().injector(); + client = injector.getInstance(SlicehostClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java index 44fe33bed2..a03a98dd6e 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.slicehost; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java index e834a42e1f..79c960841c 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java @@ -18,8 +18,11 @@ */ package org.jclouds.slicehost.compute; -import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; +import org.jclouds.slicehost.SlicehostAsyncClient; +import org.jclouds.slicehost.SlicehostClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -32,7 +35,10 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class SlicehostComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public SlicehostComputeServiceLiveTest() { provider = "slicehost"; } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java index 4b6c1d5dc1..ff8b08c660 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.slicehost.SlicehostAsyncClient; +import org.jclouds.slicehost.SlicehostClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class SlicehostTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public SlicehostTemplateBuilderLiveTest() { provider = "slicehost"; diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java index 9650629c0e..e9347a4861 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java @@ -19,50 +19,73 @@ package org.jclouds.softlayer; import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; + +import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for SoftLayer API + * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class SoftLayerApiMetadata extends BaseApiMetadata { +public class SoftLayerApiMetadata + extends + BaseComputeServiceApiMetadata, SoftLayerApiMetadata> { - public SoftLayerApiMetadata() { - this(builder() - .id("softlayer") - .type(ApiType.COMPUTE) - .name("SoftLayer API") - .identityName("API Username") - .credentialName("API Key") - .documentation(URI.create("http://sldn.softlayer.com/article/REST"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SoftLayerApiMetadata(Builder builder) { + public SoftLayerApiMetadata() { + this(new Builder()); + } + + protected SoftLayerApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + properties.setProperty("jclouds.ssh.max-retries", "5"); + properties.setProperty("jclouds.ssh.retry-auth", "true"); + return properties; + } + + public static class Builder + extends + BaseComputeServiceApiMetadata.Builder, SoftLayerApiMetadata> { + + protected Builder() { + id("softlayer") + .type(ApiType.COMPUTE) + .name("SoftLayer API") + .identityName("API Username") + .credentialName("API Key") + .documentation(URI.create("http://sldn.softlayer.com/article/REST")) + .version("3") + .defaultEndpoint("https://api.softlayer.com/rest") + .defaultProperties(SoftLayerApiMetadata.defaultProperties()) + .javaApi(SoftLayerClient.class, SoftLayerAsyncClient.class) + .contextBuilder(TypeToken.of(SoftLayerContextBuilder.class)); + } @Override public SoftLayerApiMetadata build() { return new SoftLayerApiMetadata(this); } + + @Override + public Builder fromApiMetadata(SoftLayerApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); - } - -} \ No newline at end of file +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java index f2b2aaa19f..86519a9cfc 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java @@ -19,9 +19,10 @@ package org.jclouds.softlayer; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.softlayer.compute.config.SoftLayerComputeServiceContextModule; import org.jclouds.softlayer.config.SoftLayerRestClientModule; @@ -31,10 +32,17 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class SoftLayerContextBuilder extends ComputeServiceContextBuilder { +public class SoftLayerContextBuilder + extends + ComputeServiceContextBuilder, SoftLayerApiMetadata> { - public SoftLayerContextBuilder(Properties props) { - super(SoftLayerClient.class, SoftLayerAsyncClient.class, props); + public SoftLayerContextBuilder( + ProviderMetadata, SoftLayerApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public SoftLayerContextBuilder(SoftLayerApiMetadata apiMetadata) { + super(apiMetadata); } @Override @@ -42,7 +50,6 @@ public class SoftLayerContextBuilder extends ComputeServiceContextBuilder modules) { modules.add(new SoftLayerRestClientModule()); } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerPropertiesBuilder.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerPropertiesBuilder.java deleted file mode 100644 index 142ddb9df6..0000000000 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerPropertiesBuilder.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.softlayer; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX; -import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE; -import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY; -import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME; -import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED; -import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; - -/** - * Builds properties used in SoftLayer Clients - * - * @author Adrian Cole - */ -public class SoftLayerPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.softlayer.com/rest"); - properties.setProperty(PROPERTY_API_VERSION, "3"); - properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY, "" + 60 * 60 * 1000); - properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME, "Cloud Server"); - // ex: for private (ex. don't share hardware) use "Private [0-9]+ x ([.0-9]+) GHz Core[s]?" - // ex: for private and public use ".*[0-9]+ x ([.0-9]+) GHz Core[s]?" - properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "[0-9]+ x ([0-9.]+) GHz Core[s]?"); - // SAN or LOCAL - properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "LOCAL"); - // 10, 100, 1000 - properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "10"); - properties.setProperty(PROPERTY_ISO3166_CODES, "SG,NL,US-CA,US-TX,US-VA,US-WA,US-TX"); - Builder prices = ImmutableSet.builder(); - prices.add("21"); // 1 IP Address - prices.add("55"); // Host Ping: categoryCode: monitoring, notification - prices.add("57"); // Email and Ticket: categoryCode: notification - prices.add("58"); // Automated Notification: categoryCode: response - prices.add("1800"); // 0 GB Bandwidth: categoryCode: bandwidth - prices.add("905"); // Reboot / Remote Console: categoryCode: remote_management - prices.add("418"); // Nessus Vulnerability Assessment & Reporting: categoryCode: - // vulnerability_scanner - prices.add("420"); // Unlimited SSL VPN Users & 1 PPTP VPN User per account: categoryCode: - // vpn_management - properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES, Joiner.on(',').join(prices.build())); - return properties; - } - - public SoftLayerPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java index 00f465a085..141bd163ae 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java @@ -18,46 +18,101 @@ */ package org.jclouds.softlayer; -import java.net.URI; +import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX; +import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE; +import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY; +import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME; +import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED; +import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableSet; /** - * Implementation of {@ link org.jclouds.types.ProviderMetadata} for SoftLayer. - * + * Implementation of {@link org.jclouds.types.ProviderMetadata} for SoftLayer. * @author Adrian Cole */ -public class SoftLayerProviderMetadata extends BaseProviderMetadata { - public SoftLayerProviderMetadata() { - this(builder() - .id("softlayer") - .name("SoftLayer") - .api(new SoftLayerApiMetadata()) - .homepage(URI.create("http://www.softlayer.com")) - .console(URI.create("https://manage.softlayer.com")) - .iso3166Codes("SG","US-CA","US-TX","US-VA","US-WA","US-TX")); +public class SoftLayerProviderMetadata + extends + BaseProviderMetadata, SoftLayerApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SoftLayerProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public SoftLayerProviderMetadata() { + super(builder()); + } + + public SoftLayerProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY, "" + 60 * 60 * 1000); + properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME, "Cloud Server"); + // ex: for private (ex. don't share hardware) use "Private [0-9]+ x ([.0-9]+) GHz Core[s]?" + // ex: for private and public use ".*[0-9]+ x ([.0-9]+) GHz Core[s]?" + properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "[0-9]+ x ([0-9.]+) GHz Core[s]?"); + // SAN or LOCAL + properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "LOCAL"); + // 10, 100, 1000 + properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "10"); + ImmutableSet.Builder prices = ImmutableSet.builder(); + prices.add("21"); // 1 IP Address + prices.add("55"); // Host Ping: categoryCode: monitoring, notification + prices.add("57"); // Email and Ticket: categoryCode: notification + prices.add("58"); // Automated Notification: categoryCode: response + prices.add("1800"); // 0 GB Bandwidth: categoryCode: bandwidth + prices.add("905"); // Reboot / Remote Console: categoryCode: remote_management + prices.add("418"); // Nessus Vulnerability Assessment & Reporting: categoryCode: + // vulnerability_scanner + prices.add("420"); // Unlimited SSL VPN Users & 1 PPTP VPN User per account: categoryCode: + // vpn_management + properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES, Joiner.on(',').join(prices.build())); + + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder, SoftLayerApiMetadata> { + + protected Builder() { + id("softlayer") + .name("SoftLayer") + .apiMetadata(new SoftLayerApiMetadata()) + .homepage(URI.create("http://www.softlayer.com")) + .console(URI.create("https://manage.softlayer.com")) + .iso3166Codes("SG","US-CA","US-TX","US-VA","US-WA","US-TX") + .endpoint("https://api.softlayer.com/rest") + .defaultProperties(SoftLayerProviderMetadata.defaultProperties()); + } @Override public SoftLayerProviderMetadata build() { return new SoftLayerProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, SoftLayerApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java index 01d71eb4ef..8ef1e7b13a 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.softlayer; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java index f663f86a2c..e784ee8a37 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java @@ -29,7 +29,6 @@ import org.jclouds.compute.domain.Template; import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials; import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; import org.jclouds.domain.LoginCredentials; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions; import org.jclouds.softlayer.compute.strategy.SoftLayerComputeServiceAdapter; @@ -43,7 +42,6 @@ import org.testng.annotations.Test; import com.google.common.collect.Iterables; import com.google.common.net.InetAddresses; -import com.google.inject.Guice; @Test(groups = "live", singleThreaded = true, testName = "SoftLayerComputeServiceAdapterLiveTest") public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientLiveTest { @@ -52,10 +50,9 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL private NodeAndInitialCredentials guest; @BeforeGroups(groups = { "live" }) - public void setupClient() { - super.setupClient(); - adapter = Guice.createInjector(module, new Log4JLoggingModule()) - .getInstance(SoftLayerComputeServiceAdapter.class); + public void setupContext() { + super.setupContext(); + adapter = context.utils().injector().getInstance(SoftLayerComputeServiceAdapter.class); } @Test @@ -70,7 +67,7 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL public void testCreateNodeWithGroupEncodedIntoNameThenStoreCredentials() { String group = "foo"; String name = "node" + new Random().nextInt(); - Template template = computeContext.getComputeService().templateBuilder().build(); + Template template = context.getComputeService().templateBuilder().build(); // test passing custom options template.getOptions().as(SoftLayerTemplateOptions.class).domainName("me.org"); @@ -85,7 +82,7 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL } protected void doConnectViaSsh(VirtualGuest guest, LoginCredentials creds) { - SshClient ssh = computeContext.utils().sshFactory().create(new IPSocket(guest.getPrimaryIpAddress(), 22), creds); + SshClient ssh = context.utils().sshFactory().create(new IPSocket(guest.getPrimaryIpAddress(), 22), creds); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); @@ -111,9 +108,9 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL } @AfterGroups(groups = "live") - protected void tearDown() { + protected void tearDownContext() { if (guest != null) adapter.destroyNode(guest.getNodeId() + ""); - super.tearDown(); + super.tearDownContext(); } } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java index 3562fe30e6..ffd7da5e2c 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java @@ -18,9 +18,9 @@ */ package org.jclouds.softlayer.compute; -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.rest.RestContext; import org.jclouds.softlayer.SoftLayerAsyncClient; import org.jclouds.softlayer.SoftLayerClient; @@ -37,7 +37,10 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, sequential = true) -public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class SoftLayerComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public SoftLayerComputeServiceLiveTest() { provider = "softlayer"; group = "soft-layer"; @@ -50,8 +53,7 @@ public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest public void testAssignability() throws Exception { @SuppressWarnings("unused") - RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + RestContext tmContext = context.getProviderSpecificContext(); } // softlayer does not support metadata diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java index 8dbb18e283..8e90948446 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java @@ -20,39 +20,43 @@ package org.jclouds.softlayer.compute; import static org.testng.Assert.assertEquals; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.softlayer.SoftLayerAsyncClient; +import org.jclouds.softlayer.SoftLayerClient; +import org.jclouds.softlayer.SoftLayerProviderMetadata; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; +import com.google.common.io.Closeables; /** * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "SoftLayerExperimentLiveTest") -public class SoftLayerExperimentLiveTest extends BaseVersionedServiceLiveTest { +public class SoftLayerExperimentLiveTest + extends + BaseComputeServiceContextLiveTest> { + public SoftLayerExperimentLiveTest() { - provider = "softlayer"; + provider = "glesys"; } @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = new ComputeServiceContextFactory().createContext(provider, identity, credential, ImmutableSet - . of(new Log4JLoggingModule(), new SshjSshClientModule())); + context = ComputeServiceContextBuilder + .newBuilder(new SoftLayerProviderMetadata()) + .overrides(setupProperties()) + .modules(setupModules()).build(); assertEquals(context.getComputeService().listAssignableLocations().size(), 6); } finally { - if (context != null) - context.close(); + Closeables.closeQuietly(context); } } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java index 195a63a35a..79ab1ddf01 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java @@ -29,29 +29,30 @@ import java.io.IOException; import java.util.Properties; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Volume; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.softlayer.SoftLayerAsyncClient; +import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions; import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; /** * * @author Jason King */ @Test(groups = "live") -public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - +public class SoftLayerTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { + public SoftLayerTemplateBuilderLiveTest() { provider = "softlayer"; } @@ -65,20 +66,20 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes public boolean apply(OsFamilyVersion64Bit input) { // For each os-type both 32- and 64-bit are supported. switch (input.family) { - case UBUNTU: - return input.version.equals("") || input.version.equals("10.04") || input.version.equals("8"); - case DEBIAN: - return input.version.equals("") || input.version.matches("[56].0"); - case FEDORA: - return input.version.equals("") || input.version.equals("13") || input.version.equals("15"); - case RHEL: - return input.version.equals("") || input.version.equals("5") || input.version.equals("6"); - case CENTOS: - return input.version.equals("") || input.version.equals("5") || input.version.equals("6.0"); - case WINDOWS: - return input.version.equals("") || input.version.equals("2003") || input.version.equals("2008"); - default: - return false; + case UBUNTU: + return input.version.equals("") || input.version.equals("10.04") || input.version.equals("8"); + case DEBIAN: + return input.version.equals("") || input.version.matches("[56].0"); + case FEDORA: + return input.version.equals("") || input.version.equals("13") || input.version.equals("15"); + case RHEL: + return input.version.equals("") || input.version.equals("5") || input.version.equals("6"); + case CENTOS: + return input.version.equals("") || input.version.equals("5") || input.version.equals("6.0"); + case WINDOWS: + return input.version.equals("") || input.version.equals("2003") || input.version.equals("2008"); + default: + return false; } } @@ -101,13 +102,12 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testTemplateBuilderFindsGigabitUplink() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "1000"); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet - . of(new Log4JLoggingModule()), overrides); + context = createContext(overrides, setupModules()); // TODO add something to the template about port speed? context.getComputeService().templateBuilder().build(); @@ -120,13 +120,12 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testTemplateBuilderFindsMegabitUplink() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "100"); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet - . of(new Log4JLoggingModule()), overrides); + context = createContext(overrides, setupModules()); // TODO add something to the template about port speed? context.getComputeService().templateBuilder().build(); @@ -139,13 +138,12 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testBiggestTemplateBuilderWhenBootIsSAN() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "SAN"); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet - . of(new Log4JLoggingModule()), overrides); + context = createContext(overrides, setupModules()); Template template = context.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); @@ -160,13 +158,12 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testDefaultTemplateBuilderWhenPrivateNetwork() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet - . of(new Log4JLoggingModule()), overrides); + context = createContext(overrides, setupModules()); Template template = context.getComputeService().templateBuilder().build(); assertEquals(getCores(template.getHardware()), 1.0d); @@ -181,14 +178,13 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testBiggestTemplateBuilderWhenPrivateNetwork() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet - . of(new Log4JLoggingModule()), overrides); - + context = createContext(overrides, setupModules()); + Template template = context.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 8.0d); assertEquals(template.getHardware().getRam(), 16); @@ -199,6 +195,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes context.close(); } } + @Test public void testFastestTemplateBuilder() throws IOException { Template template = context.getComputeService().templateBuilder().fastest().build(); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardwareTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardwareTest.java index 450ba1d802..329ce3e7a5 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardwareTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardwareTest.java @@ -23,12 +23,11 @@ import static org.jclouds.softlayer.compute.functions.ProductItemsToHardware.har import static org.testng.AssertJUnit.assertEquals; import java.util.List; -import java.util.Properties; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; -import org.jclouds.softlayer.SoftLayerPropertiesBuilder; +import org.jclouds.softlayer.SoftLayerProviderMetadata; import org.jclouds.softlayer.domain.ProductItem; import org.jclouds.softlayer.domain.ProductItemCategory; import org.jclouds.softlayer.domain.ProductItemPrice; @@ -59,7 +58,7 @@ public class ProductItemsToHardwareTest { toHardware = Guice.createInjector(new AbstractModule() { @Override protected void configure() { - bindProperties(binder(), new SoftLayerPropertiesBuilder(new Properties()).build()); + bindProperties(binder(), new SoftLayerProviderMetadata().getDefaultProperties()); } }).getInstance(ProductItemsToHardware.class); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountClientLiveTest.java index 10bf050c84..fa533d87ce 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountClientLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountClientLiveTest.java @@ -34,9 +34,9 @@ import org.testng.annotations.Test; @Test(groups = "live") public class AccountClientLiveTest extends BaseSoftLayerClientLiveTest { @BeforeGroups(groups = { "live" }) - public void setupClient() { - super.setupClient(); - client = context.getApi().getAccountClient(); + public void setupContext() { + super.setupContext(); + client = socontext.getApi().getAccountClient(); } private AccountClient client; diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java index 59e8ab8a8d..02d8dd7acf 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java @@ -20,20 +20,16 @@ package org.jclouds.softlayer.features; import static org.testng.Assert.assertEquals; -import java.util.Properties; - import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; -import org.jclouds.softlayer.SoftLayerAsyncClient; -import org.jclouds.softlayer.SoftLayerClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.softlayer.SoftLayerProviderMetadata; /** * @author Adrian Cole */ -public abstract class BaseSoftLayerAsyncClientTest extends RestClientTest { +public abstract class BaseSoftLayerAsyncClientTest extends BaseAsyncClientTest { @Override protected void checkFilters(HttpRequest request) { @@ -42,9 +38,8 @@ public abstract class BaseSoftLayerAsyncClientTest extends RestClientTest } @Override - public RestContextSpec createContextSpec() { - Properties props = new Properties(); - return new RestContextFactory().createContextSpec("softlayer", "apiKey", "secretKey", props); + public ProviderMetadata createProviderMetadata() { + return new SoftLayerProviderMetadata(); } } \ No newline at end of file diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java index 9f8658c2ad..0febeb7087 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java @@ -18,93 +18,31 @@ */ package org.jclouds.softlayer.features; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.inject.name.Names.bindProperties; -import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME; -import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES; - -import java.util.Properties; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.collect.Memoized; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.AuthorizationException; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.rest.RestContext; import org.jclouds.softlayer.SoftLayerAsyncClient; import org.jclouds.softlayer.SoftLayerClient; -import org.jclouds.softlayer.SoftLayerPropertiesBuilder; -import org.jclouds.softlayer.compute.config.SoftLayerComputeServiceContextModule; -import org.jclouds.softlayer.domain.ProductItemPrice; -import org.jclouds.softlayer.domain.ProductPackage; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Module; -import com.google.inject.Provides; - /** * Tests behavior of {@code SoftLayerClient} * * @author Adrian Cole */ @Test(groups = "live") -public class BaseSoftLayerClientLiveTest { +public class BaseSoftLayerClientLiveTest + extends + BaseComputeServiceContextLiveTest> { - protected RestContext context; - protected ComputeServiceContext computeContext; - protected Module module; + protected RestContext socontext; - @BeforeGroups(groups = { "live" }) - public void setupClient() { - String identity = checkNotNull(System.getProperty("test.softlayer.identity"), "test.softlayer.identity"); - String credential = checkNotNull(System.getProperty("test.softlayer.credential"), "test.softlayer.credential"); - - computeContext = new ComputeServiceContextFactory().createContext("softlayer", identity, credential, ImmutableSet - . of(new Log4JLoggingModule(), new SshjSshClientModule())); - context = computeContext.getProviderSpecificContext(); - module = new AbstractModule() { - - @Override - protected void configure() { - bindProperties(binder(), new SoftLayerPropertiesBuilder(new Properties()).build()); - bind(SoftLayerClient.class).toInstance(context.getApi()); - - } - - @SuppressWarnings("unused") - @Provides - @Singleton - @Memoized - public Supplier getProductPackage(AtomicReference authException, - SoftLayerClient client, - @Named(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME) String virtualGuestPackageName) { - return new SoftLayerComputeServiceContextModule().getProductPackage(authException, 30, client, - virtualGuestPackageName); - } - - @SuppressWarnings("unused") - @Provides - @Singleton - public Iterable prices(@Named(PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES) String prices) { - return new SoftLayerComputeServiceContextModule().prices(prices); - } - }; - } - - @AfterGroups(groups = "live") - protected void tearDown() { - if (context != null) - context.close(); + @BeforeGroups(groups = { "integration", "live" }) + @Override + public void setupContext() { + super.setupContext(); + socontext = context.getProviderSpecificContext(); } } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java index 3a852f0b53..fd1e9fedf6 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java @@ -57,7 +57,7 @@ public class DatacenterAsyncClientTest extends BaseSoftLayerAsyncClientTest ramItems = Iterables.filter(productPackage.getItems(), Predicates.and(categoryCode("ram"), capacity(2.0f))); @@ -117,7 +116,7 @@ public class VirtualGuestClientLiveTest extends BaseSoftLayerClientLiveTest { osToProductItem.get("Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (64 bit)")); Builder prices = ImmutableSet.builder(); - prices.addAll(Guice.createInjector(module).getInstance(Key.get(new TypeLiteral>() { + prices.addAll(context.utils().injector().getInstance(Key.get(new TypeLiteral>() { }))); prices.add(ramPrice); prices.add(cpuPrice); @@ -129,11 +128,11 @@ public class VirtualGuestClientLiveTest extends BaseSoftLayerClientLiveTest { ProductOrder order = ProductOrder.builder().packageId(pkgId).quantity(1).useHourlyPricing(true).prices( prices.build()).virtualGuest(guest).build(); - ProductOrderReceipt receipt = context.getApi().getVirtualGuestClient().orderVirtualGuest(order); + ProductOrderReceipt receipt = socontext.getApi().getVirtualGuestClient().orderVirtualGuest(order); ProductOrder order2 = receipt.getOrderDetails(); VirtualGuest result = Iterables.get(order2.getVirtualGuests(), 0); - ProductOrder order3 = context.getApi().getVirtualGuestClient().getOrderTemplate(result.getId()); + ProductOrder order3 = socontext.getApi().getVirtualGuestClient().getOrderTemplate(result.getId()); assertEquals(order.getPrices(), order3.getPrices()); assertNotNull(receipt); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/predicates/ProductItemPredicatesTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/predicates/ProductItemPredicatesTest.java index 52a03fa214..e8e1aab43d 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/predicates/ProductItemPredicatesTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/predicates/ProductItemPredicatesTest.java @@ -37,7 +37,7 @@ public class ProductItemPredicatesTest { private ProductItem emptyItem; @BeforeGroups(groups = { "unit" }) - public void setupClient() { + public void setupContext() { ramCategory = ProductItemCategory.builder().id(1).categoryCode("ram").build(); item = ProductItem.builder().id(1).description("a test item").categories(ImmutableSet.of(ramCategory)).capacity( diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java index 3f5758010f..c4c50fb035 100644 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java +++ b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java @@ -19,28 +19,34 @@ package org.jclouds.stratogen.vcloud.mycloud; import java.util.List; -import java.util.Properties; -import org.jclouds.stratogen.vcloud.mycloud.config.StratoGenVCloudMyCloudComputeServiceContextModule; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.stratogen.vcloud.mycloud.config.StratoGenVCloudMyCloudRestClientModule; +import org.jclouds.vcloud.VCloudApiMetadata; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudContextBuilder; +import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; import com.google.inject.Module; /** - * {@inheritDoc} - * * @author Adrian Cole */ public class StratoGenVCloudMyCloudContextBuilder extends VCloudContextBuilder { + public StratoGenVCloudMyCloudContextBuilder( + ProviderMetadata, VCloudApiMetadata> providerMetadata) { + super(providerMetadata); + } - public StratoGenVCloudMyCloudContextBuilder(Properties props) { - super(props); + public StratoGenVCloudMyCloudContextBuilder(VCloudApiMetadata apiMetadata) { + super(apiMetadata); } @Override protected void addContextModule(List modules) { - modules.add(new StratoGenVCloudMyCloudComputeServiceContextModule()); + modules.add(new VCloudComputeServiceContextModule()); } @Override diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudPropertiesBuilder.java b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudPropertiesBuilder.java deleted file mode 100644 index ddcd6bed32..0000000000 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudPropertiesBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.stratogen.vcloud.mycloud; - -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; - -import java.util.Properties; - -import org.jclouds.vcloud.VCloudPropertiesBuilder; - -/** - * Builds properties used in stratogen VCloud Clients - * - * @author Adrian Cole - */ -public class StratoGenVCloudMyCloudPropertiesBuilder extends VCloudPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "GB"); - properties.setProperty(PROPERTY_ENDPOINT, "https://vcd.stratogen.net/api"); - properties.setProperty(PROPERTY_BUILD_VERSION, "1.5.0.464915"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "Direct Internet"); - return properties; - } - - public StratoGenVCloudMyCloudPropertiesBuilder(Properties properties) { - super(properties); - } -} diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java index 56d792b129..07a245e950 100644 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java +++ b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java @@ -18,49 +18,78 @@ */ package org.jclouds.stratogen.vcloud.mycloud; -import java.net.URI; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; -import org.jclouds.providers.BaseProviderMetadata; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.VCloudApiMetadata; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for StratoGen VMware hosting * * @author Adrian Cole */ -public class StratoGenVCloudMyCloudProviderMetadata extends BaseProviderMetadata { +public class StratoGenVCloudMyCloudProviderMetadata + extends + BaseProviderMetadata, VCloudApiMetadata> { - public StratoGenVCloudMyCloudProviderMetadata() { - this(builder() - .id("stratogen-vcloud-mycloud") - .name("StratoGen VMware hosting") - .api(new VCloudApiMetadata()) - .homepage(URI.create("http://www.stratogen.net")) - .console(URI.create("https://mycloud.stratogen.net/cloud/org/YOUR_ORG_HERE")) - .iso3166Codes("GB")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected StratoGenVCloudMyCloudProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public StratoGenVCloudMyCloudProviderMetadata() { + super(builder()); + } + + public StratoGenVCloudMyCloudProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "Direct Internet"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + + protected Builder(){ + id("stratogen-vcloud-mycloud") + .name("StratoGen VMware hosting") + .apiMetadata( + new VCloudApiMetadata().toBuilder() + .buildVersion("1.5.0.464915") + .contextBuilder(TypeToken.of(StratoGenVCloudMyCloudContextBuilder.class)).build()) + .homepage(URI.create("http://www.stratogen.net")) + .console(URI.create("https://mycloud.stratogen.net/cloud/org/YOUR_ORG_HERE")) + .iso3166Codes("GB") + .endpoint("https://mycloud.greenhousedata.com/api") + .defaultProperties(StratoGenVCloudMyCloudProviderMetadata.defaultProperties()); + } @Override public StratoGenVCloudMyCloudProviderMetadata build() { return new StratoGenVCloudMyCloudProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, VCloudApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - -} +} \ No newline at end of file diff --git a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderTest.java b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderTest.java index 09ea912b2e..7f4f71fdf8 100644 --- a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderTest.java +++ b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.stratogen.vcloud.mycloud; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.jclouds.vcloud.VCloudApiMetadata; import org.testng.annotations.Test; diff --git a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java index 5d03161fe5..fb4590393d 100644 --- a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java +++ b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "StratoGenVCloudMyCloudTemplateBuilderLiveTest") -public class StratoGenVCloudMyCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class StratoGenVCloudMyCloudTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public StratoGenVCloudMyCloudTemplateBuilderLiveTest() { provider = "stratogen-vcloud-mycloud"; diff --git a/providers/synaptic-storage/pom.xml b/providers/synaptic-storage/pom.xml index 3bdfd71a8b..8eb2a76de5 100644 --- a/providers/synaptic-storage/pom.xml +++ b/providers/synaptic-storage/pom.xml @@ -34,7 +34,6 @@ bundle - org.jclouds.synaptic.storage.blobstore.integration.SynapticStorageTestInitializer https://storage.synaptic.att.com 1.3.0 @@ -106,7 +105,6 @@ ${test.synaptic-storage.build-version} ${test.synaptic-storage.identity} ${test.synaptic-storage.credential} - ${test.initializer} ${jclouds.blobstore.httpstream.url} ${jclouds.blobstore.httpstream.md5} diff --git a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStoragePropertiesBuilder.java b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStoragePropertiesBuilder.java deleted file mode 100644 index 376e5b3da8..0000000000 --- a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStoragePropertiesBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.synaptic.storage; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Atmos Clients - * - * @author Adrian Cole - */ -public class SynapticStoragePropertiesBuilder extends PropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ENDPOINT, "https://storage.synaptic.att.com"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-TX"); - properties.setProperty(PROPERTY_API_VERSION, "1.3.0"); - return properties; - } - - public SynapticStoragePropertiesBuilder() { - super(); - } - - public SynapticStoragePropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java index fdd007508b..f472292fc4 100644 --- a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java +++ b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java @@ -1,27 +1,14 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.synaptic.storage; import java.net.URI; +import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.atmos.AtmosAsyncClient; +import org.jclouds.atmos.AtmosClient; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for AT&T's @@ -29,39 +16,53 @@ import org.jclouds.providers.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class SynapticStorageProviderMetadata extends BaseProviderMetadata { - - public SynapticStorageProviderMetadata() { - this(builder() - .id("synaptic-storage") - .name("AT&T Synaptic Storage") - .api(new AtmosApiMetadata()) - .homepage(URI.create("https://www.synaptic.att.com/")) - .console(URI.create("https://www.synaptic.att.com/clouduser/login.htm")) - .iso3166Codes("US-VA", "US-TX")); +public class SynapticStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected SynapticStorageProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public SynapticStorageProviderMetadata() { + super(builder()); + } + + public SynapticStorageProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, AtmosApiMetadata> { + + protected Builder(){ + id("synaptic-storage") + .name("AT&T Synaptic Storage") + .apiMetadata(new AtmosApiMetadata()) + .homepage(URI.create("https://www.synaptic.att.com/")) + .console(URI.create("https://www.synaptic.att.com/clouduser/login.htm")) + .iso3166Codes("US-VA", "US-TX") + .endpoint("https://storage.synaptic.att.com") + .defaultProperties(SynapticStorageProviderMetadata.defaultProperties()); + } @Override public SynapticStorageProviderMetadata build() { return new SynapticStorageProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, AtmosApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } - } \ No newline at end of file diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java index be9da98de9..c25618c383 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.synaptic.storage; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobIntegrationLiveTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobIntegrationLiveTest.java index 4a1963ba4c..f16204905c 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobIntegrationLiveTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "SynapticStorageBlobIntegrationLiveTest") public class SynapticStorageBlobIntegrationLiveTest extends AtmosIntegrationLiveTest { + public SynapticStorageBlobIntegrationLiveTest() { + provider = "synaptic-storage"; + } } diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobLiveTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobLiveTest.java index 715ad8124b..8a259d5d55 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobLiveTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "SynapticStorageBlobLiveTest") public class SynapticStorageBlobLiveTest extends AtmosLiveTest { + public SynapticStorageBlobLiveTest() { + provider = "synaptic-storage"; + } } diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobMapIntegrationLiveTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobMapIntegrationLiveTest.java index fbd02dbe4c..c616b88cfe 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobMapIntegrationLiveTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobMapIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "SynapticStorageBlobMapIntegrationLiveTest") public class SynapticStorageBlobMapIntegrationLiveTest extends AtmosMapIntegrationLiveTest { + public SynapticStorageBlobMapIntegrationLiveTest() { + provider = "synaptic-storage"; + } } diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobSignerLiveTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobSignerLiveTest.java index 5aeeacee60..940e67afe1 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobSignerLiveTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageBlobSignerLiveTest.java @@ -28,4 +28,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "SynapticStorageBlobSignerLiveTest") public class SynapticStorageBlobSignerLiveTest extends AtmosBlobSignerLiveTest { + public SynapticStorageBlobSignerLiveTest() { + provider = "synaptic-storage"; + } } diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageContainerIntegrationLiveTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageContainerIntegrationLiveTest.java index 5e0666f102..f8fbd636fa 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageContainerIntegrationLiveTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageContainerIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "SynapticStorageContainerIntegrationLiveTest") public class SynapticStorageContainerIntegrationLiveTest extends AtmosContainerIntegrationLiveTest { + public SynapticStorageContainerIntegrationLiveTest() { + provider = "synaptic-storage"; + } } diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageContainerLiveTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageContainerLiveTest.java index a1fc00c54d..52a590f7f9 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageContainerLiveTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageContainerLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "SynapticStorageContainerLiveTest") public class SynapticStorageContainerLiveTest extends AtmosContainerLiveTest { + public SynapticStorageContainerLiveTest() { + provider = "synaptic-storage"; + } } diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageInputStreamMapIntegrationLiveTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageInputStreamMapIntegrationLiveTest.java index c9d8c7590c..272cf4a374 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageInputStreamMapIntegrationLiveTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageInputStreamMapIntegrationLiveTest.java @@ -27,4 +27,7 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "SynapticStorageInputStreamMapIntegrationLiveTest") public class SynapticStorageInputStreamMapIntegrationLiveTest extends AtmosInputStreamMapIntegrationLiveTest { + public SynapticStorageInputStreamMapIntegrationLiveTest() { + provider = "synaptic-storage"; + } } diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageServiceIntegrationLiveTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageServiceIntegrationLiveTest.java index a0ae41b64b..179bea88ff 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageServiceIntegrationLiveTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageServiceIntegrationLiveTest.java @@ -30,6 +30,11 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live", testName = "SynapticStorageServiceIntegrationLiveTest") public class SynapticStorageServiceIntegrationLiveTest extends AtmosServiceIntegrationLiveTest { + + public SynapticStorageServiceIntegrationLiveTest() { + provider = "synaptic-storage"; + } + @Override protected Set getIso3166Codes() { return ImmutableSet. of("US-VA", "US-TX"); diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageTestInitializer.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageTestInitializer.java deleted file mode 100644 index d8ebf06092..0000000000 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/blobstore/integration/SynapticStorageTestInitializer.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.synaptic.storage.blobstore.integration; - -import org.jclouds.atmos.blobstore.integration.AtmosTestInitializer; - -/** - * - * @author Adrian Cole - */ -public class SynapticStorageTestInitializer extends AtmosTestInitializer { - - public SynapticStorageTestInitializer() { - provider = "synaptic-storage"; - } - -} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java index 77b324a1fd..dfae1bf49f 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java @@ -1,50 +1,69 @@ package org.jclouds.trmk.ecloud; +import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; +import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for Terremark eCloud v2.8 API * * @author Adrian Cole */ -public class TerremarkECloudApiMetadata extends BaseApiMetadata { +public class TerremarkECloudApiMetadata extends + TerremarkVCloudApiMetadata { - public TerremarkECloudApiMetadata() { - this(builder() - .id("trmk-ecloud") - .type(ApiType.COMPUTE) - .name("Terremark Enterprise Cloud v2.8 API") - .identityName("Email") - .credentialName("Password") - .documentation(URI.create("http://support.theenterprisecloud.com/kb/default.asp?id=533&Lang=1&SID="))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected TerremarkECloudApiMetadata(Builder builder) { + public TerremarkECloudApiMetadata() { + this(new Builder()); + } + + protected TerremarkECloudApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = TerremarkVCloudApiMetadata.defaultProperties(); + properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "eCloudExtensions"); + properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.8"); + return properties; + } + + public static class Builder + extends + TerremarkVCloudApiMetadata.Builder { + + protected Builder() { + super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class); + id("trmk-ecloud") + .name("Terremark Enterprise Cloud v2.8 API") + .version("0.8b-ext2.8") + .defaultProperties(TerremarkECloudApiMetadata.defaultProperties()) + .defaultEndpoint("https://services.enterprisecloud.terremark.com/api") + .contextBuilder(TypeToken.of(TerremarkECloudContextBuilder.class)) + .documentation(URI.create("http://support.theenterprisecloud.com/kb/default.asp?id=533&Lang=1&SID=")); + } @Override public TerremarkECloudApiMetadata build() { return new TerremarkECloudApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); + @Override + public Builder fromApiMetadata(TerremarkECloudApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java index 852e1f9b67..da4b9fe1bd 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java @@ -19,10 +19,11 @@ package org.jclouds.trmk.ecloud; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.trmk.ecloud.compute.config.TerremarkECloudComputeServiceContextModule; import org.jclouds.trmk.ecloud.config.TerremarkECloudRestClientModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudContextBuilder; @@ -46,11 +47,20 @@ import com.google.inject.Module; * @author Adrian Cole * @see TerremarkVCloudComputeServiceContext */ -public class TerremarkECloudContextBuilder extends - TerremarkVCloudContextBuilder { +public class TerremarkECloudContextBuilder + extends + TerremarkVCloudContextBuilder, TerremarkECloudApiMetadata> { + public TerremarkECloudContextBuilder() { + this(new TerremarkECloudProviderMetadata()); + } - public TerremarkECloudContextBuilder(Properties props) { - super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class, props); + public TerremarkECloudContextBuilder( + ProviderMetadata, TerremarkECloudApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public TerremarkECloudContextBuilder(TerremarkECloudApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudPropertiesBuilder.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudPropertiesBuilder.java deleted file mode 100644 index 1af1db6eaa..0000000000 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudPropertiesBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.trmk.ecloud; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; - -import java.util.Properties; - -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; - -/** - * Builds properties used in Terremark VCloud Clients - * - * @author Adrian Cole - */ -public class TerremarkECloudPropertiesBuilder extends TerremarkVCloudPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-FL,US-VA,NL-NH,BR-SP"); - properties.setProperty(PROPERTY_API_VERSION, "0.8b-ext2.8"); - properties.setProperty(PROPERTY_ENDPOINT, "https://services.enterprisecloud.terremark.com/api"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "eCloudExtensions"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.8"); - return properties; - } - - public TerremarkECloudPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java index 2cb542fa6d..e1c562ea88 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java @@ -19,45 +19,64 @@ package org.jclouds.trmk.ecloud; import java.net.URI; +import java.util.Properties; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Terremark's Enterprise Cloud. * * @author Adrian Cole */ -public class TerremarkECloudProviderMetadata extends BaseProviderMetadata { - public TerremarkECloudProviderMetadata() { - this(builder() - .id("trmk-ecloud") - .name("Terremark Enterprise Cloud v2.8") - .api(new TerremarkECloudApiMetadata()) - .homepage(URI.create("http://www.terremark.com/services/cloudcomputing/theenterprisecloud.aspx")) - .console(URI.create("https://icenter.digitalops.net")) - .iso3166Codes("US-FL", "US-VA", "NL-NH", "BR-SP")); +public class TerremarkECloudProviderMetadata extends BaseProviderMetadata, TerremarkECloudApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected TerremarkECloudProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public TerremarkECloudProviderMetadata() { + super(builder()); + } + + public TerremarkECloudProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, TerremarkECloudApiMetadata> { + + protected Builder(){ + id("trmk-ecloud") + .name("Terremark Enterprise Cloud v2.8") + .apiMetadata(new TerremarkECloudApiMetadata()) + .endpoint("https://services.enterprisecloud.terremark.com/api") + .homepage(URI.create("http://www.terremark.com/services/cloudcomputing/theenterprisecloud.aspx")) + .console(URI.create("https://icenter.digitalops.net")) + .iso3166Codes("US-FL", "US-VA", "NL-NH", "BR-SP"); + } @Override public TerremarkECloudProviderMetadata build() { return new TerremarkECloudProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, TerremarkECloudApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java index 4047605529..c97038565f 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java @@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals; import java.net.URI; import java.util.Map; -import java.util.Properties; import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; @@ -32,11 +31,10 @@ import javax.inject.Singleton; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.trmk.ecloud.config.TerremarkECloudRestClientModule; import org.jclouds.trmk.ecloud.domain.internal.ECloudOrgImpl; import org.jclouds.trmk.vcloud_0_8.domain.Org; @@ -61,7 +59,7 @@ import com.google.inject.TypeLiteral; /** * @author Adrian Cole */ -public abstract class BaseTerremarkECloudAsyncClientTest extends RestClientTest { +public abstract class BaseTerremarkECloudAsyncClientTest extends BaseAsyncClientTest { @Override protected void checkFilters(HttpRequest request) { @@ -75,8 +73,8 @@ public abstract class BaseTerremarkECloudAsyncClientTest extends RestClientTe } @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec("trmk-ecloud", "identity", "credential", new Properties()); + public ProviderMetadata createProviderMetadata() { + return new TerremarkECloudProviderMetadata(); } protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", TerremarkECloudMediaType.ORG_XML, diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java index 726a02d1e6..57d9e41f7f 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java @@ -28,7 +28,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class BaseTerremarkECloudClientLiveTest extends BaseTerremarkClientLiveTest { +public class BaseTerremarkECloudClientLiveTest extends BaseTerremarkClientLiveTest { @Override protected Properties setupProperties() { Properties props = super.setupProperties(); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudClientLiveTest.java index 2baf7112a5..0c57ddd652 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudClientLiveTest.java @@ -39,7 +39,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "TerremarkECloudClientLiveTest") -public class TerremarkECloudClientLiveTest extends TerremarkClientLiveTest { +public class TerremarkECloudClientLiveTest extends TerremarkClientLiveTest { public TerremarkECloudClientLiveTest() { this.provider = "trmk-ecloud"; diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderTest.java index e3b13fb7e3..54e2a28b66 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.trmk.ecloud; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java index 351be4df25..8ed4c60713 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java @@ -22,8 +22,7 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Image; @@ -31,9 +30,11 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; +import org.jclouds.trmk.ecloud.TerremarkECloudAsyncClient; +import org.jclouds.trmk.ecloud.TerremarkECloudClient; import org.jclouds.trmk.vcloud_0_8.domain.VApp; import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants; import org.testng.annotations.Test; @@ -48,7 +49,9 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class TerremarkECloudComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { @Override protected Properties setupProperties() { @@ -104,10 +107,9 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv assert node.getLocation() != null; assertEquals(node.getType(), ComputeType.NODE); NodeMetadata allData = client.getNodeMetadata(node.getId()); - RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + RestContext tmContext = context.getProviderSpecificContext(); VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(allData.getLocation().getParent().getDescription(), - allData.getLocation().getDescription(), allData.getName()); + allData.getLocation().getDescription(), allData.getName()); assertEquals(vApp.getName(), allData.getName()); } } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java index 0e25edcde9..2426a7d444 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java @@ -25,10 +25,13 @@ import java.io.IOException; import java.util.Properties; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.trmk.ecloud.TerremarkECloudAsyncClient; +import org.jclouds.trmk.ecloud.TerremarkECloudClient; import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants; import org.testng.annotations.Test; @@ -40,7 +43,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class TerremarkECloudTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { @Override protected Properties setupProperties() { Properties props = super.setupProperties(); diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java index 8362bd989d..605a93fc10 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java @@ -1,50 +1,89 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.trmk.vcloudexpress; +import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; +import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; + import java.net.URI; +import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.BaseApiMetadata; +import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; + +import com.google.common.reflect.TypeToken; /** * Implementation of {@link ApiMetadata} for the Terremark vCloud Express API * * @author Adrian Cole */ -public class TerremarkVCloudExpressApiMetadata extends BaseApiMetadata { +public class TerremarkVCloudExpressApiMetadata extends + TerremarkVCloudApiMetadata { - public TerremarkVCloudExpressApiMetadata() { - this(builder() - .id("trmk-vcloudexpress") - .type(ApiType.COMPUTE) - .name("Terremark vCloud Express API") - .identityName("Email") - .credentialName("Password") - .documentation(URI.create("https://community.vcloudexpress.terremark.com/en-us/product_docs/m/vcefiles/2342.aspx"))); + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected TerremarkVCloudExpressApiMetadata(Builder builder) { + public TerremarkVCloudExpressApiMetadata() { + this(new Builder()); + } + + protected TerremarkVCloudExpressApiMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = TerremarkVCloudApiMetadata.defaultProperties(); + properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "vCloudExpressExtensions"); + properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "1.6"); + return properties; + } + + public static class Builder + extends + TerremarkVCloudApiMetadata.Builder { + + protected Builder() { + super(TerremarkVCloudExpressClient.class, TerremarkVCloudExpressAsyncClient.class); + id("trmk-vcloudexpress") + .name("Terremark vCloud Express API") + .identityName("Email") + .credentialName("Password") + .defaultProperties(TerremarkVCloudExpressApiMetadata.defaultProperties()) + .defaultEndpoint("https://services.vcloudexpress.terremark.com/api") + .defaultProperties(TerremarkVCloudExpressApiMetadata.defaultProperties()) + .contextBuilder(TypeToken.of(TerremarkVCloudExpressContextBuilder.class)) + .documentation(URI.create("https://community.vcloudexpress.terremark.com/en-us/product_docs/m/vcefiles/2342.aspx")); + } @Override public TerremarkVCloudExpressApiMetadata build() { return new TerremarkVCloudExpressApiMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - @Override - public ConcreteBuilder toBuilder() { - return builder().fromApiMetadata(this); + @Override + public Builder fromApiMetadata(TerremarkVCloudExpressApiMetadata in) { + super.fromApiMetadata(in); + return this; + } } } \ No newline at end of file diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java index 4b85951359..6a365fbbaa 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java @@ -19,10 +19,11 @@ package org.jclouds.trmk.vcloudexpress; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudContextBuilder; import org.jclouds.trmk.vcloudexpress.compute.TerremarkVCloudExpressComputeServiceContextModule; import org.jclouds.trmk.vcloudexpress.config.TerremarkVCloudExpressRestClientModule; @@ -46,11 +47,20 @@ import com.google.inject.Module; * @author Adrian Cole * @see TerremarkVCloudComputeServiceContext */ -public class TerremarkVCloudExpressContextBuilder extends - TerremarkVCloudContextBuilder { +public class TerremarkVCloudExpressContextBuilder + extends + TerremarkVCloudContextBuilder, TerremarkVCloudExpressApiMetadata> { + public TerremarkVCloudExpressContextBuilder() { + this(new TerremarkVCloudExpressProviderMetadata()); + } - public TerremarkVCloudExpressContextBuilder(Properties props) { - super(TerremarkVCloudExpressClient.class, TerremarkVCloudExpressAsyncClient.class, props); + public TerremarkVCloudExpressContextBuilder( + ProviderMetadata, TerremarkVCloudExpressApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public TerremarkVCloudExpressContextBuilder(TerremarkVCloudExpressApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java index a9a58ddf22..a36e53a0d8 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java @@ -19,46 +19,65 @@ package org.jclouds.trmk.vcloudexpress; import java.net.URI; +import java.util.Properties; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Terremark's vCloud Express. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Terremark's Enterprise Cloud. * * @author Adrian Cole */ -public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata { - public TerremarkVCloudExpressProviderMetadata() { - this(builder() - .id("trmk-vcloudexpress") - .name("Terremark vCloud Express") - .api(new TerremarkVCloudExpressApiMetadata()) - .homepage(URI.create("https://vcloudexpress.terremark.com/")) - .console(URI.create("https://my.vcloudexpress.terremark.com")) - .iso3166Codes("US-FL")); +public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata, TerremarkVCloudExpressApiMetadata> { + + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected TerremarkVCloudExpressProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public TerremarkVCloudExpressProviderMetadata() { + super(builder()); + } + + public TerremarkVCloudExpressProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, TerremarkVCloudExpressApiMetadata> { + + protected Builder(){ + id("trmk-vcloudexpress") + .name("Terremark vCloud Express") + .apiMetadata(new TerremarkVCloudExpressApiMetadata()) + .endpoint("https://services.vcloudexpress.terremark.com/api") + .homepage(URI.create("https://vcloudexpress.terremark.com/")) + .console(URI.create("https://my.vcloudexpress.terremark.com")) + .iso3166Codes("US-FL") + .defaultProperties(TerremarkVCloudExpressProviderMetadata.defaultProperties()); + } @Override public TerremarkVCloudExpressProviderMetadata build() { return new TerremarkVCloudExpressProviderMetadata(this); } - } - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } + @Override + public Builder fromProviderMetadata( + ProviderMetadata, TerremarkVCloudExpressApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); } - } \ No newline at end of file diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java index 46fa7d5a97..a25f499e91 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java @@ -19,26 +19,20 @@ package org.jclouds.trmk.vcloudexpress; import java.net.URI; -import java.util.Properties; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; -import org.jclouds.compute.BaseVersionedServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.RestContext; -import org.jclouds.sshj.config.SshjSshClientModule; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.trmk.vcloud_0_8.domain.InternetService; import org.jclouds.trmk.vcloud_0_8.domain.Node; import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress; import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -import com.google.inject.Module; /** * Tests behavior of {@code TerremarkVCloudClient} @@ -46,7 +40,9 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "InternetServiceLiveTest") -public class InternetServiceLiveTest extends BaseVersionedServiceLiveTest { +public class InternetServiceLiveTest + extends + BaseComputeServiceContextLiveTest> { public InternetServiceLiveTest() { provider = "trmk-vcloudexpress"; } @@ -55,8 +51,6 @@ public class InternetServiceLiveTest extends BaseVersionedServiceLiveTest { private Set services = Sets.newLinkedHashSet(); - private RestContext context; - public static final String PREFIX = System.getProperty("user.name") + "-terremark"; @Test @@ -90,18 +84,12 @@ public class InternetServiceLiveTest extends BaseVersionedServiceLiveTest { void cleanup() throws InterruptedException, ExecutionException, TimeoutException { delete(services); } - - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - - context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides) - .getProviderSpecificContext(); - - tmClient = context.getApi(); + + @Override + @BeforeClass(groups = { "integration", "live" }) + public void setupContext() { + super.setupContext(); + tmClient = context.getProviderSpecificContext().getApi(); } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java index 1e38085c4c..aeccab9a00 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.lang.reflect.Method; import java.net.URI; import java.util.Map; -import java.util.Properties; import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; @@ -42,15 +41,14 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.trmk.vcloud_0_8.domain.Org; import org.jclouds.trmk.vcloud_0_8.domain.Protocol; @@ -101,7 +99,7 @@ import com.google.inject.TypeLiteral; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", singleThreaded = true, testName = "TerremarkVCloudExpressAsyncClientTest") -public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest { +public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest { public void testListOrgs() { assertEquals(injector.getInstance(TerremarkVCloudExpressAsyncClient.class).listOrgs().toString(), ImmutableMap @@ -621,11 +619,10 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest createContextSpec() { - return new RestContextFactory().createContextSpec("trmk-vcloudexpress", "identity", "credential", - new Properties()); + public ProviderMetadata createProviderMetadata() { + return new TerremarkVCloudExpressProviderMetadata(); } protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", ORG_XML, diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressClientLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressClientLiveTest.java index e6ef961290..fae9ba860e 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressClientLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressClientLiveTest.java @@ -37,7 +37,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "TerremarkVCloudExpressClientLiveTest") -public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTest { +public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTest { @Override protected SshClient getConnectionFor(IPSocket socket) { diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderTest.java index 973b272f36..d170ce54aa 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.trmk.vcloudexpress; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java index c88fabda19..3038f72cdd 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java @@ -20,8 +20,7 @@ package org.jclouds.trmk.vcloudexpress.compute; import static org.testng.Assert.assertEquals; -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Image; @@ -29,11 +28,13 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.domain.Credentials; import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.jclouds.trmk.vcloud_0_8.domain.VApp; +import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressAsyncClient; +import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressClient; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -44,7 +45,10 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class TerremarkVCloudExpressComputeServiceLiveTest + extends + BaseComputeServiceLiveTest> { + public TerremarkVCloudExpressComputeServiceLiveTest() { provider = "trmk-vcloudexpress"; } @@ -74,7 +78,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeSer assert node.getUserMetadata().equals(ImmutableMap. of()) : String.format( "node userMetadata did not match %s %s", userMetadata, node); } - + @Override public void testListImages() throws Exception { for (Image image : client.listImages()) { @@ -95,8 +99,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeSer assertEquals(node.getType(), ComputeType.NODE); NodeMetadata allData = client.getNodeMetadata(node.getId()); System.out.println(allData.getHardware()); - RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + RestContext tmContext = context.getProviderSpecificContext(); VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); assertEquals(vApp.getName(), allData.getName()); } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java index 45540569c5..f8a59be4f9 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressAsyncClient; +import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,7 +42,9 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class TerremarkVCloudExpressTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class TerremarkVCloudExpressTemplateBuilderLiveTest + extends + BaseTemplateBuilderLiveTest> { public TerremarkVCloudExpressTemplateBuilderLiveTest() { provider = "trmk-vcloudexpress"; diff --git a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java index 55b8b77108..d015b534ba 100644 --- a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java +++ b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java @@ -19,9 +19,13 @@ package org.jclouds.trystack.nova; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; +import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; +import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.NovaContextBuilder; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.trystack.nova.config.TryStackNovaServiceContextModule; import com.google.inject.Module; @@ -32,12 +36,18 @@ import com.google.inject.Module; */ public class TryStackNovaContextBuilder extends NovaContextBuilder { - public TryStackNovaContextBuilder(Properties props) { - super(props); + public TryStackNovaContextBuilder( + ProviderMetadata, NovaApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public TryStackNovaContextBuilder(NovaApiMetadata apiMetadata) { + super(apiMetadata); } @Override protected void addContextModule(List modules) { modules.add(new TryStackNovaServiceContextModule()); } + } diff --git a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaPropertiesBuilder.java b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaPropertiesBuilder.java deleted file mode 100644 index f2722fbf57..0000000000 --- a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaPropertiesBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not computee 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.trystack.nova; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; - -import java.util.Properties; - -import org.jclouds.openstack.nova.v1_1.NovaPropertiesBuilder; - -/** - * - * @author Adrian Cole - */ -public class TryStackNovaPropertiesBuilder extends NovaPropertiesBuilder { - - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); - properties.setProperty(PROPERTY_ENDPOINT, "https://nova-api.trystack.org:5443"); - properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); - - properties.setProperty(CREDENTIAL_TYPE, "passwordCredentials"); - properties.setProperty(AUTO_GENERATE_KEYPAIRS, "true"); - return properties; - } - - public TryStackNovaPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java index 3c508fe33f..1a974e1dee 100644 --- a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java +++ b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java @@ -4,7 +4,7 @@ * distributed with this work for additional information * regarding copyright ownership. jclouds licenses this file * to you under the Apache License, Version 2.0 (the - * "License"); you may not computee this file except in compliance + * "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 @@ -18,49 +18,81 @@ */ package org.jclouds.trystack.nova; +import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; + import java.net.URI; +import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; +import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; +import com.google.common.reflect.TypeToken; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for TryStack Nova * * @author Adrian Cole */ -public class TryStackNovaProviderMetadata extends BaseProviderMetadata { +public class TryStackNovaProviderMetadata + extends + BaseProviderMetadata, NovaApiMetadata> { - public TryStackNovaProviderMetadata() { - this(builder() - .id("trystack-nova") - .name("TryStack.org (Nova)") - .api(new NovaApiMetadata()) - .homepage(URI.create("https://trystack.org")) - .console(URI.create("https://trystack.org/dash")) - .iso3166Codes("US-CA")); + public static Builder builder() { + return new Builder(); } - // below are so that we can reuse builders, toString, hashCode, etc. - // we have to set concrete classes here, as our base class cannot be - // concrete due to serviceLoader - protected TryStackNovaProviderMetadata(ConcreteBuilder builder) { + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public TryStackNovaProviderMetadata() { + super(builder()); + } + + public TryStackNovaProviderMetadata(Builder builder) { super(builder); } - private static class ConcreteBuilder extends Builder { + protected static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); + properties.setProperty(CREDENTIAL_TYPE, "passwordCredentials"); + properties.setProperty(AUTO_GENERATE_KEYPAIRS, "true"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder, NovaApiMetadata> { + + protected Builder(){ + id("trystack-nova") + .name("TryStack.org (Nova)") + .apiMetadata( + new NovaApiMetadata().toBuilder().contextBuilder(TypeToken.of(TryStackNovaContextBuilder.class)) + .build()) + .homepage(URI.create("https://trystack.org")) + .console(URI.create("https://trystack.org/dash")) + .iso3166Codes("US-CA") + .endpoint("https://nova-api.trystack.org:5443") + .defaultProperties(TryStackNovaProviderMetadata.defaultProperties()); + } @Override public TryStackNovaProviderMetadata build() { return new TryStackNovaProviderMetadata(this); } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata, NovaApiMetadata> in) { + super.fromProviderMetadata(in); + return this; + } } - - public static ConcreteBuilder builder() { - return new ConcreteBuilder(); - } - - public ConcreteBuilder toBuilder() { - return builder().fromProviderMetadata(this); - } -} +} \ No newline at end of file diff --git a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/TryStackNovaProviderTest.java b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/TryStackNovaProviderTest.java index 3971fadece..cc5f3d6b33 100644 --- a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/TryStackNovaProviderTest.java +++ b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/TryStackNovaProviderTest.java @@ -36,7 +36,7 @@ package org.jclouds.trystack.nova; import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; /** diff --git a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java index ffbde62fa0..ed4ae1e715 100644 --- a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java +++ b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java @@ -23,10 +23,13 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; +import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.compute.options.NovaTemplateOptions; import org.testng.annotations.Test; @@ -39,7 +42,8 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "TryStackNovaTemplateBuilderLiveTest") -public class TryStackNovaTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +public class TryStackNovaTemplateBuilderLiveTest extends + BaseTemplateBuilderLiveTest> { public TryStackNovaTemplateBuilderLiveTest() { provider = "trystack-nova"; diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java new file mode 100644 index 0000000000..b858a0fe7a --- /dev/null +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java @@ -0,0 +1,58 @@ +package org.jclouds.servermanager; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.servermanager.compute.ServerManagerComputeServiceContextBuilder; + +import com.google.common.reflect.TypeToken; + +/** + * Implementation of {@link ApiMetadata} for an example of library integration (ServerManager) + * + * @author Adrian Cole + */ +public class ServerManagerApiMetadata extends BaseComputeServiceApiMetadata, ServerManagerApiMetadata> { + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return Builder.class.cast(builder().fromApiMetadata(this)); + } + + public ServerManagerApiMetadata() { + super(builder()); + } + + protected ServerManagerApiMetadata(Builder builder) { + super(builder); + } + + public static class Builder extends BaseComputeServiceApiMetadata.Builder, ServerManagerApiMetadata> { + + protected Builder(){ + id("servermanager") + .name("ServerManager API") + .identityName("Unused") + .defaultIdentity("foo") + .defaultCredential("bar") + .defaultEndpoint("http://demo") + .context(new TypeToken>(getClass()){ + private static final long serialVersionUID = 1L; + }) + .javaApi(ServerManager.class, ServerManager.class) + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute")) + .contextBuilder(TypeToken.of(ServerManagerComputeServiceContextBuilder.class)); + } + + @Override + public ServerManagerApiMetadata build() { + return new ServerManagerApiMetadata(this); + } + + } +} \ No newline at end of file diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java index 7449626c53..f10174a8f0 100644 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java @@ -19,10 +19,12 @@ package org.jclouds.servermanager.compute; import java.util.List; -import java.util.Properties; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.StandaloneComputeServiceContextBuilder; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.servermanager.ServerManager; +import org.jclouds.servermanager.ServerManagerApiMetadata; import org.jclouds.servermanager.compute.config.ServerManagerComputeServiceContextModule; import com.google.inject.Module; @@ -31,10 +33,21 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class ServerManagerComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder { +public class ServerManagerComputeServiceContextBuilder + extends + StandaloneComputeServiceContextBuilder, ServerManagerApiMetadata> { + + public ServerManagerComputeServiceContextBuilder() { + super(new ServerManagerApiMetadata()); + } - public ServerManagerComputeServiceContextBuilder(Properties props) { - super(ServerManager.class, props); + public ServerManagerComputeServiceContextBuilder( + ProviderMetadata, ServerManagerApiMetadata> providerMetadata) { + super(providerMetadata); + } + + public ServerManagerComputeServiceContextBuilder(ServerManagerApiMetadata apiMetadata) { + super(apiMetadata); } @Override diff --git a/skeletons/standalone-compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/skeletons/standalone-compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..cbad9e4179 --- /dev/null +++ b/skeletons/standalone-compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.servermanager.ServerManagerApiMetadata \ No newline at end of file diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java index 9992f1a530..ba0eeb06ff 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java @@ -23,62 +23,57 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.compute.StandaloneComputeServiceContextSpec; +import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.rest.RestContext; -import org.jclouds.servermanager.Datacenter; -import org.jclouds.servermanager.Hardware; -import org.jclouds.servermanager.Image; -import org.jclouds.servermanager.Server; import org.jclouds.servermanager.ServerManager; +import org.jclouds.servermanager.ServerManagerApiMetadata; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * * @author Adrian Cole * */ -@Test(groups = "unit") +@Test(groups = "unit", testName = "ServerManagerComputeServiceContextBuilderTest") public class ServerManagerComputeServiceContextBuilderTest { @Test public void testCanBuildDirectly() { - ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder(new Properties()) - .buildComputeServiceContext(); + ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() + .build(); context.close(); } @Test - public void testCanBuildWithContextSpec() { - ComputeServiceContext context = new ComputeServiceContextFactory() - .createContext(new StandaloneComputeServiceContextSpec( - "servermanager", "http://host", "1", "", "", "identity", "credential", ServerManager.class, - ServerManagerComputeServiceContextBuilder.class, ImmutableSet. of())); - + public void testCanBuildWithApiMetadata() { + ComputeServiceContext context = ComputeServiceContextBuilder.newBuilder( + new ServerManagerApiMetadata()).build(); context.close(); } @Test - public void testCanBuildWithRestProperties() { - Properties restProperties = new Properties(); - restProperties.setProperty("servermanager.contextbuilder", ServerManagerComputeServiceContextBuilder.class - .getName()); - restProperties.setProperty("servermanager.endpoint", "http://host"); - restProperties.setProperty("servermanager.api-version", "1"); + public void testCanBuildById() { + ComputeServiceContext context = ComputeServiceContextBuilder.newBuilder("servermanager").build(); + context.close(); + } - ComputeServiceContext context = new ComputeServiceContextFactory(restProperties).createContext("servermanager", - "identity", "credential"); + @Test + public void testCanBuildWithOverridingProperties() { + Properties overrides = new Properties(); + overrides.setProperty("servermanager.endpoint", "http://host"); + overrides.setProperty("servermanager.api-version", "1"); + + ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() + .overrides(overrides).build(); context.close(); } @Test public void testProviderSpecificContextIsCorrectType() { - ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder(new Properties()) - .buildComputeServiceContext(); + ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() + .build(); + RestContext providerContext = context.getProviderSpecificContext(); assertEquals(providerContext.getApi().getClass(), ServerManager.class); diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java index 7844e19065..e194d09a23 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java @@ -21,14 +21,11 @@ package org.jclouds.servermanager.compute; import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; -import java.util.Properties; - -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; -import org.jclouds.rest.RestContext; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.servermanager.ServerManager; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.Test; @@ -39,21 +36,13 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class ServerManagerComputeServiceLiveTest extends BaseComputeServiceLiveTest { +public class ServerManagerComputeServiceLiveTest extends + BaseComputeServiceLiveTest> { + public ServerManagerComputeServiceLiveTest() { provider = "servermanager"; } - @Override - protected Properties setupRestProperties() { - Properties restProperties = new Properties(); - restProperties.setProperty("servermanager.contextbuilder", - ServerManagerComputeServiceContextBuilder.class.getName()); - restProperties.setProperty("servermanager.endpoint", "http://host"); - restProperties.setProperty("servermanager.api-version", "1"); - return restProperties; - } - @Test public void testTemplateBuilder() { Template defaultTemplate = client.templateBuilder().build(); @@ -76,9 +65,4 @@ public class ServerManagerComputeServiceLiveTest extends BaseComputeServiceLiveT "node userMetadata did not match %s %s", userMetadata, node); } - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext goGridContext = new ComputeServiceContextFactory().createContext( - provider, identity, credential).getProviderSpecificContext(); - } } diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java index aa547e9e9f..fefa7e3879 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java @@ -18,38 +18,31 @@ */ package org.jclouds.servermanager.compute; -import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.compute.StandaloneComputeServiceContextSpec; -import org.jclouds.servermanager.Datacenter; -import org.jclouds.servermanager.Hardware; -import org.jclouds.servermanager.Image; -import org.jclouds.servermanager.Server; +import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.servermanager.ServerManager; +import org.jclouds.servermanager.ServerManagerApiMetadata; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - /** * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ServerManagerExperimentLiveTest") -public class ServerManagerExperimentLiveTest extends BaseVersionedServiceLiveTest { +public class ServerManagerExperimentLiveTest + extends + BaseComputeServiceContextLiveTest> { + public ServerManagerExperimentLiveTest() { provider = "servermanager"; } - + @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = new ComputeServiceContextFactory() - .createContext(new StandaloneComputeServiceContextSpec( - "servermanager", endpoint, apiVersion, buildVersion, "", identity, credential, ServerManager.class, - ServerManagerComputeServiceContextBuilder.class, ImmutableSet. of())); + context = ComputeServiceContextBuilder.newBuilder(new ServerManagerApiMetadata()).build(); context.getComputeService().listNodes(); From 5a3d2a11d6f5b378c6a31cccdf018c92ce4a7488 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 11 Apr 2012 17:00:49 -0600 Subject: [PATCH 43/69] revert back to openjdk6 and without implicit apt-upgrade --- compute/src/test/resources/initscript_with_java.sh | 5 ----- compute/src/test/resources/initscript_with_jboss.sh | 5 ----- compute/src/test/resources/runscript.sh | 5 ----- scriptbuilder/src/main/resources/functions/installOpenJDK.sh | 5 ----- .../src/test/resources/test_install_jdk_scriptbuilder.sh | 5 ----- 5 files changed, 25 deletions(-) diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index e7fc3c0191..e1f991bc8e 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -154,14 +154,9 @@ END_OF_JCLOUDS_FILE function installOpenJDK() { if hash apt-get 2>/dev/null; then - pkg=openjdk-7-jdk - (apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )) && - export JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk*|grep -v common` - # ex. lucid where jdk 7 is not present export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk} test -d $JAVA_HOME || apt-get-install openjdk-6-jdk elif hash yum 2>/dev/null; then - #TODO: find a jdk7 yum repo export pkg=java-1.6.0-openjdk-devel yum --nogpgcheck -y install $pkg && export JAVA_HOME=`ls -d /usr/lib/jvm/java-1.6.0-openjdk-*` diff --git a/compute/src/test/resources/initscript_with_jboss.sh b/compute/src/test/resources/initscript_with_jboss.sh index 4186f24f62..e700985e58 100644 --- a/compute/src/test/resources/initscript_with_jboss.sh +++ b/compute/src/test/resources/initscript_with_jboss.sh @@ -154,14 +154,9 @@ END_OF_JCLOUDS_FILE function installOpenJDK() { if hash apt-get 2>/dev/null; then - pkg=openjdk-7-jdk - (apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )) && - export JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk*|grep -v common` - # ex. lucid where jdk 7 is not present export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk} test -d $JAVA_HOME || apt-get-install openjdk-6-jdk elif hash yum 2>/dev/null; then - #TODO: find a jdk7 yum repo export pkg=java-1.6.0-openjdk-devel yum --nogpgcheck -y install $pkg && export JAVA_HOME=`ls -d /usr/lib/jvm/java-1.6.0-openjdk-*` diff --git a/compute/src/test/resources/runscript.sh b/compute/src/test/resources/runscript.sh index 6d10394a79..082c625f42 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -154,14 +154,9 @@ END_OF_JCLOUDS_FILE function installOpenJDK() { if hash apt-get 2>/dev/null; then - pkg=openjdk-7-jdk - (apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )) && - export JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk*|grep -v common` - # ex. lucid where jdk 7 is not present export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk} test -d $JAVA_HOME || apt-get-install openjdk-6-jdk elif hash yum 2>/dev/null; then - #TODO: find a jdk7 yum repo export pkg=java-1.6.0-openjdk-devel yum --nogpgcheck -y install $pkg && export JAVA_HOME=`ls -d /usr/lib/jvm/java-1.6.0-openjdk-*` diff --git a/scriptbuilder/src/main/resources/functions/installOpenJDK.sh b/scriptbuilder/src/main/resources/functions/installOpenJDK.sh index 8f24fec87c..20139134f4 100644 --- a/scriptbuilder/src/main/resources/functions/installOpenJDK.sh +++ b/scriptbuilder/src/main/resources/functions/installOpenJDK.sh @@ -19,14 +19,9 @@ END_OF_JCLOUDS_FILE function installOpenJDK() { if hash apt-get 2>/dev/null; then - pkg=openjdk-7-jdk - (apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )) && - export JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk*|grep -v common` - # ex. lucid where jdk 7 is not present export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk} test -d $JAVA_HOME || apt-get-install openjdk-6-jdk elif hash yum 2>/dev/null; then - #TODO: find a jdk7 yum repo export pkg=java-1.6.0-openjdk-devel yum --nogpgcheck -y install $pkg && export JAVA_HOME=`ls -d /usr/lib/jvm/java-1.6.0-openjdk-*` diff --git a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh index f88f8fcdc5..f3a502ad4b 100644 --- a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh @@ -154,14 +154,9 @@ END_OF_JCLOUDS_FILE function installOpenJDK() { if hash apt-get 2>/dev/null; then - pkg=openjdk-7-jdk - (apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )) && - export JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk*|grep -v common` - # ex. lucid where jdk 7 is not present export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk} test -d $JAVA_HOME || apt-get-install openjdk-6-jdk elif hash yum 2>/dev/null; then - #TODO: find a jdk7 yum repo export pkg=java-1.6.0-openjdk-devel yum --nogpgcheck -y install $pkg && export JAVA_HOME=`ls -d /usr/lib/jvm/java-1.6.0-openjdk-*` From 190a28ba164490db798c83a1a563ee04c0d53c59 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 12 Apr 2012 09:32:25 +0100 Subject: [PATCH 44/69] Rename Carrenza provider --- .../pom.xml | 38 +++++++++---------- .../CarrenzaVCloudDirectorContextBuilder.java | 0 ...arrenzaVCloudDirectorProviderMetadata.java | 0 ...udDirectorComputeServiceContextModule.java | 0 ...arrenzaVCloudDirectorRestClientModule.java | 0 .../org.jclouds.providers.ProviderMetadata | 0 ...udDirectorNonClientOperationsLiveTest.java | 0 .../CarrenzaVCloudDirectorProviderTest.java | 0 ...aVCloudDirectorComputeServiceLiveTest.java | 0 ...VCloudDirectorTemplateBuilderLiveTest.java | 0 ...zaVCloudDirectorCatalogClientLiveTest.java | 0 ...enzaVCloudDirectorMediaClientLiveTest.java | 0 ...zaVCloudDirectorNetworkClientLiveTest.java | 0 ...rrenzaVCloudDirectorOrgClientLiveTest.java | 0 ...enzaVCloudDirectorQueryClientLiveTest.java | 0 ...renzaVCloudDirectorTaskClientLiveTest.java | 0 ...nzaVCloudDirectorUploadClientLiveTest.java | 0 ...renzaVCloudDirectorVAppClientLiveTest.java | 0 ...oudDirectorVAppTemplateClientLiveTest.java | 0 ...rrenzaVCloudDirectorVdcClientLiveTest.java | 0 ...oudDirectorAdminCatalogClientLiveTest.java | 0 ...oudDirectorAdminNetworkClientLiveTest.java | 0 ...aVCloudDirectorAdminOrgClientLiveTest.java | 0 ...CloudDirectorAdminQueryClientLiveTest.java | 0 ...aVCloudDirectorAdminVdcClientLiveTest.java | 0 ...enzaVCloudDirectorGroupClientLiveTest.java | 0 ...renzaVCloudDirectorUserClientLiveTest.java | 0 ...zaVCloudDirectorSessionClientLiveTest.java | 0 .../src/test/resources/log4j.xml | 0 29 files changed, 19 insertions(+), 19 deletions(-) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/pom.xml (66%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java (100%) rename labs/{carrenza-element-vcloud => carrenza-vcloud-director}/src/test/resources/log4j.xml (100%) diff --git a/labs/carrenza-element-vcloud/pom.xml b/labs/carrenza-vcloud-director/pom.xml similarity index 66% rename from labs/carrenza-element-vcloud/pom.xml rename to labs/carrenza-vcloud-director/pom.xml index fa7a2c811c..5b9fdc7ffb 100644 --- a/labs/carrenza-element-vcloud/pom.xml +++ b/labs/carrenza-vcloud-director/pom.xml @@ -30,18 +30,18 @@ org.jclouds.labs carrenza-vcloud-director jclouds Carrenza vCloud Director provider - vCloud implementation targeted to Carrenza + vCloud Director implementation targeted to Carrenza bundle - https://myvdc.carrenza.net/api - 1.5 - FIXME_VERSION - FIXME_IDENTITY - FIXME_CREDENTIAL - - - + https://myvdc.carrenza.net/api + 1.5 + 464915 + FIXME_IDENTITY + FIXME_CREDENTIAL + + + @@ -52,7 +52,7 @@ org.jclouds.labs - vcloud-director + vcloud-director-director ${project.version} test-jar test @@ -102,14 +102,14 @@ - ${test.carrenza-vcloud.endpoint} - ${test.carrenza-vcloud.api-version} - ${test.carrenza-vcloud.build-version} - ${test.carrenza-vcloud.identity} - ${test.carrenza-vcloud.credential} - ${test.carrenza-vcloud.image-id} - ${test.carrenza-vcloud.image.login-user} - ${test.carrenza-vcloud.image.authenticate-sudo} + ${test.carrenza-vcloud-director.endpoint} + ${test.carrenza-vcloud-director.api-version} + ${test.carrenza-vcloud-director.build-version} + ${test.carrenza-vcloud-director.identity} + ${test.carrenza-vcloud-director.credential} + ${test.carrenza-vcloud-director.image-id} + ${test.carrenza-vcloud-director.image.login-user} + ${test.carrenza-vcloud-director.image.authenticate-sudo} @@ -128,7 +128,7 @@ ${project.artifactId} - org.jclouds.carrenza.vcloud*;version="${project.version}" + org.jclouds.carrenza.vcloud-director*;version="${project.version}" org.jclouds.compute.internal;version="${project.version}", org.jclouds.rest.internal;version="${project.version}", diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java similarity index 100% rename from labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java rename to labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java similarity index 100% rename from labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java rename to labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java similarity index 100% rename from labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java rename to labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java diff --git a/labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java similarity index 100% rename from labs/carrenza-element-vcloud/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java rename to labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java diff --git a/labs/carrenza-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata similarity index 100% rename from labs/carrenza-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata rename to labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java similarity index 100% rename from labs/carrenza-element-vcloud/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java diff --git a/labs/carrenza-element-vcloud/src/test/resources/log4j.xml b/labs/carrenza-vcloud-director/src/test/resources/log4j.xml similarity index 100% rename from labs/carrenza-element-vcloud/src/test/resources/log4j.xml rename to labs/carrenza-vcloud-director/src/test/resources/log4j.xml From 965a7038dfa82654fe03fe219ebbd96c85769fd6 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Thu, 12 Apr 2012 11:10:40 +0200 Subject: [PATCH 45/69] Add the EventBus module when building the injector --- core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java b/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java index 4224944ebe..98a06af753 100644 --- a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java @@ -298,6 +298,7 @@ public class ContextBuilder Date: Thu, 12 Apr 2012 12:04:02 +0100 Subject: [PATCH 46/69] Updated Carrenza provider --- labs/carrenza-vcloud-director/pom.xml | 16 +++++++-- ...arrenzaVCloudDirectorProviderMetadata.java | 13 ++++--- .../org.jclouds.providers.ProviderMetadata | 2 +- ...enzaVCloudDirectorHttpClientLiveTest.java} | 9 ++--- ...aVCloudDirectorComputeServiceLiveTest.java | 5 +-- ...VCloudDirectorTemplateBuilderLiveTest.java | 35 ++----------------- ...zaVCloudDirectorCatalogClientLiveTest.java | 5 +-- ...enzaVCloudDirectorMediaClientLiveTest.java | 5 +-- ...zaVCloudDirectorNetworkClientLiveTest.java | 5 +-- ...rrenzaVCloudDirectorOrgClientLiveTest.java | 5 +-- ...enzaVCloudDirectorQueryClientLiveTest.java | 5 +-- ...renzaVCloudDirectorTaskClientLiveTest.java | 7 ++-- ...nzaVCloudDirectorUploadClientLiveTest.java | 5 +-- ...renzaVCloudDirectorVAppClientLiveTest.java | 5 +-- ...oudDirectorVAppTemplateClientLiveTest.java | 7 ++-- ...rrenzaVCloudDirectorVdcClientLiveTest.java | 5 +-- ...oudDirectorAdminCatalogClientLiveTest.java | 5 +-- ...oudDirectorAdminNetworkClientLiveTest.java | 5 +-- ...aVCloudDirectorAdminOrgClientLiveTest.java | 5 +-- ...CloudDirectorAdminQueryClientLiveTest.java | 5 +-- ...aVCloudDirectorAdminVdcClientLiveTest.java | 5 +-- ...enzaVCloudDirectorGroupClientLiveTest.java | 5 +-- ...renzaVCloudDirectorUserClientLiveTest.java | 5 +-- ...zaVCloudDirectorSessionClientLiveTest.java | 5 +-- labs/pom.xml | 1 + labs/vcloud-director/pom.xml | 10 +++--- 26 files changed, 95 insertions(+), 90 deletions(-) rename labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/{CarrenzaVCloudDirectorNonClientOperationsLiveTest.java => CarrenzaVCloudDirectorHttpClientLiveTest.java} (78%) diff --git a/labs/carrenza-vcloud-director/pom.xml b/labs/carrenza-vcloud-director/pom.xml index 5b9fdc7ffb..b2064d1d26 100644 --- a/labs/carrenza-vcloud-director/pom.xml +++ b/labs/carrenza-vcloud-director/pom.xml @@ -42,6 +42,12 @@ + + + + + + @@ -52,7 +58,7 @@ org.jclouds.labs - vcloud-director-director + vcloud-director ${project.version} test-jar test @@ -110,6 +116,12 @@ ${test.carrenza-vcloud-director.image-id} ${test.carrenza-vcloud-director.image.login-user} ${test.carrenza-vcloud-director.image.authenticate-sudo} + ${test.carrenza-vcloud-director.catalog-id} + ${test.carrenza-vcloud-director.media-id} + ${test.carrenza-vcloud-director.vapptemplate-id} + ${test.carrenza-vcloud-director.network-id} + ${test.carrenza-vcloud-director.vdc-id} + ${test.carrenza-vcloud-director.user-id} @@ -128,7 +140,7 @@ ${project.artifactId} - org.jclouds.carrenza.vcloud-director*;version="${project.version}" + org.jclouds.carrenza.vcloud.director*;version="${project.version}" org.jclouds.compute.internal;version="${project.version}", org.jclouds.rest.internal;version="${project.version}", diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java index 3c75135bd4..27745f8cc0 100644 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java +++ b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java @@ -19,6 +19,7 @@ package org.jclouds.carrenza.vcloud.director; import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; import java.net.URI; import java.util.Properties; @@ -33,9 +34,10 @@ import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import com.google.common.reflect.TypeToken; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for StratoGen VMware hosting + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Carrenza vCloud hosting * * @author Adrian Cole + * @author grkvlt@apache.org */ public class CarrenzaVCloudDirectorProviderMetadata extends @@ -60,19 +62,20 @@ public class CarrenzaVCloudDirectorProviderMetadata protected static Properties defaultProperties() { Properties properties = new Properties(); - properties.setProperty(PROPERTY_BUILD_VERSION, "???"); //FIXME -// properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); FIXME: needed? + properties.setProperty(PROPERTY_BUILD_VERSION, "1.5.0.464915"); + properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_DEFAULT_NETWORK, "orgNet-.*-External"); return properties; } public static class Builder extends BaseProviderMetadata.Builder { - protected Builder(){ + protected Builder() { id("carrenza-vcloud-director") .name("Carrenza vCloud Director") .apiMetadata(new VCloudDirectorApiMetadata().toBuilder() .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(CarrenzaVCloudDirectorContextBuilder.class)).build()) + .contextBuilder(TypeToken.of(CarrenzaVCloudDirectorContextBuilder.class)) + .build()) .homepage(URI.create("http://carrenza.com/")) .console(URI.create("https://myvdc.carrenza.net/cloud/org/YOUR_ORG_HERE")) .iso3166Codes("GB-LND") diff --git a/labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata index 8577da069b..b59c68cff5 100644 --- a/labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ b/labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -1 +1 @@ -org.jclouds.carrenza.element.vcloud.CarrenzaElementVCloudProviderMetadata +org.jclouds.carrenza.vcloud.director.CarrenzaVCloudDirectorProviderMetadata diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorHttpClientLiveTest.java similarity index 78% rename from labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java rename to labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorHttpClientLiveTest.java index c1054103e3..f3959fa55c 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorNonClientOperationsLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorHttpClientLiveTest.java @@ -22,14 +22,15 @@ import org.jclouds.vcloud.director.v1_5.HttpClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorNonClientOperationsLiveTest") -public class CarrenzaVCloudDirectorNonClientOperationsLiveTest extends HttpClientLiveTest { +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorHttpClientLiveTest") +public class CarrenzaVCloudDirectorHttpClientLiveTest extends HttpClientLiveTest { - public CarrenzaVCloudDirectorNonClientOperationsLiveTest() { + public CarrenzaVCloudDirectorHttpClientLiveTest() { provider = "carrenza-vcloud-director"; } } diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java index 8a683297ec..229aa922c1 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java @@ -21,11 +21,12 @@ package org.jclouds.carrenza.vcloud.director.compute; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorComputeServiceLiveTest") +@Test(groups = { "live", "compute" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorComputeServiceLiveTest") public class CarrenzaVCloudDirectorComputeServiceLiveTest { // FIXME: enable when compute service done // extends VCloudDirectorComputeServiceLiveTest { // diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java index dea42c7a04..a197da2d40 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java @@ -21,45 +21,16 @@ package org.jclouds.carrenza.vcloud.director.compute; import org.testng.annotations.Test; /** + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", testName = "CarrenzaVCloudDirectorTemplateBuilderLiveTest") +@Test(groups = { "live", "compute" }, testName = "CarrenzaVCloudDirectorTemplateBuilderLiveTest") public class CarrenzaVCloudDirectorTemplateBuilderLiveTest { // BaseTemplateBuilderLiveTest { // // public CarrenzaVCloudDirectorTemplateBuilderLiveTest() { // provider = "carrenza-vcloud-director"; // } -// -// @Override -// protected Predicate defineUnsupportedOperatingSystems() { -// return new Predicate() { -// -// @Override -// public boolean apply(OsFamilyVersion64Bit input) { -// switch (input.family) { -// case UBUNTU: -// return !input.version.equals("") || !input.is64Bit; -// default: -// return true; -// } -// } -// -// }; -// } -// -// @Override -// public void testDefaultTemplateBuilder() throws IOException { -// Template defaultTemplate = context.getComputeService().templateBuilder().build(); -// assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); -// assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); -// assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); -// assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); -// } -// -// @Override -// protected Set getIso3166Codes() { -// return ImmutableSet. of("GB-LND"); -// } } diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java index a31297f65f..c831e457ff 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.CatalogClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorCatalogClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorCatalogClientLiveTest") public class CarrenzaVCloudDirectorCatalogClientLiveTest extends CatalogClientLiveTest { public CarrenzaVCloudDirectorCatalogClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java index 6c50cfece5..d2ccc72e5c 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.MediaClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorMediaClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorMediaClientLiveTest") public class CarrenzaVCloudDirectorMediaClientLiveTest extends MediaClientLiveTest { public CarrenzaVCloudDirectorMediaClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java index bd2fd95e09..bc202180f2 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.NetworkClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorNetworkClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorNetworkClientLiveTest") public class CarrenzaVCloudDirectorNetworkClientLiveTest extends NetworkClientLiveTest { public CarrenzaVCloudDirectorNetworkClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java index 0257fc879d..f722ce554a 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.OrgClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorOrgClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorOrgClientLiveTest") public class CarrenzaVCloudDirectorOrgClientLiveTest extends OrgClientLiveTest { public CarrenzaVCloudDirectorOrgClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java index a941813061..ce338d35dc 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.QueryClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorQueryClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorQueryClientLiveTest") public class CarrenzaVCloudDirectorQueryClientLiveTest extends QueryClientLiveTest { public CarrenzaVCloudDirectorQueryClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java index 2f7ea669f7..0d67d79260 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.TaskClientLiveTest; import org.testng.annotations.Test; /** + * {@inheritDoc} * - * - * @author Adrian Cole + * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorTaskClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorTaskClientLiveTest") public class CarrenzaVCloudDirectorTaskClientLiveTest extends TaskClientLiveTest { public CarrenzaVCloudDirectorTaskClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java index 9370962395..900e6982d8 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.UploadClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorUploadClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorUploadClientLiveTest") public class CarrenzaVCloudDirectorUploadClientLiveTest extends UploadClientLiveTest { public CarrenzaVCloudDirectorUploadClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java index 0d02238828..f5af2b12e2 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.VAppClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorVAppClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorVAppClientLiveTest") public class CarrenzaVCloudDirectorVAppClientLiveTest extends VAppClientLiveTest { public CarrenzaVCloudDirectorVAppClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java index cac29c511f..6c272c3497 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClientLiveTest; import org.testng.annotations.Test; /** + * {@inheritDoc} * - * - * @author Adrian Cole + * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorVAppTemplateClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorVAppTemplateClientLiveTest") public class CarrenzaVCloudDirectorVAppTemplateClientLiveTest extends VAppTemplateClientLiveTest { public CarrenzaVCloudDirectorVAppTemplateClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java index d50ab80dfe..1faee1514a 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.VdcClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorVDCClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorVDCClientLiveTest") public class CarrenzaVCloudDirectorVdcClientLiveTest extends VdcClientLiveTest { public CarrenzaVCloudDirectorVdcClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java index 01c8f151f6..f4b4611274 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClientLiveTes import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminCatalogClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminCatalogClientLiveTest") public class CarrenzaVCloudDirectorAdminCatalogClientLiveTest extends AdminCatalogClientLiveTest { public CarrenzaVCloudDirectorAdminCatalogClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java index 681af62394..2fbff2d836 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkClientLiveTes import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminNetworkClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminNetworkClientLiveTest") public class CarrenzaVCloudDirectorAdminNetworkClientLiveTest extends AdminNetworkClientLiveTest { public CarrenzaVCloudDirectorAdminNetworkClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java index 5381337629..4526a10b75 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorOrgClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorOrgClientLiveTest") public class CarrenzaVCloudDirectorAdminOrgClientLiveTest extends AdminOrgClientLiveTest { public CarrenzaVCloudDirectorAdminOrgClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java index 95d47884b8..34fe21f33f 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.admin.AdminQueryClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminQueryClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminQueryClientLiveTest") public class CarrenzaVCloudDirectorAdminQueryClientLiveTest extends AdminQueryClientLiveTest { public CarrenzaVCloudDirectorAdminQueryClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java index 73f2b4da45..088269886c 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminVdcClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminVdcClientLiveTest") public class CarrenzaVCloudDirectorAdminVdcClientLiveTest extends AdminVdcClientLiveTest { public CarrenzaVCloudDirectorAdminVdcClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java index 14dd740331..3fde581535 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.admin.GroupClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorGroupClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorGroupClientLiveTest") public class CarrenzaVCloudDirectorGroupClientLiveTest extends GroupClientLiveTest { public CarrenzaVCloudDirectorGroupClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java index afbde8565d..ed58c5a613 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.features.admin.UserClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorUserClientLiveTest") +@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorUserClientLiveTest") public class CarrenzaVCloudDirectorUserClientLiveTest extends UserClientLiveTest { public CarrenzaVCloudDirectorUserClientLiveTest() { diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java index 24685c0d51..ac62c888fb 100644 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java +++ b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionClientLiveTest.java @@ -22,11 +22,12 @@ import org.jclouds.vcloud.director.v1_5.login.SessionClientLiveTest; import org.testng.annotations.Test; /** - * + * {@inheritDoc} * * @author danikov + * @author grkvlt */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CarrenzaVCloudDirectorSessionClientLiveTest") +@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorSessionClientLiveTest") public class CarrenzaVCloudDirectorSessionClientLiveTest extends SessionClientLiveTest { public CarrenzaVCloudDirectorSessionClientLiveTest() { diff --git a/labs/pom.xml b/labs/pom.xml index c0c4ae9725..60b5dee8da 100644 --- a/labs/pom.xml +++ b/labs/pom.xml @@ -40,5 +40,6 @@ aws-elb savvis-symphonyvpdc dmtf + carrenza-vcloud-director diff --git a/labs/vcloud-director/pom.xml b/labs/vcloud-director/pom.xml index 32e12456a7..cf2258d2ce 100644 --- a/labs/vcloud-director/pom.xml +++ b/labs/vcloud-director/pom.xml @@ -29,7 +29,7 @@ org.jclouds.labs vcloud-director - jcloud vcloud-director api + jclouds vcloud-director api jclouds components to access an implementation of VMware vCloud Director 1.5+ bundle @@ -42,13 +42,12 @@ - Public - + @@ -122,12 +121,11 @@ ${test.vcloud-director.image.login-user} ${test.vcloud-director.image.authenticate-sudo} ${test.vcloud-director.catalog-id} - ${test.vcloud-director.catalog-name} ${test.vcloud-director.media-id} ${test.vcloud-director.vapptemplate-id} - ${test.vcloud-director.network-name} ${test.vcloud-director.network-id} ${test.vcloud-director.vdc-id} + ${test.vcloud-director.user-id} @@ -151,7 +149,7 @@ org.jclouds.compute.internal;version="${project.version}", org.jclouds.rest.internal;version="${project.version}", org.jclouds*;version="${project.version}", - * + * From 30cee89d53a9814e1fade27465c6585d02b4e86e Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 12 Apr 2012 12:12:50 +0100 Subject: [PATCH 47/69] Remove default endpoint from ApiMetadata --- .../director/v1_5/VCloudDirectorApiMetadata.java | 8 ++++---- .../director/v1_5/VCloudDirectorContextBuilder.java | 1 + .../v1_5/internal/BaseVCloudDirectorExpectTest.java | 11 ++--------- .../BaseVCloudDirectorRestClientExpectTest.java | 4 +--- .../internal/VCloudDirectorAdminClientExpectTest.java | 1 - 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java index b39f9298f6..3d2e32edac 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java @@ -17,6 +17,7 @@ * under the License. */ package org.jclouds.vcloud.director.v1_5; + import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_VERSION_SCHEMA; @@ -36,7 +37,7 @@ import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for VCloudDirector 1.0 API + * Implementation of {@link ApiMetadata} for VCloudDirector 1.5 API * * @author Adrian Cole */ @@ -82,14 +83,13 @@ public class VCloudDirectorApiMetadata protected Builder() { super(VCloudDirectorClient.class, VCloudDirectorAsyncClient.class); - id("vcloud") - .name("VCloud Director 1.5 API") + id("vcloud-director") + .name("vCloud Director 1.5 API") .type(ApiType.COMPUTE) .identityName("User at Organization (user@org)") .credentialName("Password") .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) .version("1.5") - .defaultEndpoint("https://vcloudbeta.bluelock.com/api") .defaultProperties(VCloudDirectorApiMetadata.defaultProperties()) .context(TypeToken.of(VCloudDirectorContext.class)) .contextBuilder(TypeToken.of(VCloudDirectorContextBuilder.class)); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java index cde539d05f..1417074df4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java @@ -54,6 +54,7 @@ public class VCloudDirectorContextBuilder // modules.add(new VCloudDirectorComputeServiceContextModule()); // } + @Override protected void addClientModule(List modules) { modules.add(new VCloudDirectorRestClientModule()); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java index d620aacb2e..b1f74dfe06 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorExpectTest.java @@ -25,12 +25,10 @@ import java.net.URI; import java.util.Properties; import org.jclouds.Constants; -import org.jclouds.apis.ApiMetadata; import org.jclouds.date.DateService; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.internal.BaseRestClientExpectTest; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.testng.annotations.BeforeGroups; @@ -41,7 +39,7 @@ import com.google.common.collect.Multimap; import com.google.inject.Guice; /** - * Base class for writing KeyStone Rest Client Expect tests + * Base class for writing vCloud Director REST client expect tests. * * @author Adrian Cole */ @@ -71,6 +69,7 @@ public abstract class BaseVCloudDirectorExpectTest extends BaseRestClientExpe public Properties setupProperties() { Properties props = new Properties(); props.put(Constants.PROPERTY_MAX_RETRIES, 1); + props.put(Constants.PROPERTY_ENDPOINT, endpoint); return props; } @@ -252,10 +251,4 @@ public abstract class BaseVCloudDirectorExpectTest extends BaseRestClientExpe public URI toAdminUri(URI uri) { return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref(); } - - @Override - protected ApiMetadata createApiMetadata() { - return new VCloudDirectorApiMetadata(); - } - } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java index cff0b5c3df..ab6533a3fc 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorRestClientExpectTest.java @@ -21,10 +21,8 @@ package org.jclouds.vcloud.director.v1_5.internal; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; /** - * Base class for writing KeyStone Rest Client Expect tests - * * @author Adrian Cole */ -public abstract class BaseVCloudDirectorRestClientExpectTest extends BaseVCloudDirectorExpectTest { +public abstract class BaseVCloudDirectorRestClientExpectTest extends BaseVCloudDirectorExpectTest { } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorAdminClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorAdminClientExpectTest.java index 2f582f4b73..b862741aeb 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorAdminClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorAdminClientExpectTest.java @@ -29,7 +29,6 @@ import com.google.common.base.Function; import com.google.inject.Module; /** - * * @author Adrian Cole */ public abstract class VCloudDirectorAdminClientExpectTest extends From 585cfae86022519f35a4ac03b015bec8cbb6baad Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 12 Apr 2012 16:54:09 +0100 Subject: [PATCH 48/69] Reorganized domain objects in sub-packages for easier assimilation --- .../v1_5/domain/AbstractVAppType.java | 12 +- .../director/v1_5/domain/AdminCatalog.java | 5 +- .../vcloud/director/v1_5/domain/AdminVdc.java | 1 + .../vcloud/director/v1_5/domain/Catalog.java | 139 +++++++++-- .../director/v1_5/domain/CatalogItem.java | 4 +- .../director/v1_5/domain/CatalogType.java | 180 --------------- .../vcloud/director/v1_5/domain/Entity.java | 178 ++++++++++++++- .../director/v1_5/domain/EntityType.java | 215 ------------------ .../vcloud/director/v1_5/domain/File.java | 4 +- .../vcloud/director/v1_5/domain/Group.java | 4 +- .../vcloud/director/v1_5/domain/Media.java | 4 +- .../vcloud/director/v1_5/domain/Metadata.java | 6 +- .../director/v1_5/domain/MetadataEntry.java | 6 +- .../director/v1_5/domain/MetadataValue.java | 6 +- .../vcloud/director/v1_5/domain/Owner.java | 6 +- .../v1_5/domain/ProductSectionList.java | 6 +- .../director/v1_5/domain/RasdItemsList.java | 8 +- .../director/v1_5/domain/Reference.java | 2 +- .../vcloud/director/v1_5/domain/Resource.java | 163 +++++++++++-- ...rceEntityType.java => ResourceEntity.java} | 14 +- .../director/v1_5/domain/ResourceType.java | 207 ----------------- .../director/v1_5/domain/RoleReferences.java | 10 +- .../vcloud/director/v1_5/domain/Task.java | 4 +- .../director/v1_5/domain/TasksList.java | 6 +- .../vcloud/director/v1_5/domain/User.java | 4 +- .../director/v1_5/domain/VAppTemplate.java | 12 +- .../vcloud/director/v1_5/domain/Vdc.java | 5 +- .../v1_5/domain/VmPendingQuestion.java | 6 +- .../v1_5/domain/{ => dmtf}/Envelope.java | 2 +- .../v1_5/domain/{ => dmtf}/RasdItem.java | 10 +- .../v1_5/domain/{ => dmtf}/VirtualSystem.java | 4 +- .../v1_5/domain/dmtf/package-info.java | 35 +++ .../domain/{ => network}/DhcpService.java | 2 +- .../domain/{ => network}/ExternalNetwork.java | 3 +- .../domain/{ => network}/FirewallRule.java | 2 +- .../{ => network}/FirewallRuleProtocols.java | 2 +- .../domain/{ => network}/FirewallService.java | 2 +- .../domain/{ => network}/IpAddresses.java | 2 +- .../v1_5/domain/{ => network}/IpRange.java | 2 +- .../v1_5/domain/{ => network}/IpRanges.java | 2 +- .../v1_5/domain/{ => network}/IpScope.java | 2 +- .../{ => network}/IpsecVpnLocalPeer.java | 2 +- .../IpsecVpnManagedPeerType.java | 2 +- .../{ => network}/IpsecVpnPeerType.java | 2 +- .../{ => network}/IpsecVpnRemotePeer.java | 2 +- .../domain/{ => network}/IpsecVpnService.java | 2 +- .../{ => network}/IpsecVpnThirdPartyPeer.java | 2 +- .../domain/{ => network}/IpsecVpnTunnel.java | 2 +- .../IpsecVpnUnmanagedPeerType.java | 2 +- .../{ => network}/NatOneToOneBasicRule.java | 2 +- .../{ => network}/NatOneToOneVmRule.java | 2 +- .../{ => network}/NatPortForwardingRule.java | 2 +- .../v1_5/domain/{ => network}/NatRule.java | 2 +- .../v1_5/domain/{ => network}/NatService.java | 2 +- .../v1_5/domain/{ => network}/NatVmRule.java | 2 +- .../v1_5/domain/{ => network}/Network.java | 10 +- .../{ => network}/NetworkAssignment.java | 2 +- .../{ => network}/NetworkConfiguration.java | 5 +- .../{ => network}/NetworkConnection.java | 2 +- .../domain/{ => network}/NetworkFeatures.java | 2 +- .../{ => network}/NetworkServiceType.java | 2 +- .../v1_5/domain/{ => network}/RouterInfo.java | 2 +- .../{ => network}/SmtpServerSettings.java | 2 +- .../domain/{ => network}/StaticRoute.java | 2 +- .../{ => network}/StaticRoutingService.java | 2 +- .../{ => network}/SyslogServerSettings.java | 2 +- .../domain/{ => network}/VAppNetwork.java | 2 +- .../VAppNetworkConfiguration.java | 11 +- .../v1_5/domain/network/package-info.java | 35 +++ .../v1_5/domain/{ => org}/AdminOrg.java | 4 +- .../{ => org}/CustomOrgLdapSettings.java | 3 +- .../director/v1_5/domain/{ => org}/Org.java | 8 +- .../domain/{ => org}/OrgEmailSettings.java | 12 +- .../domain/{ => org}/OrgGeneralSettings.java | 11 +- .../{ => org}/OrgLdapGroupAttributes.java | 2 +- .../domain/{ => org}/OrgLdapSettings.java | 11 +- .../{ => org}/OrgLdapUserAttributes.java | 2 +- .../domain/{ => org}/OrgLeaseSettings.java | 11 +- .../v1_5/domain/{ => org}/OrgList.java | 3 +- .../v1_5/domain/{ => org}/OrgNetwork.java | 7 +- .../{ => org}/OrgPasswordPolicySettings.java | 11 +- .../v1_5/domain/{ => org}/OrgSettings.java | 11 +- .../OrgVAppTemplateLeaseSettings.java | 11 +- .../v1_5/domain/org/package-info.java | 35 +++ .../{ => params}/CaptureVAppParams.java | 11 +- .../domain/{ => params}/CloneMediaParams.java | 5 +- .../domain/{ => params}/CloneVAppParams.java | 2 +- .../{ => params}/CloneVAppTemplateParams.java | 5 +- .../{ => params}/ComposeVAppParams.java | 4 +- .../{ => params}/ControlAccessParams.java | 4 +- .../domain/{ => params}/DeployVAppParams.java | 2 +- .../{ => params}/InstantiateOvfParams.java | 4 +- .../{ => params}/InstantiateVAppParams.java | 4 +- .../InstantiateVAppTemplateParams.java | 2 +- .../{ => params}/InstantiationParams.java | 10 +- .../MediaInsertOrEjectParams.java | 4 +- .../v1_5/domain/{ => params}/ParamsType.java | 2 +- .../{ => params}/PublishCatalogParams.java | 2 +- .../{ => params}/RecomposeVAppParams.java | 5 +- .../domain/{ => params}/RelocateParams.java | 4 +- .../SourcedCompositionItemParam.java | 5 +- .../{ => params}/UndeployVAppParams.java | 2 +- .../UploadVAppTemplateParams.java | 4 +- .../{ => params}/VAppCreationParams.java | 4 +- .../v1_5/domain/params/package-info.java | 35 +++ .../v1_5/domain/query/ContainerType.java | 8 +- .../{ => section}/CustomizationSection.java | 3 +- .../GuestCustomizationSection.java | 3 +- .../{ => section}/LeaseSettingsSection.java | 3 +- .../{ => section}/NetworkConfigSection.java | 4 +- .../NetworkConnectionSection.java | 4 +- .../{ => section}/OperatingSystemSection.java | 4 +- .../{ => section}/RuntimeInfoSection.java | 3 +- .../{ => section}/VirtualHardwareSection.java | 4 +- .../v1_5/domain/section/package-info.java | 35 +++ .../v1_5/features/CatalogAsyncClient.java | 4 +- .../director/v1_5/features/CatalogClient.java | 4 +- .../v1_5/features/MediaAsyncClient.java | 2 +- .../director/v1_5/features/MediaClient.java | 2 +- .../v1_5/features/NetworkAsyncClient.java | 2 +- .../director/v1_5/features/NetworkClient.java | 2 +- .../v1_5/features/OrgAsyncClient.java | 6 +- .../director/v1_5/features/OrgClient.java | 6 +- .../v1_5/features/VAppAsyncClient.java | 28 +-- .../director/v1_5/features/VAppClient.java | 28 +-- .../features/VAppTemplateAsyncClient.java | 14 +- .../v1_5/features/VAppTemplateClient.java | 14 +- .../v1_5/features/VdcAsyncClient.java | 14 +- .../director/v1_5/features/VdcClient.java | 14 +- .../admin/AdminCatalogAsyncClient.java | 2 +- .../features/admin/AdminCatalogClient.java | 2 +- .../admin/AdminNetworkAsyncClient.java | 4 +- .../features/admin/AdminNetworkClient.java | 4 +- .../features/admin/AdminOrgAsyncClient.java | 16 +- .../v1_5/features/admin/AdminOrgClient.java | 16 +- .../OrgReferenceToTaskListEndpoint.java | 2 +- .../v1_5/predicates/EntityPredicates.java | 12 +- .../v1_5/AbstractVAppClientLiveTest.java | 8 +- .../director/v1_5/HttpClientLiveTest.java | 2 +- .../vcloud/director/v1_5/domain/Checks.java | 60 ++++- .../features/CatalogClientExpectTest.java | 8 +- .../v1_5/features/CatalogClientLiveTest.java | 4 +- .../v1_5/features/MediaClientExpectTest.java | 2 +- .../v1_5/features/MediaClientLiveTest.java | 2 +- .../features/NetworkClientExpectTest.java | 22 +- .../v1_5/features/NetworkClientLiveTest.java | 4 +- .../v1_5/features/OrgClientExpectTest.java | 4 +- .../v1_5/features/OrgClientLiveTest.java | 6 +- .../v1_5/features/QueryClientLiveTest.java | 6 +- .../v1_5/features/TaskClientLiveTest.java | 2 +- .../v1_5/features/VAppClientExpectTest.java | 28 +-- .../v1_5/features/VAppClientLiveTest.java | 34 +-- .../VAppTemplateClientExpectTest.java | 36 +-- .../features/VAppTemplateClientLiveTest.java | 20 +- .../v1_5/features/VdcClientExpectTest.java | 14 +- .../v1_5/features/VdcClientLiveTest.java | 28 +-- .../admin/AdminCatalogClientExpectTest.java | 2 +- .../admin/AdminCatalogClientLiveTest.java | 2 +- .../admin/AdminNetworkClientExpectTest.java | 2 +- .../admin/AdminNetworkClientLiveTest.java | 16 +- .../admin/AdminOrgClientExpectTest.java | 18 +- .../admin/AdminOrgClientLiveTest.java | 18 +- .../features/admin/GroupClientLiveTest.java | 2 +- .../features/admin/UserClientLiveTest.java | 2 +- .../BaseVCloudDirectorClientLiveTest.java | 18 +- 165 files changed, 1212 insertions(+), 1085 deletions(-) delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogType.java delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ResourceEntityType.java => ResourceEntity.java} (95%) delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => dmtf}/Envelope.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => dmtf}/RasdItem.java (94%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => dmtf}/VirtualSystem.java (95%) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/package-info.java rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/DhcpService.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/ExternalNetwork.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/FirewallRule.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/FirewallRuleProtocols.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/FirewallService.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpAddresses.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpRange.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpRanges.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpScope.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpsecVpnLocalPeer.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpsecVpnManagedPeerType.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpsecVpnPeerType.java (94%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpsecVpnRemotePeer.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpsecVpnService.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpsecVpnThirdPartyPeer.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpsecVpnTunnel.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/IpsecVpnUnmanagedPeerType.java (94%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NatOneToOneBasicRule.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NatOneToOneVmRule.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NatPortForwardingRule.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NatRule.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NatService.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NatVmRule.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/Network.java (93%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NetworkAssignment.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NetworkConfiguration.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NetworkConnection.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NetworkFeatures.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/NetworkServiceType.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/RouterInfo.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/SmtpServerSettings.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/StaticRoute.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/StaticRoutingService.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/SyslogServerSettings.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/VAppNetwork.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => network}/VAppNetworkConfiguration.java (94%) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/package-info.java rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/AdminOrg.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/CustomOrgLdapSettings.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/Org.java (94%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgEmailSettings.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgGeneralSettings.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgLdapGroupAttributes.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgLdapSettings.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgLdapUserAttributes.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgLeaseSettings.java (95%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgList.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgNetwork.java (92%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgPasswordPolicySettings.java (94%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgSettings.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => org}/OrgVAppTemplateLeaseSettings.java (94%) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/package-info.java rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/CaptureVAppParams.java (90%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/CloneMediaParams.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/CloneVAppParams.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/CloneVAppTemplateParams.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/ComposeVAppParams.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/ControlAccessParams.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/DeployVAppParams.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/InstantiateOvfParams.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/InstantiateVAppParams.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/InstantiateVAppTemplateParams.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/InstantiationParams.java (89%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/MediaInsertOrEjectParams.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/ParamsType.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/PublishCatalogParams.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/RecomposeVAppParams.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/RelocateParams.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/SourcedCompositionItemParam.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/UndeployVAppParams.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/UploadVAppTemplateParams.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => params}/VAppCreationParams.java (98%) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/package-info.java rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => section}/CustomizationSection.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => section}/GuestCustomizationSection.java (99%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => section}/LeaseSettingsSection.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => section}/NetworkConfigSection.java (96%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => section}/NetworkConnectionSection.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => section}/OperatingSystemSection.java (98%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => section}/RuntimeInfoSection.java (97%) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{ => section}/VirtualHardwareSection.java (98%) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/package-info.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java index b25b64cb15..356118c13a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AbstractVAppType.java @@ -36,6 +36,14 @@ import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -52,7 +60,7 @@ import com.google.common.collect.Sets; * @author grkvlt@apache.org */ @XmlType(name = "AbstractVAppType") -public abstract class AbstractVAppType extends ResourceEntityType { +public abstract class AbstractVAppType extends ResourceEntity { public static Builder builder() { return new ConcreteBuilder(); @@ -66,7 +74,7 @@ public abstract class AbstractVAppType extends ResourceEntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceEntityType.Builder { + public static abstract class Builder> extends ResourceEntity.Builder { private Boolean deployed; private Reference vAppParent; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminCatalog.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminCatalog.java index 3c0683066f..4dd68787f0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminCatalog.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminCatalog.java @@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; + /** * Admin representation of the container for meta data (key-value pair) associated to different * entities in the system. @@ -39,7 +40,7 @@ import javax.xml.bind.annotation.XmlType; */ @XmlRootElement(name = "AdminCatalog") @XmlType(name = "AdminCatalogType") -public class AdminCatalog extends CatalogType { +public class AdminCatalog extends Catalog { public static Builder builder() { return new ConcreteBuilder(); @@ -53,7 +54,7 @@ public class AdminCatalog extends CatalogType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends CatalogType.Builder { + public static abstract class Builder> extends Catalog.Builder { @Override public AdminCatalog build() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminVdc.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminVdc.java index 6b6cabc4e4..fd1c4f65cc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminVdc.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminVdc.java @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java index 915751e600..cd82435e3d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java @@ -18,10 +18,21 @@ */ package org.jclouds.vcloud.director.v1_5.domain; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; /** * Container for references to {@link VAppTemplate} and {@link Media} objects. @@ -30,13 +41,12 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; * <complexType name="CatalogType" /> * * - * @author grkvlt@apache.org + * @author danikov */ @XmlSeeAlso({ AdminCatalog.class }) @XmlRootElement(name = "Catalog") -public class Catalog extends CatalogType { - - public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG; +@XmlType(name = "CatalogType") +public class Catalog extends Entity { public static Builder builder() { return new ConcreteBuilder(); @@ -44,30 +54,131 @@ public class Catalog extends CatalogType { @Override public Builder toBuilder() { - return builder().fromCatalog(this); + return builder().fromCatalogType(this); } private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends CatalogType.Builder { + public static class Builder> extends Entity.Builder { + + private Owner owner; + private Set catalogItems = Sets.newLinkedHashSet(); + private Boolean isPublished; + + /** + * @see CatalogType#getOwner() + */ + public B owner(Owner owner) { + this.owner = owner; + return self(); + } + + /** + * @see CatalogItems#getCatalogItems() + */ + public B items(Iterable catalogItems) { + this.catalogItems = Sets.newLinkedHashSet(checkNotNull(catalogItems, "catalogItems")); + return self(); + } + + /** + * @see CatalogItems#getCatalogItems() + */ + public B item(Reference catalogItem) { + this.catalogItems.add(checkNotNull(catalogItem, "catalogItem")); + return self(); + } + + /** + * @see CatalogType#isPublished() + */ + public B isPublished(Boolean isPublished) { + this.isPublished = isPublished; + return self(); + } + + /** + * @see CatalogType#isPublished() + */ + public B published() { + this.isPublished = Boolean.TRUE; + return self(); + } @Override public Catalog build() { return new Catalog(this); } - - public B fromCatalog(Catalog in) { - return fromCatalogType(in); + + public B fromCatalogType(Catalog in) { + return fromEntityType(in).owner(in.getOwner()).items(in.getCatalogItems()).isPublished(in.isPublished()); } } - public Catalog(Builder builder) { + protected Catalog(Builder builder) { super(builder); + this.owner = builder.owner; + this.catalogItems = builder.catalogItems == null || builder.catalogItems.isEmpty() ? null : ImmutableSet.copyOf(builder.catalogItems); + this.isPublished = builder.isPublished; } - @SuppressWarnings("unused") - private Catalog() { - // for JAXB + protected Catalog() { + // For JAXB } + + @XmlElement(name = "Owner") + private Owner owner; + @XmlElementWrapper(name = "CatalogItems") + @XmlElement(name = "CatalogItem") + private Set catalogItems; + @XmlElement(name = "IsPublished") + private Boolean isPublished; + + /** + * Gets the value of the owner property. + */ + public Owner getOwner() { + return owner; + } + + /** + * Gets the value of the catalogItems property. + */ + public Set getCatalogItems() { + return catalogItems == null ? ImmutableSet.of() : ImmutableSet.copyOf(catalogItems); + } + + /** + * Gets the value of the isPublished property. + */ + public Boolean isPublished() { + return isPublished; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Catalog that = Catalog.class.cast(o); + return super.equals(that) && + equal(this.owner, that.owner) && + equal(this.getCatalogItems(), that.getCatalogItems()) && + equal(this.isPublished, that.isPublished); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), owner, getCatalogItems(), catalogItems); + } + + @Override + public ToStringHelper string() { + return super.string().add("owner", owner) + .add("catalogItems", getCatalogItems()) + .add("isPublished", isPublished); + } + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java index 55e7fe756a..6e5c97a6c8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java @@ -41,7 +41,7 @@ import com.google.common.collect.Sets; * @author grkvlt@apache.org */ @XmlRootElement(name = "CatalogItem") -public class CatalogItem extends EntityType { +public class CatalogItem extends Entity { public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEM; @@ -57,7 +57,7 @@ public class CatalogItem extends EntityType { private static class ConcreteBuilder extends Builder { } - public static class Builder> extends EntityType.Builder { + public static class Builder> extends Entity.Builder { private Reference entity; private Set properties = Sets.newLinkedHashSet(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogType.java deleted file mode 100644 index 91fe4de009..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogType.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Container for references to VappTemplate and Media objects. - * - *

    - * <complexType name="CatalogType" />
    - * 
    - * - * @author danikov - */ -@XmlRootElement(name = "Catalog") -public class CatalogType extends EntityType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - @Override - public Builder toBuilder() { - return builder().fromCatalogType(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends EntityType.Builder { - - private Owner owner; - private Set catalogItems = Sets.newLinkedHashSet(); - private Boolean isPublished; - - /** - * @see CatalogType#getOwner() - */ - public B owner(Owner owner) { - this.owner = owner; - return self(); - } - - /** - * @see CatalogItems#getCatalogItems() - */ - public B items(Iterable catalogItems) { - this.catalogItems = Sets.newLinkedHashSet(checkNotNull(catalogItems, "catalogItems")); - return self(); - } - - /** - * @see CatalogItems#getCatalogItems() - */ - public B item(Reference catalogItem) { - this.catalogItems.add(checkNotNull(catalogItem, "catalogItem")); - return self(); - } - - /** - * @see CatalogType#isPublished() - */ - public B isPublished(Boolean isPublished) { - this.isPublished = isPublished; - return self(); - } - - /** - * @see CatalogType#isPublished() - */ - public B published() { - this.isPublished = Boolean.TRUE; - return self(); - } - - @Override - public CatalogType build() { - return new CatalogType(this); - } - - public B fromCatalogType(CatalogType in) { - return fromEntityType(in).owner(in.getOwner()).items(in.getCatalogItems()).isPublished(in.isPublished()); - } - } - - protected CatalogType(Builder builder) { - super(builder); - this.owner = builder.owner; - this.catalogItems = builder.catalogItems == null || builder.catalogItems.isEmpty() ? null : ImmutableSet.copyOf(builder.catalogItems); - this.isPublished = builder.isPublished; - } - - protected CatalogType() { - // For JAXB - } - - @XmlElement(name = "Owner") - private Owner owner; - @XmlElementWrapper(name = "CatalogItems") - @XmlElement(name = "CatalogItem") - private Set catalogItems; - @XmlElement(name = "IsPublished") - private Boolean isPublished; - - /** - * Gets the value of the owner property. - */ - public Owner getOwner() { - return owner; - } - - /** - * Gets the value of the catalogItems property. - */ - public Set getCatalogItems() { - return catalogItems == null ? ImmutableSet.of() : ImmutableSet.copyOf(catalogItems); - } - - /** - * Gets the value of the isPublished property. - */ - public Boolean isPublished() { - return isPublished; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - CatalogType that = CatalogType.class.cast(o); - return super.equals(that) && - equal(this.owner, that.owner) && - equal(this.getCatalogItems(), that.getCatalogItems()) && - equal(this.isPublished, that.isPublished); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), owner, getCatalogItems(), catalogItems); - } - - @Override - public ToStringHelper string() { - return super.string().add("owner", owner) - .add("catalogItems", getCatalogItems()) - .add("isPublished", isPublished); - } - -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java index 9bb44e4d1c..43e8559c9e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to jclouds, Inc. (jclouds) under one or more * contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,46 +18,200 @@ */ package org.jclouds.vcloud.director.v1_5.domain; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; /** - * An entity. + * Basic entity type in the vCloud object model. + * + * Includes the entity name and an optional id, description, and set of running {@link Task}s. + * + *
    + * <xs:complexType name="EntityType" />
    + * 
    * * @author grkvlt@apache.org * @author Adam Lowe */ @XmlRootElement(name = "Entity") -public class Entity extends EntityType { - +@XmlType(name = "EntityType") +public class Entity extends Resource { + public static Builder builder() { return new ConcreteBuilder(); } @Override public Builder toBuilder() { - return builder().fromEntity(this); + return builder().fromEntityType(this); } private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends EntityType.Builder { + public static abstract class Builder> extends Resource.Builder { + + private String description; + private List tasks = Lists.newArrayList(); + private String name; + private String id; + + /** + * @see EntityType#getName() + */ + public B name(String name) { + this.name = name; + return self(); + } + + /** + * @see EntityType#getDescription() + */ + public B description(String description) { + this.description = description; + return self(); + } + + /** + * @see EntityType#getId() + */ + public B id(String id) { + this.id = id; + return self(); + } + + /** + * @see EntityType#getTasks() + */ + public B tasks(Iterable tasks) { + this.tasks = Lists.newArrayList(checkNotNull(tasks, "tasks")); + return self(); + } + + /** + * @see EntityType#getTasks() + */ + public B task(Task task) { + this.tasks.add(checkNotNull(task, "task")); + return self(); + } @Override public Entity build() { return new Entity(this); } - - public B fromEntity(Entity in) { - return fromEntityType(in); + + public B fromEntityType(Entity in) { + return fromResource(in) + .description(in.getDescription()) + .tasks(in.getTasks()) + .id(in.getId()).name(in.getName()); } } - private Entity(Builder builder) { + @XmlElement(name = "Description") + private String description; + @XmlElementWrapper(name = "Tasks") + @XmlElement(name = "Task") + private List tasks; + @XmlAttribute + private String id; + @XmlAttribute(required = true) + private String name; + + protected Entity(Builder builder) { super(builder); + this.description = builder.description; + this.tasks = builder.tasks == null || builder.tasks.isEmpty() ? null : ImmutableList.copyOf(builder.tasks); + this.id = builder.id; + this.name = builder.name; } - private Entity() { + protected Entity() { // For JAXB } -} \ No newline at end of file + + /** + * Optional description. + */ + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + /** + * A list of queued, running, or recently completed tasks associated with this entity. + */ + public List getTasks() { + return tasks == null ? ImmutableList.of() : ImmutableList.copyOf(tasks); + } + + /** + * The resource identifier, expressed in URN format. + * + * The value of this attribute uniquely identifies the resource, persists for the life of the + * resource, and is never reused. + */ + public String getId() { + return id; + } + + /** + * Contains the name of the the entity. + */ + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Entity that = Entity.class.cast(o); + return super.equals(that) && + equal(this.id, that.id) && equal(this.description, that.description) && + equal(this.tasks, that.tasks) && equal(this.name, that.name); + } + + @Override + public boolean clone(Object o) { + if (this == o) + return false; + if (o == null || getClass() != o.getClass()) + return false; + Entity that = Entity.class.cast(o); + return super.clone(that); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), description, tasks, id, name); + } + + @Override + public ToStringHelper string() { + return super.string().add("description", description).add("tasks", tasks).add("id", id).add("name", name); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java deleted file mode 100644 index 2184300250..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -/** - * Basic entity type in the vCloud object model. - * - * Includes the entity name and an optional id, description, and set of running {@link Task}s. - * - *
    - * <xs:complexType name="EntityType" />
    - * 
    - * - * @author grkvlt@apache.org - * @author Adam Lowe - */ -@XmlType(name = "EntityType") -public class EntityType extends ResourceType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - @Override - public Builder toBuilder() { - return builder().fromEntityType(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static abstract class Builder> extends ResourceType.Builder { - - private String description; - private List tasks = Lists.newArrayList(); - private String name; - private String id; - - /** - * @see EntityType#getName() - */ - public B name(String name) { - this.name = name; - return self(); - } - - /** - * @see EntityType#getDescription() - */ - public B description(String description) { - this.description = description; - return self(); - } - - /** - * @see EntityType#getId() - */ - public B id(String id) { - this.id = id; - return self(); - } - - /** - * @see EntityType#getTasks() - */ - public B tasks(Iterable tasks) { - this.tasks = Lists.newArrayList(checkNotNull(tasks, "tasks")); - return self(); - } - - /** - * @see EntityType#getTasks() - */ - public B task(Task task) { - this.tasks.add(checkNotNull(task, "task")); - return self(); - } - - @Override - public EntityType build() { - return new EntityType(this); - } - - public B fromEntityType(EntityType in) { - return fromResourceType(in) - .description(in.getDescription()) - .tasks(in.getTasks()) - .id(in.getId()).name(in.getName()); - } - } - - @XmlElement(name = "Description") - private String description; - @XmlElementWrapper(name = "Tasks") - @XmlElement(name = "Task") - private List tasks; - @XmlAttribute - private String id; - @XmlAttribute(required = true) - private String name; - - protected EntityType(Builder builder) { - super(builder); - this.description = builder.description; - this.tasks = builder.tasks == null || builder.tasks.isEmpty() ? null : ImmutableList.copyOf(builder.tasks); - this.id = builder.id; - this.name = builder.name; - } - - protected EntityType() { - // For JAXB - } - - /** - * Optional description. - */ - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - /** - * A list of queued, running, or recently completed tasks associated with this entity. - */ - public List getTasks() { - return tasks == null ? ImmutableList.of() : ImmutableList.copyOf(tasks); - } - - /** - * The resource identifier, expressed in URN format. - * - * The value of this attribute uniquely identifies the resource, persists for the life of the - * resource, and is never reused. - */ - public String getId() { - return id; - } - - /** - * Contains the name of the the entity. - */ - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - EntityType that = EntityType.class.cast(o); - return super.equals(that) && - equal(this.id, that.id) && equal(this.description, that.description) && - equal(this.tasks, that.tasks) && equal(this.name, that.name); - } - - @Override - public boolean clone(Object o) { - if (this == o) - return false; - if (o == null || getClass() != o.getClass()) - return false; - EntityType that = EntityType.class.cast(o); - return super.clone(that); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), description, tasks, id, name); - } - - @Override - public ToStringHelper string() { - return super.string().add("description", description).add("tasks", tasks).add("id", id).add("name", name); - } -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java index 2190de4f5f..f461490a6a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java @@ -53,7 +53,7 @@ import com.google.common.base.Objects.ToStringHelper; * */ @XmlType(name = "File") -public class File extends EntityType { +public class File extends Entity { public static Builder builder() { return new ConcreteBuilder(); @@ -67,7 +67,7 @@ public class File extends EntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends EntityType.Builder { + public static abstract class Builder> extends Entity.Builder { private Long size; private Long bytesTransferred; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Group.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Group.java index 08fb5bd2ef..713f11a5e8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Group.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Group.java @@ -56,7 +56,7 @@ import com.google.common.collect.Sets; "usersList", "role" }) -public class Group extends EntityType { +public class Group extends Entity { public static Builder builder() { return new ConcreteBuilder(); @@ -70,7 +70,7 @@ public class Group extends EntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends EntityType.Builder { + public static abstract class Builder> extends Entity.Builder { private String nameInSource; private Set users = Sets.newLinkedHashSet(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java index 963a603977..7eaa5aaced 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java @@ -46,7 +46,7 @@ import com.google.common.collect.Maps; * */ @XmlRootElement(name = "Media") -public class Media extends ResourceEntityType { +public class Media extends ResourceEntity { @XmlType @XmlEnum(String.class) @@ -93,7 +93,7 @@ public class Media extends ResourceEntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceEntityType.Builder { + public static abstract class Builder> extends ResourceEntity.Builder { private Owner owner; private ImageType imageType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java index 4e590fdf05..bd020be889 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java @@ -44,7 +44,7 @@ import com.google.common.collect.Sets; * @author danikov */ @XmlRootElement(name = "Metadata") -public class Metadata extends ResourceType { +public class Metadata extends Resource { public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA; @@ -60,7 +60,7 @@ public class Metadata extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private Set metadataEntries = Sets.newLinkedHashSet(); @@ -86,7 +86,7 @@ public class Metadata extends ResourceType { } public B fromMetadata(Metadata in) { - return fromResourceType(in).entries(in.getMetadataEntries()); + return fromResource(in).entries(in.getMetadataEntries()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java index 910df170d3..0319146d8a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java @@ -43,7 +43,7 @@ import com.google.common.collect.Sets; * @author danikov */ @XmlRootElement(name = "MetadataEntry") -public class MetadataEntry extends ResourceType { +public class MetadataEntry extends Resource { public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA_ENTRY; @@ -59,7 +59,7 @@ public class MetadataEntry extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private String key; private String value; @@ -131,7 +131,7 @@ public class MetadataEntry extends ResourceType { } public B fromMetadataEntry(MetadataEntry in) { - return fromResourceType(in).entry(key, value); + return fromResource(in).entry(key, value); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java index cd4a79ed18..6a6969489a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java @@ -43,7 +43,7 @@ import com.google.common.collect.Sets; * @author grkvlt@apache.org */ @XmlRootElement(name = "MetadataValue") -public class MetadataValue extends ResourceType { +public class MetadataValue extends Resource { public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA_ENTRY; @@ -59,7 +59,7 @@ public class MetadataValue extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private String value; /** @@ -112,7 +112,7 @@ public class MetadataValue extends ResourceType { } public B fromMetadataValue(MetadataValue in) { - return fromResourceType(in).value(value); + return fromResource(in).value(value); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java index b06d483e68..7b568ccb2e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java @@ -38,7 +38,7 @@ import com.google.common.base.Objects.ToStringHelper; */ @XmlRootElement(name = "Owner") @XmlType(name = "OwnerType") -public class Owner extends ResourceType { +public class Owner extends Resource { public static Builder builder() { return new ConcreteBuilder(); @@ -52,7 +52,7 @@ public class Owner extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private Reference user; @@ -70,7 +70,7 @@ public class Owner extends ResourceType { } public B fromOwner(Owner in) { - return fromResourceType(in) + return fromResource(in) .user(in.getUser()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java index 80472eeb2b..52df0dd820 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java @@ -56,7 +56,7 @@ import com.google.common.collect.Sets; */ @XmlRootElement(name = "ProductSectionList") @XmlType(name = "ProductSectionListType") -public class ProductSectionList extends ResourceType implements Set { +public class ProductSectionList extends Resource implements Set { public static Builder builder() { return new ConcreteBuilder(); @@ -70,7 +70,7 @@ public class ProductSectionList extends ResourceType implements Set { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private Set productSections = Sets.newLinkedHashSet(); @@ -96,7 +96,7 @@ public class ProductSectionList extends ResourceType implements Set { +public class RasdItemsList extends Resource implements Set { public static Builder builder() { return new ConcreteBuilder(); @@ -58,7 +60,7 @@ public class RasdItemsList extends ResourceType implements Set { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private Set items = Sets.newLinkedHashSet(); @@ -85,7 +87,7 @@ public class RasdItemsList extends ResourceType implements Set { } public B fromRasdItemsList(RasdItemsList in) { - return fromResourceType(in).items(in.getItems()); + return fromResource(in).items(in.getItems()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java index 90b5299815..f9b4526107 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java @@ -119,7 +119,7 @@ public class Reference { return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType()); } - public B fromEntity(EntityType in) { + public B fromEntity(Entity in) { return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType()); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java index 279137df6d..aee041f8a9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to jclouds, Inc. (jclouds) under one or more * contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,21 +18,49 @@ */ package org.jclouds.vcloud.director.v1_5.domain; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Collections; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.logging.Logger; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; /** - * A resource. + * The base type for all objects in the vCloud model. * - * @author grkvlt@apache.org + * Has an optional list of links and href and type attributes. + * + *
    + * <xs:complexType name="ResourceType" />
    + * 
    + * + * @author Adrian Cole + * + * @since 0.9 */ @XmlRootElement(name = "Resource") -public class Resource extends ResourceType { +@XmlType(name = "ResourceType") +public class Resource { + @javax.annotation.Resource + protected static Logger logger = Logger.NULL; + public static Builder builder() { return new ConcreteBuilder(); } - @Override public Builder toBuilder() { return builder().fromResource(this); } @@ -40,26 +68,112 @@ public class Resource extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> { + private URI href; + private String type; + private Set links; + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + + /** + * @see ResourceType#getHref() + */ + public B href(URI href) { + this.href = href; + return self(); + } + + /** + * @see ResourceType#getType() + */ + public B type(String type) { + this.type = type; + return self(); + } + + /** + * @see ResourceType#getLinks() + */ + public B links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return self(); + } + + /** + * @see ResourceType#getLinks() + */ + public B link(Link link) { + if (links == null) + links = Sets.newLinkedHashSet(); + this.links.add(checkNotNull(link, "link")); + return self(); + } - @Override public Resource build() { return new Resource(this); } protected B fromResource(Resource in) { - return fromResourceType(in); + return href(in.getHref()).type(in.getType()).links(Sets.newLinkedHashSet(in.getLinks())); } } - protected Resource(Builder builder) { - super(builder); - } + @XmlAttribute + private URI href; + @XmlAttribute + private String type; + @XmlElement(name = "Link") + private Set links = Sets.newLinkedHashSet(); + protected Resource(Builder builder) { + this.href = builder.href; + this.type = builder.type; + this.links = builder.links == null ? Collections.emptySet() : builder.links; + } + protected Resource() { // For JAXB } + /** + * Contains the URI to the entity. + * + * An object reference, expressed in URL format. Because this URL includes the object identifier + * portion of the id attribute value, it uniquely identifies the object, persists for the life of + * the object, and is never reused. The value of the href attribute is a reference to a view of + * the object, and can be used to access a representation of the object that is valid in a + * particular context. Although URLs have a well-known syntax and a well-understood + * interpretation, a client should treat each href as an opaque string. The rules that govern how + * the server constructs href strings might change in future releases. + * + * @return an opaque reference and should never be parsed + */ + public URI getHref() { + return href; + } + + /** + * Contains the type of the the entity. + * + * The object type, specified as a MIME content type, of the object that the link references. + * This attribute is present only for links to objects. It is not present for links to actions. + * + * @return type definition, type, expressed as an HTTP Content-Type + */ + public String getType() { + return type; + } + + /** + * Set of optional links to an entity or operation associated with this object. + */ + public Set getLinks() { + return links == null ? ImmutableSet.of() : Collections.unmodifiableSet(links); + } + @Override public boolean equals(Object o) { if (this == o) @@ -67,6 +181,29 @@ public class Resource extends ResourceType { if (o == null || getClass() != o.getClass()) return false; Resource that = Resource.class.cast(o); - return super.equals(that); + return equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type); } -} \ No newline at end of file + + public boolean clone(Object o) { + if (this == o) + return false; + if (o == null || getClass() != o.getClass()) + return false; + Resource that = Resource.class.cast(o); + return equal(this.type, that.type); + } + + @Override + public int hashCode() { + return Objects.hashCode(href, links, type); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return Objects.toStringHelper("").add("href", href).add("links", links).add("type", type); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntity.java similarity index 95% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntity.java index ff3b64de00..fd889a449d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntity.java @@ -49,7 +49,7 @@ import com.google.common.collect.Iterables; * @author grkvlt@apache.org */ @XmlType(name = "ResourceEntityType") -public abstract class ResourceEntityType extends EntityType { +public abstract class ResourceEntity extends Entity { @XmlType(name = "ResourceEntityTypeStatus") @XmlEnum(Integer.class) @@ -138,7 +138,7 @@ public abstract class ResourceEntityType extends EntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends EntityType.Builder { + public static abstract class Builder> extends Entity.Builder { private Set files; private Status status; @@ -166,7 +166,7 @@ public abstract class ResourceEntityType extends EntityType { return self(); } - public B fromResourceEntityType(ResourceEntityType in) { + public B fromResourceEntityType(ResourceEntity in) { return fromEntityType(in).files(in.getFiles()).status(in.getStatus()); } } @@ -177,13 +177,13 @@ public abstract class ResourceEntityType extends EntityType { @XmlAttribute private Status status; - public ResourceEntityType(Builder builder) { + public ResourceEntity(Builder builder) { super(builder); this.files = builder.files; this.status = builder.status; } - protected ResourceEntityType() { + protected ResourceEntity() { // for JAXB } @@ -207,7 +207,7 @@ public abstract class ResourceEntityType extends EntityType { return true; if (o == null || getClass() != o.getClass()) return false; - ResourceEntityType that = ResourceEntityType.class.cast(o); + ResourceEntity that = ResourceEntity.class.cast(o); return super.equals(that) && equal(this.files, that.files) && equal(this.status, that.status); } @@ -217,7 +217,7 @@ public abstract class ResourceEntityType extends EntityType { return false; if (o == null || getClass() != o.getClass()) return false; - ResourceEntityType that = ResourceEntityType.class.cast(o); + ResourceEntity that = ResourceEntity.class.cast(o); return super.clone(that) && equal(this.files, that.files); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java deleted file mode 100644 index 7f618dc7d5..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -import org.jclouds.logging.Logger; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * The base type for all objects in the vCloud model. - * - * Has an optional list of links and href and type attributes. - * - *
    - * <xs:complexType name="ResourceType" />
    - * 
    - * - * @author Adrian Cole - * - * @since 0.9 - */ -@XmlType(name = "ResourceType") -public class ResourceType { - - @javax.annotation.Resource - protected static Logger logger = Logger.NULL; - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromResourceType(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static abstract class Builder> { - private URI href; - private String type; - private Set links; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see ResourceType#getHref() - */ - public B href(URI href) { - this.href = href; - return self(); - } - - /** - * @see ResourceType#getType() - */ - public B type(String type) { - this.type = type; - return self(); - } - - /** - * @see ResourceType#getLinks() - */ - public B links(Set links) { - this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); - return self(); - } - - /** - * @see ResourceType#getLinks() - */ - public B link(Link link) { - if (links == null) - links = Sets.newLinkedHashSet(); - this.links.add(checkNotNull(link, "link")); - return self(); - } - - public ResourceType build() { - return new ResourceType(this); - } - - protected B fromResourceType(ResourceType in) { - return href(in.getHref()).type(in.getType()).links(Sets.newLinkedHashSet(in.getLinks())); - } - } - - @XmlAttribute - private URI href; - @XmlAttribute - private String type; - @XmlElement(name = "Link") - private Set links = Sets.newLinkedHashSet(); - - protected ResourceType(Builder builder) { - this.href = builder.href; - this.type = builder.type; - this.links = builder.links == null ? Collections.emptySet() : builder.links; - } - - protected ResourceType() { - // For JAXB - } - - /** - * Contains the URI to the entity. - * - * An object reference, expressed in URL format. Because this URL includes the object identifier - * portion of the id attribute value, it uniquely identifies the object, persists for the life of - * the object, and is never reused. The value of the href attribute is a reference to a view of - * the object, and can be used to access a representation of the object that is valid in a - * particular context. Although URLs have a well-known syntax and a well-understood - * interpretation, a client should treat each href as an opaque string. The rules that govern how - * the server constructs href strings might change in future releases. - * - * @return an opaque reference and should never be parsed - */ - public URI getHref() { - return href; - } - - /** - * Contains the type of the the entity. - * - * The object type, specified as a MIME content type, of the object that the link references. - * This attribute is present only for links to objects. It is not present for links to actions. - * - * @return type definition, type, expressed as an HTTP Content-Type - */ - public String getType() { - return type; - } - - /** - * Set of optional links to an entity or operation associated with this object. - */ - public Set getLinks() { - return links == null ? ImmutableSet.of() : Collections.unmodifiableSet(links); - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ResourceType that = ResourceType.class.cast(o); - return equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type); - } - - public boolean clone(Object o) { - if (this == o) - return false; - if (o == null || getClass() != o.getClass()) - return false; - ResourceType that = ResourceType.class.cast(o); - return equal(this.type, that.type); - } - - @Override - public int hashCode() { - return Objects.hashCode(href, links, type); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").add("href", href).add("links", links).add("type", type); - } -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RoleReferences.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RoleReferences.java index 93e6e6445d..8029782c08 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RoleReferences.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RoleReferences.java @@ -25,13 +25,7 @@ import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultReferences; /** - * - * Container for ReferenceType elements that reference RoleType objects. - * - * - *

    Java class for RoleReferences complex type. - * - *

    The following schema fragment specifies the expected content contained within this class. + * Container for ReferenceType elements that reference RoleType objects. * *

      * <complexType name="RoleReferences">
    @@ -45,8 +39,6 @@ import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultReferences;
      *   </complexContent>
      * </complexType>
      * 
    - * - * */ @XmlRootElement(name = "RoleReferences") public class RoleReferences extends QueryResultReferences { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java index 293811e34c..6499f19c34 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java @@ -53,7 +53,7 @@ import com.google.common.collect.Maps; * @author grkvlt@apache.org */ @XmlRootElement(name = "Task") -public class Task extends EntityType { +public class Task extends Entity { public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASK; @@ -114,7 +114,7 @@ public class Task extends EntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends EntityType.Builder { + public static abstract class Builder> extends Entity.Builder { private Error error; private Reference org; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java index 1a8e4851b0..9e678945e6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java @@ -42,7 +42,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @XmlRootElement(name = "TasksList") -public class TasksList extends ResourceType implements Set { +public class TasksList extends Resource implements Set { public static Builder builder() { return new ConcreteBuilder(); } @@ -55,7 +55,7 @@ public class TasksList extends ResourceType implements Set { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private String name; private Set tasks; @@ -92,7 +92,7 @@ public class TasksList extends ResourceType implements Set { } public B fromTasksList(TasksList in) { - return fromResourceType(in).tasks(in); + return fromResource(in).tasks(in); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java index 20a54c287e..b794c1c71e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java @@ -91,7 +91,7 @@ import com.google.common.collect.Lists; "password", "groups" }) -public class User extends EntityType { +public class User extends Entity { public static Builder builder() { return new ConcreteBuilder(); @@ -105,7 +105,7 @@ public class User extends EntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends EntityType.Builder { + public static abstract class Builder> extends Entity.Builder { private String fullName; private String emailAddress; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java index 76813ab1db..7c90d7a29c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java @@ -37,6 +37,14 @@ import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; @@ -50,7 +58,7 @@ import com.google.common.collect.Sets; * */ @XmlRootElement(name = "VAppTemplate") -public class VAppTemplate extends ResourceEntityType { +public class VAppTemplate extends ResourceEntity { public static Builder builder() { return new ConcreteBuilder(); @@ -64,7 +72,7 @@ public class VAppTemplate extends ResourceEntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceEntityType.Builder { + public static abstract class Builder> extends ResourceEntity.Builder { private Owner owner; private Set children = Sets.newLinkedHashSet(); private Set sections = Sets.newLinkedHashSet(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java index 31b92ea94a..fbf51762ea 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; @@ -45,7 +46,7 @@ import com.google.common.collect.Sets; @XmlRootElement(name = "Vdc") @XmlType(name = "VdcType") @XmlSeeAlso({ AdminVdc.class }) -public class Vdc extends EntityType { +public class Vdc extends Entity { public static Builder builder() { return new ConcreteBuilder(); @@ -59,7 +60,7 @@ public class Vdc extends EntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends EntityType.Builder { + public static abstract class Builder> extends Entity.Builder { private String allocationModel; private CapacityWithUsage storageCapacity; private ComputeCapacity computeCapacity; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VmPendingQuestion.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VmPendingQuestion.java index a2d51d9bed..f1ad49e911 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VmPendingQuestion.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VmPendingQuestion.java @@ -39,7 +39,7 @@ import com.google.common.base.Objects.ToStringHelper; * @author grkvlt@apache.org */ @XmlType(name = "VmPendingQuestion") -public class VmPendingQuestion extends ResourceType { +public class VmPendingQuestion extends Resource { public static Builder builder() { return new ConcreteBuilder(); @@ -53,7 +53,7 @@ public class VmPendingQuestion extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private String question; private String questionId; @@ -90,7 +90,7 @@ public class VmPendingQuestion extends ResourceType { } public B fromVmPendingQuestion(VmPendingQuestion in) { - return fromResourceType(in).question(in.getQuestion()).questionId(in.getQuestionId()).choices(in.getChoices()); + return fromResource(in).question(in.getQuestion()).questionId(in.getQuestionId()).choices(in.getChoices()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Envelope.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/Envelope.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Envelope.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/Envelope.java index a23500485a..a475c5f140 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Envelope.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/Envelope.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.dmtf; import static org.jclouds.dmtf.DMTFConstants.OVF_NS; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RasdItem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/RasdItem.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RasdItem.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/RasdItem.java index cf812ff5c2..ec1bc84ce1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RasdItem.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/RasdItem.java @@ -16,10 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.dmtf; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; @@ -31,6 +32,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import org.jclouds.dmtf.cim.ResourceAllocationSettingData; +import org.jclouds.vcloud.director.v1_5.domain.Link; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -38,13 +40,11 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; /** - * The ResourceAllocationSettingData class represents settings specifically - * related to an allocated resource that are outside the scope of the CIM class - * typically used to represent the resource itself. + * A vCloud specific {@link ResourceAllocationSettingData} extension. * * @author grkvlt@apache.org */ -@XmlRootElement(name = "Item", namespace = VCLOUD_1_5_NS) +@XmlRootElement(name = "Item", namespace = OVF_NS) public class RasdItem extends ResourceAllocationSettingData { public static Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualSystem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/VirtualSystem.java similarity index 95% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualSystem.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/VirtualSystem.java index 2f1eb49d48..22167157f1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualSystem.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/VirtualSystem.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.dmtf; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -28,6 +28,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.jclouds.dmtf.ovf.internal.BaseVirtualSystem; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/package-info.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/package-info.java new file mode 100644 index 0000000000..e4de819d6b --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/dmtf/package-info.java @@ -0,0 +1,35 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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. + */ +@XmlSchema(namespace = VCLOUD_1_5_NS, + elementFormDefault = XmlNsForm.QUALIFIED, + xmlns = { + @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS) + } +) +@XmlAccessorType(XmlAccessType.FIELD) +package org.jclouds.vcloud.director.v1_5.domain.dmtf; + +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; + diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DhcpService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/DhcpService.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DhcpService.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/DhcpService.java index ca8b6b848f..e0582ae0b9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DhcpService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/DhcpService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ExternalNetwork.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/ExternalNetwork.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ExternalNetwork.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/ExternalNetwork.java index bd05d84056..c12006093f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ExternalNetwork.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/ExternalNetwork.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallRule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallRule.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallRule.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallRule.java index 9ce90b4f82..c39d30933f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallRule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallRule.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallRuleProtocols.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallRuleProtocols.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallRuleProtocols.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallRuleProtocols.java index dfbb179335..b40245cfdd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallRuleProtocols.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallRuleProtocols.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallService.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallService.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallService.java index caa26ec66d..c14c3acf85 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FirewallService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/FirewallService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpAddresses.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpAddresses.java index 6d7a39923f..049c1de4eb 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpAddresses.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpRange.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpRange.java index 4d620b9ee3..8ff8d652d2 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpRange.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpRanges.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpRanges.java index 1e074bb507..c053fd3d3d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpRanges.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpScope.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpScope.java index 109739dbdf..5c497b4300 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpScope.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnLocalPeer.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnLocalPeer.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnLocalPeer.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnLocalPeer.java index e102ecbb18..93a2de0b9a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnLocalPeer.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnLocalPeer.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import javax.xml.bind.annotation.XmlRootElement; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnManagedPeerType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnManagedPeerType.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnManagedPeerType.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnManagedPeerType.java index a268f41a68..e461e82fd7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnManagedPeerType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnManagedPeerType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnPeerType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnPeerType.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnPeerType.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnPeerType.java index 03128b0d32..919314999e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnPeerType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnPeerType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import javax.xml.bind.annotation.XmlSeeAlso; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnRemotePeer.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnRemotePeer.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnRemotePeer.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnRemotePeer.java index f7aeb13dc1..7a075b781c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnRemotePeer.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnRemotePeer.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnService.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnService.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnService.java index 0a7cdd17ce..df639fb8ff 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnThirdPartyPeer.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnThirdPartyPeer.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnThirdPartyPeer.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnThirdPartyPeer.java index e4813a8aa6..17f59ddc44 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnThirdPartyPeer.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnThirdPartyPeer.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import javax.xml.bind.annotation.XmlRootElement; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnTunnel.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnTunnel.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnTunnel.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnTunnel.java index 6ef223afd9..89dd25c6ee 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnTunnel.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnTunnel.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnUnmanagedPeerType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnUnmanagedPeerType.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnUnmanagedPeerType.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnUnmanagedPeerType.java index ed92c5d415..5938c2445f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpsecVpnUnmanagedPeerType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/IpsecVpnUnmanagedPeerType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import javax.xml.bind.annotation.XmlSeeAlso; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatOneToOneBasicRule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatOneToOneBasicRule.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatOneToOneBasicRule.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatOneToOneBasicRule.java index 7792d5f91f..afe0f5ca83 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatOneToOneBasicRule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatOneToOneBasicRule.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatOneToOneVmRule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatOneToOneVmRule.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatOneToOneVmRule.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatOneToOneVmRule.java index 2aeade3071..928f89da87 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatOneToOneVmRule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatOneToOneVmRule.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatPortForwardingRule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatPortForwardingRule.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatPortForwardingRule.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatPortForwardingRule.java index 11f5afb9ed..358a1cefc1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatPortForwardingRule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatPortForwardingRule.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatRule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatRule.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatRule.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatRule.java index c713226072..0a84e291cd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatRule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatRule.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatService.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatService.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatService.java index 5727e22aba..fd495a22c9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatVmRule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatVmRule.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatVmRule.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatVmRule.java index 8dae8887d1..bb14532a12 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NatVmRule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NatVmRule.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Network.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/Network.java similarity index 93% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Network.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/Network.java index d556416003..53b1ead067 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Network.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/Network.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -30,6 +30,10 @@ import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Entity; +import org.jclouds.vcloud.director.v1_5.domain.Entity.Builder; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; + import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -38,7 +42,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; @XmlSeeAlso({ OrgNetwork.class, ExternalNetwork.class }) -public abstract class Network extends EntityType { +public abstract class Network extends Entity { @XmlType @XmlEnum(String.class) @@ -75,7 +79,7 @@ public abstract class Network extends EntityType { } } - public abstract static class Builder> extends EntityType.Builder { + public abstract static class Builder> extends Entity.Builder { protected NetworkConfiguration networkConfiguration; /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkAssignment.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkAssignment.java index 43fe6924d7..ee4a7230d6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkAssignment.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkConfiguration.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkConfiguration.java index eda312e713..e23b4673fc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkConfiguration.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -25,7 +25,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.network.Network.FenceMode; import com.google.common.base.Objects; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkConnection.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkConnection.java index 7d1d3f981b..60f71eb726 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkConnection.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkFeatures.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkFeatures.java index 00dd15f323..e8d3714923 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkFeatures.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkServiceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkServiceType.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkServiceType.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkServiceType.java index 79da3f27e9..3de01fb07d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkServiceType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/NetworkServiceType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/RouterInfo.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/RouterInfo.java index ed474d92c9..63a48e48d0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/RouterInfo.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SmtpServerSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/SmtpServerSettings.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SmtpServerSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/SmtpServerSettings.java index 02a06a7b53..3ec82df287 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SmtpServerSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/SmtpServerSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoute.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/StaticRoute.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoute.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/StaticRoute.java index 75e7b80ff5..ab9b3f8eda 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoute.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/StaticRoute.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoutingService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/StaticRoutingService.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoutingService.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/StaticRoutingService.java index 4202bd17bf..a2ec914dde 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/StaticRoutingService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/StaticRoutingService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/SyslogServerSettings.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/SyslogServerSettings.java index 5ebac9170f..8ef2210165 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/SyslogServerSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetwork.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/VAppNetwork.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetwork.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/VAppNetwork.java index 1ecbbf9a61..98fbe5d763 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetwork.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/VAppNetwork.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/VAppNetworkConfiguration.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/VAppNetworkConfiguration.java index 8f4874dc71..3049f24ad6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/VAppNetworkConfiguration.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.network; import static com.google.common.base.Objects.equal; @@ -25,6 +25,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -37,7 +40,7 @@ import com.google.common.base.Objects.ToStringHelper; */ @XmlRootElement(name = "NetworkConfiguration") @XmlType(name = "VAppNetworkConfiguration") -public class VAppNetworkConfiguration extends ResourceType { +public class VAppNetworkConfiguration extends Resource { public static Builder builder() { return new ConcreteBuilder(); @@ -51,7 +54,7 @@ public class VAppNetworkConfiguration extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private String description; private NetworkConfiguration configuration; @@ -96,7 +99,7 @@ public class VAppNetworkConfiguration extends ResourceType { } public B fromVAppNetworkConfiguration(VAppNetworkConfiguration in) { - return fromResourceType(in) + return fromResource(in) .description(in.getDescription()) .configuration(in.getConfiguration()) .isDeployed(in.isDeployed()) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/package-info.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/package-info.java new file mode 100644 index 0000000000..9b9713c319 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/network/package-info.java @@ -0,0 +1,35 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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. + */ +@XmlSchema(namespace = VCLOUD_1_5_NS, + elementFormDefault = XmlNsForm.QUALIFIED, + xmlns = { + @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS) + } +) +@XmlAccessorType(XmlAccessType.FIELD) +package org.jclouds.vcloud.director.v1_5.domain.network; + +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; + diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/AdminOrg.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/AdminOrg.java index 4ab924e91e..e92df61ba5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AdminOrg.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/AdminOrg.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -28,6 +28,8 @@ import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomOrgLdapSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/CustomOrgLdapSettings.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomOrgLdapSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/CustomOrgLdapSettings.java index fea50b3925..b7fcb57ad9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomOrgLdapSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/CustomOrgLdapSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -29,6 +29,7 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; + import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/Org.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/Org.java index 766f743bf5..4f686bb150 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/Org.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; @@ -25,6 +25,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.Entity; +import org.jclouds.vcloud.director.v1_5.domain.Entity.Builder; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -42,7 +44,7 @@ import com.google.common.base.Objects.ToStringHelper; */ @XmlRootElement(name = "Org") @XmlSeeAlso({ AdminOrg.class }) -public class Org extends EntityType { +public class Org extends Entity { public static final String MEDIA_TYPE = VCloudDirectorMediaType.ORG; @@ -58,7 +60,7 @@ public class Org extends EntityType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends EntityType.Builder { + public static abstract class Builder> extends Entity.Builder { private String fullName; private Boolean isEnabled; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgEmailSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgEmailSettings.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgEmailSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgEmailSettings.java index 9ea7f3e9e9..65fa7863e6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgEmailSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgEmailSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -27,6 +27,10 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; +import org.jclouds.vcloud.director.v1_5.domain.network.SmtpServerSettings; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableList; @@ -63,7 +67,7 @@ import com.google.common.collect.ImmutableList; "alertEmailTo", "smtpServerSettings" }) -public class OrgEmailSettings extends ResourceType { +public class OrgEmailSettings extends Resource { public static Builder builder() { return new ConcreteBuilder(); @@ -77,7 +81,7 @@ public class OrgEmailSettings extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private boolean isDefaultSmtpServer; private boolean isDefaultOrgEmail; @@ -157,7 +161,7 @@ public class OrgEmailSettings extends ResourceType { } public B fromOrgEmailSettings(OrgEmailSettings in) { - return fromResourceType(in) + return fromResource(in) .isDefaultSmtpServer(in.isDefaultSmtpServer()) .isDefaultOrgEmail(in.isDefaultOrgEmail()) .fromEmailAddress(in.getFromEmailAddress()) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgGeneralSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgGeneralSettings.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgGeneralSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgGeneralSettings.java index b6da767354..578ba49010 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgGeneralSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgGeneralSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; @@ -24,6 +24,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -55,7 +58,7 @@ import com.google.common.base.Objects.ToStringHelper; "useServerBootSequence", "delayAfterPowerOnSeconds" }) -public class OrgGeneralSettings extends ResourceType { +public class OrgGeneralSettings extends Resource { public static Builder builder() { return new ConcreteBuilder(); @@ -69,7 +72,7 @@ public class OrgGeneralSettings extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private Boolean canPublishCatalogs; private Integer deployedVMQuota; @@ -123,7 +126,7 @@ public class OrgGeneralSettings extends ResourceType { } public B fromOrgGeneralSettings(OrgGeneralSettings in) { - return fromResourceType(in) + return fromResource(in) .canPublishCatalogs(in.canPublishCatalogs()) .deployedVMQuota(in.getDeployedVMQuota()) .storedVmQuota(in.getStoredVmQuota()) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapGroupAttributes.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapGroupAttributes.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapGroupAttributes.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapGroupAttributes.java index db8a3b56cc..77babb9f3c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapGroupAttributes.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapGroupAttributes.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapSettings.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapSettings.java index 93df7dd3b7..82fa539d69 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -30,6 +30,9 @@ import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; + import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -60,7 +63,7 @@ import com.google.common.collect.Maps; "customUsersOu", "customOrgLdapSettings" }) -public class OrgLdapSettings extends ResourceType { +public class OrgLdapSettings extends Resource { @XmlType @XmlEnum(String.class) @@ -108,7 +111,7 @@ public class OrgLdapSettings extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private LdapMode ldapMode; private String customUsersOu; @@ -152,7 +155,7 @@ public class OrgLdapSettings extends ResourceType { } public B fromOrgLdapSettings(OrgLdapSettings in) { - return fromResourceType(in) + return fromResource(in) .ldapMode(in.getLdapMode()) .customUsersOu(in.getCustomUsersOu()) .customOrgLdapSettings(in.getCustomOrgLdapSettings()); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapUserAttributes.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapUserAttributes.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapUserAttributes.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapUserAttributes.java index dd945b1b98..c31f0b0c5e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLdapUserAttributes.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLdapUserAttributes.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLeaseSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLeaseSettings.java similarity index 95% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLeaseSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLeaseSettings.java index 9082f11771..0f9109c137 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgLeaseSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgLeaseSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; @@ -24,6 +24,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -51,7 +54,7 @@ import com.google.common.base.Objects.ToStringHelper; "deploymentLeaseSeconds", "storageLeaseSeconds" }) -public class OrgLeaseSettings extends ResourceType { +public class OrgLeaseSettings extends Resource { public static Builder builder() { return new ConcreteBuilder(); } @@ -64,7 +67,7 @@ public class OrgLeaseSettings extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private Boolean deleteOnStorageLeaseExpiration; private Integer deploymentLeaseSeconds; @@ -100,7 +103,7 @@ public class OrgLeaseSettings extends ResourceType { } public B fromOrgLeaseSettings(OrgLeaseSettings in) { - return fromResourceType(in) + return fromResource(in) .deleteOnStorageLeaseExpiration(in.deleteOnStorageLeaseExpiration()) .deploymentLeaseSeconds(in.getDeploymentLeaseSeconds()) .storageLeaseSeconds(in.getStorageLeaseSeconds()); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgList.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgList.java index 0788641c73..716479dfc1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgList.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgNetwork.java similarity index 92% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgNetwork.java index 6ba622207b..0c8034df0e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgNetwork.java @@ -16,13 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.network.IpAddresses; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; +import org.jclouds.vcloud.director.v1_5.domain.network.Network.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgPasswordPolicySettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgPasswordPolicySettings.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgPasswordPolicySettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgPasswordPolicySettings.java index a19d74caff..a2793b7207 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgPasswordPolicySettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgPasswordPolicySettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; @@ -24,6 +24,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -40,7 +43,7 @@ import com.google.common.base.Objects.ToStringHelper; "invalidLoginsBeforeLockout", "accountLockoutIntervalMinutes" }) -public class OrgPasswordPolicySettings extends ResourceType { +public class OrgPasswordPolicySettings extends Resource { public static Builder builder() { return new ConcreteBuilder(); } @@ -53,7 +56,7 @@ public class OrgPasswordPolicySettings extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private boolean accountLockoutEnabled; private int invalidLoginsBeforeLockout; @@ -89,7 +92,7 @@ public class OrgPasswordPolicySettings extends ResourceType { } public B fromOrgPasswordPolicySettings(OrgPasswordPolicySettings in) { - return fromResourceType(in) + return fromResource(in) .accountLockoutEnabled(in.isAccountLockoutEnabled()) .invalidLoginsBeforeLockout(in.getInvalidLoginsBeforeLockout()) .accountLockoutIntervalMinutes(in.getAccountLockoutIntervalMinutes()); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgSettings.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgSettings.java index 64aa4b1b65..d4e896d5c5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; @@ -24,6 +24,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; /** @@ -59,7 +62,7 @@ import com.google.common.base.Objects.ToStringHelper; "emailSettings", "passwordPolicy" }) -public class OrgSettings extends ResourceType { +public class OrgSettings extends Resource { public static Builder builder() { return new ConcreteBuilder(); } @@ -72,7 +75,7 @@ public class OrgSettings extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private OrgGeneralSettings generalSettings; private OrgLeaseSettings vAppLeaseSettings; @@ -135,7 +138,7 @@ public class OrgSettings extends ResourceType { } public B fromOrgSettings(OrgSettings in) { - return fromResourceType(in) + return fromResource(in) .generalSettings(in.getGeneralSettings()) .vAppLeaseSettings(in.getVAppLeaseSettings()) .vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings()) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgVAppTemplateLeaseSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgVAppTemplateLeaseSettings.java similarity index 94% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgVAppTemplateLeaseSettings.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgVAppTemplateLeaseSettings.java index e649d87a29..743cae4373 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgVAppTemplateLeaseSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/OrgVAppTemplateLeaseSettings.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.org; import static com.google.common.base.Objects.equal; @@ -24,6 +24,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; +import org.jclouds.vcloud.director.v1_5.domain.Resource.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -49,7 +52,7 @@ import com.google.common.base.Objects.ToStringHelper; "deleteOnStorageLeaseExpiration", "storageLeaseSeconds" }) -public class OrgVAppTemplateLeaseSettings extends ResourceType { +public class OrgVAppTemplateLeaseSettings extends Resource { public static Builder builder() { return new ConcreteBuilder(); } @@ -62,7 +65,7 @@ public class OrgVAppTemplateLeaseSettings extends ResourceType { private static class ConcreteBuilder extends Builder { } - public static abstract class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends Resource.Builder { private Boolean deleteOnStorageLeaseExpiration; private Integer storageLeaseSeconds; @@ -90,7 +93,7 @@ public class OrgVAppTemplateLeaseSettings extends ResourceType { } public B fromOrgVAppTemplateLeaseSettings(OrgVAppTemplateLeaseSettings in) { - return fromResourceType(in) + return fromResource(in) .deleteOnStorageLeaseExpiration(in.deleteOnStorageLeaseExpiration()) .storageLeaseSeconds(in.getStorageLeaseSeconds()); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/package-info.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/package-info.java new file mode 100644 index 0000000000..bef902de02 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/org/package-info.java @@ -0,0 +1,35 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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. + */ +@XmlSchema(namespace = VCLOUD_1_5_NS, + elementFormDefault = XmlNsForm.QUALIFIED, + xmlns = { + @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS) + } +) +@XmlAccessorType(XmlAccessType.FIELD) +package org.jclouds.vcloud.director.v1_5.domain.org; + +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; + diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CaptureVAppParams.java similarity index 90% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CaptureVAppParams.java index 4836a09b6c..a9fb259c0b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CaptureVAppParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -37,6 +37,15 @@ import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneMediaParams.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneMediaParams.java index 1988a5f5ed..7efebdb644 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneMediaParams.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; @@ -25,6 +25,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.params.ParamsType.Builder; + import com.google.common.base.Objects; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneVAppParams.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneVAppParams.java index 96b44d4f41..5cb6e10d5c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneVAppParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneVAppTemplateParams.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneVAppTemplateParams.java index aa4e4ac76f..2040f92a3c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/CloneVAppTemplateParams.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; @@ -27,6 +27,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.params.ParamsType.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ComposeVAppParams.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ComposeVAppParams.java index 4e149a2920..fbdcc3fed0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ComposeVAppParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -28,6 +28,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.params.VAppCreationParams.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableList; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ControlAccessParams.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ControlAccessParams.java index 05eedca941..dd1c66f3c9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ControlAccessParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ControlAccessParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.AccessSetting; + import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DeployVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/DeployVAppParams.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DeployVAppParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/DeployVAppParams.java index 367e33428c..03d8f61a71 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/DeployVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/DeployVAppParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateOvfParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateOvfParams.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateOvfParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateOvfParams.java index 0c62584046..d88e6fe0b0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateOvfParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateOvfParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; @@ -24,6 +24,8 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.params.VAppCreationParams.Builder; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateVAppParams.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateVAppParams.java index 2c4baef1c4..438901d96e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateVAppParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; @@ -28,6 +28,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.params.VAppCreationParams.Builder; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateVAppTemplateParams.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateVAppTemplateParams.java index d004efc0cd..a321683f46 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiateVAppTemplateParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiationParams.java similarity index 89% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiationParams.java index c3e3e59255..9fed19580d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/InstantiationParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -35,6 +35,14 @@ import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.ProductSection; import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MediaInsertOrEjectParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/MediaInsertOrEjectParams.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MediaInsertOrEjectParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/MediaInsertOrEjectParams.java index 12c568c436..362cbc4797 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MediaInsertOrEjectParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/MediaInsertOrEjectParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; @@ -24,6 +24,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; + import com.google.common.base.Objects; /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ParamsType.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ParamsType.java index f90fb4b735..5c2805ad63 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/ParamsType.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/PublishCatalogParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/PublishCatalogParams.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/PublishCatalogParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/PublishCatalogParams.java index 2436f06bee..1bd9b81b03 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/PublishCatalogParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/PublishCatalogParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RecomposeVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/RecomposeVAppParams.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RecomposeVAppParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/RecomposeVAppParams.java index db4549871a..ba809358c5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RecomposeVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/RecomposeVAppParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; @@ -27,6 +27,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.Vm; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/RelocateParams.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/RelocateParams.java index 26f7d24fef..7425e027c3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/RelocateParams.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -26,6 +26,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; + import com.google.common.base.Objects; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/SourcedCompositionItemParam.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/SourcedCompositionItemParam.java index 37e6c5b523..e76d24ffd7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/SourcedCompositionItemParam.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -29,6 +29,9 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkAssignment; + import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UndeployVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/UndeployVAppParams.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UndeployVAppParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/UndeployVAppParams.java index 9dae45bca0..dcb37b6ab9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UndeployVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/UndeployVAppParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/UploadVAppTemplateParams.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/UploadVAppTemplateParams.java index d40715e3df..0b6f67a63f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/UploadVAppTemplateParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; @@ -24,6 +24,8 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.params.ParamsType.Builder; + import com.google.common.base.Objects; /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/VAppCreationParams.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParams.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/VAppCreationParams.java index 41da48e1e6..c558d1c1c6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/VAppCreationParams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.params; import static com.google.common.base.Objects.equal; @@ -25,6 +25,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Reference; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/package-info.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/package-info.java new file mode 100644 index 0000000000..b37b11c7c1 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/params/package-info.java @@ -0,0 +1,35 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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. + */ +@XmlSchema(namespace = VCLOUD_1_5_NS, + elementFormDefault = XmlNsForm.QUALIFIED, + xmlns = { + @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS) + } +) +@XmlAccessorType(XmlAccessType.FIELD) +package org.jclouds.vcloud.director.v1_5.domain.params; + +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; + diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/ContainerType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/ContainerType.java index 659c7b4917..ecc343f327 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/ContainerType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/ContainerType.java @@ -23,7 +23,7 @@ import static com.google.common.base.Objects.equal; import javax.xml.bind.annotation.XmlAttribute; -import org.jclouds.vcloud.director.v1_5.domain.ResourceType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -37,7 +37,7 @@ import com.google.common.base.Objects.ToStringHelper; * * @author grkvlt@apache.org */ -public class ContainerType extends ResourceType { +public class ContainerType extends Resource { public static Builder builder() { return new ConcreteBuilder(); @@ -48,7 +48,7 @@ public class ContainerType extends ResourceType { return builder().fromContainerType(this); } - public static class Builder> extends ResourceType.Builder { + public static class Builder> extends Resource.Builder { private String name; private Integer page; @@ -93,7 +93,7 @@ public class ContainerType extends ResourceType { } public B fromContainerType(ContainerType in) { - return fromResourceType(in).name(in.getName()).page(in.getPage()).pageSize(in.getPageSize()).total(in.getTotal()); + return fromResource(in).name(in.getName()).page(in.getPage()).pageSize(in.getPageSize()).total(in.getTotal()); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/CustomizationSection.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/CustomizationSection.java index 471395d1bf..fa2fb84f5e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/CustomizationSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.section; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.vcloud.director.v1_5.domain.Link; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/GuestCustomizationSection.java similarity index 99% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/GuestCustomizationSection.java index 3d0d17bbac..99f1ec2f97 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/GuestCustomizationSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.section; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -32,6 +32,7 @@ import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.vcloud.director.v1_5.domain.Link; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/LeaseSettingsSection.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/LeaseSettingsSection.java index 8d838d828a..ee98abc55c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/LeaseSettingsSection.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.section; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -34,6 +34,7 @@ import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.vcloud.director.v1_5.domain.Link; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/NetworkConfigSection.java similarity index 96% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/NetworkConfigSection.java index a7a258d7a9..ad8ed2846c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/NetworkConfigSection.java @@ -17,7 +17,7 @@ * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.section; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -33,6 +33,8 @@ import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.vcloud.director.v1_5.domain.Link; +import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/NetworkConnectionSection.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/NetworkConnectionSection.java index 65b37518f6..1b1265ec3f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/NetworkConnectionSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.section; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -31,6 +31,8 @@ import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.vcloud.director.v1_5.domain.Link; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection; import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/OperatingSystemSection.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/OperatingSystemSection.java index 654fc6d0fe..48634bdb37 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OperatingSystemSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/OperatingSystemSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.section; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -33,6 +33,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Link; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RuntimeInfoSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/RuntimeInfoSection.java similarity index 97% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RuntimeInfoSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/RuntimeInfoSection.java index a923eff86f..1df7da8198 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RuntimeInfoSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/RuntimeInfoSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.section; import static com.google.common.base.Objects.equal; @@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jclouds.dmtf.ovf.SectionType; +import org.jclouds.vcloud.director.v1_5.domain.VMWareTools; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/VirtualHardwareSection.java similarity index 98% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/VirtualHardwareSection.java index 34961da6c0..e457ab535c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VirtualHardwareSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/VirtualHardwareSection.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.vcloud.director.v1_5.domain; +package org.jclouds.vcloud.director.v1_5.domain.section; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; @@ -33,6 +33,8 @@ import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; +import org.jclouds.vcloud.director.v1_5.domain.Link; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/package-info.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/package-info.java new file mode 100644 index 0000000000..021aada8f9 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/section/package-info.java @@ -0,0 +1,35 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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. + */ +@XmlSchema(namespace = VCLOUD_1_5_NS, + elementFormDefault = XmlNsForm.QUALIFIED, + xmlns = { + @XmlNs(prefix = "", namespaceURI = VCLOUD_1_5_NS) + } +) +@XmlAccessorType(XmlAccessType.FIELD) +package org.jclouds.vcloud.director.v1_5.domain.section; + +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; + diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncClient.java index ef431db0b3..9786535ebe 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncClient.java @@ -38,7 +38,7 @@ import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; -import org.jclouds.vcloud.director.v1_5.domain.CatalogType; +import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; @@ -57,7 +57,7 @@ public interface CatalogAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getCatalog(@EndpointParam URI catalogUri); + ListenableFuture getCatalog(@EndpointParam URI catalogUri); /** * Creates a catalog item in a catalog. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java index d5e4e53aad..c48029947a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; -import org.jclouds.vcloud.director.v1_5.domain.CatalogType; +import org.jclouds.vcloud.director.v1_5.domain.Catalog; /** * Provides synchronous access to {@link Catalog} objects. @@ -45,7 +45,7 @@ public interface CatalogClient { * @param catalogUri the reference for the catalog * @return a catalog */ - CatalogType getCatalog(URI catalogUri); + Catalog getCatalog(URI catalogUri); /** * Creates a catalog item in a catalog. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java index 07ee05a84f..bad50893c3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java @@ -37,10 +37,10 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java index 6180e9f33e..2d1c955743 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java @@ -23,10 +23,10 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; /** * Provides synchronous access to {@link Media}. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java index bc1eaca164..bf10e6eac4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java @@ -29,7 +29,7 @@ import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.vcloud.director.v1_5.domain.Network; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java index 95131d43d9..bbbc09af9e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java @@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.Network; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; /** * Provides synchronous access to {@link Network}. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java index e7264b232d..5f077e3bc7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java @@ -37,9 +37,9 @@ import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; -import org.jclouds.vcloud.director.v1_5.domain.Org; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.org.Org; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java index b2d226cd71..6776fd6a83 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java @@ -23,9 +23,9 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; -import org.jclouds.vcloud.director.v1_5.domain.Org; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.org.Org; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; /** * Provides synchronous access to {@link Org}. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncClient.java index 6793f86307..3da8d44b23 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncClient.java @@ -61,28 +61,28 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; -import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; -import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; -import org.jclouds.vcloud.director.v1_5.domain.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; -import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; -import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; -import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection; import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem; +import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; +import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.functions.ReturnPayloadBytes; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java index 4dbc9aae6f..f8dc431db4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppClient.java @@ -25,28 +25,28 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; -import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; -import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; -import org.jclouds.vcloud.director.v1_5.domain.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; -import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; -import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; -import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection; import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem; +import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; +import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; /** * Provides synchronous access to {@link VApp} objects. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java index 1a60ee16b8..28afee0431 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncClient.java @@ -49,18 +49,18 @@ import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.References; -import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; +import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java index 4f5a74a5bb..8bcfc9e6b5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java @@ -24,18 +24,18 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.References; -import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; +import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; /** * Provides synchronous access to {@link VAppTemplate} objects. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java index 1a27f482c9..5f5e203c05 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java @@ -35,17 +35,17 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; -import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Media; -import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.domain.params.CaptureVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.ComposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import com.google.common.util.concurrent.ListenableFuture; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java index d80c0ba680..b496e60dad 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java @@ -23,17 +23,17 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; -import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Media; -import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.domain.params.CaptureVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.ComposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UploadVAppTemplateParams; /** * Provides synchronous access to a vDC. diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncClient.java index 418c09358f..f2309d28c6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncClient.java @@ -39,7 +39,7 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.Owner; -import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams; +import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClient.java index 5cffad6c3b..c4c9d4308c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClient.java @@ -25,7 +25,7 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.Owner; -import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams; +import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.MetadataClient; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncClient.java index 883a8f4a85..31c553ee04 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncClient.java @@ -36,9 +36,9 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import org.jclouds.vcloud.director.v1_5.domain.ExternalNetwork; -import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.network.ExternalNetwork; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClient.java index 01e4884ebc..a40a17ccc1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClient.java @@ -23,9 +23,9 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.Network; -import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncClient.java index 11c303cda9..7fb8f1beb9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncClient.java @@ -35,14 +35,14 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; -import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgGeneralSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLeaseSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClient.java index ac86ada421..89a11cb38a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClient.java @@ -23,14 +23,14 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; -import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgGeneralSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLeaseSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/OrgReferenceToTaskListEndpoint.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/OrgReferenceToTaskListEndpoint.java index 0bbc020763..5cef088899 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/OrgReferenceToTaskListEndpoint.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/OrgReferenceToTaskListEndpoint.java @@ -26,7 +26,7 @@ import javax.inject.Singleton; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Link; -import org.jclouds.vcloud.director.v1_5.domain.Org; +import org.jclouds.vcloud.director.v1_5.domain.org.Org; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import com.google.common.base.Function; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/EntityPredicates.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/EntityPredicates.java index 8d6f07e629..bdd71dc257 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/EntityPredicates.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/EntityPredicates.java @@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; -import org.jclouds.vcloud.director.v1_5.domain.EntityType; +import org.jclouds.vcloud.director.v1_5.domain.Entity; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; @@ -41,7 +41,7 @@ public class EntityPredicates { * @param name value of the name attribute of the entity * @return predicate that will match entities of the given name */ - public static Predicate nameEquals(final String name) { + public static Predicate nameEquals(final String name) { checkNotNull(name, "name must be defined"); return new Predicate() { @@ -64,7 +64,7 @@ public class EntityPredicates { * @param name prefix of the name attribute of the entity * @return predicate that will match entities with names starting with the given prefix */ - public static Predicate nameStartsWith(final String prefix) { + public static Predicate nameStartsWith(final String prefix) { checkNotNull(prefix, "prefix must be defined"); return new Predicate() { @@ -88,7 +88,7 @@ public class EntityPredicates { * @param names collection of values for the name attribute of the entity * @return predicate that will match entities with names starting with the given prefix */ - public static Predicate nameIn(final Iterable names) { + public static Predicate nameIn(final Iterable names) { checkNotNull(names, "names must be defined"); return new Predicate() { @@ -113,7 +113,7 @@ public class EntityPredicates { * @return predicate that will match entities of the given type * @see VCloudDirectorMediaType */ - public static Predicate typeEquals(final String type) { + public static Predicate typeEquals(final String type) { checkNotNull(type, "type must be defined"); return new Predicate() { @@ -137,7 +137,7 @@ public class EntityPredicates { * @return predicate that will match entities with the given URI * @see VCloudDirectorMediaType */ - public static Predicate hrefEquals(final URI href) { + public static Predicate hrefEquals(final URI href) { checkNotNull(href, "href must be defined"); return new Predicate() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java index b74fcf888a..df302c2c27 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppClientLiveTest.java @@ -37,12 +37,12 @@ import org.jclouds.dmtf.cim.CimBoolean; import org.jclouds.dmtf.cim.CimString; import org.jclouds.dmtf.cim.CimUnsignedInt; import org.jclouds.dmtf.cim.CimUnsignedLong; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; -import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status; +import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java index 5f648123cb..01a27187df 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java @@ -30,8 +30,8 @@ import org.jclouds.crypto.CryptoStreams; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.util.Strings2; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.xml.internal.JAXBParser; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index b637c229ef..15b9f8a2dd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -57,12 +57,50 @@ import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.dmtf.ovf.environment.EnvironmentType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import org.jclouds.vcloud.director.v1_5.domain.CustomOrgLdapSettings.AuthenticationMechanism; -import org.jclouds.vcloud.director.v1_5.domain.CustomOrgLdapSettings.ConnectorType; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection.IpAddressAllocationMode; -import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings.LdapMode; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.VirtualSystem; +import org.jclouds.vcloud.director.v1_5.domain.network.ExternalNetwork; +import org.jclouds.vcloud.director.v1_5.domain.network.IpAddresses; +import org.jclouds.vcloud.director.v1_5.domain.network.IpRange; +import org.jclouds.vcloud.director.v1_5.domain.network.IpRanges; +import org.jclouds.vcloud.director.v1_5.domain.network.IpScope; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkFeatures; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkServiceType; +import org.jclouds.vcloud.director.v1_5.domain.network.RouterInfo; +import org.jclouds.vcloud.director.v1_5.domain.network.SyslogServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection.IpAddressAllocationMode; +import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg; +import org.jclouds.vcloud.director.v1_5.domain.org.CustomOrgLdapSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.Org; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgGeneralSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapGroupAttributes; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapUserAttributes; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLeaseSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.CustomOrgLdapSettings.AuthenticationMechanism; +import org.jclouds.vcloud.director.v1_5.domain.org.CustomOrgLdapSettings.ConnectorType; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings.LdapMode; +import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.query.ContainerType; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import com.beust.jcommander.internal.Maps; import com.google.common.base.Splitter; @@ -75,11 +113,11 @@ import com.google.common.net.InetAddresses; */ public class Checks { - public static void checkResourceEntityType(ResourceEntityType resourceEntity) { + public static void checkResourceEntityType(ResourceEntity resourceEntity) { checkResourceEntityType(resourceEntity, true); } - public static void checkResourceEntityType(ResourceEntityType resourceEntity, boolean ready) { + public static void checkResourceEntityType(ResourceEntity resourceEntity, boolean ready) { // Check optional fields // NOTE status cannot be checked (TODO: doesn't status have a range of valid values?) Set files = resourceEntity.getFiles(); @@ -91,7 +129,7 @@ public class Checks { checkEntityType(resourceEntity); } - public static void checkEntityType(EntityType entity) { + public static void checkEntityType(Entity entity) { // Check required fields assertNotNull(entity.getName(), String.format(NOT_NULL_OBJ_FIELD_FMT, "Name", "EntityType")); @@ -139,18 +177,18 @@ public class Checks { * * @see #checkResourceType(ResourceType, Collection) */ - public static void checkResourceType(ResourceType resource) { + public static void checkResourceType(Resource resource) { checkResourceType(resource, VCloudDirectorMediaType.ALL); } /** * @see #checkResourceType(ResourceType, Collection) */ - public static void checkResourceType(ResourceType resource, String type) { + public static void checkResourceType(Resource resource, String type) { checkResourceType(resource, ImmutableSet.of(type)); } - public static void checkResourceType(ResourceType resource, Collection validTypes) { + public static void checkResourceType(Resource resource, Collection validTypes) { // Check optional fields URI href = resource.getHref(); if (href != null) checkHref(href); @@ -331,7 +369,7 @@ public class Checks { checkCatalogType(catalog); } - public static void checkCatalogType(CatalogType catalog) { + public static void checkCatalogType(Catalog catalog) { // Check optional elements/attributes Owner owner = catalog.getOwner(); if (owner != null) checkOwner(owner); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java index 0335daf5ad..cbc0ffbdd9 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java @@ -27,7 +27,7 @@ import org.jclouds.http.HttpResponse; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClientExpectTest; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; -import org.jclouds.vcloud.director.v1_5.domain.CatalogType; +import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; @@ -66,7 +66,7 @@ public class CatalogClientExpectTest extends VCloudDirectorClientExpectTest { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse); - CatalogType expected = catalog(); + Catalog expected = catalog(); URI catalogURI = URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"); assertEquals(client.getCatalogClient().getCatalog(catalogURI), expected); @@ -375,8 +375,8 @@ public class CatalogClientExpectTest extends VCloudDirectorClientExpectTest { assertEquals(client.getCatalogClient().getCatalogItemMetadataClient().deleteMetadataEntry(catalogItemURI, "KEY"), expected); } - public static final CatalogType catalog() { - return CatalogType.builder() + public static final Catalog catalog() { + return Catalog.builder() .name("QunyingTestCatalog") .type("application/vnd.vmware.vcloud.catalog+xml") .id("urn:vcloud:catalog:7212e451-76e1-4631-b2de-ba1dfd8080e4") diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index bb92d538d3..ddf7c76c24 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -38,7 +38,7 @@ import static org.testng.Assert.assertTrue; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; -import org.jclouds.vcloud.director.v1_5.domain.CatalogType; +import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; @@ -136,7 +136,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(description = "GET /catalog/{id}") public void testGetCatalog() { - CatalogType catalog = catalogClient.getCatalog(catalogRef.getHref()); + Catalog catalog = catalogClient.getCatalog(catalogRef.getHref()); assertNotNull(catalog); // Double check it's pointing at the correct catalog assertEquals(catalog.getHref(), catalogRef.getHref()); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java index be405a174c..d485fc1614 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java @@ -26,12 +26,12 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.File; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media.ImageType; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index 4776eb7557..e0e7c16440 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -52,7 +52,6 @@ import java.util.Set; import org.jclouds.io.Payloads; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.File; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; @@ -63,6 +62,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates; import org.testng.annotations.AfterClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index 64842221e4..df628d4e62 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -26,22 +26,22 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import org.jclouds.vcloud.director.v1_5.domain.DhcpService; import org.jclouds.vcloud.director.v1_5.domain.Error; -import org.jclouds.vcloud.director.v1_5.domain.IpAddresses; -import org.jclouds.vcloud.director.v1_5.domain.IpRange; -import org.jclouds.vcloud.director.v1_5.domain.IpRanges; -import org.jclouds.vcloud.director.v1_5.domain.IpScope; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.Network; -import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; -import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures; -import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; -import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.network.DhcpService; +import org.jclouds.vcloud.director.v1_5.domain.network.IpAddresses; +import org.jclouds.vcloud.director.v1_5.domain.network.IpRange; +import org.jclouds.vcloud.director.v1_5.domain.network.IpRanges; +import org.jclouds.vcloud.director.v1_5.domain.network.IpScope; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkFeatures; +import org.jclouds.vcloud.director.v1_5.domain.network.SyslogServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.network.Network.FenceMode; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 7f98d5df26..ad50ecd926 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -34,9 +34,9 @@ import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.Network; -import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index 2bcf6eb09e..70008826d1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -31,9 +31,9 @@ import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.Org; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.org.Org; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index 6630bd1cdd..33dd982ad6 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -34,13 +34,13 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; -import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.Org; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.org.Org; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java index ceff2b4b55..9230ecf877 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientLiveTest.java @@ -36,7 +36,7 @@ import java.util.Set; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Entity; import org.jclouds.vcloud.director.v1_5.domain.Link; -import org.jclouds.vcloud.director.v1_5.domain.ResourceType; +import org.jclouds.vcloud.director.v1_5.domain.Resource; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; @@ -232,9 +232,9 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { return hrefs; } - private Set toHrefs(Iterable resources) { + private Set toHrefs(Iterable resources) { Set hrefs = new LinkedHashSet(); - for (ResourceType resource : resources) { + for (Resource resource : resources) { hrefs.add(resource.getHref()); } return hrefs; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java index 3db51c5ee8..674ef8da77 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java @@ -25,11 +25,11 @@ import static org.testng.Assert.assertNotNull; import java.net.URI; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.TasksList; import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java index b54e0626cb..700fd453ca 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientExpectTest.java @@ -25,31 +25,31 @@ import java.net.URI; import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; -import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Error; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.Link; -import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; -import org.jclouds.vcloud.director.v1_5.domain.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; -import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; -import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; -import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection; import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem; +import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; +import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java index e5051647ba..476fa75c4e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java @@ -80,40 +80,40 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.AccessSetting; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; -import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; -import org.jclouds.vcloud.director.v1_5.domain.MediaInsertOrEjectParams; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection.IpAddressAllocationMode; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; -import org.jclouds.vcloud.director.v1_5.domain.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; -import org.jclouds.vcloud.director.v1_5.domain.RasdItem; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; -import org.jclouds.vcloud.director.v1_5.domain.RecomposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; -import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status; -import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer; import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswerChoice; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection.IpAddressAllocationMode; +import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; +import org.jclouds.vcloud.director.v1_5.domain.params.DeployVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.MediaInsertOrEjectParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; +import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; +import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java index e42ea30c9e..c78a3f5746 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientExpectTest.java @@ -41,31 +41,31 @@ import java.util.TimeZone; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; -import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.FirewallRule; -import org.jclouds.vcloud.director.v1_5.domain.FirewallRuleProtocols; -import org.jclouds.vcloud.director.v1_5.domain.FirewallService; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.IpRange; -import org.jclouds.vcloud.director.v1_5.domain.IpRanges; -import org.jclouds.vcloud.director.v1_5.domain.IpScope; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.NatOneToOneVmRule; -import org.jclouds.vcloud.director.v1_5.domain.NatRule; -import org.jclouds.vcloud.director.v1_5.domain.NatService; -import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; -import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures; +import org.jclouds.vcloud.director.v1_5.domain.network.FirewallRule; +import org.jclouds.vcloud.director.v1_5.domain.network.FirewallRuleProtocols; +import org.jclouds.vcloud.director.v1_5.domain.network.FirewallService; +import org.jclouds.vcloud.director.v1_5.domain.network.IpRange; +import org.jclouds.vcloud.director.v1_5.domain.network.IpRanges; +import org.jclouds.vcloud.director.v1_5.domain.network.IpScope; +import org.jclouds.vcloud.director.v1_5.domain.network.NatOneToOneVmRule; +import org.jclouds.vcloud.director.v1_5.domain.network.NatRule; +import org.jclouds.vcloud.director.v1_5.domain.network.NatService; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkFeatures; +import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.Network.FenceMode; +import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java index 674084686f..85b5607211 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java @@ -48,25 +48,25 @@ import java.util.Set; import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.vcloud.director.v1_5.AbstractVAppClientLiveTest; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; -import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link.Rel; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection.IpAddressAllocationMode; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection.IpAddressAllocationMode; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; +import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; +import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.References; -import org.jclouds.vcloud.director.v1_5.domain.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.testng.annotations.AfterClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index 37872d3518..1039da78a5 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -28,21 +28,21 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.Capabilities; import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage; -import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; -import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.ComputeCapacity; import org.jclouds.vcloud.director.v1_5.domain.Error; -import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media.ImageType; +import org.jclouds.vcloud.director.v1_5.domain.params.CaptureVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.ComposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 4db5a17c49..4cbc4c783a 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -31,24 +31,24 @@ import static org.testng.Assert.fail; import java.util.Map; import java.util.Set; -import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; -import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; -import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams; -import org.jclouds.vcloud.director.v1_5.domain.InstantiationParams; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.Network.FenceMode; +import org.jclouds.vcloud.director.v1_5.domain.params.CaptureVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.ComposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.InstantiationParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType; +import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; @@ -308,8 +308,8 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { assertEquals(uploadedVAppTemplate.getName(), name, String.format(OBJ_FIELD_EQ, "VAppTemplate", "name", name, uploadedVAppTemplate.getName())); - ResourceEntityType.Status expectedStatus = ResourceEntityType.Status.UNRESOLVED; - ResourceEntityType.Status actualStatus = uploadedVAppTemplate.getStatus(); + ResourceEntity.Status expectedStatus = ResourceEntity.Status.UNRESOLVED; + ResourceEntity.Status actualStatus = uploadedVAppTemplate.getStatus(); assertEquals(actualStatus, expectedStatus, String.format(OBJ_FIELD_EQ, "VAppTemplate", "status", expectedStatus, actualStatus)); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java index 4d2b5433a0..ad2ab171a6 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientExpectTest.java @@ -27,9 +27,9 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Owner; -import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java index 957f6b331d..fbe9820376 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java @@ -38,9 +38,9 @@ import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Owner; -import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.User; +import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java index 7ff0c808d3..77ed62c295 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientExpectTest.java @@ -25,9 +25,9 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.domain.Link; -import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; import org.jclouds.vcloud.director.v1_5.features.NetworkClientExpectTest; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java index 0ecbd05541..1b96b13bcc 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkClientLiveTest.java @@ -31,16 +31,16 @@ import static org.testng.Assert.fail; import java.util.Collections; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.ExternalNetwork; -import org.jclouds.vcloud.director.v1_5.domain.IpScope; -import org.jclouds.vcloud.director.v1_5.domain.Network; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; -import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures; -import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.RouterInfo; -import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings; import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.network.ExternalNetwork; +import org.jclouds.vcloud.director.v1_5.domain.network.IpScope; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkFeatures; +import org.jclouds.vcloud.director.v1_5.domain.network.RouterInfo; +import org.jclouds.vcloud.director.v1_5.domain.network.SyslogServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java index 4c57f0fb25..4fc6b8ac7a 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientExpectTest.java @@ -24,17 +24,17 @@ import java.net.URI; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; -import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; import org.jclouds.vcloud.director.v1_5.domain.Link; -import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.network.SmtpServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgGeneralSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLeaseSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.testng.annotations.Test; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java index cb8ee41e50..53e85123cd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgClientLiveTest.java @@ -24,17 +24,17 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.R import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgSettings; -import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.network.SmtpServerSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgGeneralSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLeaseSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java index 3490762c10..e1213e9571 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/GroupClientLiveTest.java @@ -26,8 +26,8 @@ import static org.testng.Assert.fail; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Group; -import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgLdapSettings; import org.jclouds.vcloud.director.v1_5.features.admin.GroupClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java index 81ac32bcb0..959893ea9b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/UserClientLiveTest.java @@ -30,9 +30,9 @@ import static org.testng.AssertJUnit.assertFalse; import java.net.URI; import org.jclouds.rest.AuthorizationException; -import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; +import org.jclouds.vcloud.director.v1_5.domain.org.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.jclouds.vcloud.director.v1_5.domain.User; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java index 03501d9110..2ebe42c5c4 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java @@ -47,23 +47,23 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; -import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams; -import org.jclouds.vcloud.director.v1_5.domain.InstantiationParams; import org.jclouds.vcloud.director.v1_5.domain.Link; -import org.jclouds.vcloud.director.v1_5.domain.Network; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; -import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status; +import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; +import org.jclouds.vcloud.director.v1_5.domain.network.Network; +import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.org.Org; +import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.params.InstantiationParams; +import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.RoleReferences; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.User; import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.features.TaskClient; From b3e1b675ef7a4bf9cd72827a77cdf5ac889fcf6d Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 12 Apr 2012 12:20:25 -0600 Subject: [PATCH 49/69] moved AnonymousProviderMetadata to the right package --- .../test/java/org/jclouds/byon/BYONComputeServiceTest.java | 2 +- .../cloudstack/features/BaseCloudStackAsyncClientTest.java | 2 +- .../java/org/jclouds/cloudstack/filters/QuerySignerTest.java | 2 +- .../test/java/org/jclouds/aws/filters/FormSignerTest.java | 2 +- .../internal/TerremarkVCloudLoginAsyncClientTest.java | 2 +- .../internal/TerremarkVCloudVersionsAsyncClientTest.java | 2 +- .../{rest => providers}/AnonymousProviderMetadata.java | 5 +++-- .../main/java/org/jclouds/rest/internal/ContextBuilder.java | 2 +- core/src/test/java/org/jclouds/http/BaseJettyTest.java | 2 +- .../test/java/org/jclouds/rest/InputParamValidatorTest.java | 1 + .../java/org/jclouds/rest/internal/ContextBuilderTest.java | 2 +- .../jclouds/rest/internal/RestAnnotationProcessorTest.java | 2 +- 12 files changed, 14 insertions(+), 12 deletions(-) rename core/src/main/java/org/jclouds/{rest => providers}/AnonymousProviderMetadata.java (96%) diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java index ded60ea37f..258e837e5a 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java @@ -31,7 +31,7 @@ import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; -import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java index e0484cef19..66ca388819 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java @@ -25,8 +25,8 @@ import org.jclouds.cloudstack.config.CloudStackRestClientModule; import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java index fe540e843f..25fd9ae0c9 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java @@ -26,7 +26,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; diff --git a/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java b/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java index adeb2f8f10..06ddfdebfd 100644 --- a/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java +++ b/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java @@ -30,7 +30,7 @@ import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.io.Payloads; import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.RequestSigner; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.jclouds.rest.internal.ContextBuilder; diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java index 99e8f6862b..f63b0a87e1 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java @@ -29,8 +29,8 @@ import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.trmk.vcloud_0_8.endpoints.VCloudLogin; diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java index c1226a3945..a1ef333f32 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java @@ -25,8 +25,8 @@ import java.lang.reflect.Method; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.trmk.vcloud_0_8.xml.SupportedVersionsHandler; diff --git a/core/src/main/java/org/jclouds/rest/AnonymousProviderMetadata.java b/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java similarity index 96% rename from core/src/main/java/org/jclouds/rest/AnonymousProviderMetadata.java rename to core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java index 2675f01e13..4713b8c3d4 100644 --- a/core/src/main/java/org/jclouds/rest/AnonymousProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java @@ -16,15 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest; +package org.jclouds.providers; import static com.google.common.base.Preconditions.checkNotNull; import java.io.Closeable; import org.jclouds.apis.ApiMetadata; -import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.rest.AnonymousRestApiMetadata; +import org.jclouds.rest.RestContext; /** * Useful in creating arbitrary clients. diff --git a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java b/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java index 98a06af753..95a5feeb81 100644 --- a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java @@ -57,9 +57,9 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.lifecycle.config.LifeCycleModule; import org.jclouds.logging.config.LoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.ConfiguresCredentialStore; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestContext; diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index 8a9c196027..c08596437d 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -53,7 +53,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory; import org.jclouds.Constants; import org.jclouds.crypto.CryptoStreams; import org.jclouds.io.InputSuppliers; -import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.util.Strings2; diff --git a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java index 2fc944b0ab..2859bb17da 100644 --- a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java +++ b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java @@ -28,6 +28,7 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.predicates.validators.AllLowerCaseValidator; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.internal.ContextBuilder; diff --git a/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java b/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java index a2f6145493..f8884dc320 100644 --- a/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java @@ -34,7 +34,7 @@ import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.config.LoggingModule; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.CredentialStoreModule; import org.testng.annotations.Test; diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index 9432d41ef4..92e4375380 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -100,7 +100,7 @@ import org.jclouds.io.PayloadEnclosing; import org.jclouds.io.Payloads; import org.jclouds.javax.annotation.Nullable; import org.jclouds.logging.config.NullLoggingModule; -import org.jclouds.rest.AnonymousProviderMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.AsyncClientFactory; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; From ce8315f31fe462c48a4cba230837cb103bcf9e46 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 12 Apr 2012 15:52:18 -0400 Subject: [PATCH 50/69] Replaced the deprecated BlobStoreContextFactory with the new-style BlobStoreContextBuilder for gae-tweetstore --- .../tweetstore/config/GuiceServletConfig.java | 14 ++++---- .../controller/AddTweetsController.java | 4 +-- .../controller/EnqueueStoresController.java | 2 +- .../controller/StoreTweetsController.java | 6 ++-- .../ServiceToStoredTweetStatuses.java | 6 ++-- .../controller/AddTweetsControllerTest.java | 12 ++++--- .../EnqueueStoresControllerTest.java | 20 ++++++------ .../controller/StoreTweetsControllerTest.java | 32 ++++++++++--------- .../functions/KeyToStoredTweetStatusTest.java | 6 ++-- .../ServiceToStoredTweetStatusesTest.java | 13 ++++---- .../integration/TweetStoreLiveTest.java | 16 +++++----- 11 files changed, 69 insertions(+), 62 deletions(-) diff --git a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index c8a8ed000e..7f9364c47e 100644 --- a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -39,7 +39,7 @@ import java.util.Set; import javax.servlet.ServletContextEvent; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; import org.jclouds.demo.tweetstore.controller.AddTweetsController; import org.jclouds.demo.tweetstore.controller.EnqueueStoresController; @@ -73,16 +73,13 @@ import com.google.inject.servlet.ServletModule; public class GuiceServletConfig extends GuiceServletContextListener { public static final String PROPERTY_BLOBSTORE_CONTEXTS = "blobstore.contexts"; - private Map providerTypeToBlobStoreMap; + private Map> providerTypeToBlobStoreMap; private Twitter twitterClient; private String container; private Queue queue; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - - BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory(); - Properties props = loadJCloudsProperties(servletContextEvent); Module googleModule = new GoogleAppEngineConfigurationModule(); @@ -105,7 +102,8 @@ public class GuiceServletConfig extends GuiceServletContextListener { // instantiate and store references to all blobstores by provider name providerTypeToBlobStoreMap = Maps.newHashMap(); for (String hint : getBlobstoreContexts(props)) { - providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); + providerTypeToBlobStoreMap.put(hint, BlobStoreContextBuilder + .newBuilder(hint).modules(modules).overrides(props).build()); } // get a queue for submitting store tweet requests @@ -142,7 +140,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { return Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { - bind(new TypeLiteral>() { + bind(new TypeLiteral>>() { }).toInstance(providerTypeToBlobStoreMap); bind(Twitter.class).toInstance(twitterClient); bind(Queue.class).toInstance(queue); @@ -156,7 +154,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { @Override public void contextDestroyed(ServletContextEvent servletContextEvent) { - for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { + for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { context.close(); } queue.purge(); diff --git a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java index b681cfb27d..299448a481 100644 --- a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java +++ b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -54,14 +54,14 @@ public class AddTweetsController extends HttpServlet implements /** The serialVersionUID */ private static final long serialVersionUID = 3888348023150822683L; - private final Map contexts; + private final Map> contexts; private final ServiceToStoredTweetStatuses blobStoreContextToContainerResult; @Resource protected Logger logger = Logger.NULL; @Inject - AddTweetsController(Map contexts, + AddTweetsController(Map> contexts, ServiceToStoredTweetStatuses blobStoreContextToContainerResult) { this.contexts = contexts; this.blobStoreContextToContainerResult = blobStoreContextToContainerResult; diff --git a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java index 94568e4dec..150dff0f6c 100644 --- a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java +++ b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java @@ -60,7 +60,7 @@ public class EnqueueStoresController extends HttpServlet { protected Logger logger = Logger.NULL; @Inject - public EnqueueStoresController(Map contexts, + public EnqueueStoresController(Map> contexts, Queue taskQueue) { contextNames = contexts.keySet(); this.taskQueue = taskQueue; diff --git a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index ae00c69d20..95453e0894 100644 --- a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -73,7 +73,7 @@ public class StoreTweetsController extends HttpServlet { /** The serialVersionUID */ private static final long serialVersionUID = 7215420527854203714L; - private final Map contexts; + private final Map> contexts; private final Twitter client; private final String container; @@ -82,7 +82,7 @@ public class StoreTweetsController extends HttpServlet { @Inject @VisibleForTesting - public StoreTweetsController(Map contexts, + public StoreTweetsController(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container, Twitter client) { this.container = container; this.contexts = contexts; @@ -91,7 +91,7 @@ public class StoreTweetsController extends HttpServlet { @VisibleForTesting public void addMyTweets(String contextName, Iterable responseList) { - BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + contexts.keySet()); BlobMap map = context.createBlobMap(container); for (Status status : responseList) { diff --git a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java index 0807c7bb46..36437544d4 100644 --- a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java +++ b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java @@ -39,11 +39,11 @@ import com.google.common.collect.Iterables; @Singleton public class ServiceToStoredTweetStatuses implements Function> { - private final Map contexts; + private final Map> contexts; private final String container; @Inject - public ServiceToStoredTweetStatuses(Map contexts, + public ServiceToStoredTweetStatuses(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container) { this.contexts = contexts; this.container = container; @@ -53,7 +53,7 @@ public class ServiceToStoredTweetStatuses implements Function apply(String service) { - BlobStoreContext context = contexts.get(service); + BlobStoreContext context = contexts.get(service); String host = context.getProviderSpecificContext().getEndpoint().getHost(); try { BlobMap blobMap = context.createBlobMap(container); diff --git a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index f8328fa44e..d6989d8bbe 100644 --- a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -26,7 +26,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; @@ -45,11 +46,12 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class AddTweetsControllerTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -62,7 +64,7 @@ public class AddTweetsControllerTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); AddTweetsController controller = new AddTweetsController(contexts, function); diff --git a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java index dc0ac7bdf8..435285b62c 100644 --- a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java +++ b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java @@ -19,15 +19,16 @@ package org.jclouds.demo.tweetstore.controller; import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl; +import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createMock; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; import java.util.Map; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.testng.annotations.Test; import com.google.appengine.api.taskqueue.Queue; @@ -42,15 +43,16 @@ import com.google.common.collect.ImmutableMap; @Test(groups = "unit") public class EnqueueStoresControllerTest { - Map createBlobStores() { - Map contexts = ImmutableMap.of( - "test1", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), - "test2", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); + Map> createBlobStores() { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); return contexts; } public void testEnqueueStores() { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); Queue taskQueue = createMock(Queue.class); EnqueueStoresController function = new EnqueueStoresController(stores, taskQueue); diff --git a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java index 0e82a13f25..cb89719fd5 100644 --- a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java +++ b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -18,10 +18,10 @@ */ package org.jclouds.demo.tweetstore.controller; +import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createMock; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; import static org.jclouds.util.Strings2.toStringAndClose; import static org.testng.Assert.assertEquals; @@ -32,7 +32,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; import org.testng.annotations.Test; @@ -56,18 +57,19 @@ public class StoreTweetsControllerTest { return createMock(Twitter.class); } - Map createBlobStores() throws InterruptedException, ExecutionException { - Map contexts = ImmutableMap. of("test1", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), "test2", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); - for (BlobStoreContext blobstore : contexts.values()) { - blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); - } - return contexts; + Map> createBlobStores() throws InterruptedException, ExecutionException { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); + for (BlobStoreContext blobstore : contexts.values()) { + blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); + } + return contexts; } - + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); StoreTweetsController function = new StoreTweetsController(stores, "favo", createTwitter()); User frank = createMock(User.class); @@ -99,7 +101,7 @@ public class StoreTweetsControllerTest { verify(jimmy); verify(jimmyStatus); - for (Entry entry : stores.entrySet()) { + for (Entry> entry : stores.entrySet()) { BlobMap map = entry.getValue().createBlobMap("favo"); Blob frankBlob = map.get("1"); assertEquals(frankBlob.getMetadata().getName(), "1"); diff --git a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index c662dd8a74..4c05f7ac68 100644 --- a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -25,7 +25,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -40,7 +41,8 @@ import org.testng.annotations.Test; public class KeyToStoredTweetStatusTest { BlobMap createMap() throws InterruptedException, ExecutionException { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); + BlobStoreContext context = + BlobStoreContextBuilder.newBuilder(TransientApiMetadata.builder().build()).build(); context.getBlobStore().createContainerInLocation(null, "test1"); return context.createBlobMap("test1"); } diff --git a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index 51df008762..54deb948db 100644 --- a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -25,7 +25,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -42,12 +43,12 @@ import com.google.common.collect.Iterables; @Test(groups = "unit") public class ServiceToStoredTweetStatusesTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", - "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -60,7 +61,7 @@ public class ServiceToStoredTweetStatusesTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); diff --git a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 0bf21ce2ec..15073996ec 100644 --- a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -38,7 +38,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.tweetstore.config.GuiceServletConfig; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; @@ -73,7 +73,7 @@ import com.google.inject.Module; public class TweetStoreLiveTest { GoogleDevServer server; private URL url; - private Map contexts; + private Map> contexts; private String container; private static final Iterable blobstores = Splitter.on(',').split(System.getProperty(PROPERTY_TWEETSTORE_BLOBSTORES, @@ -94,13 +94,13 @@ public class TweetStoreLiveTest { // example of an ad-hoc client configuration addConfigurationForTwitter(props); - final BlobStoreContextFactory factory = new BlobStoreContextFactory(); // for testing, capture logs. final Set wiring = ImmutableSet. of(new Log4JLoggingModule()); this.contexts = Maps.newConcurrentMap(); for (String provider : blobstores) { - contexts.put(provider, factory.createContext(provider, wiring, props)); + contexts.put(provider, BlobStoreContextBuilder.newBuilder(provider) + .modules(wiring).overrides(props).build()); } Configuration conf = new ConfigurationBuilder() @@ -115,7 +115,7 @@ public class TweetStoreLiveTest { ResponseList statuses = client.getMentions(); boolean deleted = false; - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { try { if (context.getBlobStore().containerExists(container)) { System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() @@ -131,7 +131,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 60 seconds to allow containers to clear"); Thread.sleep(60000); } - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() .getEndpoint()); context.getBlobStore().createContainerInLocation(null, container); @@ -142,7 +142,7 @@ public class TweetStoreLiveTest { Thread.sleep(5000); } - for (Entry entry : contexts.entrySet()) { + for (Entry> entry : contexts.entrySet()) { System.err.printf("filling container %s at %s%n", container, entry.getKey()); controller.addMyTweets(entry.getKey(), statuses); } @@ -210,7 +210,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 20 seconds to allow for eventual consistency delay"); Thread.sleep(20000); - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { assert context.createInputStreamMap(container).size() > 0 : context.getProviderSpecificContext().getEndpoint(); } } From a919985b2bea74f249fcd57d369ee7921192c379 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 12 Apr 2012 23:04:07 +0100 Subject: [PATCH 51/69] Fix broken build due to ApiMetadata changes --- .../org/jclouds/openstack/nova/NovaAsyncClientTest.java | 2 +- .../org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java | 2 +- .../vcloud/internal/BaseVCloudAsyncClientTest.java | 8 +++----- .../vcloud/internal/VCloudLoginAsyncClientTest.java | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java index eaef7e29af..c9d67a097a 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java @@ -44,8 +44,8 @@ import org.jclouds.openstack.nova.domain.RebootType; import org.jclouds.openstack.nova.options.CreateServerOptions; import org.jclouds.openstack.nova.options.ListOptions; import org.jclouds.openstack.nova.options.RebuildServerOptions; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java index 6b37820b16..0afb3ade55 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java @@ -25,8 +25,8 @@ import java.lang.reflect.Method; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.vcloud.xml.SupportedVersionsHandler; diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java index e13e85fb12..a954d20ab7 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java @@ -33,8 +33,8 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.ovf.Envelope; import org.jclouds.ovf.xml.EnvelopeHandlerTest; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; @@ -75,8 +75,7 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BaseVCloudAsyncClientTest") public abstract class BaseVCloudAsyncClientTest extends BaseAsyncClientTest { @@ -93,8 +92,7 @@ public abstract class BaseVCloudAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { - return AnonymousProviderMetadata.forApiWithEndpoint(new VCloudApiMetadata(), - "https://vcenterprise.bluelock.com/api/v1.0"); + return AnonymousProviderMetadata.forApiWithEndpoint(new VCloudApiMetadata(), "https://vcenterprise.bluelock.com/api/v1.0"); } protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", VCloudMediaType.ORG_XML, diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java index e4f2cb3725..9bc2626430 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java @@ -29,8 +29,8 @@ import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.vcloud.endpoints.VCloudLogin; From c56c2d2f728d33e81837a6a77733291ac05e064c Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 12 Apr 2012 17:07:13 -0600 Subject: [PATCH 52/69] Issue 897: moved clojure off Factory -> Builder --- .../src/main/clojure/org/jclouds/blobstore2.clj | 17 ++++++++--------- .../src/main/clojure/org/jclouds/compute2.clj | 15 ++++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj index a34e6a8328..5e85f0ab2f 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj @@ -26,7 +26,7 @@ Current supported services are: eucalyptus-partnercloud-s3, cloudfiles-us, cloudfiles-uk, swift, scality-rs2, hosteurope-storage, tiscali-storage] -Here's a quick example of how to viewresources in rackspace +Here's a quick example of how to view resources in rackspace (use 'org.jclouds.blobstore2) @@ -46,7 +46,7 @@ See http://code.google.com/p/jclouds for details." java.util.Properties [org.jclouds.blobstore AsyncBlobStore domain.BlobBuilder BlobStore BlobStoreContext - BlobStoreContextFactory domain.BlobMetadata domain.StorageMetadata + BlobStoreContextBuilder domain.BlobMetadata domain.StorageMetadata domain.Blob domain.internal.BlobBuilderImpl options.PutOptions options.PutOptions$Builder options.CreateContainerOptions options.ListContainerOptions] @@ -112,13 +112,12 @@ Options can also be specified for extension modules (let [module-keys (set (keys module-lookup)) ext-modules (filter #(module-keys %) options) opts (apply hash-map (filter #(not (module-keys %)) options))] - (let [context (.. (BlobStoreContextFactory.) - (createContext - provider provider-identity provider-credential - (apply modules - (concat ext-modules (opts :extensions))) - (reduce #(do (.put %1 (name (first %2)) (second %2)) %1) - (Properties.) (dissoc opts :extensions))))] + (let [context (.. (BlobStoreContextBuilder/newBuilder provider) + (credentials provider-identity provider-credential) + (modules (apply modules (concat ext-modules (opts :extensions)))) + (overrides (reduce #(do (.put %1 (name (first %2)) (second %2)) %1) + (Properties.) (dissoc opts :extensions))) + (build))] (if (some #(= :async %) options) (.getAsyncBlobStore context) (.getBlobStore context))))) diff --git a/compute/src/main/clojure/org/jclouds/compute2.clj b/compute/src/main/clojure/org/jclouds/compute2.clj index c318bfbd02..a54023c97a 100644 --- a/compute/src/main/clojure/org/jclouds/compute2.clj +++ b/compute/src/main/clojure/org/jclouds/compute2.clj @@ -29,6 +29,7 @@ You can inquire about which providers are loaded via the following: (seq (org.jclouds.providers.Providers/allCompute)) + (seq (org.jclouds.apis.Apis/allCompute)) Here's an example of getting some compute configuration from rackspace: @@ -65,7 +66,7 @@ Here's an example of creating and running a small linux node in the group webser java.util.Properties [org.jclouds.domain Location] [org.jclouds.compute - ComputeService ComputeServiceContext ComputeServiceContextFactory] + ComputeService ComputeServiceContext ComputeServiceContextBuilder] [org.jclouds.compute.domain Template TemplateBuilder ComputeMetadata NodeMetadata Hardware OsFamily Image] @@ -83,13 +84,13 @@ Here's an example of creating and running a small linux node in the group webser (let [module-keys (set (keys module-lookup)) ext-modules (filter #(module-keys %) options) opts (apply hash-map (filter #(not (module-keys %)) options))] - (.. (ComputeServiceContextFactory.) - (createContext - provider provider-identity provider-credential - (apply modules (concat ext-modules (opts :extensions))) - (reduce #(do (.put %1 (name (first %2)) (second %2)) %1) + (.. (ComputeServiceContextBuilder/newBuilder provider) + (credentials provider-identity provider-credential) + (modules (apply modules (concat ext-modules (opts :extensions)))) + (overrides (reduce #(do (.put %1 (name (first %2)) (second %2)) %1) (Properties.) (dissoc opts :extensions))) - (getComputeService)))) + (build) + (getComputeService)))) ([#^ComputeServiceContext compute-context] (.getComputeService compute-context))) From c0d781a11d87908133c9784aee14c27fa4649ed3 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Fri, 13 Apr 2012 12:23:45 +0100 Subject: [PATCH 53/69] Fix vCloud test usage of new ContextBuilder --- .../jclouds/rest/internal/ContextBuilder.java | 4 - .../rest/internal/BaseContextLiveTest.java | 13 +- .../BaseVCloudDirectorClientLiveTest.java | 120 ++++++++---------- .../internal/VCloudDirectorTestSession.java | 93 +++++++------- 4 files changed, 113 insertions(+), 117 deletions(-) diff --git a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java b/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java index 95a5feeb81..2a96fd74f7 100644 --- a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java @@ -133,7 +133,6 @@ public class ContextBuilder> ContextBuilder newBuilder( ApiMetadata apiMetadata) { try { @@ -149,7 +148,6 @@ public class ContextBuilder> ContextBuilder newBuilder( ProviderMetadata providerMetadata) { try { @@ -232,10 +230,8 @@ public class ContextBuilder { protected volatile C context; + protected String identity; + protected String credential; + protected String endpoint; + protected Properties setupProperties() { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - setIfTestSystemPropertyPresent(overrides, provider + ".identity"); - setIfTestSystemPropertyPresent(overrides, provider + ".credential"); - setIfTestSystemPropertyPresent(overrides, provider + ".endpoint"); + identity = setIfTestSystemPropertyPresent(overrides, provider + ".identity"); + credential = setIfTestSystemPropertyPresent(overrides, provider + ".credential"); + endpoint = setIfTestSystemPropertyPresent(overrides, provider + ".endpoint"); setIfTestSystemPropertyPresent(overrides, provider + ".api-version"); setIfTestSystemPropertyPresent(overrides, provider + ".build-version"); return overrides; @@ -65,6 +69,7 @@ public abstract class BaseContextLiveTest { if (System.getProperties().containsKey("test." + key)) { String val = System.getProperty("test." + key); overrides.setProperty(key, val); + return val; } return null; } @@ -91,7 +96,6 @@ public abstract class BaseContextLiveTest { /** * @see org.jclouds.providers.Providers#withId */ - @SuppressWarnings("unchecked") protected ProviderMetadata createProviderMetadata() { try { return (ProviderMetadata) Providers.withId(provider); @@ -103,7 +107,6 @@ public abstract class BaseContextLiveTest { /** * @see org.jclouds.apis.Apis#withId */ - @SuppressWarnings("unchecked") protected ApiMetadata createApiMetadata() { try { return (ApiMetadata) Apis.withId(provider); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java index 2ebe42c5c4..4f66774cb0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java @@ -51,6 +51,13 @@ import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; +import org.jclouds.vcloud.director.v1_5.domain.RoleReferences; +import org.jclouds.vcloud.director.v1_5.domain.Session; +import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.User; +import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.network.Network; import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration; @@ -59,13 +66,6 @@ import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppTemplatePar import org.jclouds.vcloud.director.v1_5.domain.params.InstantiationParams; import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.RoleReferences; -import org.jclouds.vcloud.director.v1_5.domain.Session; -import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.User; -import org.jclouds.vcloud.director.v1_5.domain.VApp; -import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; -import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.features.TaskClient; import org.jclouds.vcloud.director.v1_5.features.VAppClient; import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; @@ -75,7 +75,7 @@ import org.jclouds.vcloud.director.v1_5.predicates.TaskStatusEquals; import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; -import org.testng.annotations.AfterSuite; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -89,6 +89,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.google.common.io.Closeables; import com.google.inject.Guice; /** @@ -100,7 +101,7 @@ import com.google.inject.Guice; @Listeners(FormatApiResultsListener.class) @Test(groups = "live") public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTest { - + @Resource protected Logger logger = Logger.CONSOLE; @@ -112,7 +113,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe public static final String VDC = "vdc"; public static final int REQUIRED_ADMIN_VM_QUOTA = 0; public static final int REQUIRED_USER_VM_QUOTA = 0; - + public Predicate retryTaskSuccess; public Predicate retryTaskSuccessLong; @@ -131,24 +132,24 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe protected final Set vAppNames = Sets.newLinkedHashSet(); protected static final Random random = new Random(); - + protected BaseVCloudDirectorClientLiveTest() { provider = "vcloud-director"; } protected DateService dateService; - private static VCloudDirectorTestSession testSession; + protected VCloudDirectorTestSession testSession; - private static String testStamp; + protected static String testStamp; @BeforeClass(alwaysRun = true) protected void setupDateService() { dateService = Guice.createInjector().getInstance(DateService.class); assertNotNull(dateService); } - - // NOTE Implement as required to populate xxxClient fields, or NOP + + /** Implement as required to populate xxxClient fields, or NOP */ protected abstract void setupRequiredClients(); @Inject @@ -160,71 +161,62 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe protected void initTaskSuccessLong(TaskSuccess taskSuccess) { retryTaskSuccessLong = new RetryablePredicate(taskSuccess, LONG_TASK_TIMEOUT_SECONDS * 1000L); } - //temporary until we marry up the test fixtures - protected String identity; - protected String credential; - protected String endpoint; - - @Override - protected Properties setupProperties() { - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - identity = setIfTestSystemPropertyPresent(overrides, provider + ".identity"); - credential = setIfTestSystemPropertyPresent(overrides, provider + ".credential"); - endpoint = setIfTestSystemPropertyPresent(overrides, provider + ".endpoint"); - setIfTestSystemPropertyPresent(overrides, provider + ".api-version"); - setIfTestSystemPropertyPresent(overrides, provider + ".build-version"); - return overrides; - } - - @AfterSuite(alwaysRun = true) + @AfterClass(alwaysRun = true) protected void tearDownTestSession() { - testSession.close(); + Closeables.closeQuietly(testSession); } - @BeforeClass(alwaysRun = true) @Override - public void setupContext(){ - + protected void initializeContext() { + Properties overrides = setupProperties(); + testSession = VCloudDirectorTestSession.builder() + .provider(provider) + .identity(identity) + .credential(credential) + .endpoint(endpoint) + .overrides(overrides) + .build(); + + System.err.println("*** " + endpoint + " ***"); + context = testSession.getUserContext(); adminContext = testSession.getAdminContext(); - - if(adminContext != null) { + + if (adminContext != null) { adminSession = adminContext.getApi().getCurrentSession(); adminContext.utils().injector().injectMembers(this); } - + session = context.getApi().getCurrentSession(); context.utils().injector().injectMembers(this); - + initTestParametersFromPropertiesOrLazyDiscover(); setupRequiredClients(); } - + public static String getTestDateTimeStamp() { if (testStamp == null) { testStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); } - + return testStamp; } - + public Reference getRoleReferenceFor(String name) { return getRoleReferenceFor(name, adminContext); } - + public static Reference getRoleReferenceFor(String name, RestContext adminContext) { RoleReferences roles = adminContext.getApi().getQueryClient().roleReferencesQueryAll(); // wrapped in a builder to strip out unwanted xml cruft that the api chokes on return Reference.builder().fromReference(Iterables.find(roles.getReferences(), ReferencePredicates.nameEquals(name))).build(); } - + public User randomTestUser(String prefix) { return randomTestUser(prefix, getRoleReferenceFor(DefaultRoles.USER.value())); } - + public User randomTestUser(String prefix, Reference role) { return User.builder() .name(name(prefix)+getTestDateTimeStamp()) @@ -291,19 +283,19 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe } } } - + public URI toAdminUri(Reference ref) { return toAdminUri(ref.getHref()); } - + public URI toAdminUri(URI uri) { return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref(); } - + protected void assertTaskSucceeds(Task task) { assertTrue(retryTaskSuccess.apply(task), String.format(TASK_COMPLETE_TIMELY, task)); } - + protected void assertTaskSucceedsLong(Task task) { assertTrue(retryTaskSuccessLong.apply(task), String.format(TASK_COMPLETE_TIMELY, task)); } @@ -314,17 +306,17 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, TASK_TIMEOUT_SECONDS * 1000L); return retryablePredicate.apply(task); } - + protected void assertTaskStatusEventually(Task task, Task.Status running, ImmutableSet immutableSet) { assertTrue(taskStatusEventually(task, running, immutableSet), String.format("Task '%s' must reach status %s", task.getOperationName(), running)); } - + protected boolean taskDoneEventually(Task task) { TaskClient taskClient = context.getApi().getTaskClient(); TaskStatusEquals predicate = new TaskStatusEquals( - taskClient, - ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), + taskClient, + ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), Collections.emptySet()); RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L); return retryablePredicate.apply(task); @@ -337,13 +329,13 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe /** * Instantiate a {@link VApp} in a {@link Vdc} using the {@link VAppTemplate} we have configured for the tests. - * + * * @return the VApp that is being instantiated */ protected VApp instantiateVApp() { return instantiateVApp(name("test-vapp-")); } - + protected VApp instantiateVApp(String name) { InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder() .name(name) @@ -395,7 +387,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe private NetworkConfiguration networkConfiguration() { Vdc vdc = context.getApi().getVdcClient().getVdc(vdcURI); assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC)); - + Set networks = vdc.getAvailableNetworks(); // Look up the network in the Vdc with the id configured for the tests @@ -419,7 +411,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe return networkConfiguration; } - + protected void cleanUpVAppTemplate(VAppTemplate vAppTemplate) { VAppTemplateClient vappTemplateClient = context.getApi().getVAppTemplateClient(); try { @@ -433,7 +425,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe protected void cleanUpVApp(VApp vApp) { cleanUpVApp(vApp.getHref()); } - + // TODO code tidy for cleanUpVApp? Seems extremely verbose! protected void cleanUpVApp(URI vAppURI) { VAppClient vAppClient = context.getApi().getVAppClient(); @@ -447,7 +439,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe logger.info("Cannot find VApp at %s", vAppURI.getPath()); return; } - + // Wait for busy tasks to complete (don't care if it's failed or successful) // Otherwise, get error on delete "entity is busy completing an operation. if (vApp.getTasks() != null) { @@ -457,7 +449,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe } } } - + // Shutdown and power off the VApp if necessary if (vApp.getStatus().equals(Status.POWERED_ON.getValue())) { try { @@ -480,7 +472,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp.getName()); } } - + try { Task task = vAppClient.deleteVApp(vAppURI); taskDoneEventually(task); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java index a5e4800ad0..0c9746dedd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java @@ -5,12 +5,13 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.R import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import java.io.Closeable; import java.net.URI; import java.util.Properties; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextFactory; +import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient; @@ -25,16 +26,17 @@ import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.common.io.Closeables; import com.google.inject.Module; -public class VCloudDirectorTestSession { - +public class VCloudDirectorTestSession implements Closeable { + public static Builder builder() { return new Builder(); } - + public static class Builder { - + private String provider; private String identity; private String credential; @@ -45,65 +47,68 @@ public class VCloudDirectorTestSession { this.provider = provider; return this; } - + public Builder identity(String identity) { this.identity = identity; return this; } - + public Builder credential(String credential) { this.credential = credential; return this; } - + public Builder overrides(Properties overrides) { this.overrides = overrides; return this; } - + public Builder endpoint(String endpoint) { this.endpoint = endpoint; return this; } - + public VCloudDirectorTestSession build() { return new VCloudDirectorTestSession(provider, identity, credential, overrides, endpoint); } } - + private RestContext adminContext; private RestContext userContext; private User createdAdminUser; private User createdUser; - + private VCloudDirectorTestSession(String provider, String identity, String credential, Properties overrides, String endpoint) { - VCloudDirectorContext rootContext = VCloudDirectorContext.class.cast( - new RestContextFactory().createContext(provider, identity, credential, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), overrides)); - + ContextBuilder builder = ContextBuilder.newBuilder(provider) + .credentials(identity, credential) + .endpoint(endpoint) + .modules(ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule())) + .overrides(overrides); + VCloudDirectorContext rootContext = VCloudDirectorContext.class.cast(builder.build()); + if (rootContext.getApi().getCurrentSession().getLinks().contains(Link.builder() - .rel("down") - .type("application/vnd.vmware.admin.vcloud+xml") - .href(URI.create(endpoint+"/admin/")) - .build())) { - + .rel("down") + .type("application/vnd.vmware.admin.vcloud+xml") + .href(URI.create(endpoint+"/admin/")) + .build())) { + adminContext = rootContext.getAdminContext(); - + Reference orgRef = Iterables.getFirst(rootContext.getApi().getOrgClient().getOrgList().getOrgs(), null) .toAdminReference(endpoint); assertNotNull(orgRef, String.format(REF_REQ_LIVE, "admin org")); - - Reference userRef = Iterables.find(adminContext.getApi().getOrgClient().getOrg(orgRef.getHref()).getUsers(), + + Reference userRef = Iterables.find(adminContext.getApi().getOrgClient().getOrg(orgRef.getHref()).getUsers(), ReferencePredicates.nameEquals(adminContext.getApi().getCurrentSession().getUser())); - + User user = adminContext.getApi().getUserClient().getUser(userRef.getHref()); Reference orgAdmin = user.getRole(); assertTrue(equal(orgAdmin.getName(), DefaultRoles.ORG_ADMIN.value()), "must give org admin or user-only credentials"); - + String adminIdentity = "testAdmin"+BaseVCloudDirectorClientLiveTest.getTestDateTimeStamp(); String adminCredential = "testAdminPassword"; - + createdAdminUser = rootContext.getAdminContext().getApi().getUserClient().createUser(orgRef.getHref(), User.builder() .name(adminIdentity) .password(adminCredential) @@ -112,14 +117,15 @@ public class VCloudDirectorTestSession { .deployedVmQuota(BaseVCloudDirectorClientLiveTest.REQUIRED_ADMIN_VM_QUOTA) .isEnabled(true) .build()); - - rootContext.close(); rootContext = null; - - adminContext = VCloudDirectorContext.class.cast(new RestContextFactory().createContext(provider, adminIdentity, adminCredential, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), overrides)).getAdminContext(); + + Closeables.closeQuietly(rootContext); + + builder.credentials(adminIdentity, adminCredential); + adminContext = VCloudDirectorContext.class.cast(builder.build()).getAdminContext(); + String userIdentity = "test"+BaseVCloudDirectorClientLiveTest.getTestDateTimeStamp(); String userCredential = "testPassword"; - + createdUser = adminContext.getApi().getUserClient().createUser(orgRef.getHref(), User.builder() .name(userIdentity) .password(userCredential) @@ -128,32 +134,31 @@ public class VCloudDirectorTestSession { .deployedVmQuota(BaseVCloudDirectorClientLiveTest.REQUIRED_USER_VM_QUOTA) .isEnabled(true) .build()); - - userContext = new RestContextFactory().createContext(provider, userIdentity, userCredential, ImmutableSet. of( - new Log4JLoggingModule(), new SshjSshClientModule()), overrides); + + builder.credentials(userIdentity, userCredential); + userContext = VCloudDirectorContext.class.cast(builder.build()); } else { userContext = rootContext; } } - + + @Override public void close() { if (createdUser != null) { adminContext.getApi().getUserClient().deleteUser(createdUser.getHref()); } - if (userContext != null) - userContext.close(); + if (userContext != null) userContext.close(); if (createdAdminUser != null) { // TODO: may have to preserve root context if we can't delete the user for it's own context here - adminContext.getApi().getUserClient().deleteUser(createdAdminUser.getHref()); + adminContext.getApi().getUserClient().deleteUser(createdAdminUser.getHref()); } - if (adminContext != null) - adminContext.close(); + if (adminContext != null) adminContext.close(); } - + public RestContext getUserContext() { return userContext; } - + public RestContext getAdminContext() { return adminContext; } From 281692bd0b7d5410205e0996f2cbe6482009df21 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 13 Apr 2012 10:24:00 -0600 Subject: [PATCH 54/69] switch to OpenJDK assertion as opposed to 1.7 --- .../jclouds/compute/internal/BaseComputeServiceLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index fbde83d12d..6aa7841043 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -878,7 +878,7 @@ public abstract class BaseComputeServiceLiveTest Date: Fri, 13 Apr 2012 10:48:38 -0600 Subject: [PATCH 55/69] fix cloudwatch --- .../aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index 40e15c9b77..8ebe24b440 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -55,7 +55,6 @@ import org.jclouds.ec2.domain.KeyPair; import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.ec2.services.InstanceClient; import org.jclouds.ec2.services.KeyPairClient; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.scriptbuilder.domain.Statements; @@ -68,7 +67,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; import com.google.common.util.concurrent.ListenableFuture; -import com.google.inject.Module; /** * @@ -169,7 +167,8 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest monitoringContext = ContextBuilder .newBuilder(new AWSCloudWatchProviderMetadata()) - .modules(ImmutableSet. of(new Log4JLoggingModule())).build(); + .credentials(identity, credential) + .modules(setupModules()).build(); try { Set datapoints = monitoringContext.getApi().getMetricStatisticsInRegion(instance.getRegion(), From dcc8e2f9ef38626a3aba905783267a7fdd88529a Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 13 Apr 2012 15:04:42 -0400 Subject: [PATCH 56/69] Replaced the deprecated BlobStoreContextFactory with the new-style BlobStoreContextBuilder for runatcloud-tweetstore --- .../tweetstore/config/GuiceServletConfig.java | 12 +++++----- .../controller/AddTweetsController.java | 4 ++-- .../controller/EnqueueStoresController.java | 2 +- .../controller/StoreTweetsController.java | 6 ++--- .../ServiceToStoredTweetStatuses.java | 6 ++--- .../controller/AddTweetsControllerTest.java | 12 ++++++---- .../EnqueueStoresControllerTest.java | 14 ++++++----- .../controller/StoreTweetsControllerTest.java | 24 ++++++++++--------- .../functions/KeyToStoredTweetStatusTest.java | 6 +++-- .../ServiceToStoredTweetStatusesTest.java | 13 +++++----- .../integration/TweetStoreLiveTest.java | 16 ++++++------- 11 files changed, 62 insertions(+), 53 deletions(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index 78729cbfb7..a294878748 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -39,7 +39,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.paas.PlatformServices; import org.jclouds.demo.paas.service.taskqueue.TaskQueue; import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; @@ -70,7 +70,7 @@ import com.google.inject.servlet.ServletModule; * @author Adrian Cole */ public class GuiceServletConfig extends GuiceServletContextListener { - private Map providerTypeToBlobStoreMap; + private Map> providerTypeToBlobStoreMap; private Twitter twitterClient; private String container; private TaskQueue queue; @@ -78,7 +78,6 @@ public class GuiceServletConfig extends GuiceServletContextListener { @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory(); ServletContext servletContext = servletContextEvent.getServletContext(); Properties props = new PropertiesLoader(servletContext).get(); @@ -101,7 +100,8 @@ public class GuiceServletConfig extends GuiceServletContextListener { // instantiate and store references to all blobstores by provider name providerTypeToBlobStoreMap = Maps.newHashMap(); for (String hint : getBlobstoreContexts(props)) { - providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); + providerTypeToBlobStoreMap.put(hint, BlobStoreContextBuilder + .newBuilder(hint).modules(modules).overrides(props).build()); } // get a queue for submitting store tweet requests and the application's base URL @@ -127,7 +127,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { return Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { - bind(new TypeLiteral>() {}) + bind(new TypeLiteral>>() {}) .toInstance(providerTypeToBlobStoreMap); bind(Twitter.class).toInstance(twitterClient); bind(TaskQueue.class).toInstance(queue); @@ -144,7 +144,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { @Override public void contextDestroyed(ServletContextEvent servletContextEvent) { - for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { + for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { context.close(); } queue.destroy(); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java index 007fbafdef..1805ee8f5c 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -54,14 +54,14 @@ public class AddTweetsController extends HttpServlet implements /** The serialVersionUID */ private static final long serialVersionUID = 3888348023150822683L; - private final Map contexts; + private final Map> contexts; private final ServiceToStoredTweetStatuses blobStoreContextToContainerResult; @Resource protected Logger logger = Logger.NULL; @Inject - AddTweetsController(Map contexts, + AddTweetsController(Map> contexts, ServiceToStoredTweetStatuses blobStoreContextToContainerResult) { this.contexts = contexts; this.blobStoreContextToContainerResult = blobStoreContextToContainerResult; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java index 592eaaa8bd..71b715863b 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java @@ -65,7 +65,7 @@ public class EnqueueStoresController extends HttpServlet { protected Logger logger = Logger.NULL; @Inject - public EnqueueStoresController(Map contexts, TaskQueue taskQueue, + public EnqueueStoresController(Map> contexts, TaskQueue taskQueue, @Named(PaasConstants.PROPERTY_PLATFORM_BASE_URL) String baseUrl) { contextNames = contexts.keySet(); this.taskQueue = taskQueue; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index 948c9ff4ca..edd750e90d 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -75,7 +75,7 @@ public class StoreTweetsController extends HttpServlet { /** The serialVersionUID */ private static final long serialVersionUID = 7215420527854203714L; - private final Map contexts; + private final Map> contexts; private final Twitter client; private final String container; @@ -84,7 +84,7 @@ public class StoreTweetsController extends HttpServlet { @Inject @VisibleForTesting - public StoreTweetsController(Map contexts, + public StoreTweetsController(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container, Twitter client) { this.container = container; this.contexts = contexts; @@ -93,7 +93,7 @@ public class StoreTweetsController extends HttpServlet { @VisibleForTesting public void addMyTweets(String contextName, Iterable responseList) { - BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + contexts.keySet()); BlobMap map = context.createBlobMap(container); for (Status status : responseList) { diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java index 0807c7bb46..36437544d4 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java @@ -39,11 +39,11 @@ import com.google.common.collect.Iterables; @Singleton public class ServiceToStoredTweetStatuses implements Function> { - private final Map contexts; + private final Map> contexts; private final String container; @Inject - public ServiceToStoredTweetStatuses(Map contexts, + public ServiceToStoredTweetStatuses(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container) { this.contexts = contexts; this.container = container; @@ -53,7 +53,7 @@ public class ServiceToStoredTweetStatuses implements Function apply(String service) { - BlobStoreContext context = contexts.get(service); + BlobStoreContext context = contexts.get(service); String host = context.getProviderSpecificContext().getEndpoint().getHost(); try { BlobMap blobMap = context.createBlobMap(container); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index f8328fa44e..d6989d8bbe 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -26,7 +26,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; @@ -45,11 +46,12 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class AddTweetsControllerTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -62,7 +64,7 @@ public class AddTweetsControllerTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); AddTweetsController controller = new AddTweetsController(contexts, function); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java index ff3b651175..c324579f82 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java @@ -24,7 +24,8 @@ import java.net.URI; import java.util.Map; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.demo.paas.RunnableHttpRequest; import org.jclouds.demo.paas.RunnableHttpRequest.Factory; import org.jclouds.demo.paas.service.taskqueue.TaskQueue; @@ -42,15 +43,16 @@ import com.google.common.collect.ImmutableMultimap; @Test(groups = "unit") public class EnqueueStoresControllerTest { - Map createBlobStores() { - Map contexts = ImmutableMap.of( - "test1", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), - "test2", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); + Map> createBlobStores() { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); return contexts; } public void testEnqueueStores() { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); TaskQueue taskQueue = createMock(TaskQueue.class); Factory httpRequestFactory = createMock(Factory.class); EnqueueStoresController function = new EnqueueStoresController(stores, diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java index 0e82a13f25..767245cdf7 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -18,10 +18,10 @@ */ package org.jclouds.demo.tweetstore.controller; +import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createMock; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; import static org.jclouds.util.Strings2.toStringAndClose; import static org.testng.Assert.assertEquals; @@ -32,7 +32,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; import org.testng.annotations.Test; @@ -56,18 +57,19 @@ public class StoreTweetsControllerTest { return createMock(Twitter.class); } - Map createBlobStores() throws InterruptedException, ExecutionException { - Map contexts = ImmutableMap. of("test1", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), "test2", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); - for (BlobStoreContext blobstore : contexts.values()) { + Map> createBlobStores() throws InterruptedException, ExecutionException { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); + for (BlobStoreContext blobstore : contexts.values()) { blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); } return contexts; } public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); StoreTweetsController function = new StoreTweetsController(stores, "favo", createTwitter()); User frank = createMock(User.class); @@ -99,7 +101,7 @@ public class StoreTweetsControllerTest { verify(jimmy); verify(jimmyStatus); - for (Entry entry : stores.entrySet()) { + for (Entry> entry : stores.entrySet()) { BlobMap map = entry.getValue().createBlobMap("favo"); Blob frankBlob = map.get("1"); assertEquals(frankBlob.getMetadata().getName(), "1"); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index c662dd8a74..a85df55fc8 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -25,7 +25,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -40,7 +41,8 @@ import org.testng.annotations.Test; public class KeyToStoredTweetStatusTest { BlobMap createMap() throws InterruptedException, ExecutionException { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); + BlobStoreContext context = + BlobStoreContextBuilder.newBuilder(TransientApiMetadata.builder().build()).build(); context.getBlobStore().createContainerInLocation(null, "test1"); return context.createBlobMap("test1"); } diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index 51df008762..54deb948db 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -25,7 +25,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -42,12 +43,12 @@ import com.google.common.collect.Iterables; @Test(groups = "unit") public class ServiceToStoredTweetStatusesTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", - "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -60,7 +61,7 @@ public class ServiceToStoredTweetStatusesTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 7219e4df21..303e1ec9d9 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -39,7 +39,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.AuthorizationException; @@ -73,7 +73,7 @@ public class TweetStoreLiveTest { RunAtCloudServer server; private URL url; - private Map contexts; + private Map> contexts; private String container; private static final Iterable blobstores = Splitter.on(',').split(getRequiredSystemProperty(PROPERTY_TWEETSTORE_BLOBSTORES)); @@ -92,13 +92,13 @@ public class TweetStoreLiveTest { // example of an ad-hoc client configuration addConfigurationForTwitter(props); - final BlobStoreContextFactory factory = new BlobStoreContextFactory(); // for testing, capture logs. final Set wiring = ImmutableSet. of(new Log4JLoggingModule()); this.contexts = Maps.newConcurrentMap(); for (String provider : blobstores) { - contexts.put(provider, factory.createContext(provider, wiring, props)); + contexts.put(provider, BlobStoreContextBuilder.newBuilder(provider) + .modules(wiring).overrides(props).build()); } Configuration conf = new ConfigurationBuilder() @@ -113,7 +113,7 @@ public class TweetStoreLiveTest { ResponseList statuses = client.getMentions(); boolean deleted = false; - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { try { if (context.getBlobStore().containerExists(container)) { System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() @@ -129,7 +129,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 60 seconds to allow containers to clear"); Thread.sleep(60000); } - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() .getEndpoint()); context.getBlobStore().createContainerInLocation(null, container); @@ -140,7 +140,7 @@ public class TweetStoreLiveTest { Thread.sleep(5000); } - for (Entry entry : contexts.entrySet()) { + for (Entry> entry : contexts.entrySet()) { System.err.printf("filling container %s at %s%n", container, entry.getKey()); controller.addMyTweets(entry.getKey(), statuses); } @@ -210,7 +210,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 20 seconds to allow for eventual consistency delay"); Thread.sleep(20000); - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { assert context.createInputStreamMap(container).size() > 0 : context.getProviderSpecificContext().getEndpoint(); } } From 7d0d5d91a2181a8ec770cbc1216c7f29a332e18b Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 13 Apr 2012 15:12:38 -0400 Subject: [PATCH 57/69] Replaced the deprecated BlobStoreContextFactory with the new-style BlobStoreContextBuilder for rhcloud-tweetstore --- .../tweetstore/config/GuiceServletConfig.java | 12 +++++----- .../controller/AddTweetsController.java | 4 ++-- .../controller/EnqueueStoresController.java | 2 +- .../controller/StoreTweetsController.java | 6 ++--- .../ServiceToStoredTweetStatuses.java | 6 ++--- .../controller/AddTweetsControllerTest.java | 12 ++++++---- .../EnqueueStoresControllerTest.java | 14 ++++++----- .../controller/StoreTweetsControllerTest.java | 24 ++++++++++--------- .../functions/KeyToStoredTweetStatusTest.java | 6 +++-- .../ServiceToStoredTweetStatusesTest.java | 13 +++++----- .../integration/TweetStoreLiveTest.java | 16 ++++++------- 11 files changed, 62 insertions(+), 53 deletions(-) diff --git a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index 78729cbfb7..a294878748 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -39,7 +39,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.paas.PlatformServices; import org.jclouds.demo.paas.service.taskqueue.TaskQueue; import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; @@ -70,7 +70,7 @@ import com.google.inject.servlet.ServletModule; * @author Adrian Cole */ public class GuiceServletConfig extends GuiceServletContextListener { - private Map providerTypeToBlobStoreMap; + private Map> providerTypeToBlobStoreMap; private Twitter twitterClient; private String container; private TaskQueue queue; @@ -78,7 +78,6 @@ public class GuiceServletConfig extends GuiceServletContextListener { @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory(); ServletContext servletContext = servletContextEvent.getServletContext(); Properties props = new PropertiesLoader(servletContext).get(); @@ -101,7 +100,8 @@ public class GuiceServletConfig extends GuiceServletContextListener { // instantiate and store references to all blobstores by provider name providerTypeToBlobStoreMap = Maps.newHashMap(); for (String hint : getBlobstoreContexts(props)) { - providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); + providerTypeToBlobStoreMap.put(hint, BlobStoreContextBuilder + .newBuilder(hint).modules(modules).overrides(props).build()); } // get a queue for submitting store tweet requests and the application's base URL @@ -127,7 +127,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { return Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { - bind(new TypeLiteral>() {}) + bind(new TypeLiteral>>() {}) .toInstance(providerTypeToBlobStoreMap); bind(Twitter.class).toInstance(twitterClient); bind(TaskQueue.class).toInstance(queue); @@ -144,7 +144,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { @Override public void contextDestroyed(ServletContextEvent servletContextEvent) { - for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { + for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { context.close(); } queue.destroy(); diff --git a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java index 007fbafdef..1805ee8f5c 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -54,14 +54,14 @@ public class AddTweetsController extends HttpServlet implements /** The serialVersionUID */ private static final long serialVersionUID = 3888348023150822683L; - private final Map contexts; + private final Map> contexts; private final ServiceToStoredTweetStatuses blobStoreContextToContainerResult; @Resource protected Logger logger = Logger.NULL; @Inject - AddTweetsController(Map contexts, + AddTweetsController(Map> contexts, ServiceToStoredTweetStatuses blobStoreContextToContainerResult) { this.contexts = contexts; this.blobStoreContextToContainerResult = blobStoreContextToContainerResult; diff --git a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java index 937766c460..1c653c2824 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java @@ -64,7 +64,7 @@ public class EnqueueStoresController extends HttpServlet { protected Logger logger = Logger.NULL; @Inject - public EnqueueStoresController(Map contexts, TaskQueue taskQueue, + public EnqueueStoresController(Map> contexts, TaskQueue taskQueue, @Named(PaasConstants.PROPERTY_PLATFORM_BASE_URL) String baseUrl) { contextNames = contexts.keySet(); this.taskQueue = taskQueue; diff --git a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index 948c9ff4ca..edd750e90d 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -75,7 +75,7 @@ public class StoreTweetsController extends HttpServlet { /** The serialVersionUID */ private static final long serialVersionUID = 7215420527854203714L; - private final Map contexts; + private final Map> contexts; private final Twitter client; private final String container; @@ -84,7 +84,7 @@ public class StoreTweetsController extends HttpServlet { @Inject @VisibleForTesting - public StoreTweetsController(Map contexts, + public StoreTweetsController(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container, Twitter client) { this.container = container; this.contexts = contexts; @@ -93,7 +93,7 @@ public class StoreTweetsController extends HttpServlet { @VisibleForTesting public void addMyTweets(String contextName, Iterable responseList) { - BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + contexts.keySet()); BlobMap map = context.createBlobMap(container); for (Status status : responseList) { diff --git a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java index 0807c7bb46..36437544d4 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java @@ -39,11 +39,11 @@ import com.google.common.collect.Iterables; @Singleton public class ServiceToStoredTweetStatuses implements Function> { - private final Map contexts; + private final Map> contexts; private final String container; @Inject - public ServiceToStoredTweetStatuses(Map contexts, + public ServiceToStoredTweetStatuses(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container) { this.contexts = contexts; this.container = container; @@ -53,7 +53,7 @@ public class ServiceToStoredTweetStatuses implements Function apply(String service) { - BlobStoreContext context = contexts.get(service); + BlobStoreContext context = contexts.get(service); String host = context.getProviderSpecificContext().getEndpoint().getHost(); try { BlobMap blobMap = context.createBlobMap(container); diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index f8328fa44e..d6989d8bbe 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -26,7 +26,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; @@ -45,11 +46,12 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class AddTweetsControllerTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -62,7 +64,7 @@ public class AddTweetsControllerTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); AddTweetsController controller = new AddTweetsController(contexts, function); diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java index ff3b651175..c324579f82 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java @@ -24,7 +24,8 @@ import java.net.URI; import java.util.Map; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.demo.paas.RunnableHttpRequest; import org.jclouds.demo.paas.RunnableHttpRequest.Factory; import org.jclouds.demo.paas.service.taskqueue.TaskQueue; @@ -42,15 +43,16 @@ import com.google.common.collect.ImmutableMultimap; @Test(groups = "unit") public class EnqueueStoresControllerTest { - Map createBlobStores() { - Map contexts = ImmutableMap.of( - "test1", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), - "test2", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); + Map> createBlobStores() { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); return contexts; } public void testEnqueueStores() { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); TaskQueue taskQueue = createMock(TaskQueue.class); Factory httpRequestFactory = createMock(Factory.class); EnqueueStoresController function = new EnqueueStoresController(stores, diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java index 0e82a13f25..ac7c1332e0 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -18,10 +18,10 @@ */ package org.jclouds.demo.tweetstore.controller; +import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createMock; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; import static org.jclouds.util.Strings2.toStringAndClose; import static org.testng.Assert.assertEquals; @@ -32,7 +32,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; import org.testng.annotations.Test; @@ -56,18 +57,19 @@ public class StoreTweetsControllerTest { return createMock(Twitter.class); } - Map createBlobStores() throws InterruptedException, ExecutionException { - Map contexts = ImmutableMap. of("test1", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), "test2", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); - for (BlobStoreContext blobstore : contexts.values()) { + Map> createBlobStores() throws InterruptedException, ExecutionException { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); + for (BlobStoreContext blobstore : contexts.values()) { blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); } return contexts; } public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); StoreTweetsController function = new StoreTweetsController(stores, "favo", createTwitter()); User frank = createMock(User.class); @@ -99,7 +101,7 @@ public class StoreTweetsControllerTest { verify(jimmy); verify(jimmyStatus); - for (Entry entry : stores.entrySet()) { + for (Entry> entry : stores.entrySet()) { BlobMap map = entry.getValue().createBlobMap("favo"); Blob frankBlob = map.get("1"); assertEquals(frankBlob.getMetadata().getName(), "1"); diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index c662dd8a74..a85df55fc8 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -25,7 +25,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -40,7 +41,8 @@ import org.testng.annotations.Test; public class KeyToStoredTweetStatusTest { BlobMap createMap() throws InterruptedException, ExecutionException { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); + BlobStoreContext context = + BlobStoreContextBuilder.newBuilder(TransientApiMetadata.builder().build()).build(); context.getBlobStore().createContainerInLocation(null, "test1"); return context.createBlobMap("test1"); } diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index 51df008762..54deb948db 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -25,7 +25,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -42,12 +43,12 @@ import com.google.common.collect.Iterables; @Test(groups = "unit") public class ServiceToStoredTweetStatusesTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", - "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -60,7 +61,7 @@ public class ServiceToStoredTweetStatusesTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); diff --git a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 6698931488..7681cf1297 100644 --- a/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/rhcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -39,7 +39,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.AuthorizationException; @@ -73,7 +73,7 @@ public class TweetStoreLiveTest { RhcloudServer server; private URL url; - private Map contexts; + private Map> contexts; private String container; private static final Iterable blobstores = Splitter.on(',').split(getRequiredSystemProperty(PROPERTY_TWEETSTORE_BLOBSTORES)); @@ -92,13 +92,13 @@ public class TweetStoreLiveTest { // example of an ad-hoc client configuration addConfigurationForTwitter(props); - final BlobStoreContextFactory factory = new BlobStoreContextFactory(); // for testing, capture logs. final Set wiring = ImmutableSet. of(new Log4JLoggingModule()); this.contexts = Maps.newConcurrentMap(); for (String provider : blobstores) { - contexts.put(provider, factory.createContext(provider, wiring, props)); + contexts.put(provider, BlobStoreContextBuilder.newBuilder(provider) + .modules(wiring).overrides(props).build()); } Configuration conf = new ConfigurationBuilder() @@ -113,7 +113,7 @@ public class TweetStoreLiveTest { ResponseList statuses = client.getMentions(); boolean deleted = false; - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { try { if (context.getBlobStore().containerExists(container)) { System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() @@ -129,7 +129,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 60 seconds to allow containers to clear"); Thread.sleep(60000); } - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() .getEndpoint()); context.getBlobStore().createContainerInLocation(null, container); @@ -140,7 +140,7 @@ public class TweetStoreLiveTest { Thread.sleep(5000); } - for (Entry entry : contexts.entrySet()) { + for (Entry> entry : contexts.entrySet()) { System.err.printf("filling container %s at %s%n", container, entry.getKey()); controller.addMyTweets(entry.getKey(), statuses); } @@ -209,7 +209,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 20 seconds to allow for eventual consistency delay"); Thread.sleep(20000); - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { assert context.createInputStreamMap(container).size() > 0 : context.getProviderSpecificContext().getEndpoint(); } } From 365d3af7fa023f7e8311016b857b1bca643672ee Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 13 Apr 2012 15:20:50 -0400 Subject: [PATCH 58/69] Replaced the deprecated BlobStoreContextFactory with the new-style BlobStoreContextBuilder for cf-tweetstore-spring --- .../config/SpringServletConfig.java | 11 ++++----- .../controller/AddTweetsController.java | 4 ++-- .../controller/EnqueueStoresController.java | 2 +- .../controller/StoreTweetsController.java | 6 ++--- .../ServiceToStoredTweetStatuses.java | 6 ++--- .../controller/AddTweetsControllerTest.java | 13 +++++----- .../EnqueueStoresControllerTest.java | 14 ++++++----- .../controller/StoreTweetsControllerTest.java | 24 ++++++++++--------- .../functions/KeyToStoredTweetStatusTest.java | 7 +++--- .../ServiceToStoredTweetStatusesTest.java | 13 +++++----- .../integration/TweetStoreLiveTest.java | 16 ++++++------- 11 files changed, 61 insertions(+), 55 deletions(-) diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java index 25bdbd80e6..e7f019c3d7 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java @@ -43,7 +43,7 @@ import javax.servlet.ServletConfig; import javax.servlet.ServletException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.paas.PlatformServices; import org.jclouds.demo.paas.service.taskqueue.TaskQueue; import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; @@ -85,7 +85,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA private ServletConfig servletConfig; - private Map providerTypeToBlobStoreMap; + private Map> providerTypeToBlobStoreMap; private Twitter twitterClient; private String container; private TaskQueue queue; @@ -93,8 +93,6 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA @PostConstruct public void initialize() throws IOException { - BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory(); - Properties props = loadJCloudsProperties(); LOGGER.trace("About to initialize members."); @@ -117,7 +115,8 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA // instantiate and store references to all blobstores by provider name providerTypeToBlobStoreMap = Maps.newHashMap(); for (String hint : getBlobstoreContexts(props)) { - providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); + providerTypeToBlobStoreMap.put(hint, BlobStoreContextBuilder + .newBuilder(hint).modules(modules).overrides(props).build()); } // get a queue for submitting store tweet requests and the application's base URL @@ -213,7 +212,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA @PreDestroy public void destroy() throws Exception { LOGGER.trace("About to close contexts."); - for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { + for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { context.close(); } LOGGER.trace("Contexts closed."); diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java index 5a8e6baf4b..08ccbcb1bb 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -54,14 +54,14 @@ public class AddTweetsController extends HttpServlet implements /** The serialVersionUID */ private static final long serialVersionUID = 3888348023150822683L; - private final Map contexts; + private final Map> contexts; private final ServiceToStoredTweetStatuses blobStoreContextToContainerResult; @Resource protected Logger logger = Logger.NULL; @Inject - public AddTweetsController(Map contexts, + public AddTweetsController(Map> contexts, ServiceToStoredTweetStatuses blobStoreContextToContainerResult) { this.contexts = contexts; this.blobStoreContextToContainerResult = blobStoreContextToContainerResult; diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java index 592eaaa8bd..71b715863b 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java @@ -65,7 +65,7 @@ public class EnqueueStoresController extends HttpServlet { protected Logger logger = Logger.NULL; @Inject - public EnqueueStoresController(Map contexts, TaskQueue taskQueue, + public EnqueueStoresController(Map> contexts, TaskQueue taskQueue, @Named(PaasConstants.PROPERTY_PLATFORM_BASE_URL) String baseUrl) { contextNames = contexts.keySet(); this.taskQueue = taskQueue; diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index 725ba128f6..cef530d39b 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -75,7 +75,7 @@ public class StoreTweetsController extends HttpServlet { /** The serialVersionUID */ private static final long serialVersionUID = 7215420527854203714L; - private final Map contexts; + private final Map> contexts; private final Twitter client; private final String container; @@ -84,7 +84,7 @@ public class StoreTweetsController extends HttpServlet { @Inject @VisibleForTesting - public StoreTweetsController(Map contexts, + public StoreTweetsController(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container, Twitter client) { this.container = container; this.contexts = contexts; @@ -93,7 +93,7 @@ public class StoreTweetsController extends HttpServlet { @VisibleForTesting public void addMyTweets(String contextName, Iterable responseList) { - BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + contexts.keySet()); BlobMap map = context.createBlobMap(container); for (Status status : responseList) { diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java index 0807c7bb46..36437544d4 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java @@ -39,11 +39,11 @@ import com.google.common.collect.Iterables; @Singleton public class ServiceToStoredTweetStatuses implements Function> { - private final Map contexts; + private final Map> contexts; private final String container; @Inject - public ServiceToStoredTweetStatuses(Map contexts, + public ServiceToStoredTweetStatuses(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container) { this.contexts = contexts; this.container = container; @@ -53,7 +53,7 @@ public class ServiceToStoredTweetStatuses implements Function apply(String service) { - BlobStoreContext context = contexts.get(service); + BlobStoreContext context = contexts.get(service); String host = context.getProviderSpecificContext().getEndpoint().getHost(); try { BlobMap blobMap = context.createBlobMap(container); diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index c8e1241e4a..d6989d8bbe 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -26,7 +26,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; @@ -45,12 +46,12 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class AddTweetsControllerTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", - "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -63,7 +64,7 @@ public class AddTweetsControllerTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); AddTweetsController controller = new AddTweetsController(contexts, function); diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java index ff3b651175..c324579f82 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java @@ -24,7 +24,8 @@ import java.net.URI; import java.util.Map; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.demo.paas.RunnableHttpRequest; import org.jclouds.demo.paas.RunnableHttpRequest.Factory; import org.jclouds.demo.paas.service.taskqueue.TaskQueue; @@ -42,15 +43,16 @@ import com.google.common.collect.ImmutableMultimap; @Test(groups = "unit") public class EnqueueStoresControllerTest { - Map createBlobStores() { - Map contexts = ImmutableMap.of( - "test1", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), - "test2", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); + Map> createBlobStores() { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); return contexts; } public void testEnqueueStores() { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); TaskQueue taskQueue = createMock(TaskQueue.class); Factory httpRequestFactory = createMock(Factory.class); EnqueueStoresController function = new EnqueueStoresController(stores, diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java index 0e82a13f25..f0deb2c105 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -18,10 +18,10 @@ */ package org.jclouds.demo.tweetstore.controller; +import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createMock; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; import static org.jclouds.util.Strings2.toStringAndClose; import static org.testng.Assert.assertEquals; @@ -32,7 +32,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; import org.testng.annotations.Test; @@ -56,18 +57,19 @@ public class StoreTweetsControllerTest { return createMock(Twitter.class); } - Map createBlobStores() throws InterruptedException, ExecutionException { - Map contexts = ImmutableMap. of("test1", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), "test2", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); - for (BlobStoreContext blobstore : contexts.values()) { + Map> createBlobStores() throws InterruptedException, ExecutionException { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); + for (BlobStoreContext blobstore : contexts.values()) { blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); } return contexts; } public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); StoreTweetsController function = new StoreTweetsController(stores, "favo", createTwitter()); User frank = createMock(User.class); @@ -99,7 +101,7 @@ public class StoreTweetsControllerTest { verify(jimmy); verify(jimmyStatus); - for (Entry entry : stores.entrySet()) { + for (Entry> entry : stores.entrySet()) { BlobMap map = entry.getValue().createBlobMap("favo"); Blob frankBlob = map.get("1"); assertEquals(frankBlob.getMetadata().getName(), "1"); diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index 58153eb3ed..61a6dcfffc 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -25,7 +25,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -40,8 +41,8 @@ import org.testng.annotations.Test; public class KeyToStoredTweetStatusTest { BlobMap createMap() throws InterruptedException, ExecutionException { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", - "dummy"); + BlobStoreContext context = + BlobStoreContextBuilder.newBuilder(TransientApiMetadata.builder().build()).build(); context.getBlobStore().createContainerInLocation(null, "test1"); return context.createBlobMap("test1"); } diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index 51df008762..54deb948db 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -25,7 +25,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -42,12 +43,12 @@ import com.google.common.collect.Iterables; @Test(groups = "unit") public class ServiceToStoredTweetStatusesTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", - "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -60,7 +61,7 @@ public class ServiceToStoredTweetStatusesTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); diff --git a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 18bdfe395f..957945872c 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -38,7 +38,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.tweetstore.config.SpringServletConfig; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; @@ -73,7 +73,7 @@ public class TweetStoreLiveTest { CloudFoundryServer server; private URL url; - private Map contexts; + private Map> contexts; private String container; private static final Iterable blobstores = @@ -95,13 +95,13 @@ public class TweetStoreLiveTest { // example of an ad-hoc client configuration addConfigurationForTwitter(props); - final BlobStoreContextFactory factory = new BlobStoreContextFactory(); // for testing, capture logs. final Set wiring = ImmutableSet. of(new Log4JLoggingModule()); this.contexts = Maps.newConcurrentMap(); for (String provider : blobstores) { - contexts.put(provider, factory.createContext(provider, wiring, props)); + contexts.put(provider, BlobStoreContextBuilder.newBuilder(provider) + .modules(wiring).overrides(props).build()); } Configuration conf = new ConfigurationBuilder() @@ -116,7 +116,7 @@ public class TweetStoreLiveTest { ResponseList statuses = client.getMentions(); boolean deleted = false; - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { if (context.getBlobStore().containerExists(container)) { System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() .getEndpoint()); @@ -128,7 +128,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 60 seconds to allow containers to clear"); Thread.sleep(60000); } - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() .getEndpoint()); context.getBlobStore().createContainerInLocation(null, container); @@ -138,7 +138,7 @@ public class TweetStoreLiveTest { Thread.sleep(5000); } - for (Entry entry : contexts.entrySet()) { + for (Entry> entry : contexts.entrySet()) { System.err.printf("filling container %s at %s%n", container, entry.getKey()); controller.addMyTweets(entry.getKey(), statuses); } @@ -205,7 +205,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 20 seconds to allow for eventual consistency delay"); Thread.sleep(20000); - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { assert context.createInputStreamMap(container).size() > 0 : context.getProviderSpecificContext().getEndpoint(); } } From 4539174a7fe2cf521849631d541de2051950551c Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 13 Apr 2012 15:29:24 -0400 Subject: [PATCH 59/69] Replaced the deprecated BlobStoreContextFactory with the new-style BlobStoreContextBuilder for gae-tweetstore-spring --- .../config/SpringServletConfig.java | 11 ++++----- .../controller/AddTweetsController.java | 4 ++-- .../controller/EnqueueStoresController.java | 2 +- .../controller/StoreTweetsController.java | 6 ++--- .../ServiceToStoredTweetStatuses.java | 6 ++--- .../controller/AddTweetsControllerTest.java | 13 +++++----- .../EnqueueStoresControllerTest.java | 20 +++++++++------- .../controller/StoreTweetsControllerTest.java | 24 ++++++++++--------- .../functions/KeyToStoredTweetStatusTest.java | 7 +++--- .../ServiceToStoredTweetStatusesTest.java | 13 +++++----- .../integration/TweetStoreLiveTest.java | 16 ++++++------- 11 files changed, 64 insertions(+), 58 deletions(-) diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java index ba49ded13a..ca84b6dad5 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java @@ -43,7 +43,7 @@ import javax.servlet.ServletConfig; import javax.servlet.ServletException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; import org.jclouds.demo.tweetstore.controller.AddTweetsController; import org.jclouds.demo.tweetstore.controller.EnqueueStoresController; @@ -86,15 +86,13 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA private ServletConfig servletConfig; - private Map providerTypeToBlobStoreMap; + private Map> providerTypeToBlobStoreMap; private Twitter twitterClient; private String container; private Queue queue; @PostConstruct public void initialize() throws IOException { - BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory(); - Properties props = loadJCloudsProperties(); LOGGER.trace("About to initialize members."); @@ -118,7 +116,8 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA // instantiate and store references to all blobstores by provider name providerTypeToBlobStoreMap = Maps.newHashMap(); for (String hint : getBlobstoreContexts(props)) { - providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); + providerTypeToBlobStoreMap.put(hint, BlobStoreContextBuilder + .newBuilder(hint).modules(modules).overrides(props).build()); } // get a queue for submitting store tweet requests @@ -212,7 +211,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA @PreDestroy public void destroy() throws Exception { LOGGER.trace("About to close contexts."); - for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { + for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { context.close(); } LOGGER.trace("Contexts closed."); diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java index 918132161e..2246479460 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -54,14 +54,14 @@ public class AddTweetsController extends HttpServlet implements /** The serialVersionUID */ private static final long serialVersionUID = 3888348023150822683L; - private final Map contexts; + private final Map> contexts; private final ServiceToStoredTweetStatuses blobStoreContextToContainerResult; @Resource protected Logger logger = Logger.NULL; @Inject - public AddTweetsController(Map contexts, + public AddTweetsController(Map> contexts, ServiceToStoredTweetStatuses blobStoreContextToContainerResult) { this.contexts = contexts; this.blobStoreContextToContainerResult = blobStoreContextToContainerResult; diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java index 94568e4dec..150dff0f6c 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresController.java @@ -60,7 +60,7 @@ public class EnqueueStoresController extends HttpServlet { protected Logger logger = Logger.NULL; @Inject - public EnqueueStoresController(Map contexts, + public EnqueueStoresController(Map> contexts, Queue taskQueue) { contextNames = contexts.keySet(); this.taskQueue = taskQueue; diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index ae00c69d20..95453e0894 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -73,7 +73,7 @@ public class StoreTweetsController extends HttpServlet { /** The serialVersionUID */ private static final long serialVersionUID = 7215420527854203714L; - private final Map contexts; + private final Map> contexts; private final Twitter client; private final String container; @@ -82,7 +82,7 @@ public class StoreTweetsController extends HttpServlet { @Inject @VisibleForTesting - public StoreTweetsController(Map contexts, + public StoreTweetsController(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container, Twitter client) { this.container = container; this.contexts = contexts; @@ -91,7 +91,7 @@ public class StoreTweetsController extends HttpServlet { @VisibleForTesting public void addMyTweets(String contextName, Iterable responseList) { - BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + contexts.keySet()); BlobMap map = context.createBlobMap(container); for (Status status : responseList) { diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java index 0807c7bb46..36437544d4 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java @@ -39,11 +39,11 @@ import com.google.common.collect.Iterables; @Singleton public class ServiceToStoredTweetStatuses implements Function> { - private final Map contexts; + private final Map> contexts; private final String container; @Inject - public ServiceToStoredTweetStatuses(Map contexts, + public ServiceToStoredTweetStatuses(Map> contexts, @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container) { this.contexts = contexts; this.container = container; @@ -53,7 +53,7 @@ public class ServiceToStoredTweetStatuses implements Function apply(String service) { - BlobStoreContext context = contexts.get(service); + BlobStoreContext context = contexts.get(service); String host = context.getProviderSpecificContext().getEndpoint().getHost(); try { BlobMap blobMap = context.createBlobMap(container); diff --git a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index c8e1241e4a..d6989d8bbe 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -26,7 +26,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; @@ -45,12 +46,12 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "unit") public class AddTweetsControllerTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", - "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -63,7 +64,7 @@ public class AddTweetsControllerTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); AddTweetsController controller = new AddTweetsController(contexts, function); diff --git a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java index dc0ac7bdf8..435285b62c 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/EnqueueStoresControllerTest.java @@ -19,15 +19,16 @@ package org.jclouds.demo.tweetstore.controller; import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl; +import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createMock; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; import java.util.Map; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.testng.annotations.Test; import com.google.appengine.api.taskqueue.Queue; @@ -42,15 +43,16 @@ import com.google.common.collect.ImmutableMap; @Test(groups = "unit") public class EnqueueStoresControllerTest { - Map createBlobStores() { - Map contexts = ImmutableMap.of( - "test1", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), - "test2", new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); + Map> createBlobStores() { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); return contexts; } public void testEnqueueStores() { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); Queue taskQueue = createMock(Queue.class); EnqueueStoresController function = new EnqueueStoresController(stores, taskQueue); diff --git a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java index 0e82a13f25..67e05543ae 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -18,10 +18,10 @@ */ package org.jclouds.demo.tweetstore.controller; +import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createMock; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; import static org.jclouds.util.Strings2.toStringAndClose; import static org.testng.Assert.assertEquals; @@ -32,7 +32,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; import org.testng.annotations.Test; @@ -56,18 +57,19 @@ public class StoreTweetsControllerTest { return createMock(Twitter.class); } - Map createBlobStores() throws InterruptedException, ExecutionException { - Map contexts = ImmutableMap. of("test1", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), "test2", - new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); - for (BlobStoreContext blobstore : contexts.values()) { + Map> createBlobStores() throws InterruptedException, ExecutionException { + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); + Map> contexts = ImmutableMap.>of( + "test1", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(), + "test2", BlobStoreContextBuilder.newBuilder(transientApiMetadata).build()); + for (BlobStoreContext blobstore : contexts.values()) { blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); } return contexts; } public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { - Map stores = createBlobStores(); + Map> stores = createBlobStores(); StoreTweetsController function = new StoreTweetsController(stores, "favo", createTwitter()); User frank = createMock(User.class); @@ -99,7 +101,7 @@ public class StoreTweetsControllerTest { verify(jimmy); verify(jimmyStatus); - for (Entry entry : stores.entrySet()) { + for (Entry> entry : stores.entrySet()) { BlobMap map = entry.getValue().createBlobMap("favo"); Blob frankBlob = map.get("1"); assertEquals(frankBlob.getMetadata().getName(), "1"); diff --git a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index 58153eb3ed..61a6dcfffc 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -25,7 +25,8 @@ import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -40,8 +41,8 @@ import org.testng.annotations.Test; public class KeyToStoredTweetStatusTest { BlobMap createMap() throws InterruptedException, ExecutionException { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", - "dummy"); + BlobStoreContext context = + BlobStoreContextBuilder.newBuilder(TransientApiMetadata.builder().build()).build(); context.getBlobStore().createContainerInLocation(null, "test1"); return context.createBlobMap("test1"); } diff --git a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index 51df008762..54deb948db 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -25,7 +25,8 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.TransientApiMetadata; import org.jclouds.blobstore.domain.Blob; import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; @@ -42,12 +43,12 @@ import com.google.common.collect.Iterables; @Test(groups = "unit") public class ServiceToStoredTweetStatusesTest { - Map createServices(String container) throws InterruptedException, + Map> createServices(String container) throws InterruptedException, ExecutionException { - Map services = Maps.newHashMap(); + Map> services = Maps.newHashMap(); + TransientApiMetadata transientApiMetadata = TransientApiMetadata.builder().build(); for (String name : new String[] { "1", "2" }) { - BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", - "dummy", "dummy"); + BlobStoreContext context = BlobStoreContextBuilder.newBuilder(transientApiMetadata).build(); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); @@ -60,7 +61,7 @@ public class ServiceToStoredTweetStatusesTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { String container = "container"; - Map contexts = createServices(container); + Map> contexts = createServices(container); ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); diff --git a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 974bafb9f0..0b2a80dceb 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -38,7 +38,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.demo.tweetstore.config.SpringServletConfig; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; @@ -73,7 +73,7 @@ public class TweetStoreLiveTest { GoogleDevServer server; private URL url; - private Map contexts; + private Map> contexts; private String container; private static final Iterable blobstores = @@ -95,13 +95,13 @@ public class TweetStoreLiveTest { // example of an ad-hoc client configuration addConfigurationForTwitter(props); - final BlobStoreContextFactory factory = new BlobStoreContextFactory(); // for testing, capture logs. final Set wiring = ImmutableSet. of(new Log4JLoggingModule()); this.contexts = Maps.newConcurrentMap(); for (String provider : blobstores) { - contexts.put(provider, factory.createContext(provider, wiring, props)); + contexts.put(provider, BlobStoreContextBuilder.newBuilder(provider) + .modules(wiring).overrides(props).build()); } Configuration conf = new ConfigurationBuilder() @@ -116,7 +116,7 @@ public class TweetStoreLiveTest { ResponseList statuses = client.getMentions(); boolean deleted = false; - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { if (context.getBlobStore().containerExists(container)) { System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() .getEndpoint()); @@ -128,7 +128,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 60 seconds to allow containers to clear"); Thread.sleep(60000); } - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() .getEndpoint()); context.getBlobStore().createContainerInLocation(null, container); @@ -138,7 +138,7 @@ public class TweetStoreLiveTest { Thread.sleep(5000); } - for (Entry entry : contexts.entrySet()) { + for (Entry> entry : contexts.entrySet()) { System.err.printf("filling container %s at %s%n", container, entry.getKey()); controller.addMyTweets(entry.getKey(), statuses); } @@ -205,7 +205,7 @@ public class TweetStoreLiveTest { System.err.println("sleeping 20 seconds to allow for eventual consistency delay"); Thread.sleep(20000); - for (BlobStoreContext context : contexts.values()) { + for (BlobStoreContext context : contexts.values()) { assert context.createInputStreamMap(container).size() > 0 : context.getProviderSpecificContext().getEndpoint(); } } From 0d93857601374961a0d8e02c6843cb2ae8d91cf3 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 13 Apr 2012 13:34:21 -0600 Subject: [PATCH 60/69] adjusted test glitches --- .../compute/StubComputeServiceIntegrationTest.java | 8 +------- .../compute/internal/BaseComputeServiceLiveTest.java | 10 ++++++---- .../org/jclouds/rest/internal/BaseContextLiveTest.java | 2 ++ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index 8b42c1e2eb..340817a75f 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -32,7 +32,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import org.easymock.IArgumentMatcher; import org.jclouds.compute.domain.ExecResponse; @@ -370,7 +369,7 @@ public class StubComputeServiceIntegrationTest extends client.connect(); expect(client.exec("echo hello")).andReturn(new ExecResponse("hello", "", 0)); - expect(client.exec("java -version")).andReturn(new ExecResponse("", "1.7", 0)); + expect(client.exec("java -version")).andReturn(new ExecResponse("", "OpenJDK", 0)); client.disconnect(); } @@ -530,9 +529,4 @@ public class StubComputeServiceIntegrationTest extends super.testDestroyNodes(); } - @Override - protected void cleanup() throws InterruptedException, ExecutionException, TimeoutException { - super.cleanup(); - } - } \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index 6aa7841043..bbe9921f50 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -98,7 +98,7 @@ import org.jclouds.scriptbuilder.statements.login.AdminAccess; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; import org.jclouds.util.Strings2; -import org.testng.annotations.AfterTest; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -878,7 +878,7 @@ public abstract class BaseComputeServiceLiveTest { /** * @see org.jclouds.providers.Providers#withId */ + @SuppressWarnings("unchecked") protected ProviderMetadata createProviderMetadata() { try { return (ProviderMetadata) Providers.withId(provider); @@ -107,6 +108,7 @@ public abstract class BaseContextLiveTest { /** * @see org.jclouds.apis.Apis#withId */ + @SuppressWarnings("unchecked") protected ApiMetadata createApiMetadata() { try { return (ApiMetadata) Apis.withId(provider); From 707b97e647c15fc622ad268a128a6750dc26d618 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 13 Apr 2012 13:43:07 -0600 Subject: [PATCH 61/69] typo in OpenJDK check --- .../jclouds/compute/internal/BaseComputeServiceLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index bbe9921f50..78d3d65f08 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -878,7 +878,7 @@ public abstract class BaseComputeServiceLiveTest Date: Fri, 13 Apr 2012 17:05:48 -0400 Subject: [PATCH 62/69] Using the public rather than the internal address to trigger tweet storage in Cloud Foundry TweetStore while we figure out if it's possible to use the internal address (see http://support.cloudfoundry.com/requests/102117) --- .../demo/paas/config/PlatformServicesInitializer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java index f034b2a3e4..30403e646c 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java @@ -19,6 +19,7 @@ package org.jclouds.demo.paas.config; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import static com.google.inject.name.Names.bindProperties; import static java.util.concurrent.TimeUnit.SECONDS; @@ -83,8 +84,12 @@ public class PlatformServicesInitializer implements ServletContextListener { protected static String getBaseUrl(ServletContext context) { ApplicationInstanceInfo instanceInfo = new CloudEnvironment().getInstanceInfo(); - return "http://" + checkNotNull(instanceInfo.getHost(), "instanceInfo.getHost()") - + ":" + instanceInfo.getPort() + context.getContextPath(); + // TODO: use internal address if possible. See http://support.cloudfoundry.com/requests/102117 +// return "http://" + checkNotNull(instanceInfo.getHost(), "instanceInfo.getHost()") +// + ":" + instanceInfo.getPort() + context.getContextPath(); + checkState(!instanceInfo.getUris().isEmpty(), "instanceInfo.getUris() is empty"); + return "http://" + checkNotNull(instanceInfo.getUris().get(0), "instanceInfo.getUris().get(0)") + + context.getContextPath(); } // TODO: make the number and names of queues configurable From 40bb12d41068c26880822a32c2ed3fe96c8a7e00 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Fri, 13 Apr 2012 15:20:13 -0700 Subject: [PATCH 63/69] Correct typo --- .../strategy/internal/FilesystemStorageStrategyImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java index b8836157c4..bffac5a35c 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java @@ -240,14 +240,14 @@ public class FilesystemStorageStrategyImpl implements FilesystemStorageStrategy } File containerFile = openFolder(container); - final int containerPathLenght = containerFile.getAbsolutePath().length() + 1; + final int containerPathLength = containerFile.getAbsolutePath().length() + 1; Set blobNames = new HashSet() { private static final long serialVersionUID = 3152191346558570795L; @Override public boolean add(String e) { - return super.add(e.substring(containerPathLenght)); + return super.add(e.substring(containerPathLength)); } }; populateBlobKeysInContainer(containerFile, blobNames); From 0b59dea0733e75ec94435b233a2635513afe8867 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 16 Apr 2012 00:44:20 -0700 Subject: [PATCH 64/69] removed ContextBuilder subclasses; added unwrap; undid generic params --- .../org/jclouds/atmos/AtmosApiMetadata.java | 35 +- .../jclouds/atmos/AtmosContextBuilder.java | 72 ---- .../binders/BindUserMetadataToHeaders.java | 2 +- .../atmos/blobstore/AtmosAsyncBlobStore.java | 2 +- .../atmos/blobstore/AtmosBlobStore.java | 2 +- .../config/AtmosBlobStoreContextModule.java | 6 - .../functions/ObjectToBlobMetadata.java | 2 +- .../atmos/config/AtmosRestClientModule.java | 2 - .../jclouds/atmos/filters/SignRequest.java | 2 +- .../ParseUserMetadataFromHeaders.java | 2 +- .../jclouds/atmos/AtmosAsyncClientTest.java | 6 +- .../jclouds/atmos/AtmosClientLiveTest.java | 2 +- .../blobstore/AtmosBlobRequestSignerTest.java | 6 +- .../config/AtmosBlobStoreModuleTest.java | 6 +- .../atmos/filters/SignRequestTest.java | 10 +- .../atmos/functions/AtmosObjectNameTest.java | 2 +- .../org/jclouds/byon/BYONApiMetadata.java | 28 +- .../BYONComputeServiceContextBuilder.java | 71 ---- .../BYONComputeServiceContextModule.java | 20 +- .../org/jclouds/byon/domain/YamlNode.java | 2 +- .../internal/BYONComputeServiceAdapter.java | 2 +- .../byon/BYONComputeServiceLiveTest.java | 11 +- .../jclouds/byon/BYONComputeServiceTest.java | 55 ++- .../cloudfiles/CloudFilesApiMetadata.java | 33 +- .../cloudfiles/CloudFilesContextBuilder.java | 72 ---- .../blobstore/CloudFilesAsyncBlobStore.java | 2 +- .../blobstore/CloudFilesBlobStore.java | 2 +- .../config/CloudFilesRestClientModule.java | 2 - .../cloudfiles/CloudFilesClientLiveTest.java | 2 +- .../CloudLoadBalancersApiMetadata.java | 35 +- .../CloudLoadBalancersContextBuilder.java | 57 ---- .../CloudLoadBalancersRestClientModule.java | 2 - .../cloudloadbalancers/functions/LB.java | 2 +- .../features/LoadBalancerAsyncClientTest.java | 2 +- .../features/LoadBalancerClientLiveTest.java | 4 +- .../features/NodeAsyncClientTest.java | 2 +- .../features/NodeClientLiveTest.java | 8 +- .../functions/UnwrapLoadBalancerTest.java | 2 +- .../functions/UnwrapLoadBalancersTest.java | 2 +- ...BaseCloudLoadBalancersAsyncClientTest.java | 4 +- .../BaseCloudLoadBalancersClientLiveTest.java | 17 +- .../cloudservers/CloudServersApiMetadata.java | 33 +- .../CloudServersContextBuilder.java | 57 ---- ...oudServersComputeServiceContextModule.java | 10 +- .../config/CloudServersRestClientModule.java | 2 - .../CloudServersAsyncClientTest.java | 6 +- .../CloudServersClientLiveTest.java | 5 +- .../CloudServersComputeServiceLiveTest.java | 7 +- .../BaseCloudServersRestClientExpectTest.java | 6 +- .../cloudsigma/CloudSigmaApiMetadata.java | 32 +- .../cloudsigma/CloudSigmaContextBuilder.java | 57 ---- ...CloudSigmaComputeServiceContextModule.java | 10 +- .../functions/PreinstalledDiskToImage.java | 2 +- .../config/CloudSigmaRestClientModule.java | 4 +- .../cloudsigma/functions/MapToDevices.java | 2 +- .../cloudsigma/CloudSigmaAsyncClientTest.java | 2 +- .../cloudsigma/CloudSigmaClientLiveTest.java | 7 +- .../CloudSigmaComputeServiceLiveTest.java | 7 +- .../cloudstack/CloudStackApiMetadata.java | 33 +- .../jclouds/cloudstack/CloudStackContext.java | 3 +- .../cloudstack/CloudStackContextBuilder.java | 63 ---- ...ecurityGroupPairsToIndexedQueryParams.java | 2 +- ...CloudStackComputeServiceContextModule.java | 10 +- .../functions/TemplateToOperatingSystem.java | 2 +- .../CloudStackComputeServiceAdapter.java | 2 +- .../config/CloudStackParserModule.java | 2 +- .../config/CloudStackProperties.java | 1 - .../config/CloudStackRestClientModule.java | 2 - .../cloudstack/domain/NetworkService.java | 4 +- .../features/LoadBalancerAsyncClient.java | 2 +- .../features/LoadBalancerClient.java | 2 +- .../CreatePortForwardingRulesForIP.java | 2 +- .../ParseIdToNameFromHttpResponse.java | 2 +- .../functions/ParseTypedAsyncJob.java | 4 +- .../internal/CloudStackContextImpl.java | 27 +- .../cloudstack/predicates/UserPredicates.java | 2 +- .../jclouds/cloudstack/util/ApiKeyPairs.java | 8 +- ...oudStackComputeServiceAdapterLiveTest.java | 4 +- .../CloudStackComputeServiceLiveTest.java | 12 +- .../BaseCloudStackAsyncClientTest.java | 6 +- .../BaseCloudStackClientLiveTest.java | 9 +- .../BaseCloudStackRestClientExpectTest.java | 2 +- .../features/GlobalUserClientLiveTest.java | 2 +- .../features/GuestOSClientLiveTest.java | 2 +- .../features/LoadBalancerClientLiveTest.java | 4 +- .../cloudstack/filters/QuerySignerTest.java | 2 +- .../ParseAsyncJobFromHttpResponseTest.java | 6 +- .../parse/ListAccountsResponseTest.java | 2 +- .../predicates/JobCompleteTest.java | 2 +- .../cloudwatch/CloudWatchApiMetadata.java | 55 ++- .../cloudwatch/CloudWatchContextBuilder.java | 64 ---- .../config/CloudWatchRestClientModule.java | 2 - .../cloudwatch/CloudWatchApiMetadataTest.java | 11 +- .../cloudwatch/CloudWatchAsyncClientTest.java | 7 +- .../cloudwatch/CloudWatchClientLiveTest.java | 9 +- .../deltacloud/DeltacloudApiMetadata.java | 56 ++-- .../deltacloud/DeltacloudAsyncClient.java | 2 +- .../jclouds/deltacloud/DeltacloudClient.java | 2 +- .../deltacloud/DeltacloudContextBuilder.java | 57 ---- ...DeltacloudComputeServiceContextModule.java | 11 +- .../DeltacloudComputeServiceAdapter.java | 2 +- .../config/DeltacloudRestClientModule.java | 2 - .../xml/HardwarePropertyHandler.java | 2 +- .../deltacloud/xml/InstanceHandler.java | 2 +- .../deltacloud/xml/InstanceStatesHandler.java | 4 +- .../deltacloud/DeltacloudAsyncClientTest.java | 6 +- .../ReadOnlyDeltacloudClientLiveTest.java | 9 +- .../DeltacloudComputeServiceLiveTest.java | 13 +- .../DeltacloudTemplateBuilderLiveTest.java | 7 +- ...DeltacloudRedirectionRetryHandlerTest.java | 4 +- .../deltacloud/xml/InstanceHandlerTest.java | 2 +- .../xml/InstanceStatesHandlerTest.java | 4 +- .../java/org/jclouds/ec2/EC2ApiMetadata.java | 67 ++-- .../org/jclouds/ec2/EC2ContextBuilder.java | 77 ----- .../ec2/compute/EC2ComputeService.java | 2 +- .../ec2/compute/EC2ComputeServiceContext.java | 4 +- .../EC2ComputeServiceDependenciesModule.java | 9 - .../EC2ComputeServiceContextImpl.java | 16 +- .../ec2/config/EC2RestClientModule.java | 7 +- ...icationArchitecturesEC2ClientLiveTest.java | 5 +- .../jclouds/ec2/EBSBootEC2ClientLiveTest.java | 7 +- .../org/jclouds/ec2/EC2ApiMetadataTest.java | 1 - .../compute/EC2ComputeServiceLiveTest.java | 18 +- .../compute/EC2TemplateBuilderLiveTest.java | 6 +- .../compute/TestCanRecreateGroupLiveTest.java | 4 +- ...ailabilityZoneAndRegionClientLiveTest.java | 10 +- .../ec2/services/BaseEC2AsyncClientTest.java | 7 +- .../ElasticBlockStoreClientLiveTest.java | 10 +- .../ElasticIPAddressClientLiveTest.java | 8 +- .../ec2/services/InstanceClientLiveTest.java | 8 +- .../ec2/services/KeyPairClientLiveTest.java | 8 +- .../services/SecurityGroupClientLiveTest.java | 8 +- .../ec2/services/WindowsClientLiveTest.java | 8 +- .../elasticstack/ElasticStackApiMetadata.java | 31 +- .../ElasticStackContextBuilder.java | 57 ---- ...asticStackComputeServiceContextModule.java | 12 +- .../config/ElasticStackRestClientModule.java | 4 +- .../elasticstack/functions/MapToDevices.java | 2 +- .../ElasticStackAsyncClientTest.java | 2 +- .../ElasticStackClientLiveTest.java | 5 +- .../ElasticStackComputeServiceLiveTest.java | 7 +- .../eucalyptus/EucalyptusApiMetadata.java | 12 +- .../EucalyptusComputeServiceLiveTest.java | 6 +- .../filesystem/FilesystemApiMetadata.java | 30 +- .../filesystem/FilesystemAsyncBlobStore.java | 4 +- .../FilesystemBlobStoreContextBuilder.java | 59 ---- .../FilesystemBlobStoreContextModule.java | 24 +- .../config/FilesystemBlobStoreModule.java | 45 --- .../FilesystemAsyncBlobStoreTest.java | 10 +- .../openstack/nova/NovaApiMetadata.java | 35 +- .../openstack/nova/NovaContextBuilder.java | 57 ---- .../NovaComputeServiceContextModule.java | 10 +- .../nova/config/NovaRestClientModule.java | 2 - .../nova/options/CreateServerOptions.java | 2 +- .../openstack/nova/NovaAsyncClientTest.java | 8 +- .../openstack/nova/NovaClientLiveTest.java | 5 +- .../compute/NovaComputeServiceLiveTest.java | 6 +- .../nova/ec2/NovaEC2ApiMetadata.java | 25 +- .../nova/ec2/NovaEC2ContextBuilder.java | 58 ---- .../ec2/config/NovaEC2RestClientModule.java | 2 - .../NovaEC2ComputeServiceLiveTest.java | 5 +- apis/openstack-nova/pom.xml | 2 + .../openstack/nova/v1_1/NovaApiMetadata.java | 35 +- .../nova/v1_1/NovaContextBuilder.java | 57 ---- .../BindSecurityGroupRuleToJsonPayload.java | 2 +- .../nova/v1_1/compute/NovaComputeService.java | 2 +- .../NovaComputeServiceContextModule.java | 10 +- .../compute/options/NovaTemplateOptions.java | 2 +- .../v1_1/config/NovaRestClientModule.java | 2 - .../openstack/nova/v1_1/domain/Server.java | 2 +- .../v1_1/domain/zonescoped/ZoneAndName.java | 2 +- .../ParseImageIdFromLocationHeader.java | 3 +- .../v1_1/options/CreateServerOptions.java | 4 +- .../NovaComputeServiceAdapterExpectTest.java | 2 +- .../compute/NovaComputeServiceExpectTest.java | 2 +- .../compute/NovaComputeServiceLiveTest.java | 18 +- .../loaders/CreateUniqueKeyPairTest.java | 1 - .../CreateSecurityGroupIfNeededTest.java | 2 +- .../v1_1/internal/BaseNovaClientLiveTest.java | 19 +- ...seNovaComputeServiceContextExpectTest.java | 3 +- .../BaseNovaComputeServiceExpectTest.java | 2 +- .../v1_1/parse/ParseCreatedServerTest.java | 2 +- .../nova/v1_1/parse/ParseFlavorListTest.java | 2 +- .../nova/v1_1/parse/ParseImageListTest.java | 2 +- .../nova/v1_1/parse/ParseImageTest.java | 2 +- .../nova/v1_1/parse/ParseServerListTest.java | 2 +- .../nova/v1_1/parse/ParseServerTest.java | 2 +- .../ParseServerWithInternetAddressesTest.java | 2 +- ...kShouldRerouteToPublicBlockExpectTest.java | 2 +- .../java/org/jclouds/s3/S3ApiMetadata.java | 64 ++-- .../java/org/jclouds/s3/S3ContextBuilder.java | 67 ---- .../s3/blobstore/S3AsyncBlobStore.java | 2 +- .../org/jclouds/s3/blobstore/S3BlobStore.java | 2 +- .../s3/blobstore/S3BlobStoreContext.java | 4 +- .../config/S3BlobStoreContextModule.java | 10 +- .../internal/S3BlobStoreContextImpl.java | 25 +- .../jclouds/s3/config/S3RestClientModule.java | 12 +- .../org/jclouds/s3/S3ApiMetadataTest.java | 1 - .../org/jclouds/s3/S3AsyncClientTest.java | 10 +- .../java/org/jclouds/s3/S3ClientLiveTest.java | 12 +- .../s3/blobstore/S3BlobRequestSignerTest.java | 2 - .../s3/internal/BaseS3AsyncClientTest.java | 1 - .../s3/internal/BaseS3ClientExpectTest.java | 5 +- .../jclouds/s3/services/BucketsLiveTest.java | 13 +- .../openstack/swift/SwiftApiMetadata.java | 35 +- .../openstack/swift/SwiftContextBuilder.java | 72 ---- .../swift/blobstore/SwiftAsyncBlobStore.java | 2 +- .../swift/blobstore/SwiftBlobStore.java | 2 +- .../config/SwiftBlobStoreContextModule.java | 7 - .../config/BaseSwiftRestClientModule.java | 2 - .../swift/config/SwiftRestClientModule.java | 2 - .../swift/CommonSwiftClientTest.java | 34 +- .../openstack/swift/SwiftApiMetadataTest.java | 18 + .../openstack/swift/SwiftClientLiveTest.java | 2 +- .../BindSwiftObjectMetadataToRequestTest.java | 10 +- .../blobstore/SwiftBlobRequestSignerTest.java | 11 +- .../org/jclouds/vcloud/VCloudApiMetadata.java | 33 +- .../jclouds/vcloud/VCloudContextBuilder.java | 57 ---- .../VCloudComputeServiceContextModule.java | 10 +- .../vcloud/config/VCloudRestClientModule.java | 2 - .../jclouds/vcloud/VCloudApiMetadataTest.java | 7 +- .../vcloud/VCloudSessionRefreshLiveTest.java | 3 +- .../vcloud/VCloudVersionsAsyncClientTest.java | 2 +- .../BindCloneVAppParamsToXmlPayloadTest.java | 6 +- ...oneVAppTemplateParamsToXmlPayloadTest.java | 4 +- .../BaseVCloudComputeServiceExpectTest.java | 2 +- .../compute/VCloudComputeServiceLiveTest.java | 7 +- .../features/CatalogClientLiveTest.java | 5 +- .../vcloud/features/VmClientLiveTest.java | 6 +- .../internal/BaseVCloudAsyncClientTest.java | 6 +- .../internal/BaseVCloudClientLiveTest.java | 9 +- .../internal/VCloudLoginAsyncClientTest.java | 2 +- .../org/jclouds/walrus/WalrusApiMetadata.java | 19 +- .../jclouds/walrus/WalrusContextBuilder.java | 56 ---- .../walrus/config/WalrusRestClientModule.java | 2 - .../jclouds/walrus/WalrusClientLiveTest.java | 3 +- .../main/clojure/org/jclouds/blobstore2.clj | 7 +- .../org/jclouds/blobstore/AsyncBlobStore.java | 2 +- .../java/org/jclouds/blobstore/BlobStore.java | 2 +- .../blobstore/BlobStoreApiMetadata.java | 20 -- .../jclouds/blobstore/BlobStoreContext.java | 14 +- .../blobstore/BlobStoreContextBuilder.java | 63 ---- .../blobstore/BlobStoreContextFactory.java | 32 +- .../blobstore/TransientApiMetadata.java | 39 +-- .../blobstore/TransientAsyncBlobStore.java | 2 +- .../TransientBlobStoreContextBuilder.java | 55 --- .../TransientBlobStoreContextModule.java | 12 +- .../config/TransientBlobStoreModule.java | 40 --- .../internal/BaseAsyncBlobStore.java | 6 +- .../blobstore/internal/BaseBlobStore.java | 6 +- .../internal/BaseBlobStoreApiMetadata.java | 65 ---- .../internal/BlobStoreContextImpl.java | 55 +-- .../org/jclouds/blobstore/BlobStoresTest.java | 11 +- .../TransientBlobRequestSignerTest.java | 2 +- .../binders/BindBlobToMultipartFormTest.java | 4 +- ...ndUserMetadataToHeadersWithPrefixTest.java | 4 +- .../blobstore/functions/BlobNameTest.java | 6 +- .../internal/BaseBlobMapIntegrationTest.java | 4 +- .../BaseBlobStoreIntegrationTest.java | 22 +- .../BaseInputStreamMapIntegrationTest.java | 4 +- .../internal/BaseMapIntegrationTest.java | 4 +- .../internal/BaseServiceIntegrationTest.java | 3 +- .../blobstore/internal/BaseBlobMapTest.java | 6 +- .../BaseBlobStoreApiMetadataTest.java | 37 +- .../internal/BiggerThanPageSizeTest.java | 5 +- .../aws/config/AWSRestClientModule.java | 2 - .../config/FormSigningRestClientModule.java | 2 - .../WithZonesFormSigningRestClientModule.java | 2 - .../java/org/jclouds/aws/util/AWSUtils.java | 2 +- .../jclouds/aws/filters/FormSignerTest.java | 2 +- .../storage/AzureStorageContextBuilder.java | 64 ---- .../config/AzureStorageRestClientModule.java | 2 - .../filters/SharedKeyLiteAuthentication.java | 2 +- .../SharedKeyLiteAuthenticationTest.java | 2 +- .../config/OpenStackAuthenticationModule.java | 2 - .../config/AuthenticationServiceModule.java | 2 - .../config/KeystoneAuthenticationModule.java | 2 - .../OpenStackAuthAsyncClientTest.java | 2 +- .../TerremarkVCloudContextBuilder.java | 71 ---- .../TerremarkVCloudPropertiesBuilder.java | 67 ---- .../BindVAppConfigurationToXmlPayload.java | 4 +- .../TerremarkVCloudComputeService.java | 1 - ...markVCloudComputeServiceContextModule.java | 9 - .../TerremarkVCloudRestClientModule.java | 8 +- .../internal/TerremarkVCloudApiMetadata.java | 45 +-- .../vcloud_0_8/TerremarkClientLiveTest.java | 39 ++- .../BindCloneVAppParamsToXmlPayloadTest.java | 6 +- ...ateVAppTemplateParamsToXmlPayloadTest.java | 5 +- ...BindNodeConfigurationToXmlPayloadTest.java | 5 +- ...BindVAppConfigurationToXmlPayloadTest.java | 7 +- .../VAppTemplatesInOrgsLiveTest.java | 6 +- .../internal/BaseTerremarkClientLiveTest.java | 14 +- .../TerremarkVCloudLoginAsyncClientTest.java | 2 +- ...erremarkVCloudVersionsAsyncClientTest.java | 2 +- .../xml/CatalogItemHandlerTest.java | 8 +- .../trmk/vcloud_0_8/xml/OrgHandlerTest.java | 8 +- .../src/main/clojure/org/jclouds/compute2.clj | 7 +- .../org/jclouds/compute/ComputeService.java | 2 +- .../compute/ComputeServiceApiMetadata.java | 38 --- .../compute/ComputeServiceContext.java | 14 +- .../compute/ComputeServiceContextBuilder.java | 95 ------ .../compute/ComputeServiceContextFactory.java | 32 +- .../org/jclouds/compute/RunScriptData.java | 2 +- ...tandaloneComputeServiceContextBuilder.java | 50 --- .../ComputeServiceAdapterContextModule.java | 25 +- .../config/ComputeServiceTimeoutsModule.java | 2 +- ...iveComputeServiceAdapterContextModule.java | 9 +- .../StandaloneComputeServiceClientModule.java | 41 --- .../compute/internal/BaseComputeService.java | 6 +- .../BaseComputeServiceApiMetadata.java | 63 ---- .../internal/ComputeServiceContextImpl.java | 66 ++-- .../compute/options/RunScriptOptions.java | 2 +- .../jclouds/compute/stub/StubApiMetadata.java | 23 +- .../config/StubComputeServiceAdapter.java | 4 +- .../StubComputeServiceContextModule.java | 19 +- .../StubComputeServiceContextBuilder.java | 54 --- .../compute/util/ComputeServiceUtils.java | 2 +- .../org/jclouds/ovf/xml/EnvelopeHandler.java | 2 +- .../VirtualSystemSettingDataHandlerTest.java | 2 +- .../StubComputeServiceIntegrationTest.java | 5 +- .../StubTemplateBuilderIntegrationTest.java | 7 +- .../config/ComputeServicePropertiesTest.java | 6 +- .../BaseComputeServiceApiMetadataTest.java | 17 +- .../BaseComputeServiceContextLiveTest.java | 12 +- .../internal/BaseComputeServiceLiveTest.java | 8 +- .../internal/BaseTemplateBuilderLiveTest.java | 13 +- .../predicates/ImagePredicatesTest.java | 5 +- .../{rest/internal => }/ContextBuilder.java | 317 ++++++++++-------- .../java/org/jclouds/PropertiesBuilder.java | 288 ---------------- core/src/main/java/org/jclouds/Wrapper.java | 65 ++++ .../java/org/jclouds/apis/ApiMetadata.java | 106 +++--- .../java/org/jclouds/apis/ApiPredicates.java | 107 +++--- .../main/java/org/jclouds/apis/ApiType.java | 46 --- core/src/main/java/org/jclouds/apis/Apis.java | 137 +++----- .../apis/internal/BaseApiMetadata.java | 265 +++++++-------- .../jclouds/concurrent/DynamicExecutors.java | 2 +- .../jclouds/encryption/internal/Base64.java | 8 +- .../org/jclouds/internal/BaseWrapper.java | 97 ++++++ .../location/config/LocationModule.java | 6 + .../providers/AnonymousProviderMetadata.java | 39 +-- .../jclouds/providers/ProviderMetadata.java | 40 +-- .../jclouds/providers/ProviderPredicates.java | 141 ++++---- .../java/org/jclouds/providers/Providers.java | 157 ++++----- .../internal/BaseProviderMetadata.java | 91 ++--- .../rest/AnonymousRestApiMetadata.java | 33 +- .../main/java/org/jclouds/rest/Providers.java | 11 +- .../org/jclouds/rest/RestApiMetadata.java | 25 +- .../org/jclouds/rest/RestContextBuilder.java | 40 --- .../org/jclouds/rest/RestContextFactory.java | 13 +- .../rest/config/AsyncClientProvider.java | 4 +- .../org/jclouds/rest/config/BinderUtils.java | 4 +- .../jclouds/rest/config/ClientProvider.java | 6 +- .../jclouds/rest/config/RestClientModule.java | 51 +-- .../org/jclouds/rest/config/RestModule.java | 40 ++- .../rest/internal/BaseRestApiMetadata.java | 112 +++++-- core/src/main/resources/rest.properties | 244 -------------- .../internal => }/ContextBuilderTest.java | 37 +- .../test/java/org/jclouds/apis/ApisTest.java | 18 +- .../test/java/org/jclouds/apis/Balancer.java | 24 +- .../BaseContextLiveTest.java | 27 +- .../java/org/jclouds/apis/Compute.java} | 29 +- .../apis/JcloudsTestBlobStoreApiMetadata.java | 16 +- .../apis/JcloudsTestComputeApiMetadata.java | 16 +- ...loudsTestYetAnotherComputeApiMetadata.java | 16 +- .../test/java/org/jclouds/apis/Storage.java | 24 +- .../apis/internal/BaseApiMetadataTest.java | 25 +- .../java/org/jclouds/http/BaseJettyTest.java | 8 +- .../http/HttpPropertiesBuilderTest.java | 49 --- .../http/IntegrationTestClientExpectTest.java | 2 +- .../handlers/RedirectionRetryHandlerTest.java | 31 +- .../org/jclouds/internal/BaseWrapperTest.java | 79 +++++ .../JcloudsTestBlobStoreProviderMetadata.java | 14 +- .../JcloudsTestComputeProviderMetadata.java | 14 +- ...TestYetAnotherComputeProviderMetadata.java | 14 +- .../org/jclouds/providers/ProvidersTest.java | 52 +-- .../internal/BaseProviderMetadataTest.java | 31 +- .../jclouds/rest/InputParamValidatorTest.java | 2 +- .../rest/internal/BaseAsyncClientTest.java | 10 +- .../internal/BaseRestApiMetadataTest.java | 12 +- .../internal/BaseRestClientExpectTest.java | 92 ++--- .../internal/RestAnnotationProcessorTest.java | 3 +- .../java/org/jclouds/util/PatternsTest.java | 8 +- ...oogleAppEngineConfigurationModuleTest.java | 4 +- .../aws/elb/AWSELBProviderMetadata.java | 16 +- .../aws/elb/AWSELBAsyncClientTest.java | 2 +- .../jclouds/aws/elb/AWSELBProviderTest.java | 4 +- .../AWSELBLoadBalancerServiceLiveTest.java | 4 +- .../CarrenzaVCloudDirectorContextBuilder.java | 59 ---- ...arrenzaVCloudDirectorProviderMetadata.java | 23 +- ...udDirectorComputeServiceContextModule.java | 9 +- ...arrenzaVCloudDirectorRestClientModule.java | 2 - .../org/jclouds/dmtf/ovf/SectionType.java | 1 - .../java/org/jclouds/elb/ELBApiMetadata.java | 57 ++-- .../org/jclouds/elb/ELBContextBuilder.java | 67 ---- .../org/jclouds/elb/ELBPropertiesBuilder.java | 51 --- .../elb/config/ELBRestClientModule.java | 2 - .../org/jclouds/elb/ELBApiMetadataTest.java | 1 - .../org/jclouds/elb/ELBAsyncClientTest.java | 6 +- .../org/jclouds/elb/ELBClientLiveTest.java | 30 +- .../ELBLoadBalancerServiceLiveTest.java | 7 +- .../org/jclouds/glesys/GleSYSApiMetadata.java | 31 +- .../jclouds/glesys/GleSYSContextBuilder.java | 57 ---- .../glesys/GleSYSProviderMetadata.java | 17 +- .../compute/GleSYSComputeServiceAdapter.java | 2 +- .../GleSYSComputeServiceContextModule.java | 11 +- .../compute/functions/OSTemplateToImage.java | 2 +- .../glesys/config/GleSYSRestClientModule.java | 2 - .../compute/GleSYSComputeServiceLiveTest.java | 7 +- .../compute/GleSYSExperimentExpectTest.java | 2 +- .../compute/GleSYSExperimentLiveTest.java | 14 +- .../GleSYSTemplateBuilderLiveTest.java | 7 +- .../functions/ServerSpecToHardwareTest.java | 2 +- .../BaseGleSYSComputeServiceExpectTest.java | 6 +- .../features/ArchiveClientExpectTest.java | 2 +- .../features/DomainClientExpectTest.java | 2 +- .../features/EmailClientExpectTest.java | 2 +- .../features/ServerClientExpectTest.java | 2 +- .../internal/BaseGleSYSAsyncClientTest.java | 2 +- .../internal/BaseGleSYSClientLiveTest.java | 7 +- .../servers/OpSourceServersApiMetadata.java | 27 +- .../OpSourceServersContextBuilder.java | 56 ---- .../OpSourceServersRestClientModule.java | 2 - .../BaseOpSourceServersClientLiveTest.java | 21 +- ...seOpSourceServersRestClientExpectTest.java | 2 +- .../jclouds/savvis/vpdc/VPDCApiMetadata.java | 35 +- .../savvis/vpdc/VPDCContextBuilder.java | 57 ---- .../savvis/vpdc/VPDCPropertiesBuilder.java | 50 --- .../savvis/vpdc/VPDCProviderMetadata.java | 17 +- .../VPDCComputeServiceContextModule.java | 8 +- .../vpdc/config/VPDCRestClientModule.java | 2 + .../VPDCComputeServiceLiveTestDisabled.java | 7 +- .../compute/VPDCTemplateBuilderLiveTest.java | 6 +- .../features/BaseVPDCAsyncClientTest.java | 4 +- .../vpdc/features/BaseVPDCClientLiveTest.java | 5 +- .../v1_5/VCloudDirectorApiMetadata.java | 27 +- .../v1_5/VCloudDirectorContextBuilder.java | 62 ---- .../v1_5/VCloudDirectorPropertiesBuilder.java | 69 ---- .../VCloudDirectorRestClientModule.java | 2 - .../director/v1_5/HttpClientLiveTest.java | 2 + .../v1_5/VCloudDirectorApiMetadataTest.java | 12 +- .../admin/AdminCatalogClientLiveTest.java | 6 - .../BaseVCloudDirectorClientLiveTest.java | 15 +- .../internal/VCloudDirectorTestSession.java | 4 +- .../v1_5/login/SessionClientExpectTest.java | 2 +- .../v1_5/login/SessionClientLiveTest.java | 14 +- .../virtualbox/VirtualBoxApiMetadata.java | 35 +- .../virtualbox/VirtualBoxContextBuilder.java | 80 ----- .../config/DefaultCacheNodeStoreModule.java | 83 ++--- ...VirtualBoxComputeServiceContextModule.java | 16 +- .../BaseVirtualBoxClientLiveTest.java | 8 +- .../virtualbox/VirtualBoxApiMetadataTest.java | 7 +- .../compute/VirtualBoxExperimentLiveTest.java | 7 +- .../functions/CreateAndInstallVmLiveTest.java | 1 - ...ieveActiveBridgedInterfacesExpectTest.java | 3 - .../loadbalancer/LoadBalancerService.java | 2 +- .../LoadBalancerServiceApiMetadata.java | 20 -- .../LoadBalancerServiceContext.java | 14 +- .../LoadBalancerServiceContextBuilder.java | 65 ---- .../LoadBalancerServiceContextFactory.java | 32 +- .../internal/BaseLoadBalancerService.java | 6 +- .../BaseLoadBalancerServiceApiMetadata.java | 63 ---- ...BaseLoadBalancerServiceContextBuilder.java | 39 --- .../LoadBalancerServiceContextImpl.java | 44 +-- .../BaseLoadBalancerServiceLiveTest.java | 21 +- ...aseLoadBalancerServiceApiMetadataTest.java | 35 +- .../AWSCloudWatchProviderMetadata.java | 17 +- .../cloudwatch/AWSCloudWatchProviderTest.java | 4 +- .../jclouds/aws/ec2/AWSEC2ApiMetadata.java | 26 +- .../jclouds/aws/ec2/AWSEC2ContextBuilder.java | 96 ------ .../aws/ec2/AWSEC2ProviderMetadata.java | 9 +- .../BindLaunchSpecificationToFormParams.java | 2 +- .../aws/ec2/compute/AWSEC2ComputeService.java | 2 +- .../compute/AWSEC2ComputeServiceContext.java | 4 +- .../AWSEC2ComputeServiceContextModule.java | 9 +- ...WSEC2ComputeServiceDependenciesModule.java | 51 ++- .../aws/ec2/compute/config/ImageQuery.java | 20 +- .../AWSEC2ComputeServiceContextImpl.java | 15 +- .../suppliers/AWSEC2ImageSupplier.java | 19 +- .../ec2/compute/suppliers/CallForImages.java | 2 +- .../ec2/config/AWSEC2RestClientModule.java | 2 - .../aws/ec2/AWSEC2ContextBuilderTest.java | 32 +- .../compute/AWSEC2ComputeServiceLiveTest.java | 18 +- .../AWSEC2TemplateBuilderLiveTest.java | 10 +- .../aws/ec2/services/AMIClientLiveTest.java | 18 +- .../ec2/services/AWSAMIClientLiveTest.java | 12 +- .../services/AWSInstanceClientLiveTest.java | 10 +- .../services/AWSKeyPairClientLiveTest.java | 11 +- .../AWSSecurityGroupClientLiveTest.java | 5 +- .../services/BaseAWSEC2AsyncClientTest.java | 4 +- .../services/MonitoringClientLiveTest.java | 8 +- .../PlacementGroupClientLiveTest.java | 7 +- .../services/SpotInstanceClientLiveTest.java | 7 +- .../aws/ec2/services/TagClientLiveTest.java | 14 +- .../org/jclouds/aws/s3/AWSS3ApiMetadata.java | 25 +- .../jclouds/aws/s3/AWSS3ContextBuilder.java | 60 ---- .../jclouds/aws/s3/AWSS3ProviderMetadata.java | 12 +- .../aws/s3/blobstore/AWSS3AsyncBlobStore.java | 10 +- .../aws/s3/blobstore/AWSS3BlobStore.java | 8 +- .../s3/blobstore/AWSS3BlobStoreContext.java | 4 +- .../config/AWSS3BlobStoreContextModule.java | 11 - .../internal/AWSS3BlobStoreContextImpl.java | 24 +- .../ParallelMultipartUploadStrategy.java | 6 +- .../SequentialMultipartUploadStrategy.java | 6 +- .../aws/s3/config/AWSS3RestClientModule.java | 2 - .../jclouds/aws/s3/AWSS3AsyncClientTest.java | 7 +- .../jclouds/aws/s3/AWSS3ClientLiveTest.java | 6 +- ...SequentialMultipartUploadStrategyTest.java | 12 +- .../internal/BaseAWSS3ClientExpectTest.java | 6 +- .../azureblob/AzureBlobApiMetadata.java | 49 +-- .../azureblob/AzureBlobContextBuilder.java | 76 ----- .../azureblob/AzureBlobProviderMetadata.java | 12 +- .../BindAzureBlobMetadataToRequest.java | 2 +- .../blobstore/AzureAsyncBlobStore.java | 2 +- .../azureblob/blobstore/AzureBlobStore.java | 2 +- .../config/AzureBlobStoreContextModule.java | 6 - .../config/AzureBlobRestClientModule.java | 2 - .../azureblob/AzureBlobClientLiveTest.java | 10 +- .../blobstore/AzureBlobRequestSignerTest.java | 4 +- .../config/AzureBlobStoreModuleTest.java | 4 +- .../BluelockVCloudZone01ContextBuilder.java | 72 ---- .../BluelockVCloudZone01ProviderMetadata.java | 23 +- ...ckVCloudZone01TemplateBuilderLiveTest.java | 7 +- .../CloudFilesUKProviderMetadata.java | 14 +- .../CloudFilesUKClientLiveTest.java | 3 +- .../CloudFilesUSProviderMetadata.java | 14 +- .../CloudLoadBalancersUKProviderMetadata.java | 11 +- .../CloudLoadBalancersUSProviderMetadata.java | 11 +- .../CloudOneStorageProviderMetadata.java | 11 +- .../CloudServersUKProviderMetadata.java | 14 +- ...CloudServersUKTemplateBuilderLiveTest.java | 7 +- .../CloudServersUSProviderMetadata.java | 14 +- ...CloudServersUSTemplateBuilderLiveTest.java | 7 +- .../CloudSigmaLasVegasProviderMetadata.java | 9 +- ...dSigmaLasVegasTemplateBuilderLiveTest.java | 2 +- .../CloudSigmaZurichProviderMetadata.java | 9 +- ...oudSigmaZurichTemplateBuilderLiveTest.java | 2 +- ...cHostsPeer1LosAngelesProviderMetadata.java | 11 +- ...eer1LosAngelesTemplateBuilderLiveTest.java | 2 +- ...HostsBlueSquareLondonProviderMetadata.java | 11 +- ...ueSquareLondonTemplateBuilderLiveTest.java | 2 +- ...asticHostsPeer1LondonProviderMetadata.java | 11 +- ...stsPeer1LondonTemplateBuilderLiveTest.java | 2 +- ...cHostsPeer1SanAntonioProviderMetadata.java | 19 +- ...eer1SanAntonioTemplateBuilderLiveTest.java | 7 +- ...sticHostsPeer1TorontoProviderMetadata.java | 18 +- ...tsPeer1TorontoTemplateBuilderLiveTest.java | 7 +- .../EucalyptusPartnerCloudContextBuilder.java | 52 --- ...lyptusPartnerCloudEC2ProviderMetadata.java | 23 +- ...loudEucalyptusTemplateBuilderLiveTest.java | 6 +- ...alyptusPartnerCloudS3ProviderMetadata.java | 14 +- ...Go2CloudJohannesburg1ProviderMetadata.java | 20 +- ...dJohannesburg1TemplateBuilderLiveTest.java | 7 +- .../org/jclouds/gogrid/GoGridApiMetadata.java | 33 +- .../jclouds/gogrid/GoGridContextBuilder.java | 57 ---- .../gogrid/GoGridProviderMetadata.java | 17 +- .../gogrid/compute/GoGridComputeService.java | 2 +- .../GoGridComputeServiceContextModule.java | 7 +- .../gogrid/config/GoGridRestClientModule.java | 2 - .../gogrid/GoGridLiveTestDisabled.java | 12 +- .../compute/GoGridComputeServiceLiveTest.java | 7 +- .../GoGridTemplateBuilderLiveTest.java | 7 +- .../services/BaseGoGridAsyncClientTest.java | 6 +- .../services/BaseGoGridClientLiveTest.java | 7 +- .../BaseGoGridRestClientExpectTest.java | 6 +- ...nHouseDataElementVCloudContextBuilder.java | 57 ---- ...ouseDataElementVCloudProviderMetadata.java | 24 +- ...ouseDataElementVCloudRestClientModule.java | 34 -- ...aElementVCloudTemplateBuilderLiveTest.java | 7 +- .../compute/HPCloudComputeContextBuilder.java | 53 --- .../HPCloudComputeProviderMetadata.java | 32 +- ...HPCloudComputeTemplateBuilderLiveTest.java | 6 +- .../HPCloudObjectStorageApiMetadata.java | 39 ++- .../HPCloudObjectStorageContextBuilder.java | 72 ---- .../HPCloudObjectStorageProviderMetadata.java | 15 +- .../HPCloudObjectStorageAsyncBlobStore.java | 2 +- .../HPCloudObjectStorageBlobStore.java | 2 +- .../HPCloudObjectStorageRestClientModule.java | 2 - .../HPCloudObjectStorageClientLiveTest.java | 2 +- .../HPCloudObjectStorageExpectTest.java | 2 +- .../NinefoldComputeProviderMetadata.java | 16 +- ...inefoldComputeTemplateBuilderLiveTest.java | 7 +- .../NinefoldStorageProviderMetadata.java | 14 +- .../OpenHostingEast1ProviderMetadata.java | 16 +- ...enHostingEast1TemplateBuilderLiveTest.java | 7 +- .../miro/RimuHostingApiMetadata.java | 35 +- .../miro/RimuHostingContextBuilder.java | 57 ---- .../miro/RimuHostingProviderMetadata.java | 17 +- ...stingComputeServiceDependenciesModule.java | 9 - .../config/RimuHostingRestClientModule.java | 2 - .../location/RimuHostingLocationSupplier.java | 2 +- .../miro/RimuHostingAsyncClientTest.java | 2 +- .../miro/RimuHostingClientLiveTest.java | 5 +- .../RimuHostingComputeServiceLiveTest.java | 7 +- .../RimuHostingTemplateBuilderLiveTest.java | 7 +- .../ServerloveManchesterProviderMetadata.java | 16 +- ...loveManchesterTemplateBuilderLiveTest.java | 7 +- .../SkaliCloudMalaysiaProviderMetadata.java | 16 +- ...iCloudMalaysiaTemplateBuilderLiveTest.java | 5 +- .../slicehost/SlicehostApiMetadata.java | 32 +- .../slicehost/SlicehostContextBuilder.java | 57 ---- .../slicehost/SlicehostProviderMetadata.java | 12 +- .../SlicehostComputeServiceContextModule.java | 10 +- .../config/SlicehostRestClientModule.java | 2 - .../slicehost/SlicehostAsyncClientTest.java | 2 +- .../slicehost/SlicehostClientLiveTest.java | 5 +- .../SlicehostComputeServiceLiveTest.java | 7 +- .../SlicehostTemplateBuilderLiveTest.java | 7 +- .../softlayer/SoftLayerApiMetadata.java | 34 +- .../softlayer/SoftLayerContextBuilder.java | 57 ---- .../softlayer/SoftLayerProviderMetadata.java | 17 +- .../SoftLayerComputeServiceContextModule.java | 10 +- .../config/SoftLayerRestClientModule.java | 2 - .../SoftLayerComputeServiceLiveTest.java | 13 +- .../compute/SoftLayerExperimentLiveTest.java | 14 +- .../SoftLayerTemplateBuilderLiveTest.java | 18 +- .../BaseSoftLayerAsyncClientTest.java | 2 +- .../features/BaseSoftLayerClientLiveTest.java | 7 +- .../StratoGenVCloudMyCloudContextBuilder.java | 57 ---- ...tratoGenVCloudMyCloudProviderMetadata.java | 24 +- ...nVCloudMyCloudTemplateBuilderLiveTest.java | 7 +- .../SynapticStorageProviderMetadata.java | 14 +- .../ecloud/TerremarkECloudApiMetadata.java | 29 +- .../ecloud/TerremarkECloudContextBuilder.java | 76 ----- .../TerremarkECloudProviderMetadata.java | 12 +- .../TerremarkECloudRestClientModule.java | 2 - .../BaseTerremarkECloudAsyncClientTest.java | 6 +- .../BaseTerremarkECloudClientLiveTest.java | 3 +- ...TerremarkECloudComputeServiceLiveTest.java | 7 +- ...erremarkECloudTemplateBuilderLiveTest.java | 7 +- .../DataCenterOperationsClientLiveTest.java | 6 +- .../features/TagOperationsClientLiveTest.java | 6 +- .../trmk/ecloud/xml/ECloudOrgHandlerTest.java | 8 +- .../xml/TagNameToUsageCountHandlerTest.java | 8 +- .../TerremarkVCloudExpressApiMetadata.java | 26 +- .../TerremarkVCloudExpressContextBuilder.java | 76 ----- ...rremarkVCloudExpressPropertiesBuilder.java | 52 --- ...erremarkVCloudExpressProviderMetadata.java | 12 +- ...erremarkVCloudExpressRestClientModule.java | 2 - .../InternetServiceLiveTest.java | 5 +- ...TerremarkVCloudExpressAsyncClientTest.java | 6 +- ...rkVCloudExpressComputeServiceLiveTest.java | 7 +- ...kVCloudExpressTemplateBuilderLiveTest.java | 7 +- .../nova/TryStackNovaContextBuilder.java | 53 --- .../nova/TryStackNovaProviderMetadata.java | 26 +- .../TryStackNovaTemplateBuilderLiveTest.java | 6 +- .../DunkelVCloudDirectorContextBuilder.java | 10 +- ...DunkelVCloudDirectorPropertiesBuilder.java | 8 - .../DunkelVCloudDirectorProviderMetadata.java | 7 - ...udDirectorComputeServiceContextModule.java | 9 - .../DunkelVCloudDirectorRestClientModule.java | 4 - .../vcd/DunkelVCloudDirectorProviderTest.java | 5 +- ...lVCloudDirectorComputeServiceLiveTest.java | 2 - ...VCloudDirectorTemplateBuilderLiveTest.java | 14 - .../ServerManagerApiMetadata.java | 21 +- ...erManagerComputeServiceContextBuilder.java | 57 ---- ...verManagerComputeServiceContextModule.java | 7 +- ...nagerComputeServiceContextBuilderTest.java | 32 +- .../ServerManagerComputeServiceLiveTest.java | 5 +- .../ServerManagerExperimentLiveTest.java | 11 +- 659 files changed, 3814 insertions(+), 8641 deletions(-) delete mode 100644 apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java delete mode 100644 apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java delete mode 100644 apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java delete mode 100644 apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java delete mode 100644 apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java delete mode 100644 apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java delete mode 100644 apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java delete mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java delete mode 100644 apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java delete mode 100644 apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java delete mode 100644 apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java delete mode 100644 apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ContextBuilder.java delete mode 100644 apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java delete mode 100644 apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java delete mode 100644 apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java delete mode 100644 apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java delete mode 100644 apis/walrus/src/main/java/org/jclouds/walrus/WalrusContextBuilder.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreModule.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java delete mode 100644 common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java delete mode 100644 common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java delete mode 100644 common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudPropertiesBuilder.java delete mode 100644 compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java delete mode 100644 compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java delete mode 100644 compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java delete mode 100644 compute/src/main/java/org/jclouds/compute/config/StandaloneComputeServiceClientModule.java delete mode 100644 compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java delete mode 100644 compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java rename core/src/main/java/org/jclouds/{rest/internal => }/ContextBuilder.java (62%) delete mode 100644 core/src/main/java/org/jclouds/PropertiesBuilder.java create mode 100644 core/src/main/java/org/jclouds/Wrapper.java delete mode 100644 core/src/main/java/org/jclouds/apis/ApiType.java create mode 100644 core/src/main/java/org/jclouds/internal/BaseWrapper.java delete mode 100644 core/src/main/java/org/jclouds/rest/RestContextBuilder.java delete mode 100644 core/src/main/resources/rest.properties rename core/src/test/java/org/jclouds/{rest/internal => }/ContextBuilderTest.java (83%) rename providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/config/BluelockVCloudZone01RestClientModule.java => core/src/test/java/org/jclouds/apis/Balancer.java (64%) rename core/src/test/java/org/jclouds/{rest/internal => apis}/BaseContextLiveTest.java (86%) rename core/src/{main/java/org/jclouds/rest/BackedByRestContext.java => test/java/org/jclouds/apis/Compute.java} (68%) rename providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/config/StratoGenVCloudMyCloudRestClientModule.java => core/src/test/java/org/jclouds/apis/Storage.java (64%) delete mode 100644 core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java create mode 100644 core/src/test/java/org/jclouds/internal/BaseWrapperTest.java rename core/src/test/java/org/jclouds/{apis => rest}/internal/BaseRestApiMetadataTest.java (79%) delete mode 100644 labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java delete mode 100644 labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java delete mode 100644 labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java delete mode 100644 labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java delete mode 100644 labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java delete mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java delete mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorPropertiesBuilder.java delete mode 100644 labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxContextBuilder.java rename apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java => labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/DefaultCacheNodeStoreModule.java (50%) delete mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java delete mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java delete mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java delete mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ContextBuilder.java rename core/src/main/java/org/jclouds/http/RequiresHttp.java => providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java (71%) delete mode 100644 providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ContextBuilder.java delete mode 100644 providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java delete mode 100644 providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ContextBuilder.java delete mode 100644 providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java delete mode 100644 providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java delete mode 100644 providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java delete mode 100644 providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java delete mode 100644 providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java delete mode 100644 providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java delete mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java delete mode 100644 providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java delete mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java delete mode 100644 providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java delete mode 100644 providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressPropertiesBuilder.java delete mode 100644 providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java delete mode 100644 skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java index 1dd282eff9..c4f6f01201 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java @@ -25,19 +25,31 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule; +import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * * @author Adrian Cole */ -public class AtmosApiMetadata - extends - BaseBlobStoreApiMetadata, AtmosApiMetadata> { +public class AtmosApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8067252472547486854L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + + private static Builder builder() { return new Builder(); } @@ -55,17 +67,16 @@ public class AtmosApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); return properties; } - public static class Builder - extends - BaseBlobStoreApiMetadata.Builder, AtmosApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(AtmosClient.class, AtmosAsyncClient.class); id("atmos") .name("EMC's Atmos API") .identityName("Subtenant ID (UID)") @@ -73,9 +84,9 @@ public class AtmosApiMetadata .documentation(URI.create("https://community.emc.com/docs/DOC-10508")) .version("1.4.0") .defaultEndpoint("https://accesspoint.atmosonline.com") - .contextBuilder(TypeToken.of(AtmosContextBuilder.class)) .defaultProperties(AtmosApiMetadata.defaultProperties()) - .javaApi(AtmosClient.class, AtmosAsyncClient.class); + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(AtmosRestClientModule.class, AtmosBlobStoreContextModule.class)); } @Override @@ -84,7 +95,7 @@ public class AtmosApiMetadata } @Override - public Builder fromApiMetadata(AtmosApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java deleted file mode 100644 index 6856023dee..0000000000 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.atmos; - -import java.util.List; - -import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule; -import org.jclouds.atmos.config.AtmosRestClientModule; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link AtmosStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see AtmosStoreContext - */ -public class AtmosContextBuilder - extends - BlobStoreContextBuilder, AtmosApiMetadata> { - - public AtmosContextBuilder( - ProviderMetadata, AtmosApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public AtmosContextBuilder(AtmosApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new AtmosBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AtmosRestClientModule()); - } -} diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java b/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java index 670466d589..982ef6b5d6 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java @@ -33,8 +33,8 @@ import org.jclouds.rest.Binder; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; /** * @author Adrian Cole diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java index 7c5db767a6..18c1b084be 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java @@ -85,7 +85,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { private final LoadingCache isPublic; @Inject - AtmosAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AtmosAsyncClient async, AtmosClient sync, ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java index 5dafd49b28..4ba8c4b63b 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java @@ -73,7 +73,7 @@ public class AtmosBlobStore extends BaseBlobStore { private final LoadingCache isPublic; @Inject - AtmosBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AtmosClient sync, ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, BlobStoreListOptionsToListOptions container2ContainerListOptions, diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java index d9e84e51e7..5ca4c57d49 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; -import org.jclouds.atmos.AtmosAsyncClient; import org.jclouds.atmos.AtmosClient; import org.jclouds.atmos.blobstore.AtmosAsyncBlobStore; import org.jclouds.atmos.blobstore.AtmosBlobRequestSigner; @@ -31,10 +30,8 @@ import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import com.google.common.cache.CacheBuilder; @@ -43,7 +40,6 @@ import com.google.common.cache.LoadingCache; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * Configures the {@link AtmosBlobStoreContext}; requires {@link AtmosAsyncBlobStore} bound. @@ -58,8 +54,6 @@ public class AtmosBlobStoreContextModule extends AbstractModule { bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); bind(AsyncBlobStore.class).to(AtmosAsyncBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(AtmosBlobStore.class).in(Scopes.SINGLETON); - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class); bind(BlobRequestSigner.class).to(AtmosBlobRequestSigner.class); } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadata.java index 5f1f772933..6338fff02b 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadata.java @@ -19,8 +19,8 @@ package org.jclouds.atmos.blobstore.functions; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/config/AtmosRestClientModule.java b/apis/atmos/src/main/java/org/jclouds/atmos/config/AtmosRestClientModule.java index b36f1c8d03..b9d52d486c 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/config/AtmosRestClientModule.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/config/AtmosRestClientModule.java @@ -32,7 +32,6 @@ import org.jclouds.date.DateService; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -50,7 +49,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class AtmosRestClientModule extends RestClientModule { public AtmosRestClientModule() { super(AtmosClient.class, AtmosAsyncClient.class); diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java b/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java index 568a1e50fd..94be6d2c57 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java @@ -51,8 +51,8 @@ import org.jclouds.util.Strings2; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; /** * Signs the EMC Atmos Online Storage request. diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java index de352521d2..c726f2e8b3 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java @@ -33,9 +33,9 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap.Builder; /** * @author Adrian Cole diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java index 6722aeffc4..878e0e7e8f 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java @@ -42,7 +42,6 @@ import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.options.GetOptions; @@ -320,8 +319,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest return new TestAtmosRestClientModule(); } - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient private static final class TestAtmosRestClientModule extends AtmosRestClientModule { @Override protected void configure() { @@ -337,7 +335,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest protected String provider = "atmos"; @Override - public ApiMetadata createApiMetadata() { + public ApiMetadata createApiMetadata() { return new AtmosApiMetadata(); } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java index 6d02a88be8..fc9adafdb9 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java @@ -57,7 +57,7 @@ import com.google.common.collect.Sets; public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest { public AtmosClient getApi() { - return (AtmosClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi(); } private static final class HeadMatches implements Runnable { diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java index c4f2d593be..79555eae05 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java @@ -32,7 +32,6 @@ import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; @@ -128,8 +127,7 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest createApiMetadata() { + public ApiMetadata createApiMetadata() { return new AtmosApiMetadata(); } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java index ccf9a5c840..6b40259d08 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java @@ -20,10 +20,10 @@ package org.jclouds.atmos.blobstore.config; import static org.testng.Assert.assertEquals; +import org.jclouds.ContextBuilder; import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.logging.config.NullLoggingModule; @@ -41,7 +41,7 @@ import com.google.inject.Module; public class AtmosBlobStoreModuleTest { Injector createInjector() { - return BlobStoreContextBuilder + return ContextBuilder .newBuilder(new AtmosApiMetadata()) .credentials("uid", "key") .modules( @@ -53,7 +53,7 @@ public class AtmosBlobStoreModuleTest { void testContextImpl() { Injector injector = createInjector(); - BlobStoreContext handler = injector.getInstance(BlobStoreContext.class); + BlobStoreContext handler = injector.getInstance(BlobStoreContext.class); assertEquals(handler.getClass(), BlobStoreContextImpl.class); ContainsValueInListStrategy valueList = injector .getInstance(ContainsValueInListStrategy.class); diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java index dc07a557d8..903cba2de1 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java @@ -28,12 +28,11 @@ import java.security.NoSuchAlgorithmException; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; +import org.jclouds.ContextBuilder; import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.atmos.reference.AtmosHeaders; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; @@ -43,9 +42,9 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMultimap.Builder; import com.google.inject.Injector; import com.google.inject.Module; @@ -97,7 +96,7 @@ public class SignRequestTest { @BeforeClass protected void createFilter() { - Injector injector = BlobStoreContextBuilder + Injector injector = ContextBuilder .newBuilder("atmos") .credentials(UID, KEY) .modules( @@ -108,8 +107,7 @@ public class SignRequestTest { } - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient private static final class TestAtmosRestClientModule extends AtmosRestClientModule { @Override diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/functions/AtmosObjectNameTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/functions/AtmosObjectNameTest.java index b1690107fe..1f9a5a56e1 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/functions/AtmosObjectNameTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/functions/AtmosObjectNameTest.java @@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals; import java.io.File; import org.jclouds.atmos.domain.AtmosObject; -import org.jclouds.atmos.domain.AtmosObject.Factory; import org.jclouds.atmos.domain.SystemMetadata; import org.jclouds.atmos.domain.UserMetadata; +import org.jclouds.atmos.domain.AtmosObject.Factory; import org.testng.annotations.Test; import com.google.inject.Guice; diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java index a094713c0b..1aa7293702 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java +++ b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java @@ -19,15 +19,16 @@ package org.jclouds.byon; import java.net.URI; -import java.util.Properties; import org.jclouds.JcloudsVersion; import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.byon.config.BYONComputeServiceContextModule; +import org.jclouds.byon.config.YamlNodeStoreModule; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; -import com.google.common.base.Supplier; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for jclouds BYON API @@ -39,8 +40,10 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") -public class BYONApiMetadata extends BaseComputeServiceApiMetadata, BYONApiMetadata> { +public class BYONApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -4059125995177393819L; @Override public Builder toBuilder() { @@ -55,11 +58,7 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata, BYONApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder() { id("byon") @@ -71,9 +70,8 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata>of(YamlNodeStoreModule.class, BYONComputeServiceContextModule.class)); } @Override @@ -82,7 +80,7 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata, BYONApiMetadata> { - - public BYONComputeServiceContextBuilder( - ProviderMetadata, BYONApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public BYONComputeServiceContextBuilder(BYONApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new BYONComputeServiceContextModule()); - addNodeStoreModuleIfNotPresent(modules); - } - - protected void addNodeStoreModuleIfNotPresent(List modules) { - if (!Iterables.any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresNodeStore.class); - } - - })) { - addNodeStoreModule(modules); - } - } - - protected void addNodeStoreModule(List modules) { - modules.add(new YamlNodeStoreModule()); - } -} diff --git a/apis/byon/src/main/java/org/jclouds/byon/config/BYONComputeServiceContextModule.java b/apis/byon/src/main/java/org/jclouds/byon/config/BYONComputeServiceContextModule.java index f00b3db1e7..8168e645f3 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/config/BYONComputeServiceContextModule.java +++ b/apis/byon/src/main/java/org/jclouds/byon/config/BYONComputeServiceContextModule.java @@ -21,9 +21,6 @@ package org.jclouds.byon.config; import java.io.InputStream; import java.net.URI; -import javax.inject.Singleton; - -import org.jclouds.byon.Node; import org.jclouds.byon.internal.BYONComputeServiceAdapter; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule; @@ -36,27 +33,17 @@ import org.jclouds.location.Provider; import com.google.common.base.Function; import com.google.common.base.Supplier; -import com.google.common.cache.LoadingCache; -import com.google.inject.Provides; import com.google.inject.TypeLiteral; /** * * @author Adrian Cole */ -@SuppressWarnings("unchecked") @SingleThreaded -public class BYONComputeServiceContextModule extends - JCloudsNativeComputeServiceAdapterContextModule { +public class BYONComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule { public BYONComputeServiceContextModule() { - super(Supplier.class, Supplier.class, BYONComputeServiceAdapter.class); - } - - @Provides - @Singleton - Supplier provideApi(Supplier> in) { - return in; + super(BYONComputeServiceAdapter.class); } @Override @@ -68,6 +55,7 @@ public class BYONComputeServiceContextModule extends }).annotatedWith(Provider.class).to(SupplyFromProviderURIOrNodesProperty.class); bind(new TypeLiteral>() { }).to(SupplyFromProviderURIOrNodesProperty.class); - install(new LocationsFromComputeServiceAdapterModule(){}); + install(new LocationsFromComputeServiceAdapterModule() { + }); } } diff --git a/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java b/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java index b8b8615f56..318fc515ac 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java +++ b/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java @@ -33,9 +33,9 @@ import org.yaml.snakeyaml.constructor.Constructor; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap.Builder; import com.google.common.io.Closeables; /** diff --git a/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java b/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java index 6ae9ecdd4a..19837550e7 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java +++ b/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java @@ -42,8 +42,8 @@ import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; import com.google.common.util.concurrent.UncheckedExecutionException; /** diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java index 4668ad7a45..588c5e6a41 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java @@ -24,14 +24,14 @@ import static org.jclouds.scriptbuilder.domain.Statements.exec; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; +import java.util.Map.Entry; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterClass; @@ -49,7 +49,7 @@ import com.google.inject.Module; @Test(groups = "live") public class BYONComputeServiceLiveTest { - private ComputeServiceContext context; + private ComputeServiceContext context; @BeforeClass(groups = "live") public void setup() throws FileNotFoundException, IOException { @@ -72,8 +72,9 @@ public class BYONComputeServiceLiveTest { .append("\n"); contextProperties.setProperty("byon.nodes", nodes.toString()); - context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties) - .modules(ImmutableSet. of(new SshjSshClientModule(), new Log4JLoggingModule())).build(); + context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties).modules( + ImmutableSet. of(new SshjSshClientModule(), new Log4JLoggingModule())).build( + ComputeServiceContext.class); } public void testCanRunCommandAsCurrentUser() throws Exception { diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java index 258e837e5a..9a6b4077cd 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java @@ -23,16 +23,14 @@ import static org.jclouds.byon.functions.NodeToNodeMetadataTest.expectedProvider import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled; import static org.testng.Assert.assertEquals; -import java.net.URI; - +import org.jclouds.ContextBuilder; +import org.jclouds.byon.config.BYONComputeServiceContextModule; import org.jclouds.byon.config.CacheNodeStoreModule; import org.jclouds.byon.functions.NodesFromYamlTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -40,7 +38,9 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.inject.Key; import com.google.inject.Module; +import com.google.inject.TypeLiteral; /** * @@ -51,36 +51,31 @@ public class BYONComputeServiceTest { @Test public void testNodesParseNodeMap() throws Exception { - assertNodesParse( - "foo", - ImmutableSet. of(new CacheNodeStoreModule(ImmutableMap. of( - NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))); + assertNodesParse("foo", ContextBuilder.newBuilder( + new BYONApiMetadata().toBuilder().defaultModule(BYONComputeServiceContextModule.class).build()) + .endpoint("foo").modules( + ImmutableSet. of(new CacheNodeStoreModule(ImmutableMap. of( + NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))).build( + ComputeServiceContext.class)); } @Test public void testNodesParseWithFileUrl() throws Exception { - assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ImmutableSet. of()); + assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint( + "file://" + getClass().getResource("/test1.yaml").getPath()).build(ComputeServiceContext.class)); } @Test public void testNodesParseWithClasspathUrl() throws Exception { - assertNodesParse("classpath:///test1.yaml", ImmutableSet. of()); + assertNodesParse("classpath:///test1.yaml", ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint( + "classpath:///test1.yaml").build(ComputeServiceContext.class)); } - private void assertNodesParse(String endpoint, Iterable modules) { - ComputeServiceContext context = null; + private void assertNodesParse(String endpoint, ComputeServiceContext context) { try { Location providerLocation = expectedProviderLocationFromResource(endpoint); - context = ContextBuilder.newBuilder( - AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)) - .modules(modules).build(); - - assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); - - @SuppressWarnings("unchecked") - Supplier> supplier = (Supplier>) context.getProviderSpecificContext() - .getApi(); + Supplier> supplier = supplier(context); assertEquals(supplier.get().size(), context.getComputeService().listNodes().size()); assertEquals(supplier.get().asMap(), @@ -96,17 +91,12 @@ public class BYONComputeServiceTest { } public void testNodesWithLocations() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath(); - context = ContextBuilder.newBuilder( - AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)).build(); + context = ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(endpoint).build(ComputeServiceContext.class); - assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); - - @SuppressWarnings("unchecked") - Supplier> supplier = (Supplier>) context.getProviderSpecificContext() - .getApi(); + Supplier> supplier = supplier(context); assertEquals(supplier.get().size(), context.getComputeService().listNodes().size()); assertEquals(supplier.get().asMap(), ImmutableMap. of(NodesFromYamlTest.TEST2.getId(), @@ -143,4 +133,11 @@ public class BYONComputeServiceTest { context.close(); } } + + private Supplier> supplier(ComputeServiceContext context) { + Supplier> supplier = context.utils().injector().getInstance( + Key.get(new TypeLiteral>>() { + })); + return supplier; + } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java index 5d7cf50a69..85bbdd6fd0 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java @@ -26,19 +26,29 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; +import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; import org.jclouds.openstack.OpenStackAuthAsyncClient; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * * @author Adrian Cole */ -public class CloudFilesApiMetadata - extends - BaseBlobStoreApiMetadata, CloudFilesApiMetadata> { +public class CloudFilesApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 820062881469203616L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -56,26 +66,25 @@ public class CloudFilesApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); return properties; } - public static class Builder - extends - BaseBlobStoreApiMetadata.Builder, CloudFilesApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudFilesClient.class, CloudFilesAsyncClient.class); id("cloudfiles") .name("Rackspace Cloud Files API") .identityName("Username") .credentialName("API Key") .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")) .version(OpenStackAuthAsyncClient.VERSION) - .contextBuilder(TypeToken.of(CloudFilesContextBuilder.class)) .defaultProperties(CloudFilesApiMetadata.defaultProperties()) - .javaApi(CloudFilesClient.class, CloudFilesAsyncClient.class); + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class)); } @Override @@ -84,7 +93,7 @@ public class CloudFilesApiMetadata } @Override - public Builder fromApiMetadata(CloudFilesApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java deleted file mode 100644 index 84f966e358..0000000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudfiles; - -import java.util.List; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; -import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link CloudFilesStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see CloudFilesStoreContext - */ -public class CloudFilesContextBuilder - extends - BlobStoreContextBuilder, CloudFilesApiMetadata> { - - public CloudFilesContextBuilder( - ProviderMetadata, CloudFilesApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudFilesContextBuilder(CloudFilesApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudFilesBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new CloudFilesRestClientModule()); - } -} diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java index af064f61c1..34b61b03de 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java @@ -59,7 +59,7 @@ public class CloudFilesAsyncBlobStore extends SwiftAsyncBlobStore { private final EnableCDNAndCache enableCDNAndCache; @Inject - protected CloudFilesAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, CloudFilesClient sync, CloudFilesAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java index d7309f99bc..42be6d884c 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java @@ -53,7 +53,7 @@ public class CloudFilesBlobStore extends SwiftBlobStore { private EnableCDNAndCache enableCDNAndCache; @Inject - protected CloudFilesBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected CloudFilesBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java index f665b01ad1..cdbc74dea9 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java @@ -28,7 +28,6 @@ import org.jclouds.cloudfiles.CDNManagement; import org.jclouds.cloudfiles.CloudFilesAsyncClient; import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -53,7 +52,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class CloudFilesRestClientModule extends RestClientModule { public CloudFilesRestClientModule() { diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java index 91bd107f73..e7b382059f 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java @@ -47,7 +47,7 @@ public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest, CloudLoadBalancersApiMetadata> { +public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { @@ -51,16 +61,15 @@ public class CloudLoadBalancersApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseLoadBalancerServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); return properties; } - public static class Builder - extends - BaseLoadBalancerServiceApiMetadata.Builder, CloudLoadBalancersApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class); id("cloudloadbalancers") .name("Rackspace Cloud Load Balancers API") .identityName("Username") @@ -68,9 +77,9 @@ public class CloudLoadBalancersApiMetadata .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")) .version(OpenStackAuthAsyncClient.VERSION) .defaultEndpoint("https://auth.api.rackspacecloud.com") - .javaApi(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class) .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(CloudLoadBalancersContextBuilder.class)); + .wrapper(TypeToken.of(LoadBalancerServiceContext.class)) + .defaultModules(ImmutableSet.>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class)); } @Override @@ -79,7 +88,7 @@ public class CloudLoadBalancersApiMetadata } @Override - public Builder fromApiMetadata(CloudLoadBalancersApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java deleted file mode 100644 index 2e4c8e7827..0000000000 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudloadbalancers; - -import java.util.List; - -import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule; -import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class CloudLoadBalancersContextBuilder - extends - LoadBalancerServiceContextBuilder, CloudLoadBalancersApiMetadata> { - - public CloudLoadBalancersContextBuilder( - ProviderMetadata, CloudLoadBalancersApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudLoadBalancersContextBuilder(CloudLoadBalancersApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudLoadBalancersLoadBalancerContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new CloudLoadBalancersRestClientModule()); - } - -} \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java index 58b1681999..bd9e8ce2b2 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java @@ -37,7 +37,6 @@ import org.jclouds.cloudloadbalancers.handlers.ParseCloudLoadBalancersErrorFromH import org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix; import org.jclouds.cloudloadbalancers.reference.RackspaceConstants; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -64,7 +63,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class CloudLoadBalancersRestClientModule extends RestClientModule { diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java index 213eea8d48..658a2134e5 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java @@ -22,9 +22,9 @@ import java.util.Date; import java.util.Map; import java.util.Set; -import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.VirtualIP; +import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer; import com.google.common.collect.Maps; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java index bacd9bb7f5..23c35038fd 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java @@ -22,8 +22,8 @@ import java.io.IOException; import java.lang.reflect.Method; import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes; -import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder; import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest; +import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder; import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type; import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer; import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java index b95b023667..2b672161cb 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java @@ -53,12 +53,12 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive } @Override - protected void tearDown() { + protected void tearDownContext() { for (LoadBalancer lb : lbs) { client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId()); assert loadBalancerDeleted.apply(lb) : lb; } - super.tearDown(); + super.tearDownContext(); } public void testCreateLoadBalancer() throws Exception { diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java index b0702d5d7e..fb09722a1b 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java @@ -24,8 +24,8 @@ import java.util.Collections; import java.util.Set; import org.jclouds.cloudloadbalancers.domain.NodeAttributes; -import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder; import org.jclouds.cloudloadbalancers.domain.NodeRequest; +import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder; import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition; import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest; import org.jclouds.http.HttpRequest; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java index e722442f85..64bfa9611e 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java @@ -26,16 +26,16 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import java.util.logging.Logger; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; -import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest; import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.NodeAttributes; import org.jclouds.cloudloadbalancers.domain.NodeRequest; +import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type; import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest; import org.testng.annotations.AfterGroups; @@ -137,7 +137,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { @Override @AfterGroups(groups = "live") - protected void tearDown() { + protected void tearDownContext() { for (Entry> entry : nodes.entrySet()) { LoadBalancer lb = entry.getKey(); LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion()); @@ -147,6 +147,6 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { } assert loadBalancerDeleted.apply(lb) : lb; } - super.tearDown(); + super.tearDownContext(); } } diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java index 0fc4fb0bff..521aa3a0ef 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java @@ -19,9 +19,9 @@ package org.jclouds.cloudloadbalancers.functions; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; -import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.VirtualIP; +import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.VirtualIP.IPVersion; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpResponse; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java index b6fc178223..95b1e0d848 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java @@ -21,8 +21,8 @@ package org.jclouds.cloudloadbalancers.functions; import java.util.Set; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; -import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.VirtualIP; +import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpResponse; import org.jclouds.json.BaseSetParserTest; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java index 3ddb2f6e45..d0ed3c0283 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java @@ -38,7 +38,6 @@ import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule; import org.jclouds.cloudloadbalancers.reference.Region; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.internal.ClassMethodArgs; import org.jclouds.location.config.LocationModule; import org.jclouds.openstack.filters.AuthenticateRequest; @@ -71,7 +70,6 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest extends BaseAsync } @ConfiguresRestClient - @RequiresHttp protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule { @Override protected void installLocations() { @@ -127,7 +125,7 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest extends BaseAsync } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudLoadBalancersApiMetadata(); } diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java index fc178ac0f7..201a5b363a 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.cloudloadbalancers.internal; import java.util.concurrent.TimeUnit; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; @@ -30,11 +31,10 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseContextLiveTest; -import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import com.google.common.base.Predicate; +import com.google.common.reflect.TypeToken; import com.google.inject.Guice; import com.google.inject.Injector; @@ -42,9 +42,7 @@ import com.google.inject.Injector; * * @author Adrian Cole */ -public class BaseCloudLoadBalancersClientLiveTest - extends - BaseContextLiveTest> { +public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest { public BaseCloudLoadBalancersClientLiveTest() { provider = "cloudloadbalancers"; @@ -63,7 +61,7 @@ public class BaseCloudLoadBalancersClientLiveTest @Override public void setupContext() { super.setupContext(); - lbContext = context.getProviderSpecificContext(); + lbContext = context.unwrap(); client = lbContext.getApi(); @@ -76,10 +74,9 @@ public class BaseCloudLoadBalancersClientLiveTest injector.injectMembers(loadBalancerDeleted); } - @AfterGroups(groups = "live") - protected void tearDown() { - if (lbContext != null) - lbContext.close(); + @Override + protected TypeToken contextType() { + return TypeToken.of(LoadBalancerServiceContext.class); } } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java index 7ab3010dec..208fb51b30 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java @@ -22,20 +22,30 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule; +import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.openstack.OpenStackAuthAsyncClient; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for CloudServers 1.0 API * * @author Adrian Cole */ -public class CloudServersApiMetadata - extends - BaseComputeServiceApiMetadata, CloudServersApiMetadata> { +public class CloudServersApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { @@ -50,16 +60,15 @@ public class CloudServersApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, CloudServersApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudServersClient.class, CloudServersAsyncClient.class); id("cloudservers") .name("Rackspace Cloud Servers API") .identityName("Username") @@ -67,9 +76,9 @@ public class CloudServersApiMetadata .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")) .version(OpenStackAuthAsyncClient.VERSION) .defaultEndpoint("https://auth.api.rackspacecloud.com") - .javaApi(CloudServersClient.class, CloudServersAsyncClient.class) .defaultProperties(CloudServersApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(CloudServersContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class)); } @Override @@ -78,7 +87,7 @@ public class CloudServersApiMetadata } @Override - public Builder fromApiMetadata(CloudServersApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java deleted file mode 100644 index 52e43a7d3a..0000000000 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudservers; - -import java.util.List; - -import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule; -import org.jclouds.cloudservers.config.CloudServersRestClientModule; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class CloudServersContextBuilder - extends - ComputeServiceContextBuilder, CloudServersApiMetadata> { - - public CloudServersContextBuilder( - ProviderMetadata, CloudServersApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudServersContextBuilder(CloudServersApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudServersComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new CloudServersRestClientModule()); - } - -} \ No newline at end of file diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java index d7065b96dc..9747eca77f 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java @@ -22,8 +22,6 @@ import java.util.Map; import javax.inject.Singleton; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage; import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem; import org.jclouds.cloudservers.compute.functions.FlavorToHardware; @@ -55,12 +53,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class CloudServersComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public CloudServersComputeServiceContextModule() { - super(CloudServersClient.class, CloudServersAsyncClient.class); - } +public class CloudServersComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java index dcc000ec92..13f267c7c5 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java @@ -32,7 +32,6 @@ import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -53,7 +52,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class CloudServersRestClientModule extends RestClientModule { public CloudServersRestClientModule() { diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java index 829b7a8cef..e630ff6ed6 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java @@ -50,7 +50,6 @@ import org.jclouds.cloudservers.options.ListOptions; import org.jclouds.cloudservers.options.RebuildServerOptions; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.http.functions.ReturnTrueIf2xx; @@ -890,8 +889,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudServersApiMetadata(); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java index 3618a2c58e..d1f0cc47e9 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java @@ -44,7 +44,6 @@ import org.jclouds.cloudservers.domain.ServerStatus; import org.jclouds.cloudservers.domain.SharedIpGroup; import org.jclouds.cloudservers.domain.WeeklyBackup; import org.jclouds.cloudservers.options.RebuildServerOptions; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; @@ -72,9 +71,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest") -public class CloudServersClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTest { public CloudServersClientLiveTest() { provider = "cloudservers"; diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java index d7af173018..9aa6c7671d 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java @@ -22,9 +22,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.domain.LocationScope; @@ -40,9 +37,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest") -public class CloudServersComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest { public CloudServersComputeServiceLiveTest() { provider = "cloudservers"; diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java index 71cc584289..f6018a9707 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java @@ -28,7 +28,6 @@ import org.jclouds.cloudservers.CloudServersApiMetadata; import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.RequiresHttp; import org.jclouds.openstack.filters.AddTimestampQuery; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest; @@ -49,7 +48,7 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudServersApiMetadata(); } @@ -81,8 +80,7 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient } @ConfiguresRestClient - @RequiresHttp - protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { + protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { @Override public Supplier provideCacheBusterDate() { diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java index 96cfb3893a..28be12c28c 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java @@ -24,20 +24,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule; +import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the Cloud Sigma API * * @author Adrian Cole */ -public class CloudSigmaApiMetadata - extends - BaseComputeServiceApiMetadata, CloudSigmaApiMetadata> { +public class CloudSigmaApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -51,8 +60,8 @@ public class CloudSigmaApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); // passwords are set post-boot, so auth failures are possible // from a race condition applying the password set script @@ -61,11 +70,10 @@ public class CloudSigmaApiMetadata return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, CloudSigmaApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudSigmaClient.class, CloudSigmaAsyncClient.class); id("cloudsigma") .name("CloudSigma API") .identityName("Email") @@ -74,8 +82,8 @@ public class CloudSigmaApiMetadata .version("1.0") .defaultEndpoint("https://api.cloudsigma.com") .defaultProperties(CloudSigmaApiMetadata.defaultProperties()) - .javaApi(CloudSigmaClient.class, CloudSigmaAsyncClient.class) - .contextBuilder(TypeToken.of(CloudSigmaContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class)); } @Override @@ -84,7 +92,7 @@ public class CloudSigmaApiMetadata } @Override - public Builder fromApiMetadata(CloudSigmaApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java deleted file mode 100644 index 222e790707..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudsigma; - -import java.util.List; - -import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule; -import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class CloudSigmaContextBuilder - extends - ComputeServiceContextBuilder, CloudSigmaApiMetadata> { - - public CloudSigmaContextBuilder( - ProviderMetadata, CloudSigmaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudSigmaContextBuilder(CloudSigmaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudSigmaComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new CloudSigmaRestClientModule()); - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java index 6d596eaffd..51afbb8c76 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java @@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.cloudsigma.CloudSigmaAsyncClient; import org.jclouds.cloudsigma.CloudSigmaClient; import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter; import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl; @@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class CloudSigmaComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public CloudSigmaComputeServiceContextModule() { - super(CloudSigmaClient.class, CloudSigmaAsyncClient.class); - } +public class CloudSigmaComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java index 5439b5d0ad..356fc1bec9 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java @@ -25,8 +25,8 @@ import org.jclouds.cloudsigma.domain.DriveInfo; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.domain.Location; import com.google.common.base.Function; diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java index b933c221e3..ce17878825 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java @@ -33,14 +33,13 @@ import org.jclouds.cloudsigma.domain.ServerMetrics; import org.jclouds.cloudsigma.functions.BaseDriveToMap; import org.jclouds.cloudsigma.functions.DriveDataToMap; import org.jclouds.cloudsigma.functions.MapToDevices; -import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; import org.jclouds.cloudsigma.functions.MapToDriveMetrics; import org.jclouds.cloudsigma.functions.MapToNICs; import org.jclouds.cloudsigma.functions.MapToServerMetrics; import org.jclouds.cloudsigma.functions.ServerToMap; +import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -55,7 +54,6 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class CloudSigmaRestClientModule extends RestClientModule { diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java index 709786f360..a0a6b11fef 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java @@ -31,8 +31,8 @@ import org.jclouds.cloudsigma.domain.SCSIDevice; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableSet.Builder; /** * diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java index d7fafbaf17..7b0312d639 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java @@ -648,7 +648,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudSigmaApiMetadata(); } diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java index 874a59309e..48f8c98bb7 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java @@ -43,7 +43,6 @@ import org.jclouds.cloudsigma.domain.VLANInfo; import org.jclouds.cloudsigma.options.CloneDriveOptions; import org.jclouds.cloudsigma.predicates.DriveClaimed; import org.jclouds.cloudsigma.util.Servers; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; @@ -71,9 +70,7 @@ import com.google.inject.Guice; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest") -public class CloudSigmaClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest { public CloudSigmaClientLiveTest() { provider = "cloudsigma"; @@ -92,7 +89,7 @@ public class CloudSigmaClientLiveTest @Override public void setupContext() { super.setupContext(); - cloudSigmaContext = context.getProviderSpecificContext(); + cloudSigmaContext = context.unwrap(); client = cloudSigmaContext.getApi(); driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java index 7022468935..bbedf65bdc 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java @@ -18,9 +18,6 @@ */ package org.jclouds.cloudsigma.compute; -import org.jclouds.cloudsigma.CloudSigmaAsyncClient; -import org.jclouds.cloudsigma.CloudSigmaClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; @@ -34,9 +31,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class CloudSigmaComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest { public CloudSigmaComputeServiceLiveTest() { provider = "cloudsigma"; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java index 80f97b45cf..ac6981292f 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java @@ -22,9 +22,14 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule; +import org.jclouds.cloudstack.config.CloudStackRestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack api. @@ -43,9 +48,15 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata -{ - +public class CloudStackApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3936131452958663245L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -59,17 +70,18 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata { + extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudStackClient.class, CloudStackAsyncClient.class); id("cloudstack") .name("Citrix CloudStack API") .identityName("API Key") @@ -77,10 +89,9 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata>of(CloudStackRestClientModule.class, CloudStackComputeServiceContextModule.class)); } @Override @@ -89,7 +100,7 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata { +public interface CloudStackContext extends ComputeServiceContext { + @SuppressWarnings("unchecked") @Override RestContext getProviderSpecificContext(); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java deleted file mode 100644 index 904972e5ac..0000000000 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudstack; - -import java.util.List; -import java.util.Properties; - -import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule; -import org.jclouds.cloudstack.config.CloudStackRestClientModule; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.annotations.VisibleForTesting; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class CloudStackContextBuilder extends - ComputeServiceContextBuilder { - - public CloudStackContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public CloudStackContextBuilder(CloudStackApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new CloudStackRestClientModule()); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudStackComputeServiceContextModule()); - } - - @VisibleForTesting - public Properties getOverrides() { - return overrides; - } - -} diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindAccountSecurityGroupPairsToIndexedQueryParams.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindAccountSecurityGroupPairsToIndexedQueryParams.java index 3427a394cb..8b3b1b72e2 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindAccountSecurityGroupPairsToIndexedQueryParams.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindAccountSecurityGroupPairsToIndexedQueryParams.java @@ -33,8 +33,8 @@ import org.jclouds.http.utils.ModifyRequest; import org.jclouds.rest.Binder; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMultimap.Builder; /** * diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java index f008bfe2ed..23af639fe9 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java @@ -30,7 +30,6 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.cloudstack.CloudStackAsyncClient; import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.compute.functions.ServiceOfferingToHardware; import org.jclouds.cloudstack.compute.functions.TemplateToImage; @@ -87,13 +86,8 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -public class CloudStackComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public CloudStackComputeServiceContextModule() { - super(CloudStackClient.class, CloudStackAsyncClient.class); - } +public class CloudStackComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @Override protected void configure() { diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java index 6880782594..6c63d78e54 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java @@ -33,8 +33,8 @@ import org.jclouds.cloudstack.domain.OSType; import org.jclouds.cloudstack.domain.Template; import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.util.ComputeServiceUtils; import org.jclouds.logging.Logger; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java index 2179d4fb36..c7225110b5 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java @@ -63,8 +63,8 @@ import com.google.common.base.Supplier; import com.google.common.base.Throwables; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableSet.Builder; import com.google.common.primitives.Ints; /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java index 065662b09a..91bd2075a4 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java @@ -27,11 +27,11 @@ import java.util.Set; import javax.inject.Singleton; import org.jclouds.cloudstack.domain.Account; -import org.jclouds.cloudstack.domain.Account.State; import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.PortForwardingRule; import org.jclouds.cloudstack.domain.User; +import org.jclouds.cloudstack.domain.Account.State; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java index 4508246b79..3f937c56ce 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java @@ -18,7 +18,6 @@ */ package org.jclouds.cloudstack.config; -import org.jclouds.compute.ComputeServiceContextBuilder; /** * Configuration properties and constants used in CloudStack connections. diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java index e4e7336a7f..a5b63e1d09 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java @@ -123,7 +123,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -155,7 +154,6 @@ import com.google.inject.name.Named; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class CloudStackRestClientModule extends RestClientModule { diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java index a3d8306359..39c910507b 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java @@ -21,13 +21,13 @@ package org.jclouds.cloudstack.domain; import static com.google.common.base.Preconditions.checkNotNull; import java.util.Map; -import java.util.Map.Entry; import java.util.SortedSet; +import java.util.Map.Entry; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedSet; +import com.google.common.collect.ImmutableMap.Builder; import com.google.gson.annotations.SerializedName; /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java index 670e2698fb..eeb36a23a7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java @@ -26,8 +26,8 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import org.jclouds.cloudstack.domain.LoadBalancerRule; -import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.domain.VirtualMachine; +import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerClient.java index ab20d2e2e0..c80e3d59d7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerClient.java @@ -22,8 +22,8 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.cloudstack.domain.LoadBalancerRule; -import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.domain.VirtualMachine; +import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java index 572ef7ede2..8153196602 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java @@ -38,8 +38,8 @@ import org.jclouds.logging.Logger; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; /** * diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java index ec9a209a3a..fdd1aa8718 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java @@ -30,8 +30,8 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.json.internal.GsonWrapper; import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSortedMap; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Inject; import com.google.inject.TypeLiteral; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseTypedAsyncJob.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseTypedAsyncJob.java index 7f1ba7d325..50e63eb1ab 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseTypedAsyncJob.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseTypedAsyncJob.java @@ -29,9 +29,7 @@ import javax.inject.Singleton; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.AsyncJob; -import org.jclouds.cloudstack.domain.AsyncJob.Builder; import org.jclouds.cloudstack.domain.AsyncJobError; -import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.IPForwardingRule; import org.jclouds.cloudstack.domain.LoadBalancerRule; @@ -45,6 +43,8 @@ import org.jclouds.cloudstack.domain.TemplateExtraction; import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.Volume; +import org.jclouds.cloudstack.domain.AsyncJob.Builder; +import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.domain.JsonBall; import org.jclouds.json.Json; import org.jclouds.logging.Logger; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java index 2be7231dd2..3267f9d56b 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.internal; +import java.io.Closeable; import java.util.Map; import javax.inject.Inject; @@ -34,34 +35,34 @@ import org.jclouds.compute.ComputeService; import org.jclouds.compute.Utils; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.domain.Credentials; +import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class CloudStackContextImpl extends ComputeServiceContextImpl implements - CloudStackContext { - private final RestContext providerSpecificContext; +public class CloudStackContextImpl extends ComputeServiceContextImpl implements CloudStackContext { private final RestContext domainContext; private final RestContext globalContext; @Inject - public CloudStackContextImpl(ComputeService computeService, Map credentialStore, Utils utils, - RestContext providerSpecificContext, - RestContext domainContext, - RestContext globalContext) { - super(computeService, credentialStore, utils, providerSpecificContext); - this.providerSpecificContext=providerSpecificContext; + public CloudStackContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + ComputeService computeService, Map credentialStore, Utils utils, + RestContext domainContext, + RestContext globalContext) { + super(wrapped, wrappedType, computeService, credentialStore, utils); this.domainContext = domainContext; this.globalContext = globalContext; } - + @Override - public RestContext getProviderSpecificContext() { - return providerSpecificContext; + public RestContext getProviderSpecificContext() { + return unwrap(); } - + @Override public RestContext getDomainContext() { return domainContext; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java index 52dc210313..ce3e1bfa95 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java @@ -21,8 +21,8 @@ package org.jclouds.cloudstack.predicates; import static com.google.common.base.Preconditions.checkNotNull; import org.jclouds.cloudstack.domain.Account; -import org.jclouds.cloudstack.domain.Account.Type; import org.jclouds.cloudstack.domain.User; +import org.jclouds.cloudstack.domain.Account.Type; import com.google.common.base.Predicate; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java index 1683fd9524..d5bd2bd5da 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java @@ -26,13 +26,13 @@ import java.util.Properties; import java.util.Set; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.ApiKeyPair; import org.jclouds.cloudstack.domain.User; -import org.jclouds.compute.ComputeServiceContextBuilder; /** * @author Andrei Savu @@ -62,12 +62,12 @@ public class ApiKeyPairs { overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true"); overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials"); - context = ComputeServiceContextBuilder.newBuilder(new CloudStackApiMetadata()) + context = ContextBuilder.newBuilder(new CloudStackApiMetadata()) .endpoint(checkNotNull(endpoint, "endpoint").toASCIIString()) .credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password) - .overrides(overrides).build(); + .overrides(overrides).build(CloudStackContext.class); - CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); + CloudStackClient client = context.getProviderSpecificContext().getApi(); Set listOfAccounts = client.getAccountClient().listAccounts(); domain = (domain.equals("") || domain.equals("/")) ? "ROOT" : domain; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java index 8dad16187e..0da85d8081 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java @@ -53,8 +53,8 @@ import org.jclouds.cloudstack.suppliers.GetCurrentUser; import org.jclouds.cloudstack.suppliers.NetworksForCurrentUser; import org.jclouds.cloudstack.suppliers.ZoneIdToZoneSupplier; import org.jclouds.collect.Memoized; -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeTestUtils; +import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.domain.Template; import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials; import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; @@ -102,7 +102,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien @Override protected void configure() { bindProperties(binder(), setupProperties()); - bind(String.class).annotatedWith(Identity.class).toInstance(context.getProviderSpecificContext().getIdentity()); + bind(String.class).annotatedWith(Identity.class).toInstance(identity); bind(new TypeLiteral>() { }).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON); bind(new TypeLiteral>>() { diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java index a0ae087295..a112d37849 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java @@ -18,12 +18,8 @@ */ package org.jclouds.cloudstack.compute; -import org.jclouds.cloudstack.CloudStackAsyncClient; -import org.jclouds.cloudstack.CloudStackClient; -import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -37,8 +33,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class CloudStackComputeServiceLiveTest extends - BaseComputeServiceLiveTest { +public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest { public CloudStackComputeServiceLiveTest() { provider = "cloudstack"; } @@ -48,11 +43,6 @@ public class CloudStackComputeServiceLiveTest extends return new SshjSshClientModule(); } - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = context.getProviderSpecificContext(); - } - // cloudstack does not support metadata @Override protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap userMetadata) { diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java index 66ca388819..6be2724084 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java @@ -24,7 +24,6 @@ import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.config.CloudStackRestClientModule; import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; @@ -37,8 +36,7 @@ import com.google.inject.Module; */ public abstract class BaseCloudStackAsyncClientTest extends BaseAsyncClientTest { - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient public static class CloudStackRestClientModuleExtension extends CloudStackRestClientModule { } @@ -55,7 +53,7 @@ public abstract class BaseCloudStackAsyncClientTest extends BaseAsyncClientTe } @Override - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forApiWithEndpoint(new CloudStackApiMetadata(), "http://localhost:8080/client/api"); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java index db2510239e..d202c58841 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java @@ -73,8 +73,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class BaseCloudStackClientLiveTest extends - BaseComputeServiceContextLiveTest { +public class BaseCloudStackClientLiveTest extends BaseComputeServiceContextLiveTest { protected String domainAdminIdentity; protected String domainAdminCredential; protected String globalAdminIdentity; @@ -195,13 +194,13 @@ public class BaseCloudStackClientLiveTest extends public void setupContext() { super.setupContext(); computeClient = context.getComputeService(); - cloudStackContext = context.getProviderSpecificContext(); + cloudStackContext = context.unwrap(); client = cloudStackContext.getApi(); user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER); domainAdminEnabled = setupDomainAdminProperties() != null; if (domainAdminEnabled) { - domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()); + domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()).unwrap(); domainAdminContext = domainAdminComputeContext.getDomainContext(); domainAdminClient = domainAdminContext.getApi(); domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN); @@ -210,7 +209,7 @@ public class BaseCloudStackClientLiveTest extends globalAdminEnabled = setupGlobalAdminProperties() != null; if (globalAdminEnabled) { - globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()); + globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()).unwrap(); globalAdminContext = globalAdminComputeContext.getGlobalContext(); globalAdminClient = globalAdminContext.getApi(); globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java index 5686229973..a2e027d082 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java @@ -47,7 +47,7 @@ public abstract class BaseCloudStackRestClientExpectTest extends BaseRestClie } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudStackApiMetadata(); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java index e3b3a1cb58..fbc3166f7d 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java @@ -83,7 +83,7 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest { } private void checkAuthAsUser(ApiKeyPair keyPair) { - ComputeServiceContext context = createContext(credentialsAsProperties(keyPair), setupModules()); + ComputeServiceContext context = createContext(credentialsAsProperties(keyPair), setupModules()); CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); Set accounts = client.getAccountClient().listAccounts(); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java index 2a65eb3e48..57f3f9c405 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java @@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import org.jclouds.cloudstack.domain.OSType; import org.jclouds.cloudstack.options.ListOSTypesOptions; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java index 759579c4f4..441a0d8b8a 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java @@ -35,11 +35,11 @@ import javax.annotation.Nullable; import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.cloudstack.domain.JobResult; import org.jclouds.cloudstack.domain.LoadBalancerRule; -import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; -import org.jclouds.cloudstack.domain.LoadBalancerRule.State; import org.jclouds.cloudstack.domain.Network; import org.jclouds.cloudstack.domain.PublicIPAddress; import org.jclouds.cloudstack.domain.VirtualMachine; +import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; +import org.jclouds.cloudstack.domain.LoadBalancerRule.State; import org.jclouds.cloudstack.predicates.LoadBalancerRuleActive; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java index 25fd9ae0c9..2c4bea015d 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java @@ -22,13 +22,13 @@ import static org.testng.Assert.assertEquals; import java.net.URI; +import org.jclouds.ContextBuilder; import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; -import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java index 27957ba85f..4b912b2389 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java @@ -24,14 +24,14 @@ import static org.testng.Assert.assertTrue; import java.io.InputStream; import org.jclouds.cloudstack.domain.AsyncJob; -import org.jclouds.cloudstack.domain.AsyncJob.ResultCode; -import org.jclouds.cloudstack.domain.AsyncJob.Status; import org.jclouds.cloudstack.domain.AsyncJobError; -import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.cloudstack.domain.IPForwardingRule; import org.jclouds.cloudstack.domain.PublicIPAddress; import org.jclouds.cloudstack.domain.Template; import org.jclouds.cloudstack.domain.TemplateExtraction; +import org.jclouds.cloudstack.domain.AsyncJob.ResultCode; +import org.jclouds.cloudstack.domain.AsyncJob.Status; +import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.domain.JsonBall; import org.jclouds.http.HttpResponse; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java index 2b585c4ea8..d323a0b88c 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java @@ -22,9 +22,9 @@ import java.util.Set; import org.jclouds.cloudstack.config.CloudStackParserModule; import org.jclouds.cloudstack.domain.Account; +import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.Account.State; import org.jclouds.cloudstack.domain.Account.Type; -import org.jclouds.cloudstack.domain.User; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/predicates/JobCompleteTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/predicates/JobCompleteTest.java index 53310e5e0a..a4ef0a60db 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/predicates/JobCompleteTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/predicates/JobCompleteTest.java @@ -28,9 +28,9 @@ import static org.testng.Assert.fail; import org.jclouds.cloudstack.AsyncJobException; import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.domain.AsyncJob; +import org.jclouds.cloudstack.domain.AsyncJobError; import org.jclouds.cloudstack.domain.AsyncJob.ResultCode; import org.jclouds.cloudstack.domain.AsyncJob.Status; -import org.jclouds.cloudstack.domain.AsyncJobError; import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.cloudstack.features.AsyncJobClient; import org.testng.annotations.BeforeMethod; diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java index 51fb3b648d..d40bd4ee25 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java @@ -25,73 +25,68 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.cloudwatch.config.CloudWatchRestClientModule; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.reflect.TypeToken; + /** * Implementation of {@link ApiMetadata} for Amazon's CloudWatch api. * - *

    note

    - *

    - * This class allows overriding of types {@code S}(client) and {@code A}(asyncClient), so that - * children can add additional methods not declared here, such as new features - * from AWS. - *

    - * - * This class is not setup to allow a different context than {@link RestContext} - * . By doing so, it reduces the type complexity. - * * @author Adrian Cole */ -public class CloudWatchApiMetadata extends - BaseRestApiMetadata, CloudWatchApiMetadata> { +public class CloudWatchApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3450830053589179249L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } public CloudWatchApiMetadata() { - this(new Builder(CloudWatchClient.class, CloudWatchAsyncClient.class)); + this(new Builder(CloudWatchClient.class, CloudWatchAsyncClient.class)); } - @SuppressWarnings("unchecked") - protected CloudWatchApiMetadata(Builder builder) { + protected CloudWatchApiMetadata(Builder builder) { super(Builder.class.cast(builder)); } - protected static Properties defaultProperties() { - Properties properties = BaseApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); return properties; } - public static class Builder extends - BaseRestApiMetadata.Builder, CloudWatchApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder(Class client, Class asyncClient) { + protected Builder(Class client, Class asyncClient) { super(client, asyncClient); id("cloudwatch") - .type(ApiType.MONITOR) .name("Amazon CloudWatch Api") .identityName("Access Key ID") .credentialName("Secret Access Key") .version(CloudWatchAsyncClient.VERSION) - .defaultProperties(CloudWatchApiMetadata.defaultProperties()) + .documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/")) .defaultEndpoint("https://monitoring.us-east-1.amazonaws.com") - .documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/")); + .defaultProperties(CloudWatchApiMetadata.defaultProperties()) + .defaultModule(CloudWatchRestClientModule.class); } @Override - public CloudWatchApiMetadata build() { - return new CloudWatchApiMetadata(this); + public CloudWatchApiMetadata build() { + return new CloudWatchApiMetadata(this); } @Override - public Builder fromApiMetadata(CloudWatchApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java deleted file mode 100644 index 7d60ccef2b..0000000000 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.cloudwatch; - -import java.util.List; - -import org.jclouds.cloudwatch.config.CloudWatchRestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextBuilder; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link MonitoringContext} or {@link Injector} instances based on the - * most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see MonitoringContext - */ -public class CloudWatchContextBuilder - extends RestContextBuilder, CloudWatchApiMetadata> { - - public CloudWatchContextBuilder(ProviderMetadata, CloudWatchApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudWatchContextBuilder(CloudWatchApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new CloudWatchRestClientModule()); - } -} diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java index 5bddf2e30f..ebede447d3 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java @@ -21,7 +21,6 @@ package org.jclouds.cloudwatch.config; import org.jclouds.aws.config.FormSigningRestClientModule; import org.jclouds.cloudwatch.CloudWatchAsyncClient; import org.jclouds.cloudwatch.CloudWatchClient; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; /** @@ -29,7 +28,6 @@ import org.jclouds.rest.ConfiguresRestClient; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class CloudWatchRestClientModule extends FormSigningRestClientModule { public CloudWatchRestClientModule() { diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java index 0321386289..ad68f537f7 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java @@ -18,19 +18,22 @@ */ package org.jclouds.cloudwatch; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseRestApiMetadataTest; +import org.jclouds.Wrapper; +import org.jclouds.rest.internal.BaseRestApiMetadataTest; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; + /** * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "CloudWatchApiMetadataTest") public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest { + // no monitoring abstraction, yet public CloudWatchApiMetadataTest() { - super(new CloudWatchApiMetadata(), ApiType.MONITOR); + super(new CloudWatchApiMetadata(), ImmutableSet.> of()); } } diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java index 193b032682..690c7092fc 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java @@ -39,7 +39,6 @@ import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler; import org.jclouds.date.DateService; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; @@ -91,8 +90,7 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + public ApiMetadata createApiMetadata() { return new CloudWatchApiMetadata(); } diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java index 7bf1a80563..5109d92c4f 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java @@ -24,15 +24,17 @@ import java.util.Calendar; import java.util.Date; import java.util.Set; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.cloudwatch.domain.Datapoint; import org.jclouds.cloudwatch.domain.Statistics; import org.jclouds.cloudwatch.domain.Unit; import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.common.reflect.TypeToken; + /** * Tests behavior of {@code CloudWatchClient} * @@ -67,4 +69,9 @@ public class CloudWatchClientLiveTest extends BaseContextLiveTest> contextType() { + return CloudWatchApiMetadata.CONTEXT_TOKEN; + } } diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java index f84a352a8f..8908404e72 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java @@ -23,16 +23,28 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule; +import org.jclouds.deltacloud.config.DeltacloudRestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Apache Deltacloud API * * @author Adrian Cole */ -public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata, DeltacloudApiMetadata> { +public class DeltacloudApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { @@ -47,13 +59,14 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata, DeltacloudApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(DeltacloudClient.class, DeltacloudAsyncClient.class); id("deltacloud") .name("Apache Deltacloud API") .identityName("Username") @@ -61,21 +74,22 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata>of(DeltacloudRestClientModule.class, DeltacloudComputeServiceContextModule.class)); } - } \ No newline at end of file + @Override + public DeltacloudApiMetadata build() { + return new DeltacloudApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + + } + +} \ No newline at end of file diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java index 83c6ab4ef9..3c672c145e 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java @@ -36,9 +36,9 @@ import org.jclouds.deltacloud.domain.DeltacloudCollection; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Image; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.functions.ReturnVoidOnRedirectedDelete; import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.deltacloud.xml.DeltacloudCollectionsHandler; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java index 96ab9b62b5..39f4da8db7 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java @@ -27,9 +27,9 @@ import org.jclouds.deltacloud.domain.DeltacloudCollection; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Image; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.http.HttpRequest; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java deleted file mode 100644 index b37769c36e..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.deltacloud; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule; -import org.jclouds.deltacloud.config.DeltacloudRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class DeltacloudContextBuilder - extends - ComputeServiceContextBuilder, DeltacloudApiMetadata> { - - public DeltacloudContextBuilder( - ProviderMetadata, DeltacloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public DeltacloudContextBuilder(DeltacloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new DeltacloudComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new DeltacloudRestClientModule()); - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java index fe11997826..34d21cb1af 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java @@ -21,8 +21,6 @@ package org.jclouds.deltacloud.compute.config; import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.deltacloud.DeltacloudAsyncClient; -import org.jclouds.deltacloud.DeltacloudClient; import org.jclouds.deltacloud.compute.functions.DeltacloudImageToImage; import org.jclouds.deltacloud.compute.functions.HardwareProfileToHardware; import org.jclouds.deltacloud.compute.functions.InstanceToNodeMetadata; @@ -40,13 +38,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class DeltacloudComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public DeltacloudComputeServiceContextModule() { - super(DeltacloudClient.class, DeltacloudAsyncClient.class); - } +public class DeltacloudComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @Override protected void configure() { diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java index 0e304deaf6..0a6349a02d 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java @@ -35,11 +35,11 @@ import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.deltacloud.DeltacloudClient; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.PasswordAuthentication; import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.TransitionOnAction; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.deltacloud.predicates.InstanceFinished; import org.jclouds.deltacloud.predicates.InstanceRunning; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java index bbd43b2a69..8a1664db3d 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java @@ -40,7 +40,6 @@ import org.jclouds.deltacloud.handlers.DeltacloudErrorHandler; import org.jclouds.deltacloud.handlers.DeltacloudRedirectionRetryHandler; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -61,7 +60,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class DeltacloudRestClientModule extends RestClientModule { diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java index cf83cdfce5..c7c392e82f 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java @@ -27,8 +27,8 @@ import org.jclouds.deltacloud.domain.EnumHardwareProperty; import org.jclouds.deltacloud.domain.FixedHardwareProperty; import org.jclouds.deltacloud.domain.HardwareParameter; import org.jclouds.deltacloud.domain.HardwareProperty; -import org.jclouds.deltacloud.domain.HardwareProperty.Kind; import org.jclouds.deltacloud.domain.RangeHardwareProperty; +import org.jclouds.deltacloud.domain.HardwareProperty.Kind; import org.jclouds.http.functions.ParseSax; import org.jclouds.javax.annotation.Nullable; import org.jclouds.util.SaxUtils; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java index 98ecc44514..6309f9816d 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java @@ -27,9 +27,9 @@ import java.util.Set; import javax.annotation.Resource; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.Authentication; import org.jclouds.deltacloud.domain.KeyAuthentication; import org.jclouds.deltacloud.domain.PasswordAuthentication; +import org.jclouds.deltacloud.domain.Instance.Authentication; import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.http.HttpRequest; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java index ae31df317a..3be3d3fcbc 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java @@ -22,11 +22,11 @@ import java.util.Map; import javax.annotation.Resource; -import org.jclouds.deltacloud.domain.Instance.Action; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.TransitionAutomatically; import org.jclouds.deltacloud.domain.TransitionOnAction; +import org.jclouds.deltacloud.domain.Instance.Action; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.http.functions.ParseSax; import org.jclouds.logging.Logger; import org.jclouds.util.SaxUtils; diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java index d8f0e1899b..cc0463dd8e 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java @@ -41,7 +41,6 @@ import org.jclouds.deltacloud.xml.InstancesHandler; import org.jclouds.deltacloud.xml.RealmHandler; import org.jclouds.deltacloud.xml.RealmsHandler; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -298,8 +297,7 @@ public class DeltacloudAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new DeltacloudApiMetadata(); } } diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java index 3aefc77489..c63cbd8b47 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java @@ -25,15 +25,14 @@ import static org.testng.Assert.assertTrue; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.deltacloud.domain.DeltacloudCollection; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Image; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.predicates.InstanceFinished; import org.jclouds.deltacloud.predicates.InstanceRunning; import org.jclouds.net.IPSocket; @@ -57,9 +56,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ReadOnlyDeltacloudClientLiveTest") -public class ReadOnlyDeltacloudClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class ReadOnlyDeltacloudClientLiveTest extends BaseComputeServiceContextLiveTest { public ReadOnlyDeltacloudClientLiveTest() { provider = "deltacloud"; @@ -74,7 +71,7 @@ public class ReadOnlyDeltacloudClientLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi(); + client = context.unwrap(DeltacloudApiMetadata.CONTEXT_TOKEN).getApi(); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS); stateChanges = ImmutableMap.> of(// Instance.State.RUNNING, new RetryablePredicate(new InstanceRunning(client), 600, 1, diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java index 7fc4ca3ff2..55ce6df8ac 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java @@ -22,13 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.deltacloud.DeltacloudAsyncClient; -import org.jclouds.deltacloud.DeltacloudClient; import org.jclouds.domain.LocationScope; -import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -41,9 +37,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "DeltacloudComputeServiceLiveTest") -public class DeltacloudComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class DeltacloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { public DeltacloudComputeServiceLiveTest() { provider = "deltacloud"; @@ -61,11 +55,6 @@ public class DeltacloudComputeServiceLiveTest "node userMetadata did not match %s %s", userMetadata, node); } - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = context.getProviderSpecificContext(); - } - @Override protected void checkNodes(Iterable nodes, String group, String task) throws IOException { super.checkNodes(nodes, group, task); diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java index b1aaea7f7c..4af99e42f0 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.deltacloud.DeltacloudAsyncClient; -import org.jclouds.deltacloud.DeltacloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class DeltacloudTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public DeltacloudTemplateBuilderLiveTest() { provider = "deltacloud"; diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java index 1403fdf20e..ae78bdc42a 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java @@ -25,7 +25,7 @@ import static org.easymock.EasyMock.verify; import java.net.URI; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; @@ -40,7 +40,7 @@ import com.google.inject.Injector; */ @Test(groups = "unit") public class DeltacloudRedirectionRetryHandlerTest { - Injector injector = ComputeServiceContextBuilder.forTests().buildInjector(); + Injector injector = ContextBuilder.newBuilder("stub").buildInjector(); @Test public void test302DoesNotRetryOnDelete() { diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java index 3c335e0b9c..e50213ab28 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java @@ -24,9 +24,9 @@ import java.io.InputStream; import java.net.URI; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.Authentication; import org.jclouds.deltacloud.domain.KeyAuthentication; import org.jclouds.deltacloud.domain.PasswordAuthentication; +import org.jclouds.deltacloud.domain.Instance.Authentication; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java index 95daf73045..3c818153ce 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java @@ -22,11 +22,11 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; -import org.jclouds.deltacloud.domain.Instance.Action; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.TransitionAutomatically; import org.jclouds.deltacloud.domain.TransitionOnAction; +import org.jclouds.deltacloud.domain.Instance.Action; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.http.functions.BaseHandlerTest; import org.testng.annotations.Test; diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java index 80c26fc456..b15f95636d 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java @@ -29,11 +29,16 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; +import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; +import org.jclouds.ec2.config.EC2RestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; -import com.google.common.reflect.TypeParameter; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Amazon's EC2 api. @@ -52,26 +57,30 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -public class EC2ApiMetadata, M extends EC2ApiMetadata> - extends BaseComputeServiceApiMetadata { +public class EC2ApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 4424763314988423886L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Builder toBuilder() { - return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public EC2ApiMetadata() { this(new Builder(EC2Client.class, EC2AsyncClient.class)); } - protected EC2ApiMetadata(Builder builder) { + protected EC2ApiMetadata(Builder builder) { super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); @@ -81,10 +90,11 @@ public class EC2ApiMetadata, M extends EC2ApiMetadata> - extends BaseComputeServiceApiMetadata.Builder { + public static class Builder + extends BaseRestApiMetadata.Builder { - protected Builder(Class syncClient, Class asyncClient) { + protected Builder(Class syncClient, Class asyncClient) { + super(syncClient, asyncClient); id("ec2") .name("Amazon Elastic Compute Cloud (EC2) API") .identityName("Access Key ID") @@ -93,32 +103,17 @@ public class EC2ApiMetadata>(getClass()) { - private static final long serialVersionUID = 1L; - }); + .wrapper(EC2ComputeServiceContext.class) + .defaultModules(ImmutableSet.>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EC2ComputeServiceContextModule.class)); } - - /** - * {@inheritDoc} - */ + @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); + public ApiMetadata build() { + return new EC2ApiMetadata(this); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override - public M build() { - return (M) new EC2ApiMetadata(this); - } - - @Override - public Builder fromApiMetadata(M in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java deleted file mode 100644 index 4836d97f87..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.ec2; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; -import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; -import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link EC2ComputeServiceContext} or {@link Injector} instances based - * on the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see EC2ComputeServiceContext - */ -public class EC2ContextBuilder, M extends EC2ApiMetadata> - extends ComputeServiceContextBuilder { - - public EC2ContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public EC2ContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new EC2ComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new EC2RestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi(), - EC2RestClientModule.DELEGATE_MAP)); - } - - @Override - protected void addImageResolutionModule() { - modules.add(new EC2ResolveImagesModule()); - } -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java index be5f90d46f..3ea04e1638 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java @@ -87,7 +87,7 @@ public class EC2ComputeService extends BaseComputeService { private final LoadingCache securityGroupMap; @Inject - protected EC2ComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected EC2ComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java index 255d4dd868..606c8b7ceb 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java @@ -19,8 +19,6 @@ package org.jclouds.ec2.compute; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl; import com.google.inject.ImplementedBy; @@ -29,7 +27,7 @@ import com.google.inject.ImplementedBy; * @author Adrian Cole */ @ImplementedBy(EC2ComputeServiceContextImpl.class) -public interface EC2ComputeServiceContext extends ComputeServiceContext { +public interface EC2ComputeServiceContext extends ComputeServiceContext { @Override EC2ComputeService getComputeService(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java index 9055515736..f82fa97ec4 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java @@ -29,16 +29,12 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Credentials; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.EC2ComputeService; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.AddElasticIpsToNodemetadata; @@ -70,7 +66,6 @@ import com.google.common.collect.Maps; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.Provides; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; @@ -93,7 +88,6 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule { return instanceToNodeState; } - @SuppressWarnings("rawtypes") @Override protected void configure() { bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class); @@ -109,9 +103,6 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule { }).annotatedWith(Names.named("SECURITY")).to(CreateSecurityGroupIfNeeded.class); bind(new TypeLiteral>() { }).annotatedWith(Names.named("ELASTICIP")).to(LoadPublicIpForInstanceOrNull.class); - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(WindowsLoginCredentialsFromEncryptedData.class); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java index 1d55021e64..b63728b8b1 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java @@ -18,6 +18,7 @@ */ package org.jclouds.ec2.compute.internal; +import java.io.Closeable; import java.util.Map; import javax.inject.Inject; @@ -26,22 +27,21 @@ import javax.inject.Singleton; import org.jclouds.compute.Utils; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.domain.Credentials; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.EC2ComputeService; import org.jclouds.ec2.compute.EC2ComputeServiceContext; -import org.jclouds.rest.RestContext; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; /** * @author Adrian Cole */ @Singleton -public class EC2ComputeServiceContextImpl extends - ComputeServiceContextImpl implements EC2ComputeServiceContext { +public class EC2ComputeServiceContextImpl extends ComputeServiceContextImpl implements EC2ComputeServiceContext { @Inject - public EC2ComputeServiceContextImpl(EC2ComputeService computeService, Map credentialStore, - Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { - super(computeService, credentialStore, utils, providerSpecificContext); + public EC2ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + EC2ComputeService computeService, Map credentialStore, Utils utils){ + super(wrapped, wrappedType, computeService, credentialStore, utils); } @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java index e9d1862270..aad33fa08f 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java @@ -41,7 +41,6 @@ import org.jclouds.ec2.services.WindowsAsyncClient; import org.jclouds.ec2.services.WindowsClient; import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; import org.jclouds.ec2.suppliers.DescribeRegionsForConfiguredRegions; -import org.jclouds.http.RequiresHttp; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; @@ -57,7 +56,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole (EDIT: Nick Terry nterry@familysearch.org) */ -@RequiresHttp @ConfiguresRestClient public class EC2RestClientModule extends WithZonesFormSigningRestClientModule { @@ -73,6 +71,11 @@ public class EC2RestClientModule .put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)// .build(); + @SuppressWarnings("unchecked") + public EC2RestClientModule() { + this((Class) EC2Client.class, (Class) EC2AsyncClient.class, DELEGATE_MAP); + } + public EC2RestClientModule(Class sync, Class async, Map, Class> delegateMap) { super(sync, async, delegateMap); } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java index 8efc145d76..1993e42c3a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java @@ -36,9 +36,7 @@ import org.jclouds.aws.AWSResponseException; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.BlockDevice; -import org.jclouds.ec2.domain.Image.EbsBlockDevice; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.IpProtocol; @@ -46,6 +44,7 @@ import org.jclouds.ec2.domain.KeyPair; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; +import org.jclouds.ec2.domain.Image.EbsBlockDevice; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; import org.jclouds.ec2.predicates.InstanceHasIpAddress; import org.jclouds.ec2.predicates.InstanceStateRunning; @@ -76,7 +75,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", enabled = false, singleThreaded = true, testName = "CloudApplicationArchitecturesEC2ClientLiveTest") -public class CloudApplicationArchitecturesEC2ClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeServiceContextLiveTest { public CloudApplicationArchitecturesEC2ClientLiveTest() { provider = "ec2"; } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java index c51173f3d0..87c75162a6 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java @@ -36,12 +36,9 @@ import org.jclouds.aws.AWSResponseException; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.Image.Architecture; -import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.IpProtocol; @@ -51,6 +48,8 @@ import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; +import org.jclouds.ec2.domain.Image.Architecture; +import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; import org.jclouds.ec2.predicates.InstanceStateRunning; import org.jclouds.ec2.predicates.InstanceStateStopped; @@ -89,7 +88,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", enabled = false, singleThreaded = true, testName = "EBSBootEC2ClientLiveTest") -public class EBSBootEC2ClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest { public EBSBootEC2ClientLiveTest() { provider = "ec2"; } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java index 74478bf7b0..35f5e82578 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java @@ -25,7 +25,6 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "EC2ApiMetadataTest") public class EC2ApiMetadataTest extends BaseComputeServiceApiMetadataTest { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index 41d53a20fd..500a0b0786 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -37,7 +37,7 @@ import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.options.EC2TemplateOptions; import org.jclouds.ec2.domain.BlockDevice; @@ -72,7 +72,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class EC2ComputeServiceLiveTest> extends BaseComputeServiceLiveTest { +public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { public EC2ComputeServiceLiveTest() { provider = "ec2"; @@ -102,13 +102,13 @@ public class EC2ComputeServiceLiveTest context = null; + ComputeServiceContext context = null; String group = this.group + "aip"; try { Properties overrides = setupProperties(); @@ -202,7 +202,7 @@ public class EC2ComputeServiceLiveTest ipidpairs = ec2.getElasticIPAddressServices().describeAddressesInRegion(region, publicIps.toArray(new String[0])); assertEquals(ipidpairs.size(), 1, String.format("there should only be one address pair (%s)", @@ -233,10 +233,10 @@ public class EC2ComputeServiceLiveTest> extends BaseTemplateBuilderLiveTest { +public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Test public void testTemplateBuilderCanUseImageIdWithoutFetchingAllImages() throws Exception { @@ -56,7 +54,7 @@ public abstract class EC2TemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { // Track http commands final List commandsInvoked = Lists.newArrayList(); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java index c0dbdb145f..fc7ca34a97 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java @@ -22,8 +22,6 @@ import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.predicates.NodePredicates; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.testng.annotations.Test; import com.google.common.base.Throwables; @@ -33,7 +31,7 @@ import com.google.common.base.Throwables; * @author Adrian Cole */ @Test(groups = "live", testName="TestCanRecreateGroupLiveTest") -public class TestCanRecreateGroupLiveTest> extends BaseComputeServiceContextLiveTest { +public class TestCanRecreateGroupLiveTest extends BaseComputeServiceContextLiveTest { public TestCanRecreateGroupLiveTest() { provider = "ec2"; } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java index dff51b3b23..80dbaf4d1c 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java @@ -25,15 +25,13 @@ import static org.testng.Assert.assertNotNull; import java.net.URI; import java.util.Iterator; -import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; +import java.util.Map.Entry; import org.jclouds.aws.domain.Region; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.domain.AvailabilityZoneInfo; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -47,7 +45,7 @@ import com.google.common.collect.Maps; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AvailabilityZoneAndRegionClientLiveTest") -public class AvailabilityZoneAndRegionClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class AvailabilityZoneAndRegionClientLiveTest extends BaseComputeServiceContextLiveTest { public AvailabilityZoneAndRegionClientLiveTest() { provider = "ec2"; } @@ -58,7 +56,7 @@ public class AvailabilityZoneAndRegionClientLiveTest extends BaseAsyncClientTest { - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient protected static class StubEC2RestClientModule extends EC2RestClientModule { public StubEC2RestClientModule() { @@ -143,9 +141,8 @@ public abstract class BaseEC2AsyncClientTest extends BaseAsyncClientTest { return new StubEC2RestClientModule(); } - @SuppressWarnings("rawtypes") @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new EC2ApiMetadata(); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java index 6871c9cc7c..4fd9676cec 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java @@ -28,9 +28,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.predicates.SnapshotCompleted; @@ -50,7 +48,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ElasticBlockStoreClientLiveTest") -public class ElasticBlockStoreClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLiveTest { public ElasticBlockStoreClientLiveTest() { provider = "ec2"; } @@ -63,12 +61,12 @@ public class ElasticBlockStoreClientLiveTest allResults = Sets.newTreeSet(client.describeVolumesInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java index a1de5fc423..83bb5c4503 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java @@ -25,9 +25,7 @@ import java.util.SortedSet; import org.jclouds.aws.domain.Region; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -41,7 +39,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ElasticIPAddressClientLiveTest") -public class ElasticIPAddressClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class ElasticIPAddressClientLiveTest extends BaseComputeServiceContextLiveTest { public ElasticIPAddressClientLiveTest() { provider = "ec2"; } @@ -52,7 +50,7 @@ public class ElasticIPAddressClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class InstanceClientLiveTest extends BaseComputeServiceContextLiveTest { public InstanceClientLiveTest() { provider = "ec2"; } @@ -51,7 +49,7 @@ public class InstanceClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { public KeyPairClientLiveTest() { provider = "ec2"; } @@ -53,7 +51,7 @@ public class KeyPairClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTest { public SecurityGroupClientLiveTest() { provider = "ec2"; } @@ -62,7 +60,7 @@ public class SecurityGroupClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class WindowsClientLiveTest extends BaseComputeServiceContextLiveTest { public WindowsClientLiveTest() { provider = "ec2"; } @@ -78,7 +76,7 @@ public class WindowsClientLiveTest, ElasticStackApiMetadata> { +public class ElasticStackApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -51,8 +61,8 @@ public class ElasticStackApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); // passwords are set post-boot, so auth failures are possible // from a race condition applying the password set script @@ -63,9 +73,10 @@ public class ElasticStackApiMetadata public static class Builder extends - BaseComputeServiceApiMetadata.Builder, ElasticStackApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(ElasticStackClient.class, ElasticStackAsyncClient.class); id("elasticstack") .name("ElasticStack API") .identityName("UUID") @@ -74,8 +85,8 @@ public class ElasticStackApiMetadata .version("1.0") .defaultEndpoint("https://api.lon-p.elastichosts.com") .defaultProperties(ElasticStackApiMetadata.defaultProperties()) - .javaApi(ElasticStackClient.class, ElasticStackAsyncClient.class) - .contextBuilder(TypeToken.of(ElasticStackContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(ElasticStackRestClientModule.class, ElasticStackComputeServiceContextModule.class)); } @Override @@ -84,7 +95,7 @@ public class ElasticStackApiMetadata } @Override - public Builder fromApiMetadata(ElasticStackApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java deleted file mode 100644 index 63b5f65cb5..0000000000 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elasticstack; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule; -import org.jclouds.elasticstack.config.ElasticStackRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class ElasticStackContextBuilder - extends - ComputeServiceContextBuilder, ElasticStackApiMetadata> { - - public ElasticStackContextBuilder( - ProviderMetadata, ElasticStackApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public ElasticStackContextBuilder(ElasticStackApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new ElasticStackComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new ElasticStackRestClientModule()); - } - -} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java index d98a4c388c..e38b10138b 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java @@ -34,14 +34,13 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; -import org.jclouds.elasticstack.ElasticStackAsyncClient; import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.elasticstack.compute.ElasticStackComputeServiceAdapter; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata; +import org.jclouds.elasticstack.compute.functions.WellKnownImageToImage; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.DeviceToVolume; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.FindImageForId; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.GetImageIdFromServer; -import org.jclouds.elasticstack.compute.functions.WellKnownImageToImage; import org.jclouds.elasticstack.domain.Device; import org.jclouds.elasticstack.domain.DriveInfo; import org.jclouds.elasticstack.domain.Server; @@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class ElasticStackComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public ElasticStackComputeServiceContextModule() { - super(ElasticStackClient.class, ElasticStackAsyncClient.class); - } +public class ElasticStackComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings( { "unchecked", "rawtypes" }) @Override diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java index c0c0cc2b42..93781f3be8 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java @@ -33,14 +33,13 @@ import org.jclouds.elasticstack.domain.ServerMetrics; import org.jclouds.elasticstack.functions.CreateDriveRequestToMap; import org.jclouds.elasticstack.functions.DriveDataToMap; import org.jclouds.elasticstack.functions.MapToDevices; -import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId; import org.jclouds.elasticstack.functions.MapToDriveMetrics; import org.jclouds.elasticstack.functions.MapToNICs; import org.jclouds.elasticstack.functions.MapToServerMetrics; import org.jclouds.elasticstack.functions.ServerToMap; +import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId; import org.jclouds.elasticstack.handlers.ElasticStackErrorHandler; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -55,7 +54,6 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class ElasticStackRestClientModule extends RestClientModule { diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDevices.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDevices.java index 9df5195ae8..6d0a5875ea 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDevices.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDevices.java @@ -31,8 +31,8 @@ import org.jclouds.elasticstack.domain.SCSIDevice; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableSet.Builder; /** * diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java index 37dccdfe18..37d82bae9f 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java @@ -453,7 +453,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new ElasticStackApiMetadata(); } diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java index 3a199e02b5..0eb8854bf1 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java @@ -26,7 +26,6 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; @@ -71,7 +70,7 @@ import com.google.inject.Guice; @Test(groups = "live", singleThreaded = true, testName = "ElasticStackClientLiveTest") public class ElasticStackClientLiveTest extends - BaseComputeServiceContextLiveTest> { + BaseComputeServiceContextLiveTest { public ElasticStackClientLiveTest() { provider = "elasticstack"; @@ -89,7 +88,7 @@ public class ElasticStackClientLiveTest @Override public void setupContext() { super.setupContext(); - cloudStackContext = context.getProviderSpecificContext(); + cloudStackContext = context.unwrap(); client = cloudStackContext.getApi(); driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java index 6f4e93ebae..98af64bd1c 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java @@ -18,12 +18,9 @@ */ package org.jclouds.elasticstack.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -34,9 +31,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticStackComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class ElasticStackComputeServiceLiveTest extends BaseComputeServiceLiveTest { public ElasticStackComputeServiceLiveTest() { provider = "elasticstack"; diff --git a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java index 0297ea0b50..80855d365b 100644 --- a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java +++ b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java @@ -28,14 +28,16 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; /** * Implementation of {@link ApiMetadata} for the Eucalyptus (EC2 clone) api. * * @author Adrian Cole */ -public class EucalyptusApiMetadata extends EC2ApiMetadata, EucalyptusApiMetadata> { +public class EucalyptusApiMetadata extends EC2ApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 3060225665040763827L; + private static Builder builder() { return new Builder(); } @@ -53,7 +55,7 @@ public class EucalyptusApiMetadata extends EC2ApiMetadata, EucalyptusApiMetadata> { + public static class Builder extends EC2ApiMetadata.Builder { protected Builder(){ super(EC2Client.class, EC2AsyncClient.class); id("eucalyptus") @@ -76,7 +78,7 @@ public class EucalyptusApiMetadata extends EC2ApiMetadata> { +public class EucalyptusComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public EucalyptusComputeServiceLiveTest() { provider = "eucalyptus"; diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java index 91595c3389..3ea463e4f9 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java @@ -18,27 +18,22 @@ */ package org.jclouds.filesystem; -import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; -import static org.jclouds.Constants.PROPERTY_USER_THREADS; - import java.net.URI; import org.jclouds.apis.ApiMetadata; -import org.jclouds.blobstore.BlobStore; +import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; - -import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; +import org.jclouds.filesystem.config.FilesystemBlobStoreContextModule; /** * Implementation of {@link ApiMetadata} for jclouds Filesystem-based BlobStore * * @author Adrian Cole */ -public class FilesystemApiMetadata - extends - BaseBlobStoreApiMetadata, FilesystemApiMetadata> { +public class FilesystemApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -2625620001657309404L; public static Builder builder() { return new Builder(); @@ -57,24 +52,19 @@ public class FilesystemApiMetadata super(builder); } -public static class Builder extends - BaseBlobStoreApiMetadata.Builder, FilesystemApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder() { id("filesystem") .name("Filesystem-based BlobStore") .identityName("Unused") - .contextBuilder(TypeToken.of(FilesystemBlobStoreContextBuilder.class)) - .javaApi(BlobStore.class, FilesystemAsyncBlobStore.class) - .identityName("Unused") .defaultEndpoint("http://localhost/transient") .defaultIdentity(System.getProperty("user.name")) .defaultCredential("bar") .version("1") - .defaultProperties( - BaseBlobStoreApiMetadata.Builder.defaultPropertiesAnd(ImmutableMap.of(PROPERTY_USER_THREADS, "0", - PROPERTY_IO_WORKER_THREADS, "0"))) - .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")); + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")) + .wrapper(BlobStoreContext.class) + .defaultModule(FilesystemBlobStoreContextModule.class); } @Override diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java index 6b9013fb76..7c828ec7ff 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java @@ -48,10 +48,10 @@ import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import javax.annotation.Resource; @@ -126,7 +126,7 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore { protected final FilesystemStorageStrategy storageStrategy; @Inject - protected FilesystemAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, DateService dateService, Crypto crypto, + protected FilesystemAsyncBlobStore(BlobStoreContext context, DateService dateService, Crypto crypto, HttpGetOptionsListToGetOptions httpGetOptionsConverter, IfDirectoryReturnNameStrategy ifDirectoryReturnName, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java deleted file mode 100644 index eb5cd39033..0000000000 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.filesystem; - -import java.util.List; - -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.filesystem.config.FilesystemBlobStoreContextModule; -import org.jclouds.filesystem.config.FilesystemBlobStoreModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Alfredo "Rainbowbreeze" Morresi - */ -public class FilesystemBlobStoreContextBuilder - extends - BlobStoreContextBuilder, FilesystemApiMetadata> { - - public FilesystemBlobStoreContextBuilder( - ProviderMetadata, FilesystemApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public FilesystemBlobStoreContextBuilder(FilesystemApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - public void addContextModule(List modules) { - modules.add(new FilesystemBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new FilesystemBlobStoreModule()); - } - -} diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java index 8223e1280b..4560bd5156 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java @@ -21,13 +21,12 @@ package org.jclouds.filesystem.config; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.TransientBlobRequestSigner; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; import org.jclouds.blobstore.config.BlobStoreObjectModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.util.BlobUtils; +import org.jclouds.filesystem.FilesystemAsyncBlobStore; import org.jclouds.filesystem.FilesystemBlobStore; import org.jclouds.filesystem.predicates.validators.FilesystemBlobKeyValidator; import org.jclouds.filesystem.predicates.validators.FilesystemContainerNameValidator; @@ -36,12 +35,10 @@ import org.jclouds.filesystem.predicates.validators.internal.FilesystemContainer import org.jclouds.filesystem.strategy.FilesystemStorageStrategy; import org.jclouds.filesystem.strategy.internal.FilesystemStorageStrategyImpl; import org.jclouds.filesystem.util.internal.FileSystemBlobUtilsImpl; +import org.jclouds.rest.config.BinderUtils; +import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.Singleton; -import com.google.inject.TypeLiteral; /** * @@ -49,12 +46,13 @@ import com.google.inject.TypeLiteral; */ public class FilesystemBlobStoreContextModule extends AbstractModule { - @SuppressWarnings("rawtypes") @Override protected void configure() { - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); + bind(AsyncBlobStore.class).to(FilesystemAsyncBlobStore.class).asEagerSingleton(); + // forward all requests from TransientBlobStore to TransientAsyncBlobStore. needs above binding as cannot proxy a class + BinderUtils.bindClient(binder(), FilesystemBlobStore.class, AsyncBlobStore.class, ImmutableMap., Class>of()); + bind(BlobStore.class).to(FilesystemBlobStore.class); + install(new BlobStoreObjectModule()); install(new BlobStoreMapModule()); bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); @@ -65,10 +63,4 @@ public class FilesystemBlobStoreContextModule extends AbstractModule { bind(BlobRequestSigner.class).to(TransientBlobRequestSigner.class); } - @Provides - @Singleton - BlobStore provide(FilesystemBlobStore in) { - return in; - } - } diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java deleted file mode 100644 index f836d82ab0..0000000000 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.filesystem.config; - -import org.jclouds.blobstore.AsyncBlobStore; -import org.jclouds.filesystem.FilesystemAsyncBlobStore; -import org.jclouds.filesystem.FilesystemBlobStore; -import org.jclouds.rest.config.RestClientModule; - -/** - * - * @author Alfredo "Rainbowbreeze" Morresi - */ -public class FilesystemBlobStoreModule extends RestClientModule { - - public FilesystemBlobStoreModule() { - super(FilesystemBlobStore.class, AsyncBlobStore.class); - } - - @Override - protected void configure() { - super.configure(); - } - - @Override - protected void bindAsyncClient() { - bind(AsyncBlobStore.class).to(FilesystemAsyncBlobStore.class).asEagerSingleton(); - } -} diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java index 37907664e7..e9f6b3cbb5 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java @@ -40,10 +40,10 @@ import junit.framework.Assert; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; @@ -85,7 +85,7 @@ public class FilesystemAsyncBlobStoreTest { System.setProperty(LOGGING_CONFIG_KEY, LOGGING_CONFIG_VALUE); } - private BlobStoreContext context = null; + private BlobStoreContext context = null; private BlobStore blobStore = null; private Set resourcesToBeDeleted = new HashSet(); @@ -94,7 +94,7 @@ public class FilesystemAsyncBlobStoreTest { // create context for filesystem container Properties prop = new Properties(); prop.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); - context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(prop).build(); + context = ContextBuilder.newBuilder(PROVIDER).overrides(prop).build(BlobStoreContext.class); // create a container in the default location blobStore = context.getBlobStore(); @@ -131,7 +131,7 @@ public class FilesystemAsyncBlobStoreTest { // no base directory declared in properties try { Properties props = new Properties(); - context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(props).build(); + context = ContextBuilder.newBuilder(PROVIDER).overrides(props).build(); fail("No error if base directory is not specified"); } catch (CreationException e) { } @@ -140,7 +140,7 @@ public class FilesystemAsyncBlobStoreTest { try { Properties props = new Properties(); props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, null); - context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(props).build(); + context = ContextBuilder.newBuilder(PROVIDER).overrides(props).build(); fail("No error if base directory is null in the option"); } catch (NullPointerException e) { } diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java index 80a98df306..60540982d9 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java @@ -23,18 +23,28 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.openstack.nova.compute.config.NovaComputeServiceContextModule; +import org.jclouds.openstack.nova.config.NovaRestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Nova 1.0 API * * @author Adrian Cole */ -public class NovaApiMetadata - extends - BaseComputeServiceApiMetadata, NovaApiMetadata> { +public class NovaApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { @@ -49,26 +59,25 @@ public class NovaApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, NovaApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { - id("nova") + super(NovaClient.class, NovaAsyncClient.class); + id("nova") .name("OpenStack Nova Pre-Diablo API") .identityName("accessKey") .credentialName("secretKey") .documentation(URI.create("http://api.openstack.org/")) .version("1.1") .defaultEndpoint("http://localhost:5000") - .javaApi(NovaClient.class, NovaAsyncClient.class) .defaultProperties(NovaApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(NovaContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class)); } @Override @@ -77,7 +86,7 @@ public class NovaApiMetadata } @Override - public Builder fromApiMetadata(NovaApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java deleted file mode 100644 index 6a147dbfe6..0000000000 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openstack.nova; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.openstack.nova.compute.config.NovaComputeServiceContextModule; -import org.jclouds.openstack.nova.config.NovaRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class NovaContextBuilder - extends - ComputeServiceContextBuilder, NovaApiMetadata> { - - public NovaContextBuilder( - ProviderMetadata, NovaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public NovaContextBuilder(NovaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new NovaComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new NovaRestClientModule()); - } - -} \ No newline at end of file diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java index b027028613..6ac995e84e 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java @@ -32,8 +32,6 @@ import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -import org.jclouds.openstack.nova.NovaAsyncClient; -import org.jclouds.openstack.nova.NovaClient; import org.jclouds.openstack.nova.compute.functions.FlavorToHardware; import org.jclouds.openstack.nova.compute.functions.NovaImageToImage; import org.jclouds.openstack.nova.compute.functions.NovaImageToOperatingSystem; @@ -54,12 +52,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class NovaComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public NovaComputeServiceContextModule() { - super(NovaClient.class, NovaAsyncClient.class); - } +public class NovaComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java index e5cf6aac85..e1c3186b98 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java @@ -23,7 +23,6 @@ import java.net.URI; import javax.inject.Singleton; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -47,7 +46,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class NovaRestClientModule extends RestClientModule { private final OpenStackAuthenticationModule module; diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/options/CreateServerOptions.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/options/CreateServerOptions.java index 03f5e5cedf..902d074d0a 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/options/CreateServerOptions.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/options/CreateServerOptions.java @@ -24,8 +24,8 @@ import static com.google.common.base.Preconditions.checkState; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import javax.inject.Inject; diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java index c9d67a097a..792101bb3c 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java @@ -32,7 +32,6 @@ import java.util.Date; import javax.ws.rs.core.MediaType; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.UnwrapOnlyJsonValue; @@ -44,7 +43,7 @@ import org.jclouds.openstack.nova.domain.RebootType; import org.jclouds.openstack.nova.options.CreateServerOptions; import org.jclouds.openstack.nova.options.ListOptions; import org.jclouds.openstack.nova.options.RebuildServerOptions; -import org.jclouds.providers.AnonymousProviderMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; @@ -767,8 +766,7 @@ public class NovaAsyncClientTest extends BaseAsyncClientTest { } @ConfiguresRestClient - @RequiresHttp - protected static class TestNovaRestClientModule extends NovaRestClientModule { + protected static class TestNovaRestClientModule extends NovaRestClientModule { private TestNovaRestClientModule() { super(new TestOpenStackAuthenticationModule()); } @@ -778,7 +776,7 @@ public class NovaAsyncClientTest extends BaseAsyncClientTest { protected String provider = "nova"; @Override - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forApiWithEndpoint(new NovaApiMetadata(), "http://endpoint"); } } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java index d93ec24277..117e97c726 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpResponseException; @@ -65,9 +64,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaClientLiveTest") -public class NovaClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class NovaClientLiveTest extends BaseComputeServiceContextLiveTest { public NovaClientLiveTest() { provider = "nova"; diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java index eb0dc9eea2..11fa629666 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java @@ -22,12 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.domain.LocationScope; -import org.jclouds.openstack.nova.NovaAsyncClient; -import org.jclouds.openstack.nova.NovaClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -39,8 +36,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "NovaComputeServiceLiveTest") -public class NovaComputeServiceLiveTest extends - BaseComputeServiceLiveTest> { +public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest { public NovaComputeServiceLiveTest() { provider = "nova"; diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java index 240b37c49f..e0c53d8051 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java @@ -31,16 +31,29 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; +import org.jclouds.openstack.nova.ec2.config.NovaEC2ComputeServiceContextModule; +import org.jclouds.openstack.nova.ec2.config.NovaEC2RestClientModule; +import org.jclouds.rest.RestContext; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the OpenStack Nova's EC2-clone API * * @author Adrian Cole */ -public class NovaEC2ApiMetadata extends EC2ApiMetadata, NovaEC2ApiMetadata> { +public class NovaEC2ApiMetadata extends EC2ApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1492951757032303845L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -58,7 +71,7 @@ public class NovaEC2ApiMetadata extends EC2ApiMetadata, NovaEC2ApiMetadata> { + public static class Builder extends EC2ApiMetadata.Builder { protected Builder(){ super(EC2Client.class, EC2AsyncClient.class); id("openstack-nova-ec2") @@ -83,7 +96,7 @@ public class NovaEC2ApiMetadata extends EC2ApiMetadata>of(NovaEC2RestClientModule.class, EC2ResolveImagesModule.class, NovaEC2ComputeServiceContextModule.class)); } @Override @@ -92,7 +105,7 @@ public class NovaEC2ApiMetadata extends EC2ApiMetadata, NovaEC2ApiMetadata> { - - public NovaEC2ContextBuilder( - ProviderMetadata, NovaEC2ApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public NovaEC2ContextBuilder(NovaEC2ApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new NovaEC2RestClientModule()); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new NovaEC2ComputeServiceContextModule()); - } - -} diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java index 0ac573ff26..f2ff664f35 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java @@ -22,7 +22,6 @@ import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.config.EC2RestClientModule; import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; -import org.jclouds.http.RequiresHttp; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; import org.jclouds.location.suppliers.ZoneIdsSupplier; @@ -35,7 +34,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class NovaEC2RestClientModule extends EC2RestClientModule { diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java index 253a799832..14d614e7b6 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java @@ -20,9 +20,6 @@ package org.jclouds.openstack.nova.ec2.compute; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest; import org.testng.annotations.Test; @@ -31,7 +28,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaEC2ComputeServiceLiveTest") -public class NovaEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest> { +public class NovaEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public NovaEC2ComputeServiceLiveTest() { provider = "openstack-nova-ec2"; diff --git a/apis/openstack-nova/pom.xml b/apis/openstack-nova/pom.xml index fa2663a3c3..8e144f766b 100644 --- a/apis/openstack-nova/pom.xml +++ b/apis/openstack-nova/pom.xml @@ -45,6 +45,7 @@ false + passwordCredentials @@ -125,6 +126,7 @@ ${test.openstack-nova.image.login-user} ${test.openstack-nova.image.authenticate-sudo} ${test.jclouds.openstack-nova.auto-allocate-floating-ips} + ${test.jclouds.keystone.credential-type} diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java index 578d6b929d..de321c2366 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java @@ -28,20 +28,30 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; +import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; import org.jclouds.openstack.services.ServiceType; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Nova 1.0 API * * @author Adrian Cole */ -public class NovaApiMetadata - extends - BaseComputeServiceApiMetadata, NovaApiMetadata> { +public class NovaApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { @@ -56,8 +66,8 @@ public class NovaApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); // auth fail can happen while cloud-init applies keypair updates properties.setProperty("jclouds.ssh.max-retries", "7"); properties.setProperty("jclouds.ssh.retry-auth", "true"); @@ -72,11 +82,10 @@ public class NovaApiMetadata return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, NovaApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(NovaClient.class, NovaAsyncClient.class); id("openstack-nova") .name("OpenStack Nova Diablo+ API") .identityName("tenantId:user") @@ -84,18 +93,18 @@ public class NovaApiMetadata .documentation(URI.create("http://api.openstack.org/")) .version("1.1") .defaultEndpoint("http://localhost:5000") - .javaApi(NovaClient.class, NovaAsyncClient.class) .defaultProperties(NovaApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(NovaContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class)); } - + @Override public NovaApiMetadata build() { return new NovaApiMetadata(this); } @Override - public Builder fromApiMetadata(NovaApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java deleted file mode 100644 index 06be070cb8..0000000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openstack.nova.v1_1; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; -import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class NovaContextBuilder - extends - ComputeServiceContextBuilder, NovaApiMetadata> { - - public NovaContextBuilder( - ProviderMetadata, NovaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public NovaContextBuilder(NovaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new NovaComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new NovaRestClientModule()); - } - -} \ No newline at end of file diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java index 90e229479a..ee9fec20ec 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java @@ -35,8 +35,8 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableMap.Builder; /** * diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java index d3f56d941c..bd799523ce 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java @@ -86,7 +86,7 @@ public class NovaComputeService extends BaseComputeService { protected final GroupNamingConvention.Factory namingConvention; @Inject - protected NovaComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected NovaComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/config/NovaComputeServiceContextModule.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/config/NovaComputeServiceContextModule.java index 37e169c240..2351ac7164 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/config/NovaComputeServiceContextModule.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/config/NovaComputeServiceContextModule.java @@ -44,8 +44,6 @@ import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThen import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; import org.jclouds.functions.IdentityFunction; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.compute.NovaComputeService; import org.jclouds.openstack.nova.v1_1.compute.NovaComputeServiceAdapter; import org.jclouds.openstack.nova.v1_1.compute.functions.CreateSecurityGroupIfNeeded; @@ -91,12 +89,8 @@ import com.google.inject.name.Names; * * @author Matt Stephenson */ -public class NovaComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public NovaComputeServiceContextModule() { - super(NovaClient.class, NovaAsyncClient.class); - } +public class NovaComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/options/NovaTemplateOptions.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/options/NovaTemplateOptions.java index cfa96773a8..bc0d9e43b4 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/options/NovaTemplateOptions.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/options/NovaTemplateOptions.java @@ -31,8 +31,8 @@ import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.util.Preconditions2; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java index 0b4fdc5602..32c8513874 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java @@ -26,7 +26,6 @@ import javax.inject.Provider; import javax.inject.Singleton; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -68,7 +67,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class NovaRestClientModule extends RestClientModule { diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java index e8bee1ae3c..985066392c 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java @@ -34,10 +34,10 @@ import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient; import org.jclouds.util.InetAddresses2; import org.jclouds.util.Multimaps2; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Strings; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/zonescoped/ZoneAndName.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/zonescoped/ZoneAndName.java index c09b0ccb01..1bc8b5a631 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/zonescoped/ZoneAndName.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/zonescoped/ZoneAndName.java @@ -24,8 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Function; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Splitter; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Iterables; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/ParseImageIdFromLocationHeader.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/ParseImageIdFromLocationHeader.java index 1bdeb2c8f0..0b4873b3a2 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/ParseImageIdFromLocationHeader.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/ParseImageIdFromLocationHeader.java @@ -20,11 +20,10 @@ package org.jclouds.openstack.nova.v1_1.functions; import javax.inject.Singleton; - import javax.ws.rs.core.HttpHeaders; -import org.jclouds.openstack.nova.v1_1.domain.Image; import org.jclouds.http.HttpResponse; +import org.jclouds.openstack.nova.v1_1.domain.Image; import com.google.common.base.Function; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java index ff9bb7269a..3bd7fad2b3 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java @@ -26,8 +26,8 @@ import static com.google.common.base.Preconditions.checkState; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import javax.inject.Inject; @@ -40,8 +40,8 @@ import org.jclouds.rest.binders.BindToJsonPayload; import org.jclouds.util.Preconditions2; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java index e2072a77b3..b2df3a5eee 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java @@ -24,8 +24,8 @@ import static org.testng.Assert.assertNotNull; import java.net.URI; import java.util.Map; -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.domain.LoginCredentials; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java index 23e4de0e8b..ac69ac22b6 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java @@ -41,9 +41,9 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.AbstractModule; import com.google.inject.TypeLiteral; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java index 683fb6b301..df697bc88a 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java @@ -1,9 +1,10 @@ package org.jclouds.openstack.nova.v1_1.compute; -import org.jclouds.compute.ComputeServiceContext; +import java.util.Properties; + import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.nova.v1_1.config.NovaProperties; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -14,8 +15,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaComputeServiceLiveTest") -public class NovaComputeServiceLiveTest extends - BaseComputeServiceLiveTest> { +public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest { public NovaComputeServiceLiveTest() { provider = "openstack-nova"; @@ -53,4 +53,12 @@ public class NovaComputeServiceLiveTest extends public void testDestroyNodes() { super.testDestroyNodes(); } + + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); + setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS); + return props; + } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/loaders/CreateUniqueKeyPairTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/loaders/CreateUniqueKeyPairTest.java index 8c62b08550..8f99d867c0 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/loaders/CreateUniqueKeyPairTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/loaders/CreateUniqueKeyPairTest.java @@ -27,7 +27,6 @@ import static org.testng.Assert.assertEquals; import java.net.UnknownHostException; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.compute.loaders.CreateUniqueKeyPair; import org.jclouds.openstack.nova.v1_1.domain.KeyPair; import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ZoneAndName; import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java index fcdd6cfd3c..3b15224a9d 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java @@ -34,9 +34,9 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableMap.Builder; /** * diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java index 3e6679ed37..f4cc9157e4 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java @@ -18,10 +18,13 @@ */ package org.jclouds.openstack.nova.v1_1.internal; -import org.jclouds.compute.ComputeServiceContext; +import java.util.Properties; + import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.nova.v1_1.config.NovaProperties; import org.jclouds.rest.RestContext; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; @@ -33,9 +36,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live") -public class BaseNovaClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseNovaClientLiveTest extends BaseComputeServiceContextLiveTest { public BaseNovaClientLiveTest() { provider = "openstack-nova"; @@ -47,9 +48,17 @@ public class BaseNovaClientLiveTest @Override public void setupContext() { super.setupContext(); - novaContext = context.getProviderSpecificContext(); + novaContext = context.unwrap(); } + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); + setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS); + return props; + } + @AfterGroups(groups = "live") protected void tearDown() { if (novaContext != null) diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java index 59f81af989..f7e3681aad 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java @@ -33,7 +33,6 @@ import org.jclouds.rest.config.CredentialStoreModule; import com.google.common.base.Function; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; import com.google.common.io.InputSupplier; import com.google.inject.Module; @@ -88,7 +87,7 @@ public abstract class BaseNovaComputeServiceContextExpectTest extends BaseNov } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new NovaApiMetadata(); } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java index d79e19dc45..15f68e6afa 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java @@ -30,7 +30,7 @@ import org.jclouds.compute.ComputeServiceContext; public class BaseNovaComputeServiceExpectTest extends BaseNovaComputeServiceContextExpectTest { @Override - public ComputeService apply(@SuppressWarnings("rawtypes") ComputeServiceContext input) { + public ComputeService apply(ComputeServiceContext input) { return input.getComputeService(); } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java index 66110be35c..b322aad8e5 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.Server.Status; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java index 0f92a1c75f..eb78746d73 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java @@ -27,8 +27,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java index 45d20150ea..da4a4c63bd 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java @@ -27,8 +27,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java index 33efaacb56..c7579ee71d 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Image; import org.jclouds.openstack.nova.v1_1.domain.Image.Status; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java index dc911c2515..7ad940b6a9 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java @@ -27,8 +27,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java index cf7d2760bc..f249f3bdb1 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java index a7703ea142..b5272f2cbc 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest.java index 789234c3fd..7df750e8c3 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java index 45b84df2e6..10f0ce4ee6 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java @@ -32,12 +32,16 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; import org.jclouds.s3.blobstore.S3BlobStoreContext; +import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; +import org.jclouds.s3.config.S3RestClientModule; import org.jclouds.s3.reference.S3Headers; -import com.google.common.reflect.TypeParameter; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Amazon's S3 api. @@ -56,26 +60,30 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -public class S3ApiMetadata, M extends S3ApiMetadata> - extends BaseBlobStoreApiMetadata { +public class S3ApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 820062881469203616L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Builder toBuilder() { - return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public S3ApiMetadata() { this(new Builder(S3Client.class, S3AsyncClient.class)); } - protected S3ApiMetadata(Builder builder) { + protected S3ApiMetadata(Builder builder) { super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_API_VERSION, S3AsyncClient.VERSION); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, S3Headers.DEFAULT_AMAZON_HEADERTAG); @@ -87,9 +95,10 @@ public class S3ApiMetadata, M extends S3ApiMetadata> extends BaseBlobStoreApiMetadata.Builder { + public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder(Class syncClient, Class asyncClient){ + protected Builder(Class syncClient, Class asyncClient){ + super(syncClient, asyncClient); id("s3") .name("Amazon Simple Storage Service (S3) API") .identityName("Access Key ID") @@ -98,32 +107,17 @@ public class S3ApiMetadata>(getClass()){ - private static final long serialVersionUID = 1L; - }); + .wrapper(TypeToken.of(S3BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(S3RestClientModule.class, S3BlobStoreContextModule.class)); } - - /** - * {@inheritDoc} - */ + @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); + public ApiMetadata build() { + return new S3ApiMetadata(this); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override - public M build() { - return (M) new S3ApiMetadata(this); - } - - @Override - public Builder fromApiMetadata(M in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java b/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java deleted file mode 100644 index 8c011628d1..0000000000 --- a/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.s3; - -import java.util.List; - -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.s3.blobstore.S3BlobStoreContext; -import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; -import org.jclouds.s3.config.S3RestClientModule; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link S3Context} or {@link Injector} instances based on the most commonly requested - * arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

    - *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see S3Context - */ -public class S3ContextBuilder, M extends S3ApiMetadata> - extends BlobStoreContextBuilder { - - public S3ContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public S3ContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new S3BlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(S3RestClientModule.create()); - } -} diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java index 0bd44b881c..3bded56016 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java @@ -93,7 +93,7 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore { private final LoadingCache bucketAcls; @Inject - protected S3AsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected S3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, S3AsyncClient async, S3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java index 2e2104879b..3c75d3d3c2 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java @@ -84,7 +84,7 @@ public class S3BlobStore extends BaseBlobStore { private final LoadingCache bucketAcls; @Inject - protected S3BlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected S3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, S3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob, diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java index 58e8b1fec6..f60926047d 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java @@ -19,8 +19,6 @@ package org.jclouds.s3.blobstore; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.s3.S3AsyncClient; -import org.jclouds.s3.S3Client; import org.jclouds.s3.blobstore.internal.S3BlobStoreContextImpl; import com.google.inject.ImplementedBy; @@ -29,7 +27,7 @@ import com.google.inject.ImplementedBy; * @author Adrian Cole */ @ImplementedBy(S3BlobStoreContextImpl.class) -public interface S3BlobStoreContext extends BlobStoreContext { +public interface S3BlobStoreContext extends BlobStoreContext { @Override S3BlobStore getBlobStore(); diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/config/S3BlobStoreContextModule.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/config/S3BlobStoreContextModule.java index 709333e7df..165257678e 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/config/S3BlobStoreContextModule.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/config/S3BlobStoreContextModule.java @@ -25,16 +25,14 @@ import javax.inject.Singleton; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.domain.Location; -import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3Client; import org.jclouds.s3.blobstore.S3AsyncBlobStore; import org.jclouds.s3.blobstore.S3BlobRequestSigner; import org.jclouds.s3.blobstore.S3BlobStore; +import org.jclouds.s3.blobstore.S3BlobStoreContext; import org.jclouds.s3.blobstore.functions.LocationFromBucketLocation; import org.jclouds.s3.domain.AccessControlList; import org.jclouds.s3.domain.BucketMetadata; @@ -61,16 +59,10 @@ public class S3BlobStoreContextModule extends AbstractModule { bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); bind(AsyncBlobStore.class).to(S3AsyncBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(S3BlobStore.class).in(Scopes.SINGLETON); - bindContext(); bind(BlobRequestSigner.class).to(S3BlobRequestSigner.class); bindBucketLocationStrategy(); } - protected void bindContext() { - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); - } - protected void bindBucketLocationStrategy() { bind(new TypeLiteral>() { }).to(LocationFromBucketLocation.class); diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java index 92f9066a67..16146c35c8 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java @@ -18,34 +18,39 @@ */ package org.jclouds.s3.blobstore.internal; +import java.io.Closeable; + import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.InputStreamMap; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.internal.BlobStoreContextImpl; -import org.jclouds.rest.RestContext; +import org.jclouds.location.Provider; import org.jclouds.rest.Utils; -import org.jclouds.s3.S3AsyncClient; -import org.jclouds.s3.S3Client; import org.jclouds.s3.blobstore.S3AsyncBlobStore; import org.jclouds.s3.blobstore.S3BlobStore; import org.jclouds.s3.blobstore.S3BlobStoreContext; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class S3BlobStoreContextImpl extends - BlobStoreContextImpl implements S3BlobStoreContext { - +public class S3BlobStoreContextImpl extends BlobStoreContextImpl implements S3BlobStoreContext { + @Inject - public S3BlobStoreContextImpl(BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, - InputStreamMap.Factory inputStreamMapFactory, S3AsyncBlobStore ablobStore, S3BlobStore blobStore, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext, BlobRequestSigner blobRequestSigner) { - super(blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, blobStore, providerSpecificContext, blobRequestSigner); + public S3BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, + InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, + BlobRequestSigner blobRequestSigner) { + super(wrapped, wrappedType, blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, + blobStore, blobRequestSigner); } @Override diff --git a/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java b/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java index 9fcfb355df..a1c4450ebb 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java +++ b/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java @@ -30,7 +30,6 @@ import org.jclouds.date.DateService; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -56,10 +55,11 @@ import com.google.inject.Scopes; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class S3RestClientModule extends AWSRestClientModule { - public static S3RestClientModule create() { - return new S3RestClientModule(S3Client.class, S3AsyncClient.class); + + @SuppressWarnings("unchecked") + public S3RestClientModule() { + this((Class) S3Client.class, (Class) S3AsyncClient.class); } public S3RestClientModule(Class sync, Class async) { @@ -100,7 +100,7 @@ public class S3RestClientModule ext protected RequestSigner provideRequestSigner(RequestAuthorizeSignature in) { return in; } - + @Override protected void bindRetryHandlers() { bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(S3RedirectionRetryHandler.class); @@ -119,7 +119,7 @@ public class S3RestClientModule ext @TimeStamp @Singleton protected Supplier provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds, - final DateService dateService) { + final DateService dateService) { return Suppliers.memoizeWithExpiration(new Supplier() { public String get() { return dateService.rfc822DateFormat(); diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java index 8445d01a19..dc4a6838ed 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java @@ -25,7 +25,6 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "S3ApiMetadataTest") public class S3ApiMetadataTest extends BaseBlobStoreApiMetadataTest { diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java index 94b088cee4..5e54b10483 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java @@ -33,7 +33,6 @@ import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -43,13 +42,13 @@ import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.s3.config.S3RestClientModule; import org.jclouds.s3.domain.AccessControlList; -import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee; -import org.jclouds.s3.domain.AccessControlList.Grant; -import org.jclouds.s3.domain.AccessControlList.Permission; import org.jclouds.s3.domain.BucketLogging; import org.jclouds.s3.domain.CannedAccessPolicy; import org.jclouds.s3.domain.Payer; import org.jclouds.s3.domain.S3Object; +import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee; +import org.jclouds.s3.domain.AccessControlList.Grant; +import org.jclouds.s3.domain.AccessControlList.Permission; import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders; import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState; @@ -479,8 +478,7 @@ public abstract class S3AsyncClientTest extends BaseS3A checkFilters(request); } - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient private static final class TestS3RestClientModule extends S3RestClientModule { public TestS3RestClientModule() { diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java index c5ee33c702..74c0b0989a 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java @@ -32,6 +32,7 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.io.IOException; +import java.net.URI; import java.net.URL; import java.util.Date; import java.util.Map; @@ -41,13 +42,13 @@ import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.http.HttpResponseException; import org.jclouds.s3.domain.AccessControlList; +import org.jclouds.s3.domain.CannedAccessPolicy; +import org.jclouds.s3.domain.ObjectMetadata; +import org.jclouds.s3.domain.S3Object; import org.jclouds.s3.domain.AccessControlList.CanonicalUserGrantee; import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee; import org.jclouds.s3.domain.AccessControlList.GroupGranteeURI; import org.jclouds.s3.domain.AccessControlList.Permission; -import org.jclouds.s3.domain.CannedAccessPolicy; -import org.jclouds.s3.domain.ObjectMetadata; -import org.jclouds.s3.domain.S3Object; import org.jclouds.s3.options.PutObjectOptions; import org.jclouds.util.Strings2; import org.testng.annotations.Test; @@ -67,7 +68,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest { } public S3Client getApi() { - return (S3Client) context.getProviderSpecificContext().getApi(); + return context.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi(); } /** @@ -90,8 +91,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest { } protected URL getObjectURL(String containerName, String key) throws Exception { - URL url = new URL(String.format("http://%s.%s/%s", containerName, context.getProviderSpecificContext() - .getEndpoint().getHost(), key)); + URL url = new URL(String.format("http://%s.%s/%s", containerName, URI.create(endpoint).getHost(), key)); return url; } diff --git a/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java b/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java index c88a77899e..edc9b03ad1 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java @@ -29,7 +29,6 @@ import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.s3.S3AsyncClient; @@ -116,7 +115,6 @@ public class S3BlobRequestSignerTest extends BaseS3AsyncClientTest { diff --git a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3AsyncClientTest.java b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3AsyncClientTest.java index 2fbccb556c..de840e6b59 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3AsyncClientTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3AsyncClientTest.java @@ -60,7 +60,6 @@ public abstract class BaseS3AsyncClientTest extends Bas super(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public S3ApiMetadata createApiMetadata() { return new S3ApiMetadata(); diff --git a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java index c759c546ff..f38e1e4659 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java @@ -19,7 +19,6 @@ package org.jclouds.s3.internal; import org.jclouds.date.TimeStamp; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.s3.S3ApiMetadata; @@ -38,8 +37,7 @@ public abstract class BaseS3ClientExpectTest extends BaseRestClientExpectTest { public TestS3RestClientModule() { @@ -57,7 +55,6 @@ public abstract class BaseS3ClientExpectTest extends BaseRestClientExpectTest, SwiftApiMetadata> { +public class SwiftApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -57,27 +66,25 @@ public class SwiftApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); return properties; } - public static class Builder - extends - BaseBlobStoreApiMetadata.Builder, SwiftApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(SwiftClient.class, SwiftAsyncClient.class); id("swift") - .type(ApiType.BLOBSTORE) .name("OpenStack Swift Pre-Diablo API") .identityName("tenantId:user") .credentialName("password") .documentation(URI.create("http://api.openstack.org/")) .version(OpenStackAuthAsyncClient.VERSION) - .contextBuilder(TypeToken.of(SwiftContextBuilder.class)) .defaultProperties(SwiftApiMetadata.defaultProperties()) - .javaApi(SwiftClient.class, SwiftAsyncClient.class); + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(SwiftRestClientModule.class, SwiftBlobStoreContextModule.class)); } @Override @@ -86,7 +93,7 @@ public class SwiftApiMetadata } @Override - public Builder fromApiMetadata(SwiftApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java deleted file mode 100644 index a64a01c24a..0000000000 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openstack.swift; - -import java.util.List; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; -import org.jclouds.openstack.swift.config.SwiftRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link SwiftStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see SwiftStoreContext - */ -public class SwiftContextBuilder - extends - BlobStoreContextBuilder, SwiftApiMetadata> { - - public SwiftContextBuilder( - ProviderMetadata, SwiftApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public SwiftContextBuilder(SwiftApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new SwiftBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new SwiftRestClientModule()); - } -} \ No newline at end of file diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java index ec12eec9ec..b0873c9af6 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java @@ -83,7 +83,7 @@ public class SwiftAsyncBlobStore extends BaseAsyncBlobStore { private final Provider fetchBlobMetadataProvider; @Inject - protected SwiftAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected SwiftAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, CommonSwiftAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java index 9d2fab5638..e96909ba18 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java @@ -73,7 +73,7 @@ public class SwiftBlobStore extends BaseBlobStore { private final Provider fetchBlobMetadataProvider; @Inject - protected SwiftBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected SwiftBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java index ff440f8b59..01d39c7d2d 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java @@ -21,19 +21,14 @@ package org.jclouds.openstack.swift.blobstore.config; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; -import org.jclouds.openstack.swift.CommonSwiftAsyncClient; -import org.jclouds.openstack.swift.CommonSwiftClient; import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore; import org.jclouds.openstack.swift.blobstore.SwiftBlobRequestSigner; import org.jclouds.openstack.swift.blobstore.SwiftBlobStore; import com.google.inject.AbstractModule; import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * Configures the {@link CloudFilesBlobStoreContext}; requires {@link SwiftAsyncBlobStore} @@ -49,8 +44,6 @@ public class SwiftBlobStoreContextModule extends AbstractModule { bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); bind(AsyncBlobStore.class).to(SwiftAsyncBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(SwiftBlobStore.class).in(Scopes.SINGLETON); - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(BlobRequestSigner.class).to(SwiftBlobRequestSigner.class); } diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java index d750b7a325..4dd913724a 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java @@ -23,7 +23,6 @@ import java.net.URI; import javax.inject.Singleton; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -47,7 +46,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class BaseSwiftRestClientModule extends RestClientModule { private final OpenStackAuthenticationModule module; diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java index 9186c7e38c..a647924ca4 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.openstack.swift.config; import javax.inject.Singleton; -import org.jclouds.http.RequiresHttp; import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClient; import org.jclouds.openstack.swift.SwiftAsyncClient; @@ -34,7 +33,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class SwiftRestClientModule extends BaseSwiftRestClientModule { public SwiftRestClientModule() { diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java index 4906ebd24e..ced9b5fab5 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java @@ -24,16 +24,20 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; +import javax.inject.Singleton; + import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.openstack.TestOpenStackAuthenticationModule; import org.jclouds.openstack.swift.config.BaseSwiftRestClientModule; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; import com.google.inject.Module; +import com.google.inject.Provides; +import com.google.inject.TypeLiteral; /** * Tests behavior of {@code BindSwiftObjectMetadataToRequest} @@ -42,8 +46,14 @@ import com.google.inject.Module; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SwiftClientTest") -public abstract class CommonSwiftClientTest extends BaseAsyncClientTest { - +public abstract class CommonSwiftClientTest extends BaseAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + @Override protected void checkFilters(HttpRequest request) { } @@ -54,17 +64,27 @@ public abstract class CommonSwiftClientTest ex } @ConfiguresRestClient - @RequiresHttp protected static class TestSwiftRestClientModule extends - BaseSwiftRestClientModule { + BaseSwiftRestClientModule { private TestSwiftRestClientModule() { - super(new TestOpenStackAuthenticationModule(), CommonSwiftClient.class, CommonSwiftAsyncClient.class); + super(new TestOpenStackAuthenticationModule(), SwiftClient.class, SwiftAsyncClient.class); + } + @Provides + @Singleton + CommonSwiftClient provideCommonSwiftClient(SwiftClient in) { + return in; + } + + @Provides + @Singleton + CommonSwiftAsyncClient provideCommonSwiftClient(SwiftAsyncClient in) { + return in; } } protected String provider = "swift"; - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new SwiftApiMetadata(); } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java index f9cd2b4882..383d5cd173 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java @@ -1,3 +1,21 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.openstack.swift; import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java index 8cc7bd1e1a..06a26a5ca3 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java @@ -33,7 +33,7 @@ public class SwiftClientLiveTest extends CommonSwiftClientLiveTest @Override public SwiftClient getApi() { - return (SwiftClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi(); } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java index d2b5ddb5f9..7cd857c41b 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java @@ -28,15 +28,12 @@ import javax.ws.rs.HttpMethod; import org.jclouds.http.HttpRequest; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; -import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClientTest; import org.jclouds.openstack.swift.domain.SwiftObject; -import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; -import com.google.inject.TypeLiteral; /** * Tests behavior of {@code BindSwiftObjectMetadataToRequest} @@ -45,12 +42,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BindSwiftObjectMetadataToRequestTest") -public class BindSwiftObjectMetadataToRequestTest extends CommonSwiftClientTest { - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } +public class BindSwiftObjectMetadataToRequestTest extends CommonSwiftClientTest { @Test public void testPassWithMinimumDetailsAndPayload5GB() { diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java index bdfe049363..127d4d1945 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java @@ -26,14 +26,10 @@ import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClientTest; -import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.inject.TypeLiteral; - /** * Tests behavior of {@code CommonSwiftBlobRequestSigner} * @@ -41,12 +37,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SwiftBlobRequestSignerTest") -public class SwiftBlobRequestSignerTest extends CommonSwiftClientTest { - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } +public class SwiftBlobRequestSignerTest extends CommonSwiftClientTest { private BlobRequestSigner signer; private Factory blobFactory; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java index 9238fca5ea..eeb118be97 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java @@ -30,20 +30,30 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; +import org.jclouds.vcloud.config.VCloudRestClientModule; import org.jclouds.vcloud.domain.network.FenceMode; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for VCloud 1.0 API * * @author Adrian Cole */ -public class VCloudApiMetadata - extends - BaseComputeServiceApiMetadata, VCloudApiMetadata> { +public class VCloudApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -57,8 +67,8 @@ public class VCloudApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1"); properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA)); @@ -75,20 +85,19 @@ public class VCloudApiMetadata return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, VCloudApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(VCloudClient.class, VCloudAsyncClient.class); id("vcloud") .name("VCloud 1.0 API") .identityName("User at Organization (user@org)") .credentialName("Password") .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) .version("1.0") - .javaApi(VCloudClient.class, VCloudAsyncClient.class) .defaultProperties(VCloudApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(VCloudContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(VCloudRestClientModule.class, VCloudComputeServiceContextModule.class)); } @Override @@ -97,7 +106,7 @@ public class VCloudApiMetadata } @Override - public Builder fromApiMetadata(VCloudApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java deleted file mode 100644 index a69b0105c2..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; -import org.jclouds.vcloud.config.VCloudRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class VCloudContextBuilder - extends - ComputeServiceContextBuilder, VCloudApiMetadata> { - - public VCloudContextBuilder( - ProviderMetadata, VCloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public VCloudContextBuilder(VCloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new VCloudRestClientModule()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java index 7dd57118dc..bc29a2fe87 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java @@ -23,8 +23,6 @@ import static org.jclouds.compute.domain.OsFamily.UBUNTU; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.domain.Location; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; @@ -36,12 +34,8 @@ import com.google.inject.Injector; * * @author Adrian Cole */ -public class VCloudComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public VCloudComputeServiceContextModule() { - super(VCloudClient.class, VCloudAsyncClient.class); - } +public class VCloudComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @Override protected void configure() { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java index 910e5d37d9..486df9b030 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java @@ -47,7 +47,6 @@ import javax.inject.Singleton; import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.domain.Location; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -129,7 +128,6 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class VCloudRestClientModule extends RestClientModule { diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java index 9bb06859b2..6751518b91 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.vcloud; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "VCloudApiMetadataTest") -public class VCloudApiMetadataTest extends BaseApiMetadataTest { +public class VCloudApiMetadataTest extends BaseComputeServiceApiMetadataTest { public VCloudApiMetadataTest() { - super(new VCloudApiMetadata(), ApiType.COMPUTE); + super(new VCloudApiMetadata()); } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java index cf802d6715..bcbaa94231 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java @@ -33,7 +33,8 @@ public class VCloudSessionRefreshLiveTest extends BaseVCloudClientLiveTest { @Test public void testSessionRefresh() throws Exception { - VCloudClient connection = VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi()); + VCloudClient connection = VCloudClient.class.cast(client.getContext().unwrap(VCloudApiMetadata.CONTEXT_TOKEN) + .getApi()); connection.getOrgClient().findOrgNamed(null); Thread.sleep(timeOut * 1000); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java index 0afb3ade55..5f98738c1b 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java @@ -70,7 +70,7 @@ public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudVersionsClient.class, VCloudVersionsAsyncClient.class, "http://localhost:8080"); } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java index fb2c2c2483..a2aac9fe2a 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java @@ -27,9 +27,9 @@ import java.io.IOException; import java.net.URI; import java.util.Properties; -import org.jclouds.PropertiesBuilder; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.options.CloneVAppOptions; import org.testng.annotations.Test; @@ -52,10 +52,10 @@ public class BindCloneVAppParamsToXmlPayloadTest { @Override protected void configure() { - Properties props = new Properties(); + Properties props = new VCloudApiMetadata().getDefaultProperties(); props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v1"); props.setProperty("jclouds.vcloud.xml.schema", "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); - Names.bindProperties(binder(), new PropertiesBuilder(props).build()); + Names.bindProperties(binder(), props); } }); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java index e0caf5fbdc..8212c52f23 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java @@ -27,9 +27,9 @@ import java.io.IOException; import java.net.URI; import java.util.Properties; -import org.jclouds.PropertiesBuilder; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.options.CloneVAppTemplateOptions; import org.testng.annotations.Test; @@ -55,7 +55,7 @@ public class BindCloneVAppTemplateParamsToXmlPayloadTest { Properties props = new Properties(); props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v1"); props.setProperty("jclouds.vcloud.xml.schema", "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); - Names.bindProperties(binder(), new PropertiesBuilder(props).build()); + Names.bindProperties(binder(), new VCloudApiMetadata().getDefaultProperties()); } }); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java index 59b371f4e3..3dca2658d4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java @@ -151,7 +151,7 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new VCloudApiMetadata(); } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java index e10e9dc449..b2b266c854 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java @@ -18,12 +18,9 @@ */ package org.jclouds.vcloud.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -35,9 +32,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class VCloudComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { public VCloudComputeServiceLiveTest() { provider = "vcloud"; diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java index 28e1aeed00..36ee0a4b00 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java @@ -22,12 +22,15 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import org.jclouds.rest.annotations.ApiVersion; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.internal.BaseVCloudClientLiveTest; import org.testng.annotations.Test; +import com.google.inject.Key; + /** * @author Adrian Cole */ @@ -46,7 +49,7 @@ public class CatalogClientLiveTest extends BaseVCloudClientLiveTest { public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception { // when we are in vCloud 1.0.0 public catalogs don't work, so our default // catalog is private - if (!context.getProviderSpecificContext().getApiVersion().startsWith("1.5")) + if (!context.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5")) assertTrue(getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).isReadOnly()); } } \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java index eee3b7ecb8..2fd7661601 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java @@ -29,7 +29,7 @@ import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.net.IPSocket; -import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; import org.jclouds.vcloud.domain.Org; @@ -109,8 +109,8 @@ public class VmClientLiveTest extends BaseVCloudClientLiveTest { options.as(VCloudTemplateOptions.class).description(group); node = getOnlyElement(client.createNodesInGroup(group, 1, options)); - VApp vapp = ((VCloudClient) client.getContext().getProviderSpecificContext().getApi()).getVAppClient() - .getVApp(node.getUri()); + VApp vapp = client.getContext().unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi().getVAppClient().getVApp( + node.getUri()); assertEquals(vapp.getDescription(), group); Vm vm = Iterables.get(vapp.getChildren(), 0); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java index a954d20ab7..93edd14153 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java @@ -30,7 +30,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.ovf.Envelope; import org.jclouds.ovf.xml.EnvelopeHandlerTest; import org.jclouds.providers.AnonymousProviderMetadata; @@ -91,7 +90,7 @@ public abstract class BaseVCloudAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forApiWithEndpoint(new VCloudApiMetadata(), "https://vcenterprise.bluelock.com/api/v1.0"); } @@ -126,8 +125,7 @@ public abstract class BaseVCloudAsyncClientTest extends BaseAsyncClientTest of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false); - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient public static class VCloudRestClientModuleExtension extends VCloudRestClientModule { @Override diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java index 07edbf1379..e806763fe3 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java @@ -19,10 +19,9 @@ package org.jclouds.vcloud.internal; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -34,9 +33,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseVCloudClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public abstract class BaseVCloudClientLiveTest extends BaseComputeServiceContextLiveTest { // username is too long for name constraints protected String prefix = "vcd"; @@ -48,7 +45,7 @@ public abstract class BaseVCloudClientLiveTest } protected VCloudClient getVCloudApi() { - return VCloudClient.class.cast(context.getProviderSpecificContext().getApi()); + return VCloudClient.class.cast(context.unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi()); } @Override diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java index 9bc2626430..b9f72de188 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java @@ -98,7 +98,7 @@ public class VCloudLoginAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudLoginClient.class, VCloudLoginAsyncClient.class, "http://localhost:8080/login"); } diff --git a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java index d69db928ac..c2d4364949 100644 --- a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java +++ b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java @@ -27,16 +27,21 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.s3.S3ApiMetadata; import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3Client; -import org.jclouds.s3.blobstore.S3BlobStoreContext; +import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; +import org.jclouds.walrus.config.WalrusRestClientModule; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the Walrus S3 API * * @author Adrian Cole */ -public class WalrusApiMetadata extends S3ApiMetadata, WalrusApiMetadata> { +public class WalrusApiMetadata extends S3ApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 820062881469203616L; + private static Builder builder() { return new Builder(); } @@ -54,21 +59,21 @@ public class WalrusApiMetadata extends S3ApiMetadata, WalrusApiMetadata> { + public static class Builder extends S3ApiMetadata.Builder { protected Builder(){ super(S3Client.class, S3AsyncClient.class); id("walrus") .name("Walrus (S3 clone) API") .version("Walrus-1.6") .defaultProperties(WalrusApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(WalrusContextBuilder.class)); + .defaultModules(ImmutableSet.>of(WalrusRestClientModule.class, S3BlobStoreContextModule.class)); } @Override @@ -77,7 +82,7 @@ public class WalrusApiMetadata extends S3ApiMetadata, WalrusApiMetadata> { - public WalrusContextBuilder() { - this(new WalrusApiMetadata()); - } - - public WalrusContextBuilder( - ProviderMetadata, WalrusApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public WalrusContextBuilder(WalrusApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new WalrusRestClientModule()); - } -} diff --git a/apis/walrus/src/main/java/org/jclouds/walrus/config/WalrusRestClientModule.java b/apis/walrus/src/main/java/org/jclouds/walrus/config/WalrusRestClientModule.java index 3f1fc1784d..9cf9b5560a 100644 --- a/apis/walrus/src/main/java/org/jclouds/walrus/config/WalrusRestClientModule.java +++ b/apis/walrus/src/main/java/org/jclouds/walrus/config/WalrusRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.walrus.config; import javax.inject.Singleton; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3Client; @@ -34,7 +33,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class WalrusRestClientModule extends S3RestClientModule { public WalrusRestClientModule() { diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusClientLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusClientLiveTest.java index 57a35d2fb9..f939eeca1f 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusClientLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusClientLiveTest.java @@ -36,8 +36,7 @@ public class WalrusClientLiveTest extends S3ClientLiveTest { // path based, not virtual host @Override protected URL getObjectURL(String containerName, String key) throws Exception { - URL url = new URL(String.format(context.getProviderSpecificContext().getEndpoint().toASCIIString() - + "/services/Walrus/%s/%s", containerName, key)); + URL url = new URL(String.format(endpoint + "/services/Walrus/%s/%s", containerName, key)); return url; } diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj index 5e85f0ab2f..1bb2a87abb 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj @@ -44,9 +44,10 @@ See http://code.google.com/p/jclouds for details." (:use [org.jclouds.core]) (:import [java.io File FileOutputStream OutputStream] java.util.Properties + [org.jclouds ContextBuilder] [org.jclouds.blobstore AsyncBlobStore domain.BlobBuilder BlobStore BlobStoreContext - BlobStoreContextBuilder domain.BlobMetadata domain.StorageMetadata + domain.BlobMetadata domain.StorageMetadata domain.Blob domain.internal.BlobBuilderImpl options.PutOptions options.PutOptions$Builder options.CreateContainerOptions options.ListContainerOptions] @@ -112,12 +113,12 @@ Options can also be specified for extension modules (let [module-keys (set (keys module-lookup)) ext-modules (filter #(module-keys %) options) opts (apply hash-map (filter #(not (module-keys %)) options))] - (let [context (.. (BlobStoreContextBuilder/newBuilder provider) + (let [context (.. (ContextBuilder/newBuilder provider) (credentials provider-identity provider-credential) (modules (apply modules (concat ext-modules (opts :extensions)))) (overrides (reduce #(do (.put %1 (name (first %2)) (second %2)) %1) (Properties.) (dissoc opts :extensions))) - (build))] + (build BlobStoreContext))] (if (some #(= :async %) options) (.getAsyncBlobStore context) (.getBlobStore context))))) diff --git a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java index 1a7427e43d..cf2897988b 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java @@ -43,7 +43,7 @@ public interface AsyncBlobStore { /** * @see BlobStore#getContext */ - BlobStoreContext getContext(); + BlobStoreContext getContext(); /** * @see BlobStore#blobBuilder diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index 89a9b4359a..b9fa416c25 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -44,7 +44,7 @@ public interface BlobStore { /** * @return a reference to the context that created this BlobStore. */ - BlobStoreContext getContext(); + BlobStoreContext getContext(); /** * diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java deleted file mode 100644 index 77d55ce334..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jclouds.blobstore; - -import org.jclouds.apis.ApiMetadata; - -import com.google.common.annotations.Beta; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public interface BlobStoreApiMetadata, M extends BlobStoreApiMetadata> - extends ApiMetadata { - - public static interface Builder, M extends BlobStoreApiMetadata> - extends ApiMetadata.Builder { - } - -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java index 81f42afbe1..c30a7adb7d 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java @@ -20,10 +20,11 @@ package org.jclouds.blobstore; import java.io.Closeable; +import org.jclouds.Wrapper; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.options.ListContainerOptions; -import org.jclouds.rest.BackedByRestContext; +import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; import com.google.inject.ImplementedBy; @@ -36,7 +37,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(BlobStoreContextImpl.class) -public interface BlobStoreContext extends Closeable, BackedByRestContext { +public interface BlobStoreContext extends Closeable, Wrapper { /** * * Generates signed requests for blobs. useful in other tools such as backup utilities. @@ -115,6 +116,15 @@ public interface BlobStoreContext extends Closeable, BackedByRestContext RestContext getProviderSpecificContext(); + /** * closes threads and resources related to this connection. * diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java deleted file mode 100644 index e38fad5fa1..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.blobstore; -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.NoSuchElementException; - -import org.jclouds.blobstore.config.TransientBlobStore; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -/** - * @author Adrian Cole - */ -public abstract class BlobStoreContextBuilder, M extends BlobStoreApiMetadata> - extends ContextBuilder { - - /** - * looks up a provider or api with the given id - * - * @param providerOrApi - * id of the provider or api - * @return means to build a context to that provider - * @throws NoSuchElementException - * if the id was not configured. - * @throws IllegalArgumentException - * if the api or provider isn't assignable from BlobStoreContext - */ - public static BlobStoreContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { - ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); - checkArgument(builder instanceof BlobStoreContextBuilder, - "type of providerOrApi[%s] is not BlobStoreContextBuilder: %s", providerOrApi, builder); - return BlobStoreContextBuilder.class.cast(builder); - } - - public static ContextBuilder, TransientApiMetadata> forTests() { - return ContextBuilder.newBuilder(new TransientApiMetadata()); - } - - public BlobStoreContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public BlobStoreContextBuilder(M apiMetadata) { - super(apiMetadata); - } -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java index 9c32b49d99..f663d220bf 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java @@ -21,11 +21,11 @@ package org.jclouds.blobstore; import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -54,21 +54,21 @@ public class BlobStoreContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, String identity, String credential) { + public BlobStoreContext createContext(String providerOrApi, String identity, String credential) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** * @see #createContext(String, String, String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, Properties overrides) { + public BlobStoreContext createContext(String providerOrApi, Properties overrides) { return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** * @see #createContext(String, String,String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, Iterable wiring, + public BlobStoreContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { return createContext(providerOrApi, null, null, wiring, overrides); } @@ -76,7 +76,7 @@ public class BlobStoreContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Properties overrides) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); } @@ -84,7 +84,7 @@ public class BlobStoreContextFactory { /** * @see createContext(String, String,String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring) { return createContext(providerOrApi, identity, credential, wiring, new Properties()); } @@ -104,28 +104,20 @@ public class BlobStoreContextFactory { * properties to override defaults with. * @return initialized context ready for use */ - @SuppressWarnings("unchecked") - public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - ContextBuilder builder = null; + ContextBuilder builder = null; try { - ProviderMetadata pm = Providers.withId(providerOrApi); - builder = BlobStoreContextBuilder.newBuilder(pm); + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = ContextBuilder.newBuilder(pm); } catch (NoSuchElementException e) { builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } - builder.modules(Iterable.class.cast(wiring)); + builder.modules(wiring); builder.overrides(overrides); if (identity != null) builder.credentials(identity, credential); - Object context = builder.build(); - if (context instanceof BlobStoreContext) { - return BlobStoreContext.class.cast(context); - } else { - throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " - + context.getClass().getSimpleName()); - } - + return builder.build(BlobStoreContext.class); } } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java index fbd1465eb7..88f9fc1d07 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java @@ -18,26 +18,21 @@ */ package org.jclouds.blobstore; -import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; -import static org.jclouds.Constants.PROPERTY_USER_THREADS; - import java.net.URI; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.blobstore.config.TransientBlobStore; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; - -import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; +import org.jclouds.blobstore.config.TransientBlobStoreContextModule; /** * Implementation of {@link ApiMetadata} for jclouds in-memory (Transient) API * * @author Adrian Cole */ -public class TransientApiMetadata extends - BaseBlobStoreApiMetadata, TransientApiMetadata> { +public class TransientApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -6541485071006878726L; public static Builder builder() { return new Builder(); @@ -56,23 +51,19 @@ public class TransientApiMetadata extends super(builder); } - public static class Builder extends - BaseBlobStoreApiMetadata.Builder, TransientApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder() { id("transient") - .name("in-memory (Transient) API") - .javaApi(TransientBlobStore.class, AsyncBlobStore.class) - .contextBuilder(TypeToken.of(TransientBlobStoreContextBuilder.class)) - .identityName("Unused") - .defaultEndpoint("http://localhost") - .defaultIdentity(System.getProperty("user.name")) - .defaultCredential("bar") - .version("1") - .defaultProperties( - BaseBlobStoreApiMetadata.Builder.defaultPropertiesAnd(ImmutableMap.of(PROPERTY_USER_THREADS, "0", - PROPERTY_IO_WORKER_THREADS, "0"))) - .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")); + .name("in-memory (Transient) API") + .identityName("Unused") + .defaultEndpoint("http://localhost") + .defaultIdentity(System.getProperty("user.name")) + .defaultCredential("bar") + .version("1") + .wrapper(BlobStoreContext.class) + .defaultModule(TransientBlobStoreContextModule.class) + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")); } @Override diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java index 44fdce6afa..81ef2f5dfd 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java @@ -128,7 +128,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore { protected final Factory blobFactory; @Inject - protected TransientAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, DateService dateService, Crypto crypto, + protected TransientAsyncBlobStore(BlobStoreContext context, DateService dateService, Crypto crypto, ConcurrentMap> containerToBlobs, Provider uriBuilders, ConcurrentMap containerToLocation, HttpGetOptionsListToGetOptions httpGetOptionsConverter, diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java deleted file mode 100644 index e85910ecad..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.blobstore; - -import java.util.List; - -import org.jclouds.blobstore.config.TransientBlobStore; -import org.jclouds.blobstore.config.TransientBlobStoreContextModule; -import org.jclouds.blobstore.config.TransientBlobStoreModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -public class TransientBlobStoreContextBuilder extends - BlobStoreContextBuilder, TransientApiMetadata> { - - public TransientBlobStoreContextBuilder( - ProviderMetadata, TransientApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public TransientBlobStoreContextBuilder(TransientApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - public void addContextModule(List modules) { - modules.add(new TransientBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new TransientBlobStoreModule()); - } - -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java index 2381329687..32dcfca029 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java @@ -24,16 +24,15 @@ import java.util.concurrent.ConcurrentMap; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.TransientAsyncBlobStore; import org.jclouds.blobstore.TransientBlobRequestSigner; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.domain.Location; +import org.jclouds.rest.config.BinderUtils; +import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; /** @@ -47,12 +46,11 @@ public class TransientBlobStoreContextModule extends AbstractModule { static final ConcurrentHashMap> map = new ConcurrentHashMap>(); static final ConcurrentHashMap containerToLocation = new ConcurrentHashMap(); - @SuppressWarnings("rawtypes") @Override protected void configure() { - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); + bind(AsyncBlobStore.class).to(TransientAsyncBlobStore.class).asEagerSingleton(); + // forward all requests from TransientBlobStore to TransientAsyncBlobStore. needs above binding as cannot proxy a class + BinderUtils.bindClient(binder(), TransientBlobStore.class, AsyncBlobStore.class, ImmutableMap., Class>of()); bind(new TypeLiteral>>() { }).toInstance(map); bind(new TypeLiteral>() { diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreModule.java b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreModule.java deleted file mode 100644 index e9db97e6c4..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreModule.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.blobstore.config; - -import org.jclouds.blobstore.AsyncBlobStore; -import org.jclouds.blobstore.TransientAsyncBlobStore; -import org.jclouds.rest.config.RestClientModule; - -/** - * - * @author Adrian Cole - */ -public class TransientBlobStoreModule extends RestClientModule { - - public TransientBlobStoreModule() { - super(TransientBlobStore.class, AsyncBlobStore.class); - } - - @Override - protected void bindAsyncClient() { - bind(AsyncBlobStore.class).to(TransientAsyncBlobStore.class).asEagerSingleton(); - } - -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java index f698a7b6ca..ef1b3f455b 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java @@ -53,14 +53,14 @@ import com.google.common.util.concurrent.ListenableFuture; */ public abstract class BaseAsyncBlobStore implements AsyncBlobStore { - protected final BlobStoreContext context; + protected final BlobStoreContext context; protected final BlobUtils blobUtils; protected final ExecutorService service; protected final Supplier defaultLocation; protected final Supplier> locations; @Inject - protected BaseAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected BaseAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations) { this.context = checkNotNull(context, "context"); @@ -71,7 +71,7 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore { } @Override - public BlobStoreContext getContext() { + public BlobStoreContext getContext() { return context; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java index 8b2d980452..dc344cf454 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java @@ -47,13 +47,13 @@ import com.google.common.base.Supplier; */ public abstract class BaseBlobStore implements BlobStore { - protected final BlobStoreContext context; + protected final BlobStoreContext context; protected final BlobUtils blobUtils; protected final Supplier defaultLocation; protected final Supplier> locations; @Inject - protected BaseBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected BaseBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations) { this.context = checkNotNull(context, "context"); this.blobUtils = checkNotNull(blobUtils, "blobUtils"); @@ -62,7 +62,7 @@ public abstract class BaseBlobStore implements BlobStore { } @Override - public BlobStoreContext getContext() { + public BlobStoreContext getContext() { return context; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java deleted file mode 100644 index d89c1f0d8e..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.blobstore.internal; - -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.blobstore.BlobStoreApiMetadata; -import org.jclouds.blobstore.BlobStoreContext; - -import com.google.common.annotations.Beta; -import com.google.common.reflect.TypeParameter; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public abstract class BaseBlobStoreApiMetadata, M extends BlobStoreApiMetadata> - extends BaseApiMetadata implements BlobStoreApiMetadata { - - public static class Builder, M extends BlobStoreApiMetadata> - extends BaseApiMetadata.Builder implements BlobStoreApiMetadata.Builder { - public Builder() { - type(ApiType.BLOBSTORE); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); - } - - } - - - protected BaseBlobStoreApiMetadata(BaseBlobStoreApiMetadata.Builder builder) { - super(builder); - } - -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java index 6c8abad039..3a08168b26 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java @@ -20,6 +20,8 @@ package org.jclouds.blobstore.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.io.Closeable; + import javax.inject.Inject; import javax.inject.Singleton; @@ -31,31 +33,33 @@ import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.InputStreamMap; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; +import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class BlobStoreContextImpl implements BlobStoreContext { +public class BlobStoreContextImpl extends BaseWrapper implements BlobStoreContext { private final BlobMap.Factory blobMapFactory; private final InputStreamMap.Factory inputStreamMapFactory; private final AsyncBlobStore ablobStore; private final BlobStore blobStore; - private final RestContext providerSpecificContext; private final ConsistencyModel consistencyModel; private final Utils utils; private final BlobRequestSigner blobRequestSigner; - @SuppressWarnings("unchecked") @Inject - public BlobStoreContextImpl(BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, + public BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext, BlobRequestSigner blobRequestSigner) { - // unravel guice and avoid passing in a million type args by not injecting generic types for - // rest context - this.providerSpecificContext = checkNotNull(providerSpecificContext, "providerSpecificContext"); + BlobRequestSigner blobRequestSigner) { + super(wrapped, wrappedType); this.consistencyModel = checkNotNull(consistencyModel, "consistencyModel"); this.blobMapFactory = checkNotNull(blobMapFactory, "blobMapFactory"); this.inputStreamMapFactory = checkNotNull(inputStreamMapFactory, "inputStreamMapFactory"); @@ -100,16 +104,6 @@ public class BlobStoreContextImpl implements BlobStoreContext { return ablobStore; } - @Override - public RestContext getProviderSpecificContext() { - return providerSpecificContext; - } - - @Override - public void close() { - providerSpecificContext.close(); - } - @Override public Utils getUtils() { return utils(); @@ -121,22 +115,33 @@ public class BlobStoreContextImpl implements BlobStoreContext { } @Override + public BlobRequestSigner getSigner() { + return blobRequestSigner; + } + + @SuppressWarnings("unchecked") + @Override + public RestContext getProviderSpecificContext() { + return (RestContext) getWrapped(); + } + + @Override + public void close() { + Closeables.closeQuietly(getWrapped()); + } + public int hashCode() { - return providerSpecificContext.hashCode(); + return getWrapped().hashCode(); } @Override public String toString() { - return providerSpecificContext.toString(); + return getWrapped().toString(); } @Override public boolean equals(Object obj) { - return providerSpecificContext.equals(obj); + return getWrapped().equals(obj); } - @Override - public BlobRequestSigner getSigner() { - return blobRequestSigner; - } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java b/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java index 3422312966..41cf4c711d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.Set; import org.easymock.EasyMock; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.internal.PageSetImpl; @@ -47,7 +48,7 @@ public class BlobStoresTest { public void testListAllForUnknownContainerFromTransientBlobStoreEagerly() throws Exception { ListContainerOptions containerOptions = ListContainerOptions.NONE; ListAllOptions listAllOptions = ListAllOptions.Builder.eager(true); - BlobStoreContext context = blobStoreContext(); + BlobStoreContext context = blobStoreContext(); try { BlobStore blobStore = context.getBlobStore(); BlobStores.listAll(blobStore, "wrongcontainer", containerOptions, listAllOptions); @@ -62,7 +63,7 @@ public class BlobStoresTest { @Test(expectedExceptions = { ContainerNotFoundException.class }) public void testListAllForUnknownContainerFromTransientBlobStore() throws Exception { ListContainerOptions options = ListContainerOptions.NONE; - BlobStoreContext context = blobStoreContext(); + BlobStoreContext context = blobStoreContext(); try { BlobStore blobStore = context.getBlobStore(); Iterable iterable = BlobStores.listAll(blobStore, "wrongcontainer", options); @@ -72,8 +73,8 @@ public class BlobStoresTest { } } - protected BlobStoreContext blobStoreContext() { - return BlobStoreContextBuilder.forTests().build(); + protected BlobStoreContext blobStoreContext() { + return ContextBuilder.newBuilder("transient").build(BlobStoreContext.class); } @Test @@ -90,7 +91,7 @@ public class BlobStoresTest { final int numTimesToIterate = 2; final int NUM_BLOBS = 31; ListContainerOptions containerOptions = ListContainerOptions.Builder.maxResults(10); - BlobStoreContext context = blobStoreContext(); + BlobStoreContext context = blobStoreContext(); BlobStore blobStore = null; try { blobStore = context.getBlobStore(); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java b/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java index f3edf1a509..a1bb3f59c9 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java @@ -128,7 +128,7 @@ public class TransientBlobRequestSignerTest extends BaseAsyncClientTest createApiMetadata() { + public ApiMetadata createApiMetadata() { return new TransientApiMetadata(); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java index 4b0be65a8d..65a2f9c78e 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java @@ -28,7 +28,7 @@ import java.net.URI; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.MediaType; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.http.HttpRequest; @@ -47,7 +47,7 @@ public class BindBlobToMultipartFormTest { public static final Blob TEST_BLOB; static { - blobProvider = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class); + blobProvider = ContextBuilder.newBuilder("transient").buildInjector().getInstance(Blob.Factory.class); StringBuilder builder = new StringBuilder("--"); addData(BOUNDARY, "hello", builder); builder.append("--").append(BOUNDARY).append("--").append("\r\n"); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java index 5f5e4c798c..d01894630b 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java @@ -25,7 +25,7 @@ import java.net.URI; import javax.ws.rs.HttpMethod; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.http.HttpRequest; import org.testng.annotations.Test; @@ -47,7 +47,7 @@ public class BindUserMetadataToHeadersWithPrefixTest { BindUserMetadataToHeadersWithPrefix binder = new BindUserMetadataToHeadersWithPrefix( new BindMapToHeadersWithPrefix("prefix:")); - Blob blob = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class).create(null); + Blob blob = ContextBuilder.newBuilder("transient").buildInjector().getInstance(Blob.Factory.class).create(null); blob.getMetadata().setUserMetadata(ImmutableMap.of("imageName", "foo", "serverId", "2")); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java b/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java index 551ff1147d..dece50daa0 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java @@ -1,5 +1,5 @@ /** - * Licensed to jclouds, Inc. (jclouds) under one or more +s * Licensed to jclouds, Inc. (jclouds) under one or more * contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. jclouds licenses this file @@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals; import java.io.File; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.testng.annotations.Test; @@ -35,7 +35,7 @@ import org.testng.annotations.Test; public class BlobNameTest { BlobName fn = new BlobName(); - private static final Factory BLOB_FACTORY = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class); + private static final Factory BLOB_FACTORY = ContextBuilder.newBuilder("transient").buildInjector().getInstance(Blob.Factory.class); @Test public void testCorrect() throws SecurityException, NoSuchMethodException { diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java index e5667e2325..384c9121f5 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java @@ -266,12 +266,12 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< } @Override - protected BlobMap createMap(BlobStoreContext context, String bucket) { + protected BlobMap createMap(BlobStoreContext context, String bucket) { return createMap(context, bucket, maxResults(maxResultsForTestListings())); } @Override - protected BlobMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { + protected BlobMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { return context.createBlobMap(bucket, options); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java index c57d41ed55..2872c1db01 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java @@ -24,8 +24,8 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CancellationException; @@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.ws.rs.core.MediaType; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.domain.Blob; @@ -43,7 +44,6 @@ import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.testng.ITestContext; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -56,9 +56,10 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import com.google.common.reflect.TypeToken; import com.google.inject.Module; -public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest>{ +public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest { protected static final String LOCAL_ENCODING = System.getProperty("file.encoding"); protected static final String XML_STRING_FORMAT = " "; protected static final String TEST_STRING = String.format(XML_STRING_FORMAT, "apple"); @@ -123,7 +124,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context, ITestContext testContext) + protected void createContainersSharedByAllThreads(BlobStoreContext context, ITestContext testContext) throws Exception { while (!initialized) { synchronized (BaseBlobStoreIntegrationTest.class) { @@ -156,7 +157,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context, String containerName) { + private static void deleteContainerOrWarnIfUnable(BlobStoreContext context, String containerName) { try { context.getBlobStore().deleteContainer(containerName); } catch (Throwable ex) { @@ -171,7 +172,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context) throws Exception { + protected static void deleteEverything(final BlobStoreContext context) throws Exception { try { for (int i = 0; i < 2; i++) { Iterable testContainers = Iterables.filter(context.getBlobStore().list(), @@ -200,7 +201,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context, Runnable assertion) + protected static void assertConsistencyAware(BlobStoreContext context, Runnable assertion) throws InterruptedException { if (context.getConsistencyModel() == ConsistencyModel.STRICT) { assertion.run(); @@ -226,7 +227,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context, final String containerName) + protected static void createContainerAndEnsureEmpty(BlobStoreContext context, final String containerName) throws InterruptedException { context.getBlobStore().createContainerInLocation(null, containerName); if (context.getConsistencyModel() == ConsistencyModel.EVENTUAL) @@ -427,4 +428,9 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest contextType() { + return TypeToken.of(BlobStoreContext.class); + } + } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java index a92952c6e0..085b0d7fc9 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java @@ -330,11 +330,11 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati return 100; } - protected InputStreamMap createMap(BlobStoreContext context, String bucket) { + protected InputStreamMap createMap(BlobStoreContext context, String bucket) { return createMap(context, bucket, maxResults(maxResultsForTestListings())); } - protected InputStreamMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { + protected InputStreamMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { return context.createInputStreamMap(bucket, options); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java index 5d0e089ab1..6e59bd2a58 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java @@ -97,9 +97,9 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration } } - protected abstract Map createMap(BlobStoreContext context, String containerName); + protected abstract Map createMap(BlobStoreContext context, String containerName); - protected abstract Map createMap(BlobStoreContext context, String containerName, + protected abstract Map createMap(BlobStoreContext context, String containerName, ListContainerOptions options); @Test(groups = { "integration", "live" }) diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java index 12816e33d1..43a5abb102 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java @@ -79,7 +79,8 @@ public class BaseServiceIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }) public void testGetAssignableLocations() throws Exception { - assertProvider(context.getProviderSpecificContext()); + if (context.unwrap() instanceof Location) + assertProvider(Location.class.cast(context.unwrap())); for (Location location : context.getBlobStore().listAssignableLocations()) { System.err.printf("location %s%n", location); assert location.getId() != null : location; diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java index a109ea9317..baa5e6309c 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java @@ -22,8 +22,8 @@ import static org.testng.Assert.assertEquals; import java.util.Map; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -40,13 +40,13 @@ import com.google.inject.util.Types; @Test(groups = { "unit" }) public class BaseBlobMapTest { - BlobStoreContext context; + BlobStoreContext context; InputStreamMapImpl map; @BeforeClass void addDefaultObjectsSoThatTestsWillPass() { - context = BlobStoreContextBuilder.forTests().build(); + context = ContextBuilder.newBuilder("transient").build(BlobStoreContext.class); map = (InputStreamMapImpl) context.createInputStreamMap("test"); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java index 32a2303059..fcb31cdbe3 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java @@ -1,12 +1,26 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.blobstore.internal; -import java.util.Set; - +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.Apis; import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.jclouds.blobstore.BlobStoreApiMetadata; import org.jclouds.blobstore.BlobStoreContext; import org.testng.annotations.Test; @@ -20,15 +34,8 @@ import com.google.common.reflect.TypeToken; @Test(groups = "unit") public abstract class BaseBlobStoreApiMetadataTest extends BaseApiMetadataTest { - @SuppressWarnings("rawtypes") - public BaseBlobStoreApiMetadataTest(BlobStoreApiMetadata toTest) { - super(toTest, ApiType.BLOBSTORE); - } - - @Test - public void testContextAssignableFromBlobStoreContext() { - Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(BlobStoreContext.class))); - assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); - } + public BaseBlobStoreApiMetadataTest(ApiMetadata toTest) { + super(toTest, ImmutableSet.>of(TypeToken.of(BlobStoreContext.class))); + } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java b/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java index a95f01ca9c..32aa5fe42d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java @@ -22,8 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.options.ListContainerOptions; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -38,7 +39,7 @@ public class BiggerThanPageSizeTest { @BeforeTest void setupBlobStore() { - blobstore = BlobStoreContextBuilder.forTests().build().getBlobStore(); + blobstore = ContextBuilder.newBuilder("transient").build(BlobStoreContext.class).getBlobStore(); } public void test() throws IOException { diff --git a/common/aws/src/main/java/org/jclouds/aws/config/AWSRestClientModule.java b/common/aws/src/main/java/org/jclouds/aws/config/AWSRestClientModule.java index 42f5929b52..62772ab3d1 100644 --- a/common/aws/src/main/java/org/jclouds/aws/config/AWSRestClientModule.java +++ b/common/aws/src/main/java/org/jclouds/aws/config/AWSRestClientModule.java @@ -25,7 +25,6 @@ import org.jclouds.aws.handlers.AWSClientErrorRetryHandler; import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -38,7 +37,6 @@ import org.jclouds.rest.config.RestClientModule; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class AWSRestClientModule extends RestClientModule { public AWSRestClientModule(Class syncClientType, Class asyncClientType, Map, Class> delegates) { diff --git a/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java b/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java index 42c7d0bfe7..cda15e2d13 100644 --- a/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java +++ b/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java @@ -28,7 +28,6 @@ import org.jclouds.Constants; import org.jclouds.aws.filters.FormSigner; import org.jclouds.date.DateService; import org.jclouds.date.TimeStamp; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RequestSigner; @@ -39,7 +38,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class FormSigningRestClientModule extends AWSRestClientModule { public FormSigningRestClientModule(Class syncClientType, Class asyncClientType, diff --git a/common/aws/src/main/java/org/jclouds/aws/config/WithZonesFormSigningRestClientModule.java b/common/aws/src/main/java/org/jclouds/aws/config/WithZonesFormSigningRestClientModule.java index 0d2d8f21ad..de773344e6 100644 --- a/common/aws/src/main/java/org/jclouds/aws/config/WithZonesFormSigningRestClientModule.java +++ b/common/aws/src/main/java/org/jclouds/aws/config/WithZonesFormSigningRestClientModule.java @@ -21,7 +21,6 @@ package org.jclouds.aws.config; import java.util.Map; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; @@ -30,7 +29,6 @@ import org.jclouds.rest.ConfiguresRestClient; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class WithZonesFormSigningRestClientModule extends FormSigningRestClientModule { public WithZonesFormSigningRestClientModule(Class syncClientType, Class asyncClientType, diff --git a/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java b/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java index 7e25dfc498..9863c38399 100644 --- a/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java +++ b/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java @@ -46,9 +46,9 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Function; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMultimap.Builder; /** * Needed to sign and verify requests and responses. diff --git a/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java b/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java index 06ddfdebfd..76d3f8375a 100644 --- a/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java +++ b/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java @@ -24,6 +24,7 @@ import java.net.URI; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.ContextBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; @@ -33,7 +34,6 @@ import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.RequestSigner; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; -import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java b/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java deleted file mode 100644 index ef23a9a7d8..0000000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.azure.storage; - -import java.io.Closeable; -import java.util.List; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.azure.storage.config.AzureStorageRestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link AzureStorageStoreContext} or {@link Injector} instances based - * on the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see AzureStorageStoreContext - */ -public class AzureStorageContextBuilder> extends - ContextBuilder { - public AzureStorageContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public AzureStorageContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AzureStorageRestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi())); - } -} diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java b/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java index 1420f4c075..2a8ed8caf2 100644 --- a/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java +++ b/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java @@ -30,7 +30,6 @@ import org.jclouds.date.DateService; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -47,7 +46,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class AzureStorageRestClientModule extends RestClientModule { public AzureStorageRestClientModule(Class syncClientType, Class asyncClientType) { diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java b/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java index 9bdb901e71..a6c38634f9 100644 --- a/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java +++ b/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java @@ -49,8 +49,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; /** * Signs the Azure Storage request. diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java index 5e3b0e16c6..4f9c8b6d27 100644 --- a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java +++ b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java @@ -26,6 +26,7 @@ import java.net.URI; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.ContextBuilder; import org.jclouds.azure.storage.config.AzureStorageRestClientModule; import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; @@ -33,7 +34,6 @@ import org.jclouds.http.IntegrationTestClient; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; -import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java index f9f2ccb760..eca6fe8678 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java @@ -33,7 +33,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.date.TimeStamp; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.location.Provider; import org.jclouds.openstack.Authentication; @@ -58,7 +57,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -@RequiresHttp public class OpenStackAuthenticationModule extends AbstractModule { @Override diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java index 26545f9c30..ba16265d27 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java @@ -31,7 +31,6 @@ import javax.inject.Singleton; import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.RegionIdToURISupplier; @@ -56,7 +55,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -@RequiresHttp public class AuthenticationServiceModule extends AbstractModule { @Override diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java index 24eef509e6..4730cf4efd 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java @@ -31,7 +31,6 @@ import javax.inject.Singleton; import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.RegionIdToURISupplier; @@ -66,7 +65,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -@RequiresHttp public class KeystoneAuthenticationModule extends AbstractModule { private final Module locationModule; diff --git a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java index bcfcc5017f..7acee18f31 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java @@ -72,7 +72,7 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + public ApiMetadata createApiMetadata() { return AnonymousRestApiMetadata.forClientMappedToAsyncClient(IntegrationTestClient.class, IntegrationTestAsyncClient.class).toBuilder().defaultEndpoint( "http://localhost:8080").version("1.0").build(); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java deleted file mode 100644 index 2876428613..0000000000 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.trmk.vcloud_0_8; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.trmk.vcloud_0_8.compute.config.TerremarkVCloudComputeServiceContextModule; -import org.jclouds.trmk.vcloud_0_8.config.TerremarkVCloudRestClientModule; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link VCloudComputeServiceContext} or {@link Injector} instances - * based on the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see VCloudComputeServiceContext - */ -public class TerremarkVCloudContextBuilder, M extends ComputeServiceApiMetadata> - extends ComputeServiceContextBuilder { - - public TerremarkVCloudContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public TerremarkVCloudContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new TerremarkVCloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new TerremarkVCloudRestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi())); - } -} diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudPropertiesBuilder.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudPropertiesBuilder.java deleted file mode 100644 index c294ec643b..0000000000 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudPropertiesBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.trmk.vcloud_0_8; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Terremark VCloud Clients - * - * @author Adrian Cole - */ -public class TerremarkVCloudPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "0.8"); - properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8"); - properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + ""); - properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, "allowInOut"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NS, String.format("urn:tmrk:${%s}-${%s}", - PROPERTY_TERREMARK_EXTENSION_NAME, PROPERTY_TERREMARK_EXTENSION_VERSION)); - properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, - String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA)); - properties.setProperty("jclouds.dns_name_length_min", "1"); - properties.setProperty("jclouds.dns_name_length_max", "15"); - // terremark can sometimes block extremely long times - properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, TimeUnit.MINUTES.toMillis(20) + ""); - - return properties; - } - - public TerremarkVCloudPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayload.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayload.java index 8c26cf4888..5d7de94ad2 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayload.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayload.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; -import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; @@ -42,6 +41,7 @@ import org.jclouds.cim.ResourceAllocationSettingData; import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.http.HttpRequest; import org.jclouds.rest.MapBinder; +import org.jclouds.rest.annotations.ApiVersion; import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.domain.Status; @@ -68,7 +68,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java index 5d13535e30..4788da82b6 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -25,17 +25,13 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.jclouds.trmk.vcloud_0_8.compute.TerremarkVCloudComputeService; import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName; import org.jclouds.trmk.vcloud_0_8.compute.functions.ImagesInVCloudExpressOrg; @@ -53,7 +49,6 @@ import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.inject.Provides; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; /** @@ -77,7 +72,6 @@ public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServi return VAPPSTATUS_TO_NODESTATE; } - @SuppressWarnings("rawtypes") @Override protected void configure() { super.configure(); @@ -92,9 +86,6 @@ public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServi install(new TerremarkBindComputeStrategiesByClass()); install(new TerremarkBindComputeSuppliersByClass()); bindVAppConverter(); - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(new TypeLiteral>>() { }).to(new TypeLiteral() { }); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java index 0d48d18910..393690996f 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java @@ -33,8 +33,8 @@ import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCL import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Map.Entry; import java.util.SortedMap; +import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; @@ -52,7 +52,6 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.jclouds.trmk.vcloud_0_8.VCloudToken; import org.jclouds.trmk.vcloud_0_8.compute.functions.FindLocationForResource; @@ -88,15 +87,14 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Injector; import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; -public class TerremarkVCloudRestClientModule - extends RestClientModule { +public class TerremarkVCloudRestClientModule extends RestClientModule { public TerremarkVCloudRestClientModule(Class syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java index 713450b93e..cf132779ed 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java @@ -15,36 +15,24 @@ import java.util.concurrent.TimeUnit; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** - * Implementation of {@link ApiMetadata} for Amazon's TerremarkVCloud api. - * - *

    note

    - *

    - * This class allows overriding of types {@code S}(client) and {@code A} - * (asyncClient), so that children can add additional methods not declared here, - * such as new features from AWS. - *

    - * - * As this is a popular api, we also allow overrides for type {@code C} - * (context). This allows subtypes to add in new feature groups or extensions, - * not present in the base api. For example, you could make a subtype for - * context, that exposes admin operations. - * + * Implementation of {@link ApiMetadata} for Terremark's VCloud api. + * @author Adrian Cole */ -public abstract class TerremarkVCloudApiMetadata> - extends BaseComputeServiceApiMetadata, M> { +public abstract class TerremarkVCloudApiMetadata extends BaseRestApiMetadata { - protected TerremarkVCloudApiMetadata(Builder builder) { + /** The serialVersionUID */ + private static final long serialVersionUID = 866164758867358381L; + + protected TerremarkVCloudApiMetadata(Builder builder) { super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8"); properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + ""); properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); @@ -60,20 +48,19 @@ public abstract class TerremarkVCloudApiMetadata> - extends BaseComputeServiceApiMetadata.Builder, M> { + public static abstract class Builder extends BaseRestApiMetadata.Builder { - protected Builder(Class syncClient, Class asyncClient) { - id("vcloud-common") - .identityName("Email") + protected Builder(Class syncClient, Class asyncClient) { + super(syncClient, asyncClient); + identityName("Email") .credentialName("Password") .version("0.8") .defaultProperties(TerremarkVCloudApiMetadata.defaultProperties()) - .javaApi(syncClient, asyncClient); + .wrapper(ComputeServiceContext.class); } @Override - public Builder fromApiMetadata(M in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java index b25256d6f3..c193253b2b 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java @@ -32,9 +32,9 @@ import java.io.IOException; import java.net.URI; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -42,7 +42,6 @@ import java.util.concurrent.TimeoutException; import org.jclouds.cim.CIMPredicates; import org.jclouds.cim.ResourceAllocationSettingData; import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; @@ -50,8 +49,8 @@ import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.RestContext; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.SshException; +import org.jclouds.ssh.SshClient.Factory; import org.jclouds.trmk.vcloud_0_8.domain.Catalog; import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem; import org.jclouds.trmk.vcloud_0_8.domain.CustomizationParameters; @@ -84,8 +83,7 @@ import com.google.common.collect.Lists; import com.google.inject.Injector; @Test(groups = "live", singleThreaded = true) -public abstract class TerremarkClientLiveTest - extends BaseComputeServiceContextLiveTest> { +public abstract class TerremarkClientLiveTest extends BaseComputeServiceContextLiveTest { protected String expectedOs = "Ubuntu Linux (64-bit)"; protected String itemName = "Ubuntu JeOS 9.10 (64-bit)"; @@ -103,6 +101,7 @@ public abstract class TerremarkClientLiveTest(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS); - connection = context.getProviderSpecificContext().getApi(); + connection = (S) RestContext.class.cast(context.unwrap()).getApi(); orgs = listOrgs(); } - protected S connection; @Test public void testOrg() throws Exception { @@ -517,7 +516,7 @@ public abstract class TerremarkClientLiveTest -extends BaseComputeServiceContextLiveTest> { +public class VAppTemplatesInOrgsLiveTest +extends BaseComputeServiceContextLiveTest { public VAppTemplatesInOrgsLiveTest() { provider = "trmk-vcloudexpress"; diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java index f8e90f1d2c..453b394d0e 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java @@ -21,11 +21,11 @@ package org.jclouds.trmk.vcloud_0_8.internal; import java.util.concurrent.TimeUnit; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.rest.RestContext; import org.jclouds.ssh.SshClient.Factory; import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; @@ -41,9 +41,8 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseTerremarkClientLiveTest - extends BaseComputeServiceContextLiveTest> { - +public abstract class BaseTerremarkClientLiveTest extends BaseComputeServiceContextLiveTest { + protected String prefix = System.getProperty("user.name"); protected ComputeService client; @@ -54,11 +53,9 @@ public abstract class BaseTerremarkClientLiveTest socketTester; protected Factory sshFactory; + protected S connection; - protected S getApi() { - return context.getProviderSpecificContext().getApi(); - } - + @SuppressWarnings("unchecked") @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { @@ -66,6 +63,7 @@ public abstract class BaseTerremarkClientLiveTest(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS); sshFactory = injector.getInstance(Factory.class); + connection = (S) RestContext.class.cast(context.unwrap()).getApi(); } protected Module getSshModule() { diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java index f63b0a87e1..0f05666743 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java @@ -99,7 +99,7 @@ public class TerremarkVCloudLoginAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(TerremarkVCloudLoginClient.class, TerremarkVCloudLoginAsyncClient.class, "http://localhost:8080/login"); } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java index a1ef333f32..7830e6cee1 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java @@ -70,7 +70,7 @@ public class TerremarkVCloudVersionsAsyncClientTest extends BaseAsyncClientTest< } @Override - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(TerremarkVCloudVersionsClient.class, TerremarkVCloudVersionsAsyncClient.class, "http://localhost:8080"); } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogItemHandlerTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogItemHandlerTest.java index 1a4e1631ee..7fb74cf3be 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogItemHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogItemHandlerTest.java @@ -18,20 +18,18 @@ */ package org.jclouds.trmk.vcloud_0_8.xml; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; -import java.util.Properties; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem; import org.jclouds.trmk.vcloud_0_8.domain.internal.CatalogItemImpl; import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl; +import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -55,9 +53,7 @@ public class CatalogItemHandlerTest extends BaseHandlerTest { @Override public void configure() { super.configure(); - Properties props = new Properties(); - Names.bindProperties(binder(), - checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + Names.bindProperties(binder(), TerremarkVCloudApiMetadata.defaultProperties()); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/OrgHandlerTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/OrgHandlerTest.java index 58f95b8772..29a9b4779c 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/OrgHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/OrgHandlerTest.java @@ -18,22 +18,20 @@ */ package org.jclouds.trmk.vcloud_0_8.xml; -import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType.CATALOG_XML; import static org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType.TASKSLIST_XML; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; -import java.util.Properties; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; import org.jclouds.trmk.vcloud_0_8.domain.Org; import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl; +import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -56,9 +54,7 @@ public class OrgHandlerTest extends BaseHandlerTest { @Override public void configure() { super.configure(); - Properties props = new Properties(); - Names.bindProperties(binder(), checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), - "properties")); + Names.bindProperties(binder(), TerremarkVCloudApiMetadata.defaultProperties()); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/compute/src/main/clojure/org/jclouds/compute2.clj b/compute/src/main/clojure/org/jclouds/compute2.clj index a54023c97a..35169afb6a 100644 --- a/compute/src/main/clojure/org/jclouds/compute2.clj +++ b/compute/src/main/clojure/org/jclouds/compute2.clj @@ -64,9 +64,10 @@ Here's an example of creating and running a small linux node in the group webser (org.jclouds predicate) [clojure.core.incubator :only (-?>)]) (:import java.io.File java.util.Properties + [org.jclouds ContextBuilder] [org.jclouds.domain Location] [org.jclouds.compute - ComputeService ComputeServiceContext ComputeServiceContextBuilder] + ComputeService ComputeServiceContext] [org.jclouds.compute.domain Template TemplateBuilder ComputeMetadata NodeMetadata Hardware OsFamily Image] @@ -84,12 +85,12 @@ Here's an example of creating and running a small linux node in the group webser (let [module-keys (set (keys module-lookup)) ext-modules (filter #(module-keys %) options) opts (apply hash-map (filter #(not (module-keys %)) options))] - (.. (ComputeServiceContextBuilder/newBuilder provider) + (.. (ContextBuilder/newBuilder provider) (credentials provider-identity provider-credential) (modules (apply modules (concat ext-modules (opts :extensions)))) (overrides (reduce #(do (.put %1 (name (first %2)) (second %2)) %1) (Properties.) (dissoc opts :extensions))) - (build) + (build ComputeServiceContext) (getComputeService)))) ([#^ComputeServiceContext compute-context] (.getComputeService compute-context))) diff --git a/compute/src/main/java/org/jclouds/compute/ComputeService.java b/compute/src/main/java/org/jclouds/compute/ComputeService.java index 1fd310b619..701f8f3102 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeService.java @@ -54,7 +54,7 @@ public interface ComputeService { /** * @return a reference to the context that created this ComputeService. */ - ComputeServiceContext getContext(); + ComputeServiceContext getContext(); /** * Makes a new template builder for this service diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java deleted file mode 100644 index f3927be7f6..0000000000 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.compute; - -import org.jclouds.apis.ApiMetadata; - -import com.google.common.annotations.Beta; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public interface ComputeServiceApiMetadata, M extends ComputeServiceApiMetadata> - extends ApiMetadata { - - public static interface Builder, M extends ComputeServiceApiMetadata> - extends ApiMetadata.Builder { - } - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java index e89f428708..1d0b93fd5e 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java @@ -21,9 +21,10 @@ package org.jclouds.compute; import java.io.Closeable; import java.util.Map; +import org.jclouds.Wrapper; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.domain.Credentials; -import org.jclouds.rest.BackedByRestContext; +import org.jclouds.rest.RestContext; import com.google.common.annotations.Beta; import com.google.inject.ImplementedBy; @@ -36,7 +37,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(ComputeServiceContextImpl.class) -public interface ComputeServiceContext extends Closeable, BackedByRestContext { +public interface ComputeServiceContext extends Closeable, Wrapper { ComputeService getComputeService(); @@ -71,6 +72,15 @@ public interface ComputeServiceContext extends Closeable, BackedByRestCont * @see #getUtils */ Utils utils(); + + /** + * will be removed in jclouds 1.6 + * + * @see Wrapper#getInputType + * @see Wrapper#unwrap + */ + @Deprecated + RestContext getProviderSpecificContext(); @Override void close(); diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java deleted file mode 100644 index 5a1c302eac..0000000000 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.compute; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.NoSuchElementException; -import java.util.concurrent.ConcurrentMap; - -import org.jclouds.compute.config.ResolvesImages; -import org.jclouds.compute.stub.StubApiMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -public abstract class ComputeServiceContextBuilder, M extends ComputeServiceApiMetadata> extends - ContextBuilder { - - /** - * looks up a provider or api with the given id - * - * @param providerOrApi - * id of the provider or api - * @return means to build a context to that provider - * @throws NoSuchElementException - * if the id was not configured. - * @throws IllegalArgumentException - * if the api or provider isn't assignable from ComputeServiceContext - */ - public static ComputeServiceContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { - ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); - checkArgument(builder instanceof ComputeServiceContextBuilder, - "type of providerOrApi[%s] is not ComputeServiceContextBuilder: %s", providerOrApi, builder); - return ComputeServiceContextBuilder.class.cast(builder); - } - - @SuppressWarnings("rawtypes") - public static ContextBuilder, StubApiMetadata> forTests() { - return ContextBuilder.newBuilder(new StubApiMetadata()); - } - - public ComputeServiceContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public ComputeServiceContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - protected void addImageResolutionModule() { - // do nothing; - // this is to be overridden when needed - } - - @Override - public Injector buildInjector() { - addImageResolutionModuleIfNotPresent(); - return super.buildInjector(); - } - - protected void addImageResolutionModuleIfNotPresent() { - if (!Iterables.any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ResolvesImages.class); - } - - })) { - addImageResolutionModule(); - } - } - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java index 0aaa4f3b06..30b697a25d 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java @@ -21,11 +21,11 @@ package org.jclouds.compute; import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -54,21 +54,21 @@ public class ComputeServiceContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, String identity, String credential) { + public ComputeServiceContext createContext(String providerOrApi, String identity, String credential) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** * @see #createContext(String, String, String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, Properties overrides) { + public ComputeServiceContext createContext(String providerOrApi, Properties overrides) { return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** * @see #createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, Iterable wiring, + public ComputeServiceContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { return createContext(providerOrApi, null, null, wiring, overrides); } @@ -76,7 +76,7 @@ public class ComputeServiceContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Properties overrides) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); } @@ -84,7 +84,7 @@ public class ComputeServiceContextFactory { /** * @see createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring) { return createContext(providerOrApi, identity, credential, wiring, new Properties()); } @@ -104,28 +104,20 @@ public class ComputeServiceContextFactory { * properties to override defaults with. * @return initialized context ready for use */ - @SuppressWarnings("unchecked") - public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - ContextBuilder builder = null; + ContextBuilder builder = null; try { - ProviderMetadata pm = Providers.withId(providerOrApi); - builder = ComputeServiceContextBuilder.newBuilder(pm); + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = ContextBuilder.newBuilder(pm); } catch (NoSuchElementException e) { builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } - builder.modules(Iterable.class.cast(wiring)); + builder.modules(wiring); builder.overrides(overrides); if (identity != null) builder.credentials(identity, credential); - Object context = builder.build(); - if (context instanceof ComputeServiceContext) { - return ComputeServiceContext.class.cast(context); - } else { - throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " - + context.getClass().getSimpleName()); - } - + return builder.build(ComputeServiceContext.class); } } diff --git a/compute/src/main/java/org/jclouds/compute/RunScriptData.java b/compute/src/main/java/org/jclouds/compute/RunScriptData.java index c678d6b851..c2ecdedfc1 100644 --- a/compute/src/main/java/org/jclouds/compute/RunScriptData.java +++ b/compute/src/main/java/org/jclouds/compute/RunScriptData.java @@ -36,8 +36,8 @@ import org.jclouds.scriptbuilder.statements.login.AdminAccess; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableList.Builder; /** * diff --git a/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java deleted file mode 100644 index 218c2d876b..0000000000 --- a/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.compute; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceApiMetadata; -import org.jclouds.compute.config.StandaloneComputeServiceClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class StandaloneComputeServiceContextBuilder, M extends ComputeServiceApiMetadata> - extends ComputeServiceContextBuilder { - - public StandaloneComputeServiceContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public StandaloneComputeServiceContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new StandaloneComputeServiceClientModule(providerMetadata.getApiMetadata() - .getApi())); - } - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java index f478be5af8..212ab43b6f 100644 --- a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java @@ -22,7 +22,6 @@ import static com.google.common.base.Functions.compose; import static com.google.common.base.Predicates.notNull; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.transform; -import static com.google.inject.util.Types.newParameterizedType; import java.util.Set; @@ -31,11 +30,9 @@ import javax.inject.Singleton; import org.jclouds.collect.TransformingSetSupplier; import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; @@ -54,33 +51,13 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * * @author Adrian Cole */ -public class ComputeServiceAdapterContextModule extends BaseComputeServiceContextModule { +public class ComputeServiceAdapterContextModule extends BaseComputeServiceContextModule { - private Class asyncClientType; - private Class syncClientType; - - public ComputeServiceAdapterContextModule(Class syncClientType, Class asyncClientType) { - this.syncClientType = syncClientType; - this.asyncClientType = asyncClientType; - } - - @SuppressWarnings( { "unchecked", "rawtypes" }) - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral() { - }).to( - (TypeLiteral) TypeLiteral.get(newParameterizedType(ComputeServiceContextImpl.class, syncClientType, - asyncClientType))).in(Scopes.SINGLETON); - } - /** * install this, if you want to use your computeservice adapter to handle locations. Note that if * you do this, you'll want to instantiate a subclass to prevent type erasure. diff --git a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java index aa49e72ea9..311a651175 100644 --- a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java @@ -29,8 +29,8 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.predicates.AtomicNodeRunning; import org.jclouds.compute.predicates.AtomicNodeSuspended; import org.jclouds.compute.predicates.ScriptStatusReturnsZero; -import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient; import org.jclouds.compute.predicates.TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse; +import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient; import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; import org.jclouds.predicates.RetryablePredicate; diff --git a/compute/src/main/java/org/jclouds/compute/config/JCloudsNativeComputeServiceAdapterContextModule.java b/compute/src/main/java/org/jclouds/compute/config/JCloudsNativeComputeServiceAdapterContextModule.java index fce4c42be7..1dd4c5937d 100644 --- a/compute/src/main/java/org/jclouds/compute/config/JCloudsNativeComputeServiceAdapterContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/JCloudsNativeComputeServiceAdapterContextModule.java @@ -33,13 +33,12 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class JCloudsNativeComputeServiceAdapterContextModule extends - ComputeServiceAdapterContextModule { +public class JCloudsNativeComputeServiceAdapterContextModule extends + ComputeServiceAdapterContextModule { protected final Class> adapter; - public JCloudsNativeComputeServiceAdapterContextModule(Class syncClientType, Class asyncClientType, - Class> adapter) { - super(syncClientType, asyncClientType); + public JCloudsNativeComputeServiceAdapterContextModule( + Class> adapter) { this.adapter = adapter; } diff --git a/compute/src/main/java/org/jclouds/compute/config/StandaloneComputeServiceClientModule.java b/compute/src/main/java/org/jclouds/compute/config/StandaloneComputeServiceClientModule.java deleted file mode 100644 index bcc424b1da..0000000000 --- a/compute/src/main/java/org/jclouds/compute/config/StandaloneComputeServiceClientModule.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.compute.config; - -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -@ConfiguresRestClient -@RequiresHttp -public class StandaloneComputeServiceClientModule extends RestClientModule { - - public StandaloneComputeServiceClientModule(Class clazz) { - super(clazz, clazz); - } - - @Override - protected void bindAsyncClient() { - } - - @Override - protected void bindClient() { - - } -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index 72fd556769..bd4496b219 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -110,7 +110,7 @@ public class BaseComputeService implements ComputeService { @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - protected final ComputeServiceContext context; + protected final ComputeServiceContext context; protected final Map credentialStore; private final Supplier> images; @@ -136,7 +136,7 @@ public class BaseComputeService implements ComputeService { private final ExecutorService executor; @Inject - protected BaseComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected BaseComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, @@ -178,7 +178,7 @@ public class BaseComputeService implements ComputeService { * {@inheritDoc} */ @Override - public ComputeServiceContext getContext() { + public ComputeServiceContext getContext() { return context; } diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java deleted file mode 100644 index c5d828eac0..0000000000 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.compute.internal; - -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.compute.ComputeServiceApiMetadata; -import org.jclouds.compute.ComputeServiceContext; - -import com.google.common.annotations.Beta; -import com.google.common.reflect.TypeParameter; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public abstract class BaseComputeServiceApiMetadata, M extends ComputeServiceApiMetadata> - extends BaseApiMetadata implements ComputeServiceApiMetadata { - - public static class Builder, M extends ComputeServiceApiMetadata> - extends BaseApiMetadata.Builder implements ComputeServiceApiMetadata.Builder { - public Builder() { - type(ApiType.COMPUTE); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); - } - } - - protected BaseComputeServiceApiMetadata(BaseComputeServiceApiMetadata.Builder builder) { - super(builder); - } - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java index b880525b78..dfcfdfdb8f 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java @@ -20,6 +20,7 @@ package org.jclouds.compute.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.io.Closeable; import java.util.Map; import javax.inject.Inject; @@ -29,25 +30,28 @@ import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.Utils; import org.jclouds.domain.Credentials; +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; +import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class ComputeServiceContextImpl implements ComputeServiceContext { +public class ComputeServiceContextImpl extends BaseWrapper implements ComputeServiceContext { private final ComputeService computeService; - private final RestContext providerSpecificContext; private final Utils utils; private final Map credentialStore; - @SuppressWarnings( { "unchecked" }) @Inject - public ComputeServiceContextImpl(ComputeService computeService, Map credentialStore, - Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { + public ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + ComputeService computeService, Map credentialStore, Utils utils) { + super(wrapped, wrappedType); this.credentialStore = credentialStore; this.utils = utils; - this.providerSpecificContext = providerSpecificContext; this.computeService = checkNotNull(computeService, "computeService"); } @@ -55,16 +59,6 @@ public class ComputeServiceContextImpl implements ComputeServiceContext getProviderSpecificContext() { - return (RestContext) providerSpecificContext; - } - - @Override - public void close() { - providerSpecificContext.close(); - } - @Override public Utils getUtils() { return utils(); @@ -75,20 +69,6 @@ public class ComputeServiceContextImpl implements ComputeServiceContext getCredentialStore() { return credentialStore; @@ -98,4 +78,30 @@ public class ComputeServiceContextImpl implements ComputeServiceContext credentialStore() { return credentialStore; } + + @SuppressWarnings("unchecked") + @Override + public RestContext getProviderSpecificContext() { + return (RestContext) getWrapped(); + } + + @Override + public void close() { + Closeables.closeQuietly(getWrapped()); + } + + public int hashCode() { + return getWrapped().hashCode(); + } + + @Override + public String toString() { + return getWrapped().toString(); + } + + @Override + public boolean equals(Object obj) { + return getWrapped().equals(obj); + } + } diff --git a/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java b/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java index 4057142a93..534b8b7c4f 100644 --- a/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java +++ b/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java @@ -26,8 +26,8 @@ import org.jclouds.domain.LoginCredentials; import org.jclouds.javax.annotation.Nullable; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; /** * Enables additional options for running a script. diff --git a/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java b/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java index c8c299c620..c08c89ab6f 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java +++ b/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java @@ -19,22 +19,22 @@ package org.jclouds.compute.stub; import java.net.URI; -import java.util.concurrent.ConcurrentMap; import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; -import org.jclouds.compute.stub.internal.StubComputeServiceContextBuilder; - -import com.google.common.reflect.TypeToken; +import org.jclouds.compute.stub.config.StubComputeServiceContextModule; /** * Implementation of {@link ApiMetadata} for jclouds in-memory (Stub) API * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") -public class StubApiMetadata extends BaseComputeServiceApiMetadata, StubApiMetadata> { +public class StubApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -4880642520937391337L; + public static Builder builder() { return new Builder(); } @@ -52,7 +52,7 @@ public class StubApiMetadata extends BaseComputeServiceApiMetadata, StubApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder(){ id("stub") @@ -61,12 +61,9 @@ public class StubApiMetadata extends BaseComputeServiceApiMetadata>(getClass()){ - private static final long serialVersionUID = 1L; - }) - .javaApi(ConcurrentMap.class, ConcurrentMap.class) .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute")) - .contextBuilder(TypeToken.of(StubComputeServiceContextBuilder.class)); + .wrapper(ComputeServiceContext.class) + .defaultModule(StubComputeServiceContextModule.class); } @Override diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java index 0bb2a81782..0200b4474e 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java @@ -19,8 +19,8 @@ package org.jclouds.compute.stub.config; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutorService; @@ -48,8 +48,8 @@ import org.jclouds.rest.ResourceNotFoundException; import com.google.common.base.Supplier; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList.Builder; /** * diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java index 50e80faefc..dec1c7f0ad 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java @@ -18,33 +18,18 @@ */ package org.jclouds.compute.stub.config; -import java.util.concurrent.ConcurrentMap; - -import javax.inject.Singleton; - import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.concurrent.SingleThreaded; -import com.google.inject.Provides; - /** * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @SingleThreaded -public class StubComputeServiceContextModule extends - JCloudsNativeComputeServiceAdapterContextModule { +public class StubComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule { public StubComputeServiceContextModule() { - super(ConcurrentMap.class, ConcurrentMap.class, StubComputeServiceAdapter.class); - } - - @Provides - @Singleton - ConcurrentMap provideApi(ConcurrentMap in) { - return in; + super(StubComputeServiceAdapter.class); } @Override diff --git a/compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java deleted file mode 100644 index 843939dcb8..0000000000 --- a/compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.compute.stub.internal; - -import java.util.List; -import java.util.concurrent.ConcurrentMap; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.StandaloneComputeServiceContextBuilder; -import org.jclouds.compute.stub.StubApiMetadata; -import org.jclouds.compute.stub.config.StubComputeServiceContextModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -@SuppressWarnings("rawtypes") -public class StubComputeServiceContextBuilder extends - StandaloneComputeServiceContextBuilder, StubApiMetadata> { - - public StubComputeServiceContextBuilder( - ProviderMetadata, StubApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public StubComputeServiceContextBuilder(StubApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new StubComputeServiceContextModule()); - } - -} diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java index a5f0ab0035..34e73036a0 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java @@ -30,8 +30,8 @@ import static org.jclouds.scriptbuilder.domain.Statements.pipeHttpResponseToBash import java.net.URI; import java.util.Formatter; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; +import java.util.Map.Entry; import java.util.regex.Pattern; import org.jclouds.compute.ComputeServiceContext; diff --git a/compute/src/main/java/org/jclouds/ovf/xml/EnvelopeHandler.java b/compute/src/main/java/org/jclouds/ovf/xml/EnvelopeHandler.java index 5a05f4bc30..b415224d16 100644 --- a/compute/src/main/java/org/jclouds/ovf/xml/EnvelopeHandler.java +++ b/compute/src/main/java/org/jclouds/ovf/xml/EnvelopeHandler.java @@ -22,8 +22,8 @@ import javax.inject.Inject; import javax.inject.Provider; import org.jclouds.ovf.Envelope; -import org.jclouds.ovf.Envelope.Builder; import org.jclouds.ovf.VirtualSystem; +import org.jclouds.ovf.Envelope.Builder; import org.jclouds.ovf.xml.internal.BaseEnvelopeHandler; /** diff --git a/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java b/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java index 5417fab19e..d693593ee9 100644 --- a/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java +++ b/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java @@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index 340817a75f..de65693865 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.Serializable; import java.util.Map; import java.util.Set; -import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -63,10 +62,8 @@ import com.google.inject.Module; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "live", testName="StubComputeServiceIntegrationTest") -public class StubComputeServiceIntegrationTest extends - BaseComputeServiceLiveTest> { +public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTest { private static final ExecResponse EXEC_GOOD = new ExecResponse("", "", 0); private static final ExecResponse EXEC_BAD = new ExecResponse("", "", 1); diff --git a/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java index 50955a05cf..8ffffecf35 100644 --- a/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java @@ -19,7 +19,6 @@ package org.jclouds.compute; import java.util.Set; -import java.util.concurrent.ConcurrentMap; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.testng.annotations.Test; @@ -31,10 +30,8 @@ import com.google.common.collect.ImmutableSet; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = { "integration", "live" }) -public class StubTemplateBuilderIntegrationTest extends - BaseTemplateBuilderLiveTest> { +public class StubTemplateBuilderIntegrationTest extends BaseTemplateBuilderLiveTest { public StubTemplateBuilderIntegrationTest() { provider = "stub"; @@ -44,5 +41,5 @@ public class StubTemplateBuilderIntegrationTest extends protected Set getIso3166Codes() { return ImmutableSet. of(); } - + } \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java b/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java index 206d6d574c..573d333351 100644 --- a/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java +++ b/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java @@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.compute.reference.ComputeServiceConstants.InitStatusProperties; import org.testng.annotations.Test; @@ -33,7 +33,7 @@ import org.testng.annotations.Test; @Test(groups = "unit", testName = "ComputeServicePropertiesTest") public class ComputeServicePropertiesTest { public void testDefaultInitStatusProperties() { - InitStatusProperties props = ComputeServiceContextBuilder.forTests().buildInjector() + InitStatusProperties props = ContextBuilder.newBuilder("stub").buildInjector() .getInstance(InitStatusProperties.class); assertEquals(props.initStatusInitialPeriod, 500); assertEquals(props.initStatusMaxPeriod, 5000); @@ -44,7 +44,7 @@ public class ComputeServicePropertiesTest { overrides.setProperty(ComputeServiceProperties.INIT_STATUS_INITIAL_PERIOD, "501"); overrides.setProperty(ComputeServiceProperties.INIT_STATUS_MAX_PERIOD, "5001"); - InitStatusProperties props = ComputeServiceContextBuilder.forTests().overrides(overrides).buildInjector() + InitStatusProperties props = ContextBuilder.newBuilder("stub").overrides(overrides).buildInjector() .getInstance(InitStatusProperties.class); assertEquals(props.initStatusInitialPeriod, 501); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java index acbe40a87f..2079f0ef67 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java @@ -1,12 +1,8 @@ package org.jclouds.compute.internal; -import java.util.Set; - +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.Apis; import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.jclouds.compute.ComputeServiceApiMetadata; import org.jclouds.compute.ComputeServiceContext; import org.testng.annotations.Test; @@ -20,15 +16,8 @@ import com.google.common.reflect.TypeToken; @Test(groups = "unit") public abstract class BaseComputeServiceApiMetadataTest extends BaseApiMetadataTest { - @SuppressWarnings("rawtypes") - public BaseComputeServiceApiMetadataTest(ComputeServiceApiMetadata toTest) { - super(toTest, ApiType.COMPUTE); - } - - @Test - public void testContextAssignableFromComputeServiceContext() { - Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(ComputeServiceContext.class))); - assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); + public BaseComputeServiceApiMetadataTest(ApiMetadata toTest) { + super(toTest, ImmutableSet.>of(TypeToken.of(ComputeServiceContext.class))); } } \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java index a9f8eb3b3d..c1c4f90d21 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java @@ -22,24 +22,25 @@ import java.io.InputStream; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.io.CopyInputStreamInputSupplierMap; import org.jclouds.rest.config.CredentialStoreModule; -import org.jclouds.rest.internal.BaseContextLiveTest; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.io.InputSupplier; +import com.google.common.reflect.TypeToken; import com.google.inject.Module; import com.google.inject.util.Modules; /** * @author Jason King, Adrian Cole */ -public abstract class BaseComputeServiceContextLiveTest> extends BaseContextLiveTest { +public abstract class BaseComputeServiceContextLiveTest extends BaseContextLiveTest { protected String imageId; protected String loginUser; @@ -49,7 +50,12 @@ public abstract class BaseComputeServiceContextLiveTest>())); - + + @Override + protected TypeToken contextType() { + return TypeToken.of(ComputeServiceContext.class); + } + @Override protected Properties setupProperties() { Properties overrides = super.setupProperties(); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index 78d3d65f08..eff4c31be0 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -53,10 +53,10 @@ import java.io.InputStream; import java.net.URI; import java.util.Collection; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedSet; +import java.util.Map.Entry; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; @@ -119,7 +119,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = { "integration", "live" }, singleThreaded = true) -public abstract class BaseComputeServiceLiveTest> extends BaseComputeServiceContextLiveTest { +public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceContextLiveTest { protected String group; @@ -174,12 +174,12 @@ public abstract class BaseComputeServiceLiveTest context = null; + ComputeServiceContext context = null; try { context = newBuilder() .credentials("MOMMA", "MIA") .modules(ImmutableSet.of(getLoggingModule(), credentialStoreModule)) - .overrides(setupProperties()).build(); + .overrides(setupProperties()).build(ComputeServiceContext.class); context.getComputeService().listNodes(); } catch (AuthorizationException e) { throw e; diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java index 7dc9760c6c..51fe154b80 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java @@ -24,10 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.io.InputStream; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Properties; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import org.jclouds.compute.ComputeServiceContext; @@ -63,8 +63,8 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "integration,live") -public abstract class BaseTemplateBuilderLiveTest> extends - BaseComputeServiceContextLiveTest { +public abstract class BaseTemplateBuilderLiveTest extends + BaseComputeServiceContextLiveTest { public void testCompareSizes() throws Exception { Hardware defaultSize = context.getComputeService().templateBuilder().build().getHardware(); @@ -180,7 +180,8 @@ public abstract class BaseTemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty("jclouds.image-id", defaultTemplate.getImage().getId()); @@ -259,7 +260,7 @@ public abstract class BaseTemplateBuilderLiveTest>())); - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); String login = loginUser != null ? loginUser : "foo:bar"; diff --git a/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java b/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java index 23ccd6f0af..4987dbc940 100644 --- a/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java +++ b/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java @@ -18,8 +18,9 @@ */ package org.jclouds.compute.predicates; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.testng.annotations.Test; @@ -34,7 +35,7 @@ import com.google.common.collect.Iterables; */ @Test public class ImagePredicatesTest { - ComputeService computeService = ComputeServiceContextBuilder.forTests().build().getComputeService(); + ComputeService computeService = ContextBuilder.newBuilder("stub").build(ComputeServiceContext.class).getComputeService(); public void testImageId() { Image first = Iterables.get(computeService.listImages(), 0); diff --git a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java b/core/src/main/java/org/jclouds/ContextBuilder.java similarity index 62% rename from core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java rename to core/src/main/java/org/jclouds/ContextBuilder.java index 2a96fd74f7..b3ed279960 100644 --- a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/ContextBuilder.java @@ -16,14 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest.internal; +package org.jclouds; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.instanceOf; import static com.google.common.collect.Iterables.addAll; import static com.google.common.collect.Iterables.any; -import static com.google.inject.Scopes.SINGLETON; -import static com.google.inject.util.Types.newParameterizedType; import static org.jclouds.Constants.PROPERTY_API; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; @@ -35,13 +33,14 @@ import static org.jclouds.Constants.PROPERTY_PROVIDER; import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; import java.io.Closeable; -import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Properties; +import javax.inject.Singleton; + import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.Apis; import org.jclouds.concurrent.MoreExecutors; @@ -50,11 +49,12 @@ import org.jclouds.concurrent.config.ConfiguresExecutorService; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.events.config.ConfiguresEventBus; import org.jclouds.events.config.EventBusModule; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.config.LifeCycleModule; +import org.jclouds.location.Provider; import org.jclouds.logging.config.LoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.providers.AnonymousProviderMetadata; @@ -62,7 +62,7 @@ import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; import org.jclouds.rest.ConfiguresCredentialStore; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.ConfiguresRestContext; +import org.jclouds.rest.RestApiMetadata; import org.jclouds.rest.RestContext; import org.jclouds.rest.config.BindPropertiesToAnnotations; import org.jclouds.rest.config.CredentialStoreModule; @@ -72,41 +72,58 @@ import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Objects; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMultimap.Builder; +import com.google.common.reflect.TypeToken; import com.google.common.util.concurrent.ExecutionList; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; +import com.google.inject.Provides; import com.google.inject.Stage; import com.google.inject.TypeLiteral; /** - * Creates {@link RestContext} or {@link Injector} instances based on the most - * commonly requested arguments. + * Creates {@link RestContext} or {@link Injector} instances based on the most commonly requested + * arguments. *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. *

    *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. + * If no Modules are specified, the default {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. * * @author Adrian Cole, Andrew Newdigate * @see RestContext */ -public class ContextBuilder> { +public final class ContextBuilder { + + private final class BindDefaultContextQualifiedToProvider extends AbstractModule { + @Override + protected void configure() { + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(apiMetadata.getContext()); + } + + @SuppressWarnings("unused") + @Provides + @Provider + @Singleton + protected Closeable wrapped(Injector i, @Provider TypeToken wrappedType) { + return (Closeable) i.getInstance(Key.get(TypeLiteral.get(wrappedType.getType()))); + } + } /** * looks up a provider or api with the given id @@ -117,7 +134,7 @@ public class ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { + public static ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { try { try { return ContextBuilder.newBuilder(Providers.withId(providerOrApi)); @@ -129,41 +146,31 @@ public class ContextBuilder> ContextBuilder newBuilder( - ApiMetadata apiMetadata) { + public static ContextBuilder newBuilder(ApiMetadata apiMetadata) { try { - for (Constructor ctor : apiMetadata.getContextBuilder().getRawType().getConstructors()) { - if (ctor.getParameterTypes().length == 1 - && ctor.getParameterTypes()[0].isAssignableFrom(apiMetadata.getClass())) - return (ContextBuilder) ctor.newInstance(apiMetadata); - } - throw new IllegalArgumentException(String.format("class %s has no constructor that accepts %s", apiMetadata - .getContextBuilder().getRawType().getSimpleName(), apiMetadata.getClass().getSimpleName())); + return new ContextBuilder(apiMetadata); } catch (Exception e) { return propagateAuthorizationOrOriginalException(e); } } - public static > ContextBuilder newBuilder( - ProviderMetadata providerMetadata) { + public static ContextBuilder newBuilder(ProviderMetadata providerMetadata) { try { - Class contextBuilderClass = providerMetadata.getApiMetadata().getContextBuilder().getRawType(); - return (ContextBuilder) contextBuilderClass.getConstructor(ProviderMetadata.class).newInstance( - providerMetadata); + return new ContextBuilder(providerMetadata); } catch (Exception e) { return propagateAuthorizationOrOriginalException(e); } } - protected ProviderMetadata providerMetadata; + protected ProviderMetadata providerMetadata; protected String endpoint; protected String identity; protected String credential; - protected M apiMetadata; + protected ApiMetadata apiMetadata; protected String apiVersion; protected String buildVersion; protected Properties overrides = new Properties();; @@ -172,14 +179,14 @@ public class ContextBuilder providerMetadata) { + + protected ContextBuilder(ProviderMetadata providerMetadata) { this(providerMetadata, providerMetadata.getApiMetadata()); } - protected ContextBuilder(@Nullable ProviderMetadata providerMetadata, M apiMetadata) { + protected ContextBuilder(@Nullable ProviderMetadata providerMetadata, ApiMetadata apiMetadata) { this.apiMetadata = checkNotNull(apiMetadata, "apiMetadata"); this.providerMetadata = providerMetadata; if (providerMetadata != null) @@ -194,37 +201,37 @@ public class ContextBuilder credentials(String identity, String credential) { + public ContextBuilder credentials(String identity, String credential) { this.identity = identity; this.credential = credential; return this; } - public ContextBuilder endpoint(String endpoint) { + public ContextBuilder endpoint(String endpoint) { this.endpoint = endpoint; return this; } - public ContextBuilder apiVersion(String apiVersion) { + public ContextBuilder apiVersion(String apiVersion) { this.apiVersion = checkNotNull(apiVersion, "apiVersion"); return this; } - public ContextBuilder buildVersion(String buildVersion) { + public ContextBuilder buildVersion(String buildVersion) { this.buildVersion = checkNotNull(buildVersion, "buildVersion"); return this; } - public ContextBuilder modules(Iterable modules) { + public ContextBuilder modules(Iterable modules) { addAll(this.modules, modules); return this; } - public ContextBuilder overrides(Properties overrides) { + public ContextBuilder overrides(Properties overrides) { this.overrides.putAll(overrides); return this; } @@ -233,10 +240,10 @@ public class ContextBuilder defaultModules = ifSpecifiedByUserDontIncludeDefaultRestModule(restModuleSpecifiedByUser); + Iterables.addAll(modules, defaultModules); addClientModuleIfNotPresent(modules); addLoggingModuleIfNotPresent(modules); addHttpModuleIfNeededAndNotPresent(modules); - ifHttpConfigureRestOtherwiseGuiceClientFactory(modules); addExecutorServiceIfNotPresent(modules); addEventBusIfNotPresent(modules); addCredentialStoreIfNotPresent(modules); modules.add(new LifeCycleModule()); modules.add(new BindPropertiesToAnnotations()); + modules.add(new BindDefaultContextQualifiedToProvider()); Injector returnVal = Guice.createInjector(Stage.PRODUCTION, modules); returnVal.getInstance(ExecutionList.class).execute(); return returnVal; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + private Iterable ifSpecifiedByUserDontIncludeDefaultRestModule(boolean restModuleSpecifiedByUser) { + Iterable defaultModules = Iterables.transform(apiMetadata.getDefaultModules(), + new Function, Module>() { + + @Override + public Module apply(Class arg0) { + try { + return arg0.newInstance(); + } catch (InstantiationException e) { + throw Throwables.propagate(e); + } catch (IllegalAccessException e) { + throw Throwables.propagate(e); + } + } + + }); + if (restModuleSpecifiedByUser) + defaultModules = Iterables.filter(defaultModules, Predicates.not(configuresRest)); + return defaultModules; + } + + @SuppressWarnings( { "unchecked" }) Map propertiesPrefixedWithJcloudsApiOrProviderId(Properties properties, String providerId) { - return Maps.filterKeys((Map) System.getProperties(), - Predicates.containsPattern("^(jclouds|" + providerId + "|" + apiMetadata.getId() + ").*")); + return Maps.filterKeys((Map) System.getProperties(), Predicates.containsPattern("^(jclouds|" + providerId + "|" + + apiMetadata.getId() + ").*")); } @VisibleForTesting @@ -317,7 +349,7 @@ public class ContextBuilder modules) { - if (defaultOrAtLeastOneModuleRequiresHttp(modules) && nothingConfiguresAnHttpService(modules)) + if (nothingConfiguresAnHttpService(modules)) modules.add(new JavaUrlHttpCommandExecutorServiceModule()); } @@ -330,59 +362,6 @@ public class ContextBuilder modules) { - if (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresRestContext.class); - } - - })) { - addContextModule(modules); - } - } - - @VisibleForTesting - protected void addContextModule(List modules) { - modules.add(new AbstractModule() { - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - protected void configure() { - bind( - (TypeLiteral) TypeLiteral.get(newParameterizedType(RestContext.class, providerMetadata - .getApiMetadata().getApi(), apiMetadata.getAsyncApi()))).to( - TypeLiteral.get(newParameterizedType(RestContextImpl.class, apiMetadata.getApi(), - apiMetadata.getAsyncApi()))).in(SINGLETON); - } - - public String toString() { - return String.format("configure rest context %s->%s", apiMetadata.getApi().getSimpleName(), apiMetadata - .getAsyncApi().getSimpleName()); - } - - }); - } - - @VisibleForTesting - protected void ifHttpConfigureRestOtherwiseGuiceClientFactory(List modules) { - if (defaultOrAtLeastOneModuleRequiresHttp(modules)) { - modules.add(new RestModule()); - } - } - - private boolean defaultOrAtLeastOneModuleRequiresHttp(List modules) { - return atLeastOneModuleRequiresHttp(modules) || !restClientModulePresent(modules); - } - - private boolean atLeastOneModuleRequiresHttp(List modules) { - return any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(RequiresHttp.class); - } - }); - } - @VisibleForTesting protected void addClientModuleIfNotPresent(List modules) { if (!restClientModulePresent(modules)) { @@ -390,32 +369,41 @@ public class ContextBuilder configuresRest = new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresRestClient.class); + } + + }; + private boolean restClientModulePresent(List modules) { - return any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresRestClient.class); - } - - }); + return any(modules, configuresRest); } + @SuppressWarnings("unchecked") protected void addClientModule(List modules) { - modules.add(new RestClientModule(apiMetadata.getApi(), providerMetadata.getApiMetadata().getAsyncApi())); + // TODO: move this up + if (apiMetadata instanceof RestApiMetadata) { + final RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata); + modules.add(new RestClientModule(rest.getApi(), rest.getAsyncApi())); + } else { + modules.add(new RestModule()); + } } - + @VisibleForTesting protected void addEventBusIfNotPresent(List modules) { - if (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresEventBus.class); - } - } - - )) { - modules.add(new EventBusModule()); - } + if (!any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresEventBus.class); + } + } + + )) { + modules.add(new EventBusModule()); + } } - + @VisibleForTesting protected void addExecutorServiceIfNotPresent(List modules) { if (!any(modules, new Predicate() { @@ -431,7 +419,7 @@ public class ContextBuilder C build() { + return (C) build(apiMetadata.getContext()); } - - public M getApiMetadata() { + + /** + * @see #build(TypeToken) + */ + public C build(Class contextType) { + return build(TypeToken.of(checkNotNull(contextType, "contextType"))); + } + + /** + * this will build any context supported by the ApiMetadata. This includes the base + * {@link ApiMetadata#getContext() context}, or any {@link ApiMetadata#getWrappers() wrapper} it + * supports. + * + * ex. {@code builder.build(BlobStoreContext.class) } will work, if {@code TypeToken} + * is a configured {@link ApiMetadata#getWrappers() wrapper} of this api. + * + * + */ + @SuppressWarnings("unchecked") + public C build(final TypeToken contextType) { + TypeToken returnType = null; + if (contextType.isAssignableFrom(apiMetadata.getContext())) + returnType = (TypeToken) apiMetadata.getContext(); + else + try { + returnType = (TypeToken) Apis.findWrapper(apiMetadata, contextType); + } catch (NoSuchElementException e) { + throw new IllegalArgumentException(String.format( + "api %s not assignable from or transformable to %s; context: %s, wrappers: %s", apiMetadata, + contextType, apiMetadata.getContext(), apiMetadata.getWrappers())); + } + return (C) buildInjector().getInstance(Key.get(TypeLiteral.get(returnType.getType()))); + } + + public ApiMetadata getApiMetadata() { return apiMetadata; } } diff --git a/core/src/main/java/org/jclouds/PropertiesBuilder.java b/core/src/main/java/org/jclouds/PropertiesBuilder.java deleted file mode 100644 index ceaba15898..0000000000 --- a/core/src/main/java/org/jclouds/PropertiesBuilder.java +++ /dev/null @@ -1,288 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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; - -import static org.jclouds.Constants.PROPERTY_API; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_IDENTITY; -import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT; -import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST; -import static org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE; -import static org.jclouds.Constants.PROPERTY_MAX_REDIRECTS; -import static org.jclouds.Constants.PROPERTY_MAX_RETRIES; -import static org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES; -import static org.jclouds.Constants.PROPERTY_PROVIDER; -import static org.jclouds.Constants.PROPERTY_PROXY_HOST; -import static org.jclouds.Constants.PROPERTY_PROXY_PASSWORD; -import static org.jclouds.Constants.PROPERTY_PROXY_PORT; -import static org.jclouds.Constants.PROPERTY_PROXY_SYSTEM; -import static org.jclouds.Constants.PROPERTY_PROXY_USER; -import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME; -import static org.jclouds.Constants.PROPERTY_RETRY_DELAY_START; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; -import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS; -import static org.jclouds.Constants.PROPERTY_USER_THREADS; -import static org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS; - -import java.util.Properties; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Joiner; - -/** - * Builds properties used in Http engines - * - * @author Adrian Cole, Andrew Newdigate - */ -public class PropertiesBuilder { - - /** - * @see org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME - */ - public PropertiesBuilder relaxSSLHostname(boolean relax) { - properties.setProperty(PROPERTY_RELAX_HOSTNAME, relax + ""); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS - */ - public PropertiesBuilder trustAllCerts(boolean trust) { - properties.setProperty(PROPERTY_TRUST_ALL_CERTS, trust + ""); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_SYSTEM - */ - public PropertiesBuilder useSystemProxies(boolean useSystemProxies) { - properties.setProperty(PROPERTY_PROXY_SYSTEM, useSystemProxies + ""); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_HOST - */ - public PropertiesBuilder withProxyHost(String proxyHost) { - properties.setProperty(PROPERTY_PROXY_HOST, proxyHost); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_PORT - */ - public PropertiesBuilder withProxyPort(int proxyPort) { - properties.setProperty(PROPERTY_PROXY_PORT, Integer.toString(proxyPort)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_USER - */ - public PropertiesBuilder withProxyUser(String proxyUser) { - properties.setProperty(PROPERTY_PROXY_USER, proxyUser); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_PASSWORD - */ - public PropertiesBuilder withProxyPassword(String proxyPassword) { - properties.setProperty(PROPERTY_PROXY_PASSWORD, proxyPassword); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_SO_TIMEOUT - */ - public PropertiesBuilder withSOTimeout(long soTimeout) { - properties.setProperty(PROPERTY_SO_TIMEOUT, Long.toString(soTimeout)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT - */ - public PropertiesBuilder withConnectionTimeout(long connectionTimeout) { - properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, Long.toString(connectionTimeout)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_RETRIES - */ - public PropertiesBuilder withMaxRetries(int httpMaxRetries) { - properties.setProperty(PROPERTY_MAX_RETRIES, Integer.toString(httpMaxRetries)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_RETRY_DELAY_START - */ - public PropertiesBuilder withRetriesDelayStart(long delayStart) { - properties.setProperty(PROPERTY_RETRY_DELAY_START, Long.toString(delayStart)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS - */ - public PropertiesBuilder withMaxRedirects(int httpMaxRedirects) { - properties.setProperty(PROPERTY_MAX_REDIRECTS, Integer.toString(httpMaxRedirects)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE - */ - public PropertiesBuilder withMaxClientReuse(int poolMaxClientReuse) { - properties.setProperty(PROPERTY_MAX_CONNECTION_REUSE, Integer.toString(poolMaxClientReuse)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES - */ - public PropertiesBuilder withMaxSessionFailures(int poolMaxSessionFailures) { - properties.setProperty(PROPERTY_MAX_SESSION_FAILURES, Integer.toString(poolMaxSessionFailures)); - return this; - - } - - /** - * @see org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS - */ - public PropertiesBuilder limitIoWorkerThreadsTo(int poolIoWorkerThreads) { - properties.setProperty(PROPERTY_IO_WORKER_THREADS, Integer.toString(poolIoWorkerThreads)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_USER_THREADS - */ - public PropertiesBuilder limitUserThreadsTo(int poolUserThreads) { - properties.setProperty(PROPERTY_USER_THREADS, Integer.toString(poolUserThreads)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT - */ - public PropertiesBuilder limitConnectionsTo(int connectionLimit) { - properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, Integer.toString(connectionLimit)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST - */ - public PropertiesBuilder limitConnectionsPerHostTo(int connectionLimit) { - properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, Integer.toString(connectionLimit)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS - */ - public PropertiesBuilder prettyPrintPayloads(boolean prettyPrintPayloads) { - properties.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, Boolean.toString(prettyPrintPayloads)); - return this; - } - - protected final Properties properties; - - public PropertiesBuilder() { - this.properties = defaultProperties(); - } - - protected Properties defaultProperties() { - Properties props = new Properties(); - props.setProperty(PROPERTY_ISO3166_CODES, ""); - props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + ""); - props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + ""); - props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + ""); - props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); - props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); - props.setProperty(PROPERTY_USER_THREADS, 0 + ""); - props.setProperty(PROPERTY_API, ""); - props.setProperty(PROPERTY_API_VERSION, ""); - props.setProperty(PROPERTY_BUILD_VERSION, ""); - props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); - props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); - props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); - props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "true"); - return props; - } - - public PropertiesBuilder(Properties properties) { - this(); - this.properties.putAll(properties); - } - - public PropertiesBuilder provider(String providerName) { - properties.setProperty(PROPERTY_PROVIDER, providerName); - return this; - } - - public PropertiesBuilder endpoint(String endpoint) { - properties.setProperty(PROPERTY_ENDPOINT, endpoint); - return this; - } - - public PropertiesBuilder iso3166Codes(Iterable codes) { - properties.setProperty(PROPERTY_ISO3166_CODES, Joiner.on(',').join(codes)); - return this; - } - - public PropertiesBuilder apiVersion(String apiVersion) { - properties.setProperty(PROPERTY_API_VERSION, apiVersion); - return this; - } - - public PropertiesBuilder buildVersion(String buildVersion) { - properties.setProperty(PROPERTY_BUILD_VERSION, buildVersion); - return this; - } - - public PropertiesBuilder credentials(String identity, @Nullable String credential) { - properties.setProperty(PROPERTY_IDENTITY, identity); - if (credential != null) - properties.setProperty(PROPERTY_CREDENTIAL, credential); - return this; - } - - public PropertiesBuilder sessionInterval(long seconds) { - properties.setProperty(PROPERTY_SESSION_INTERVAL, seconds + ""); - return this; - } - - @VisibleForTesting - public Properties build() { - return properties; - } -} diff --git a/core/src/main/java/org/jclouds/Wrapper.java b/core/src/main/java/org/jclouds/Wrapper.java new file mode 100644 index 0000000000..e5a740a46c --- /dev/null +++ b/core/src/main/java/org/jclouds/Wrapper.java @@ -0,0 +1,65 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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; + +import java.io.Closeable; + +import com.google.common.annotations.Beta; +import com.google.common.reflect.TypeToken; + +/** + * + * + * @author Adrian Cole + * + */ +@Beta +public interface Wrapper { + + /** + * + * @return type of the context powering the current one. + */ + TypeToken getWrappedType(); + + /** + * Return an object of the specified type to allow access to the wrapped context. If the wrapped + * context is not assignable from the supplied type, an {@link IllegalArgumentException} is + * thrown. + * + * @param type + * the type of the context to be returned. The wrapped context must be assignable from + * this type. + * @return an instance of the specified type + * @throws IllegalArgumentException + * if the wrapped context is not assignable from the specified class. + * @see #getWrappedType() + */ + C unwrap(TypeToken type); + + /** + * shortcut for {@code unwrap(getWrappedType())} + * + * @throws ClassCastException + * if the user supplied {@code C} param is not assignableFrom + * {@link #getWrappedType()} + */ + C unwrap() throws ClassCastException; + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/ApiMetadata.java b/core/src/main/java/org/jclouds/apis/ApiMetadata.java index f81e3040a5..736a0fcdfc 100644 --- a/core/src/main/java/org/jclouds/apis/ApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/ApiMetadata.java @@ -19,16 +19,18 @@ package org.jclouds.apis; import java.io.Closeable; +import java.io.Serializable; import java.net.URI; import java.util.Properties; +import java.util.Set; +import org.jclouds.Wrapper; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.annotations.Beta; import com.google.common.base.Optional; import com.google.common.reflect.TypeToken; -import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Module; /** * The ApiMetadata interface allows jclouds to provide a plugin framework for @@ -38,94 +40,109 @@ import com.google.common.util.concurrent.ListenableFuture; * @since 1.5 */ @Beta -public interface ApiMetadata> { +public interface ApiMetadata extends Serializable { - public static interface Builder> { + public static interface Builder { /** * @see ApiMetadata#getId() */ - Builder id(String id); + Builder id(String id); /** * @see ApiMetadata#getName() */ - Builder name(String name); + Builder name(String name); /** - * @see ApiMetadata#getType() + * @see ApiMetadata#getContext() */ - Builder type(ApiType type); + Builder context(TypeToken context); + + /** + * @see ApiMetadata#getWrappers() + */ + Builder wrapper(Class wrapper); + /** + * @see ApiMetadata#getWrappers() + */ + Builder wrapper(TypeToken wrapper); + + /** + * @see ApiMetadata#getWrappers() + */ + Builder wrappers(Set> wrappers); + /** * @see ApiMetadata#getEndpointName() */ - Builder endpointName(String endpointName); + Builder endpointName(String endpointName); /** * @see ApiMetadata#getIdentityName() */ - Builder identityName(String identityName); + Builder identityName(String identityName); /** * @see ApiMetadata#getCredentialName() */ - Builder credentialName(@Nullable String credentialName); + Builder credentialName(@Nullable String credentialName); /** * @see ApiMetadata#getVersion() */ - Builder version(String version); + Builder version(String version); /** * @see ApiMetadata#getBuildVersion() */ - Builder buildVersion(@Nullable String buildVersion); + Builder buildVersion(@Nullable String buildVersion); /** * @see ApiMetadata#getDefaultEndpoint() */ - Builder defaultEndpoint(@Nullable String defaultEndpoint); + Builder defaultEndpoint(@Nullable String defaultEndpoint); /** * @see ApiMetadata#getDefaultIdentity() */ - Builder defaultIdentity(@Nullable String defaultIdentity); + Builder defaultIdentity(@Nullable String defaultIdentity); /** * @see ApiMetadata#getDefaultCredential() */ - Builder defaultCredential(@Nullable String defaultCredential); + Builder defaultCredential(@Nullable String defaultCredential); /** * @see ApiMetadata#getDefaultProperties() */ - Builder defaultProperties(Properties defaultProperties); + Builder defaultProperties(Properties defaultProperties); + + /** + * @see ApiMetadata#getDefaultModules() + */ + Builder defaultModule(Class defaultModule); /** - * @see ApiMetadata#getApi() - * @see ApiMetadata#getAsyncApi() + * @see ApiMetadata#getDefaultModules() */ - Builder javaApi(Class api, Class asyncApi); - + Builder defaultModules(Set> defaultModules); + /** * @see ApiMetadata#getDocumentation() */ - Builder documentation(URI documentation); + Builder documentation(URI documentation); - M build(); + ApiMetadata build(); - Builder fromApiMetadata(M from); - - Builder context(TypeToken context); - - Builder contextBuilder(TypeToken> contextBuilder); + Builder fromApiMetadata(ApiMetadata from); } /** * @see Builder */ - Builder> toBuilder(); + Builder toBuilder(); /** * @@ -139,12 +156,6 @@ public interface ApiMetadata> getDefaultModules(); + /** * * @return the url for the API documentation related to this service @@ -242,21 +260,13 @@ public interface ApiMetadata} */ - Class getApi(); - + TypeToken getContext(); + /** - * - * @return the type of the api, which is the same as {@link #getApi}, except - * all methods return {@link ListenableFuture} + * @return types of contexts this can be transformed into, for example {@code BlobStoreContext} */ - Class getAsyncApi(); - - TypeToken getContext(); - - // internal use - TypeToken> getContextBuilder(); + Set> getWrappers(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/ApiPredicates.java b/core/src/main/java/org/jclouds/apis/ApiPredicates.java index 45b8e5e770..2e9327ec5f 100644 --- a/core/src/main/java/org/jclouds/apis/ApiPredicates.java +++ b/core/src/main/java/org/jclouds/apis/ApiPredicates.java @@ -20,6 +20,8 @@ package org.jclouds.apis; import static com.google.common.base.Preconditions.checkNotNull; +import org.jclouds.Wrapper; +import org.jclouds.rest.RestApiMetadata; import org.jclouds.util.Preconditions2; import com.google.common.base.Predicate; @@ -28,36 +30,36 @@ import com.google.common.reflect.TypeToken; /** * Container for api filters (predicates). - * + * * @author Jeremy Whitlock */ public class ApiPredicates { /** * Returns all apis available to jclouds regardless of type. - * + * * @return all available apis */ - public static Predicate> all() { - return Predicates.> alwaysTrue(); + public static Predicate all() { + return Predicates. alwaysTrue(); } /** * Returns all apis with the given id. - * + * * @param id * the id of the api to return - * + * * @return the apis with the given id */ - public static Predicate> id(final String id) { + public static Predicate id(final String id) { Preconditions2.checkNotEmpty(id, "id must be defined"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ApiMetadata apiMetadata) { + public boolean apply(ApiMetadata apiMetadata) { return apiMetadata.getId().equals(id); } @@ -73,49 +75,20 @@ public class ApiPredicates { /** * Returns all apis with the given type. - * + * * @param type * the type of the api to return - * + * * @return the apis with the given type */ - public static Predicate> type(final ApiType type) { + public static Predicate apiAssignableFrom(final TypeToken type) { checkNotNull(type, "type must be defined"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ApiMetadata apiMetadata) { - return apiMetadata.getType().equals(type); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "type(" + type + ")"; - } - }; - } - - /** - * Returns all apis with the given type. - * - * @param type - * the type of the api to return - * - * @return the apis with the given type - */ - public static Predicate> apiAssignableFrom(final TypeToken type) { - checkNotNull(type, "type must be defined"); - return new Predicate>() { - /** - * {@inheritDoc} - */ - @Override - public boolean apply(ApiMetadata apiMetadata) { + public boolean apply(RestApiMetadata apiMetadata) { return type.isAssignableFrom(apiMetadata.getApi()); } @@ -131,21 +104,21 @@ public class ApiPredicates { /** * Returns all apis who's contexts are assignable from the parameter - * + * * @param type * the type of the context to search for - * + * * @return the apis with contexts assignable from given type */ - public static Predicate> contextAssignableFrom(final TypeToken contextType) { - checkNotNull(contextType, "context must be defined"); - return new Predicate>() { + public static Predicate contextAssignableFrom(final TypeToken type) { + checkNotNull(type, "context must be defined"); + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ApiMetadata apiMetadata) { - return contextType.isAssignableFrom(apiMetadata.getContext().getRawType()); + public boolean apply(ApiMetadata apiMetadata) { + return type.isAssignableFrom(apiMetadata.getContext()); } /** @@ -153,7 +126,39 @@ public class ApiPredicates { */ @Override public String toString() { - return "contextAssignableFrom(" + contextType + ")"; + return "contextAssignableFrom(" + type + ")"; + } + }; + } + + /** + * Returns all apis who's contexts are transformable to the parameter + * + * @param type + * the type of the context to search for + * + * @return the apis with contexts transformable to the given type + */ + public static Predicate contextWrappableAs(final TypeToken type) { + checkNotNull(type, "context must be defined"); + return new Predicate() { + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ApiMetadata apiMetadata) { + for (TypeToken to : apiMetadata.getWrappers()) + if (type.isAssignableFrom(to)) + return true; + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "contextWrappableAs(" + type + ")"; } }; } diff --git a/core/src/main/java/org/jclouds/apis/ApiType.java b/core/src/main/java/org/jclouds/apis/ApiType.java deleted file mode 100644 index f923d4bec1..0000000000 --- a/core/src/main/java/org/jclouds/apis/ApiType.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.apis; - -import static org.jclouds.util.Preconditions2.checkNotEmpty; - -import com.google.common.base.CaseFormat; - -/** - * - * @author Adrian Cole - */ -public enum ApiType { - - BLOBSTORE, COMPUTE, LOADBALANCER, TABLE, QUEUE, MONITOR, UNRECOGNIZED; - - @Override - public String toString() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - public static ApiType fromValue(String type) { - checkNotEmpty(type, "type must be defined"); - try { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, type)); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/Apis.java b/core/src/main/java/org/jclouds/apis/Apis.java index 2629f1edc8..35e36af2d9 100644 --- a/core/src/main/java/org/jclouds/apis/Apis.java +++ b/core/src/main/java/org/jclouds/apis/Apis.java @@ -18,13 +18,18 @@ */ package org.jclouds.apis; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; import java.util.NoSuchElementException; import java.util.ServiceLoader; +import org.jclouds.Wrapper; + import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import com.google.common.reflect.TypeToken; /** @@ -34,28 +39,27 @@ import com.google.common.reflect.TypeToken; */ public class Apis { - public static enum IdFunction implements Function, String> { + public static enum IdFunction implements Function { INSTANCE; @Override - public String apply(ApiMetadata input) { + public String apply(ApiMetadata input) { return input.getId(); } } - public static Function, String> idFunction() { + public static Function idFunction() { return IdFunction.INSTANCE; } - + /** - * Returns the apis located on the classpath via - * {@link java.util.ServiceLoader}. + * Returns the apis located on the classpath via {@link java.util.ServiceLoader}. * * @return all available apis loaded from classpath via ServiceLoader */ @SuppressWarnings("unchecked") - private static Iterable> fromServiceLoader() { + private static Iterable fromServiceLoader() { return Iterable.class.cast(ServiceLoader.load(ApiMetadata.class)); } @@ -64,7 +68,7 @@ public class Apis { * * @return all available apis */ - public static Iterable> all() { + public static Iterable all() { return fromServiceLoader(); } @@ -79,92 +83,57 @@ public class Apis { * @throws NoSuchElementException * whenever there are no apis with the provided id */ - public static ApiMetadata withId(String id) throws NoSuchElementException { + public static ApiMetadata withId(String id) throws NoSuchElementException { return find(all(), ApiPredicates.id(id)); } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#BLOBSTORE}. - * - * @return the blobstore apis - */ - public static Iterable> allBlobStore() { - return filter(all(), ApiPredicates.type(ApiType.BLOBSTORE)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#COMPUTE}. - * - * @return the compute service apis - */ - public static Iterable> allCompute() { - return filter(all(), ApiPredicates.type(ApiType.COMPUTE)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#QUEUE}. - * - * @return the queue service apis - */ - public static Iterable> allQueue() { - return filter(all(), ApiPredicates.type(ApiType.QUEUE)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#TABLE}. - * - * @return the table service apis - */ - public static Iterable> allTable() { - return filter(all(), ApiPredicates.type(ApiType.TABLE)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#LOADBALANCER}. - * - * @return the load balancer service apis - */ - public static Iterable> allLoadBalancer() { - return filter(all(), ApiPredicates.type(ApiType.LOADBALANCER)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#MONITOR}. - * - * @return the load balancer service apis - */ - public static Iterable> allMonitor() { - return filter(all(), ApiPredicates.type(ApiType.MONITOR)); - } - - /** - * Returns the apis that are of the provided type. - * - * @param type - * the type to apis to return - * - * @return the apis of the provided type - */ - public static Iterable> ofType(ApiType type) { - return filter(all(), ApiPredicates.type(type)); - } /** * Returns all apis who's contexts are assignable from the parameter - * + * * @param type * the type of the context to search for - * + * * @return the apis with contexts assignable from given type */ - public static Iterable> contextAssignableFrom(TypeToken type) { + public static Iterable contextAssignableFrom(TypeToken type) { return filter(all(), ApiPredicates.contextAssignableFrom(type)); } + /** + * Returns all apis who's contexts are assignable from the parameter + * + * @param type + * the type of the context to search for + * + * @return the apis with contexts assignable from given type + */ + public static Iterable contextWrappableAs(TypeToken type) { + return filter(all(), ApiPredicates.contextWrappableAs(type)); + } + + public static Iterable contextWrappableAs(Class type) { + return filter(all(), ApiPredicates.contextWrappableAs(TypeToken.of(type))); + } + + /** + * Returns the type of context + * + * @param type + * the type of the context to search for + * + * @return the apis with contexts transformable to the given type + */ + public static TypeToken findWrapper(final ApiMetadata apiMetadata, final TypeToken wrapper) + throws NoSuchElementException { + checkNotNull(apiMetadata, "apiMetadata must be defined"); + checkNotNull(wrapper, "context must be defined"); + return Iterables.find(apiMetadata.getWrappers(), new Predicate>() { + + @Override + public boolean apply(TypeToken input) { + return wrapper.isAssignableFrom(input); + } + + }); + } } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java index 8496c32620..ac87f3641b 100644 --- a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java @@ -34,37 +34,54 @@ import static org.jclouds.Constants.PROPERTY_USER_THREADS; import java.io.Closeable; import java.net.URI; -import java.util.Map; import java.util.Properties; +import java.util.Set; +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.ContextBuilder; +import org.jclouds.lifecycle.Closer; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; -import com.google.common.reflect.TypeParameter; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** - * The BaseApiMetadata class is an abstraction of {@link ApiMetadata} to be - * extended by those implementing ApiMetadata. + * The BaseApiMetadata class is an abstraction of {@link ApiMetadata} to be extended by those + * implementing ApiMetadata. * - * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} - * to work properly. + * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} to work properly. * * @author Jeremy Whitlock , Adrian Cole */ -public abstract class BaseApiMetadata> implements - ApiMetadata { +public abstract class BaseApiMetadata implements ApiMetadata { - public static class Builder> implements - ApiMetadata.Builder { + /** The serialVersionUID */ + private static final long serialVersionUID = -8080028444066498110L; + + public static Properties defaultProperties() { + Properties props = new Properties(); + // TODO: move this to ApiMetadata + props.setProperty(PROPERTY_ISO3166_CODES, ""); + props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + ""); + props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + ""); + props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + ""); + props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); + props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); + props.setProperty(PROPERTY_USER_THREADS, 0 + ""); + props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); + props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); + props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); + props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "true"); + return props; + } + + public static class Builder implements ApiMetadata.Builder { protected String id; protected String name; - protected ApiType type; + protected Set> wrappers = ImmutableSet.of(); protected String endpointName = "https endpoint"; protected String identityName; protected Optional credentialName = Optional.absent(); @@ -73,44 +90,17 @@ public abstract class BaseApiMetadata defaultEndpoint = Optional.absent(); protected Optional defaultIdentity = Optional.absent(); protected Optional defaultCredential = Optional.absent(); - protected Properties defaultProperties = defaultProperties(); + protected Properties defaultProperties = BaseApiMetadata.defaultProperties(); protected URI documentation; // - protected Class api; - protected Class asyncApi; - protected TypeToken context; - protected TypeToken> contextBuilder = new TypeToken>(getClass()) { - private static final long serialVersionUID = 1L; - }; - - public static Properties defaultProperties() { - Properties props = new Properties(); - // TODO: move this to ApiMetadata - props.setProperty(PROPERTY_ISO3166_CODES, ""); - props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + ""); - props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + ""); - props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + ""); - props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); - props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); - props.setProperty(PROPERTY_USER_THREADS, 0 + ""); - props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); - props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); - props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); - props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "true"); - return props; - } - - public static Properties defaultPropertiesAnd(Map overrides) { - Properties props = defaultProperties(); - props.putAll(overrides); - return props; - } + protected TypeToken context = TypeToken.of(Closer.class); + protected Set> defaultModules = ImmutableSet.of(); /** * {@inheritDoc} */ @Override - public Builder id(String id) { + public Builder id(String id) { this.id = checkNotNull(id, "id"); return this; } @@ -119,17 +109,33 @@ public abstract class BaseApiMetadata name(String name) { + public Builder name(String name) { this.name = checkNotNull(name, "name"); return this; } - + /** * {@inheritDoc} */ @Override - public Builder type(ApiType type) { - this.type = checkNotNull(type, "type"); + public Builder wrapper(Class wrapper) { + return wrapper(TypeToken.of(checkNotNull(wrapper, "wrapper"))); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder wrapper(TypeToken wrapper) { + return wrappers(ImmutableSet.>of(checkNotNull(wrapper, "wrapper"))); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder wrappers(Set> wrappers) { + this.wrappers = ImmutableSet.copyOf(checkNotNull(wrappers, "wrappers")); return this; } @@ -137,7 +143,7 @@ public abstract class BaseApiMetadata endpointName(String endpointName) { + public Builder endpointName(String endpointName) { this.endpointName = checkNotNull(endpointName, "endpointName"); return this; } @@ -146,7 +152,7 @@ public abstract class BaseApiMetadata identityName(String identityName) { + public Builder identityName(String identityName) { this.identityName = checkNotNull(identityName, "identityName"); return this; } @@ -155,7 +161,7 @@ public abstract class BaseApiMetadata credentialName(String credentialName) { + public Builder credentialName(String credentialName) { this.credentialName = Optional.fromNullable(credentialName); return this; } @@ -164,7 +170,7 @@ public abstract class BaseApiMetadata version(String version) { + public Builder version(String version) { this.version = checkNotNull(version, "version"); return this; } @@ -173,7 +179,7 @@ public abstract class BaseApiMetadata buildVersion(String buildVersion) { + public Builder buildVersion(String buildVersion) { this.buildVersion = Optional.fromNullable(buildVersion); return this; } @@ -182,7 +188,7 @@ public abstract class BaseApiMetadata defaultEndpoint(String defaultEndpoint) { + public Builder defaultEndpoint(String defaultEndpoint) { this.defaultEndpoint = Optional.fromNullable(defaultEndpoint); return this; } @@ -191,7 +197,7 @@ public abstract class BaseApiMetadata defaultIdentity(String defaultIdentity) { + public Builder defaultIdentity(String defaultIdentity) { this.defaultIdentity = Optional.fromNullable(defaultIdentity); return this; } @@ -200,7 +206,7 @@ public abstract class BaseApiMetadata defaultCredential(String defaultCredential) { + public Builder defaultCredential(String defaultCredential) { this.defaultCredential = Optional.fromNullable(defaultCredential); return this; } @@ -209,7 +215,7 @@ public abstract class BaseApiMetadata defaultProperties(Properties defaultProperties) { + public Builder defaultProperties(Properties defaultProperties) { this.defaultProperties = checkNotNull(defaultProperties, "defaultProperties"); return this; } @@ -217,30 +223,8 @@ public abstract class BaseApiMetadata javaApi(Class api, Class asyncApi) { - this.api = checkNotNull(api, "api"); - this.asyncApi = checkNotNull(asyncApi, "asyncApi"); - if (context == null) - context(contextToken(TypeToken.of(checkNotNull(api, "api")), TypeToken.of(checkNotNull(asyncApi, "asyncApi")))); - return this; - } - - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder documentation(URI documentation) { + public Builder documentation(URI documentation) { this.documentation = checkNotNull(documentation, "documentation"); return this; } @@ -249,7 +233,7 @@ public abstract class BaseApiMetadata context(TypeToken context) { + public Builder context(TypeToken context) { this.context = checkNotNull(context, "context"); return this; } @@ -258,25 +242,33 @@ public abstract class BaseApiMetadata contextBuilder(TypeToken> contextBuilder) { - this.contextBuilder = checkNotNull(contextBuilder, "contextBuilder"); + public Builder defaultModule(Class defaultModule) { + return defaultModules(ImmutableSet.>of(checkNotNull(defaultModule, "defaultModule"))); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder defaultModules(Set> defaultModules) { + this.defaultModules = ImmutableSet.copyOf(checkNotNull(defaultModules, "defaultModules")); return this; } - public Builder fromApiMetadata(M in) { - return id(in.getId()).type(in.getType()).name(in.getName()).endpointName(in.getEndpointName()) - .identityName(in.getIdentityName()).credentialName(in.getCredentialName().orNull()) - .version(in.getVersion()).buildVersion(in.getBuildVersion().orNull()) - .defaultEndpoint(in.getDefaultEndpoint().orNull()).defaultIdentity(in.getDefaultIdentity().orNull()) - .defaultCredential(in.getDefaultCredential().orNull()).defaultProperties(in.getDefaultProperties()) - .documentation(in.getDocumentation()).javaApi(in.getApi(), in.getAsyncApi()).context(in.getContext()) - .contextBuilder(in.getContextBuilder()); + public Builder fromApiMetadata(ApiMetadata in) { + return id(in.getId()).wrappers(in.getWrappers()).name(in.getName()).endpointName(in.getEndpointName()).identityName( + in.getIdentityName()).credentialName(in.getCredentialName().orNull()).version(in.getVersion()) + .buildVersion(in.getBuildVersion().orNull()).defaultEndpoint(in.getDefaultEndpoint().orNull()) + .defaultIdentity(in.getDefaultIdentity().orNull()).defaultCredential( + in.getDefaultCredential().orNull()).defaultProperties(in.getDefaultProperties()) + .documentation(in.getDocumentation()).context(in.getContext()).defaultModules(in.getDefaultModules()); } - @SuppressWarnings("unchecked") @Override - public M build() { - return (M) new BaseApiMetadata(this) { + public ApiMetadata build() { + return new BaseApiMetadata(this) { + /** The serialVersionUID */ + private static final long serialVersionUID = 3599854558038790678L; }; } @@ -284,7 +276,7 @@ public abstract class BaseApiMetadata> wrappers; protected final String endpointName; protected final String identityName; protected final Optional credentialName; @@ -295,29 +287,24 @@ public abstract class BaseApiMetadata defaultCredential; protected final Properties defaultProperties; protected final URI documentation; - protected final Class api; - protected final Class asyncApi; - protected final TypeToken context; - protected final TypeToken> contextBuilder; + protected final TypeToken context; + protected final Set> defaultModules; - @SuppressWarnings("unchecked") - protected BaseApiMetadata(Builder builder) { - this(builder.id, builder.name, builder.type, builder.endpointName, builder.identityName, builder.credentialName, - builder.version, builder.buildVersion, builder.defaultEndpoint, builder.defaultIdentity, - builder.defaultCredential, builder.defaultProperties, builder.documentation, Class.class.cast(builder.api), - Class.class.cast(builder.asyncApi), TypeToken.class.cast(builder.context), TypeToken.class - .cast(builder.contextBuilder)); + protected BaseApiMetadata(Builder builder) { + this(builder.id, builder.name, builder.wrappers, builder.endpointName, builder.identityName, builder.credentialName, + builder.version, builder.buildVersion, builder.defaultEndpoint, builder.defaultIdentity, + builder.defaultCredential, builder.defaultProperties, builder.documentation, builder.context, + builder.defaultModules); } - - public BaseApiMetadata(String id, String name, ApiType type, String endpointName, String identityName, - Optional credentialName, String version, Optional buildVersion, - Optional defaultEndpoint, Optional defaultIdentity, Optional defaultCredential, - Properties defaultProperties, URI documentation, Class api, Class asyncApi, TypeToken context, - TypeToken> contextBuilder) { + public BaseApiMetadata(String id, String name, Set> wrappers, String endpointName, String identityName, + Optional credentialName, String version, Optional buildVersion, + Optional defaultEndpoint, Optional defaultIdentity, Optional defaultCredential, + Properties defaultProperties, URI documentation, TypeToken context, + Set> defaultModules) { this.id = checkNotNull(id, "id"); this.name = checkNotNull(name, "name"); - this.type = checkNotNull(type, "type"); + this.wrappers = ImmutableSet.copyOf(checkNotNull(wrappers, "wrappers")); this.endpointName = checkNotNull(endpointName, "endpointName"); this.identityName = checkNotNull(identityName, "identityName"); this.credentialName = checkNotNull(credentialName, "credentialName"); @@ -328,10 +315,8 @@ public abstract class BaseApiMetadata that = ApiMetadata.class.cast(o); + ApiMetadata that = ApiMetadata.class.cast(o); return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) - && equal(this.getType(), that.getType()); + && equal(this.getWrappers(), that.getWrappers()); } @Override public int hashCode() { - return Objects.hashCode(getId(), getName(), getType()); + return Objects.hashCode(getId(), getName(), getWrappers()); } @Override @@ -358,10 +343,9 @@ public abstract class BaseApiMetadata> getWrappers() { + return wrappers; } /** @@ -472,23 +456,7 @@ public abstract class BaseApiMetadata getApi() { - return api; - } - - /** - * {@inheritDoc} - */ - @Override - public Class getAsyncApi() { - return asyncApi; - } - - /** - * {@inheritDoc} - */ - @Override - public TypeToken getContext() { + public TypeToken getContext() { return context; } @@ -496,14 +464,13 @@ public abstract class BaseApiMetadata> getContextBuilder() { - return contextBuilder; + public Set> getDefaultModules() { + return defaultModules; } - @SuppressWarnings("unchecked") @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata((M) this); + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/concurrent/DynamicExecutors.java b/core/src/main/java/org/jclouds/concurrent/DynamicExecutors.java index 71089131a2..811d32bc0d 100644 --- a/core/src/main/java/org/jclouds/concurrent/DynamicExecutors.java +++ b/core/src/main/java/org/jclouds/concurrent/DynamicExecutors.java @@ -157,7 +157,7 @@ public class DynamicExecutors { /* * Thread name: owner-pool-N-thread-M, where N is the sequence number of this factory, - * and M is the sequence number of the thread created by this factory. + * and ApiMetadata is the sequence number of the thread created by this factory. */ t.setName(o + t.getName()); diff --git a/core/src/main/java/org/jclouds/encryption/internal/Base64.java b/core/src/main/java/org/jclouds/encryption/internal/Base64.java index d20add1434..d68ef16d9d 100644 --- a/core/src/main/java/org/jclouds/encryption/internal/Base64.java +++ b/core/src/main/java/org/jclouds/encryption/internal/Base64.java @@ -199,7 +199,7 @@ public class Base64 -/* ******** E N C O D I N G M E T H O D S ******** */ +/* ******** E N C O D I N G ApiMetadata E T H O D S ******** */ /** @@ -568,7 +568,7 @@ public class Base64 -/* ******** D E C O D I N G M E T H O D S ******** */ +/* ******** D E C O D I N G ApiMetadata E T H O D S ******** */ /** @@ -1011,7 +1011,7 @@ public class Base64 - /* ******** I N N E R C L A S S I N P U T S T R E A M ******** */ + /* ******** I N N E R C L A S S I N P U T S T R E A ApiMetadata ******** */ @@ -1241,7 +1241,7 @@ public class Base64 - /* ******** I N N E R C L A S S O U T P U T S T R E A M ******** */ + /* ******** I N N E R C L A S S O U T P U T S T R E A ApiMetadata ******** */ diff --git a/core/src/main/java/org/jclouds/internal/BaseWrapper.java b/core/src/main/java/org/jclouds/internal/BaseWrapper.java new file mode 100644 index 0000000000..b28208c5f9 --- /dev/null +++ b/core/src/main/java/org/jclouds/internal/BaseWrapper.java @@ -0,0 +1,97 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.internal; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.Closeable; + +import javax.inject.Singleton; + +import org.jclouds.Wrapper; +import org.jclouds.location.Provider; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.reflect.TypeToken; + +/** + * @author Adrian Cole + */ +@Singleton +public abstract class BaseWrapper implements Wrapper { + + private final Closeable wrapped; + private final TypeToken wrappedType; + + + protected BaseWrapper(@Provider Closeable wrapped, @Provider TypeToken wrappedType) { + this.wrapped = checkNotNull(wrapped, "wrapped"); + this.wrappedType = checkNotNull(wrappedType, "wrappedType"); + } + + @SuppressWarnings("unchecked") + @Override + public C unwrap(TypeToken type) { + checkArgument(checkNotNull(type, "type").isAssignableFrom(wrappedType), "wrapped type: %s not assignable from %s", wrappedType, type); + return (C) wrapped; + } + + @Override + public TypeToken getWrappedType() { + return wrappedType; + } + + @SuppressWarnings("unchecked") + @Override + public C unwrap() throws ClassCastException { + return (C) unwrap(getWrappedType()); + } + + public Closeable getWrapped() { + return wrapped; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + BaseWrapper that = BaseWrapper.class.cast(o); + return equal(this.getWrapped(), that.getWrapped()) && equal(this.getWrappedType(), that.getWrappedType()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getWrapped(), getWrappedType()); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return Objects.toStringHelper("").add("wrapped", getWrapped()).add("wrappedType", getWrappedType()); + } + + +} diff --git a/core/src/main/java/org/jclouds/location/config/LocationModule.java b/core/src/main/java/org/jclouds/location/config/LocationModule.java index 640c872452..1a9a09648b 100644 --- a/core/src/main/java/org/jclouds/location/config/LocationModule.java +++ b/core/src/main/java/org/jclouds/location/config/LocationModule.java @@ -30,6 +30,7 @@ import javax.inject.Singleton; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; +import org.jclouds.internal.ClassMethodArgsAndReturnVal; import org.jclouds.location.Iso3166; import org.jclouds.location.Provider; import org.jclouds.location.Region; @@ -45,11 +46,15 @@ import org.jclouds.location.suppliers.RegionIdsSupplier; import org.jclouds.location.suppliers.ZoneIdToURISupplier; import org.jclouds.location.suppliers.ZoneIdsSupplier; import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.functions.ImplicitOptionalConverter; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; +import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.base.Supplier; import com.google.inject.AbstractModule; import com.google.inject.Provides; +import com.google.inject.TypeLiteral; /** * All of these are memoized as locations do not change often at runtime. Note that we take care to @@ -61,6 +66,7 @@ public class LocationModule extends AbstractModule { @Override protected void configure() { + bind(new TypeLiteral>>(){}).to(ImplicitOptionalConverter.class); } @Provides diff --git a/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java b/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java index 4713b8c3d4..d49edcb8fc 100644 --- a/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java @@ -20,50 +20,47 @@ package org.jclouds.providers; import static com.google.common.base.Preconditions.checkNotNull; -import java.io.Closeable; - import org.jclouds.apis.ApiMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.rest.AnonymousRestApiMetadata; -import org.jclouds.rest.RestContext; /** * Useful in creating arbitrary clients. * * @author Adrian Cole */ -public class AnonymousProviderMetadata> extends - BaseProviderMetadata { +public class AnonymousProviderMetadata extends BaseProviderMetadata { - public static ProviderMetadata, AnonymousRestApiMetadata> forClientMappedToAsyncClientOnEndpoint(Class client, Class asyncClient, - String endpoint) { + /** The serialVersionUID */ + private static final long serialVersionUID = 3038298137724260273L; + + public static ProviderMetadata forClientMappedToAsyncClientOnEndpoint(Class client, Class asyncClient, + String endpoint) { return forApiWithEndpoint(AnonymousRestApiMetadata.forClientMappedToAsyncClient(client, asyncClient), endpoint); } - - public static > ProviderMetadata forApiWithEndpoint(M md, - String endpoint) { + + public static ProviderMetadata forApiWithEndpoint(ApiMetadata md, String endpoint) { checkNotNull(md, "api"); checkNotNull(endpoint, "endpoint (%s)", md.getEndpointName()); - return new AnonymousProviderMetadata(md, endpoint); + return new AnonymousProviderMetadata(md, endpoint); } @Override - public Builder toBuilder() { - return (Builder) new Builder(getApiMetadata(), getEndpoint()).fromProviderMetadata(this); + public Builder toBuilder() { + return (Builder) new Builder(getApiMetadata(), getEndpoint()).fromProviderMetadata(this); } - public AnonymousProviderMetadata(M apiMetadata, String endpoint) { - super(new Builder(apiMetadata, endpoint)); + public AnonymousProviderMetadata(ApiMetadata apiMetadata, String endpoint) { + super(new Builder(apiMetadata, endpoint)); } - public AnonymousProviderMetadata(Builder builder) { + public AnonymousProviderMetadata(Builder builder) { super(builder); } - public static class Builder> extends - BaseProviderMetadata.Builder { + public static class Builder extends BaseProviderMetadata.Builder { - public Builder(M apiMetadata, String endpoint) { + public Builder(ApiMetadata apiMetadata, String endpoint) { id(checkNotNull(apiMetadata, "apiMetadata").getId()) .name(apiMetadata.getName()) .apiMetadata(apiMetadata) @@ -71,8 +68,8 @@ public class AnonymousProviderMetadata build() { - return new AnonymousProviderMetadata(this); + public AnonymousProviderMetadata build() { + return new AnonymousProviderMetadata(this); } } diff --git a/core/src/main/java/org/jclouds/providers/ProviderMetadata.java b/core/src/main/java/org/jclouds/providers/ProviderMetadata.java index b4b4f25318..57d9d04f85 100644 --- a/core/src/main/java/org/jclouds/providers/ProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/ProviderMetadata.java @@ -18,7 +18,7 @@ */ package org.jclouds.providers; -import java.io.Closeable; +import java.io.Serializable; import java.net.URI; import java.util.Properties; import java.util.Set; @@ -34,82 +34,82 @@ import com.google.common.base.Optional; * * @author Jeremy Whitlock , Adrian Cole */ -public interface ProviderMetadata> { +public interface ProviderMetadata extends Serializable { /** * * @author Adrian Cole * @since 1.5 */ - public static interface Builder> { + public static interface Builder { /** * @see ProviderMetadata#getId() */ - Builder id(String id); + Builder id(String id); /** * @see ProviderMetadata#getName() */ - Builder name(String name); + Builder name(String name); /** * @see ProviderMetadata#getApiMetadata() */ - Builder apiMetadata(M api); + Builder apiMetadata(ApiMetadata api); /** * @see ProviderMetadata#getEndpoint() */ - Builder endpoint(String endpoint); + Builder endpoint(String endpoint); /** * @see ProviderMetadata#getDefaultProperties() */ - Builder defaultProperties(Properties defaultProperties); + Builder defaultProperties(Properties defaultProperties); /** * @see ProviderMetadata#getConsole() */ - Builder console(@Nullable URI console); + Builder console(@Nullable URI console); /** * @see ProviderMetadata#getHomepage() */ - Builder homepage(@Nullable URI homepage); + Builder homepage(@Nullable URI homepage); /** * @see ProviderMetadata#getLinkedServices() */ - Builder linkedServices(Iterable linkedServices); + Builder linkedServices(Iterable linkedServices); /** * @see ProviderMetadata#getLinkedServices() */ - Builder linkedServices(String... linkedServices); + Builder linkedServices(String... linkedServices); /** * @see ProviderMetadata#getLinkedServices() */ - Builder linkedService(String linkedService); + Builder linkedService(String linkedService); /** * @see ProviderMetadata#getIso3166Code() */ - Builder iso3166Codes(Iterable iso3166Codes); + Builder iso3166Codes(Iterable iso3166Codes); /** * @see ProviderMetadata#getIso3166Code() */ - Builder iso3166Codes(String... iso3166Codes); + Builder iso3166Codes(String... iso3166Codes); /** * @see ProviderMetadata#getIso3166Code() */ - Builder iso3166Code(String iso3166Code); + Builder iso3166Code(String iso3166Code); - ProviderMetadata build(); + ProviderMetadata build(); - Builder fromProviderMetadata(ProviderMetadata in); + Builder fromProviderMetadata(ProviderMetadata in); } @@ -117,7 +117,7 @@ public interface ProviderMetadata toBuilder(); + Builder toBuilder(); /** * @@ -136,7 +136,7 @@ public interface ProviderMetadata> implements Predicate> { - private final TypeToken contextClass; + public static class ContextAssignableFrom implements Predicate { + private final TypeToken type; - public ContextAssignableFrom(TypeToken contextClass) { - Preconditions.checkNotNull(contextClass, "context must be defined"); - this.contextClass = contextClass; + public ContextAssignableFrom(TypeToken type) { + Preconditions.checkNotNull(type, "context must be defined"); + this.type = type; } /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { - return ApiPredicates.contextAssignableFrom(contextClass).apply(providerMetadata.getApiMetadata()); + public boolean apply(ProviderMetadata providerMetadata) { + return ApiPredicates.contextAssignableFrom(type).apply(providerMetadata.getApiMetadata()); } /** @@ -58,7 +58,32 @@ public class ProviderPredicates { */ @Override public String toString() { - return "contextAssignableFrom(" + contextClass + ")"; + return "contextAssignableFrom(" + type + ")"; + } + } + + public static class TransformableTo implements Predicate { + private final TypeToken type; + + public TransformableTo(TypeToken type) { + Preconditions.checkNotNull(type, "context must be defined"); + this.type = type; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ProviderMetadata providerMetadata) { + return ApiPredicates.contextWrappableAs(type).apply(providerMetadata.getApiMetadata()); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "contextWrappableAs(" + type + ")"; } } @@ -67,8 +92,8 @@ public class ProviderPredicates { * * @return all available providers */ - public static Predicate> all() { - return Predicates.> alwaysTrue(); + public static Predicate all() { + return Predicates. alwaysTrue(); } /** @@ -79,14 +104,14 @@ public class ProviderPredicates { * * @return the providers with the given id */ - public static Predicate> id(final String id) { + public static Predicate id(final String id) { Preconditions2.checkNotEmpty(id, "id must be defined"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { return providerMetadata.getId().equals(id); } @@ -100,43 +125,6 @@ public class ProviderPredicates { }; } - /** - * Returns all providers with the given type. - * - * @param type - * the type of the provider to return - * - * @return the providers with the given type - */ - public static Predicate> type(final ApiType type) { - Preconditions.checkNotNull(type, "type must be defined"); - return new Predicate>() { - /** - * {@inheritDoc} - */ - @Override - public boolean apply(ProviderMetadata providerMetadata) { - return providerMetadata.getApiMetadata().getType().equals(type); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "type(" + type + ")"; - } - }; - } - - /** - * @see #type(ApiMetadata) - */ - @Deprecated - public static Predicate> type(final String type) { - return type(ApiType.fromValue(type)); - } - /** * Returns the providers that are bound to the same location as the given ISO * 3166 code. @@ -146,15 +134,15 @@ public class ProviderPredicates { * * @return the providers with the given ISO 3166 code */ - public static Predicate> boundedByIso3166Code(final String iso3166Code) { + public static Predicate boundedByIso3166Code(final String iso3166Code) { Preconditions.checkNotNull(iso3166Code, "iso3166Code must not be null"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { return providerContainsIso3166Code(providerMetadata, iso3166Code); } @@ -177,16 +165,16 @@ public class ProviderPredicates { * * @return the providers that have at least one ISO 3166 code in common */ - public static Predicate> intersectingIso3166Code( - final ProviderMetadata refProviderMetadata) { + public static Predicate intersectingIso3166Code( + final ProviderMetadata refProviderMetadata) { Preconditions.checkNotNull(refProviderMetadata, "refProviderMetadata must not be null"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { for (String refIso3166Code : refProviderMetadata.getIso3166Codes()) { // Return only if the potential provider contains the same ISO // 3166 code and the provider and @@ -221,7 +209,7 @@ public class ProviderPredicates { * * @return the result */ - private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) { + private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) { for (String availCode : providerMetadata.getIso3166Codes()) { if (iso3166Code.indexOf('-') == -1) { if (availCode.startsWith(iso3166Code + "-")) { @@ -243,15 +231,15 @@ public class ProviderPredicates { * * @return the providers with an apimetadata assignable from the given api. */ - public static > Predicate> apiMetadataAssignableFrom( - final TypeToken apiClass) { + public static Predicate apiMetadataAssignableFrom( + final TypeToken apiClass) { Preconditions.checkNotNull(apiClass, "api must be defined"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { return apiClass.isAssignableFrom(providerMetadata.getApiMetadata().getClass()); } @@ -264,18 +252,29 @@ public class ProviderPredicates { } }; } - + /** - * Returns all providers with an context assignable from the given class. + * Returns all providers with an context assignable from the given type. * - * @param contextClass + * @param type * the context of the provider to return * - * @return the providers with an context assignable from the given class. + * @return the providers with an context assignable from the given type. */ - public static > Predicate> contextAssignableFrom( - final TypeToken contextClass) { - return new ContextAssignableFrom(contextClass); + public static Predicate contextAssignableFrom(final TypeToken type) { + return new ContextAssignableFrom(type); } - + + /** + * Returns all providers with an context transformable to the given type. + * + * @param type + * the context you wish to achieve ex. {@code BlobStoreContext} + * + * @return the providers with an context transformable to from the given type. + */ + public static Predicate contextWrappableAs(final TypeToken type) { + return new TransformableTo(type); + } + } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/Providers.java b/core/src/main/java/org/jclouds/providers/Providers.java index 32fb5844db..b866e699ba 100644 --- a/core/src/main/java/org/jclouds/providers/Providers.java +++ b/core/src/main/java/org/jclouds/providers/Providers.java @@ -25,8 +25,8 @@ import java.io.Closeable; import java.util.NoSuchElementException; import java.util.ServiceLoader; +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import com.google.common.base.Function; import com.google.common.base.Preconditions; @@ -40,41 +40,39 @@ import com.google.common.reflect.TypeToken; */ public class Providers { - public static enum IdFunction implements Function, String> { + public static enum IdFunction implements Function { INSTANCE; @Override - public String apply(ProviderMetadata input) { + public String apply(ProviderMetadata input) { return input.getId(); } } - public static Function, String> idFunction() { + public static Function idFunction() { return IdFunction.INSTANCE; } - - public static class ApiMetadataFunction> implements - Function, ApiMetadata> { + + public static class ApiMetadataFunction implements Function { @Override - public ApiMetadata apply(ProviderMetadata input) { + public ApiMetadata apply(ProviderMetadata input) { return input.getApiMetadata(); } } - public static > Function, ApiMetadata> apiMetadataFunction() { - return new ApiMetadataFunction(); + public static Function apiMetadataFunction() { + return new ApiMetadataFunction(); } /** - * 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 */ @SuppressWarnings("unchecked") - public static Iterable> fromServiceLoader() { + public static Iterable fromServiceLoader() { return Iterable.class.cast(ServiceLoader.load(ProviderMetadata.class)); } @@ -83,7 +81,7 @@ public class Providers { * * @return all available providers */ - public static Iterable> all() { + public static Iterable all() { return fromServiceLoader(); } @@ -98,70 +96,24 @@ public class Providers { * @throws NoSuchElementException * 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}. + * Returns the providers that are of the provided contextWrappableAs. * - * @return the blobstore providers + * @param contextWrappableAs + * the contextWrappableAs to providers to return + * + * @return the providers of the provided contextWrappableAs */ - public static Iterable> allBlobStore() { - return filter(all(), ProviderPredicates.type(ApiType.BLOBSTORE)); + public static Iterable contextWrappableAs(TypeToken contextWrappableAs) { + return filter(all(), ProviderPredicates.contextWrappableAs(contextWrappableAs)); } - /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#COMPUTE}. - * - * @return the compute service providers - */ - public static Iterable> allCompute() { - return filter(all(), ProviderPredicates.type(ApiType.COMPUTE)); - } - - /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#QUEUE}. - * - * @return the queue service providers - */ - public static Iterable> allQueue() { - return filter(all(), ProviderPredicates.type(ApiType.QUEUE)); - } - - /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#TABLE}. - * - * @return the table service providers - */ - public static Iterable> allTable() { - return filter(all(), ProviderPredicates.type(ApiType.TABLE)); - } - - /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#LOADBALANCER}. - * - * @return the load balancer service providers - */ - public static Iterable> allLoadBalancer() { - return filter(all(), ProviderPredicates.type(ApiType.LOADBALANCER)); - } - - /** - * 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(ApiType type) { - return filter(all(), ProviderPredicates.type(type)); + public static Iterable contextWrappableAs(Class contextWrappableAs) { + return filter(all(), ProviderPredicates.contextWrappableAs(TypeToken.of(contextWrappableAs))); } /** @@ -172,7 +124,7 @@ public class Providers { * * @return the providers of the provided api */ - public static Iterable> apiMetadataAssignableFrom(TypeToken api) { + public static Iterable apiMetadataAssignableFrom(TypeToken api) { Preconditions.checkNotNull(api, "api must be defined"); return filter(all(), ProviderPredicates.apiMetadataAssignableFrom(api)); } @@ -185,71 +137,80 @@ public class Providers { * * @return the providers of the provided context */ - public static Iterable> contextAssignableFrom(TypeToken context) { + public static Iterable contextAssignableFrom( + TypeToken context) { Preconditions.checkNotNull(context, "context must be defined"); return filter(all(), new ProviderPredicates.ContextAssignableFrom(context)); } - /** - * Returns the providers that are bound to the same location as the given ISO - * 3166 code regardless of type. + * Returns the providers that are bound to the same location as the given ISO 3166 code + * regardless of contextWrappableAs. * * @param isoCode * the ISO 3166 code to filter providers by * * @return the providers bound by the given ISO 3166 code */ - public static Iterable> boundedByIso3166Code(String iso3166Code) { + public static Iterable boundedByIso3166Code(String iso3166Code) { return filter(all(), ProviderPredicates.boundedByIso3166Code(iso3166Code)); } /** - * Returns the providers that are bound to the same location as the given ISO - * 3166 code and of the given type. + * Returns the providers that are bound to the same location as the given ISO 3166 code and of + * the given contextWrappableAs. * * @param iso3166Code * the ISO 3166 code to filter providers by - * @param type - * the type to filter providers by + * @param contextWrappableAs + * the contextWrappableAs to filter providers by * - * @return the providers bound by the given ISO 3166 code and of the proper - * type + * @return the providers bound by the given ISO 3166 code and of the proper contextWrappableAs */ - public static Iterable> boundedByIso3166Code(String iso3166Code, ApiType type) { - return filter(all(), - Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), ProviderPredicates.type(type))); + public static Iterable boundedByIso3166Code(String iso3166Code, + TypeToken contextWrappableAs) { + return filter(all(), Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), ProviderPredicates + .contextWrappableAs(contextWrappableAs))); + } + + public static Iterable boundedByIso3166Code(String iso3166Code, + Class contextWrappableAs) { + return boundedByIso3166Code(iso3166Code, TypeToken.of(contextWrappableAs)); } /** - * Returns the providers that have at least one common ISO 3166 code in - * common regardless of type. + * Returns the providers that have at least one common ISO 3166 code in common regardless of + * contextWrappableAs. * * @param providerMetadata * the provider metadata to use to filter providers by * * @return the providers that share at least one common ISO 3166 code */ - public static Iterable> collocatedWith(ProviderMetadata providerMetadata) { + public static Iterable collocatedWith(ProviderMetadata providerMetadata) { return filter(all(), ProviderPredicates.intersectingIso3166Code(providerMetadata)); } /** - * Returns the providers that have at least one common ISO 3166 code and are - * of the given type. + * Returns the providers that have at least one common ISO 3166 code and are of the given + * contextWrappableAs. * * @param providerMetadata * the provider metadata to use to filter providers by - * @param type - * the type to filter providers by + * @param contextWrappableAs + * the contextWrappableAs to filter providers by * - * @return the providers that share at least one common ISO 3166 code and of - * the given type + * @return the providers that share at least one common ISO 3166 code and of the given + * contextWrappableAs */ - public static Iterable> collocatedWith(ProviderMetadata providerMetadata, - ApiType type) { - return filter(all(), - Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), ProviderPredicates.type(type))); + public static Iterable collocatedWith(ProviderMetadata providerMetadata, + TypeToken contextWrappableAs) { + return filter(all(), Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), + ProviderPredicates.contextWrappableAs(contextWrappableAs))); } + public static Iterable collocatedWith(ProviderMetadata providerMetadata, + Class contextWrappableAs) { + return collocatedWith(providerMetadata, TypeToken.of(contextWrappableAs)); + } } diff --git a/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java b/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java index 89376f9d23..3ad8d84a3c 100644 --- a/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.addAll; import static com.google.common.collect.Sets.newLinkedHashSet; -import java.io.Closeable; import java.net.URI; import java.util.Properties; import java.util.Set; @@ -33,32 +32,32 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; /** - * The BaseProviderMetadata class is an abstraction of {@link ProviderMetadata} - * to be extended by those implementing ProviderMetadata. + * The BaseProviderMetadata class is an abstraction of {@link ProviderMetadata} to be extended by + * those implementing ProviderMetadata. * - * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} - * to work properly. + * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} to work properly. * * @author Adrian Cole */ -public abstract class BaseProviderMetadata> - implements ProviderMetadata { +public abstract class BaseProviderMetadata implements ProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -6647397371073751922L; @Override - public ProviderMetadata.Builder toBuilder() { - return new BaseProviderMetadata.Builder().fromProviderMetadata(this); + public ProviderMetadata.Builder toBuilder() { + return new BaseProviderMetadata.Builder().fromProviderMetadata(this); } - public static class Builder> implements - ProviderMetadata.Builder { + public static class Builder implements ProviderMetadata.Builder { protected String id; protected String name; - protected M api; + protected ApiMetadata api; protected String endpoint; protected Properties defaultProperties = new Properties(); protected URI console; @@ -70,7 +69,7 @@ public abstract class BaseProviderMetadata id(String id) { + public Builder id(String id) { this.id = checkNotNull(id, "id"); return linkedService(id); } @@ -79,7 +78,7 @@ public abstract class BaseProviderMetadata name(String name) { + public Builder name(String name) { this.name = checkNotNull(name, "name"); return this; } @@ -88,7 +87,7 @@ public abstract class BaseProviderMetadata apiMetadata(M api) { + public Builder apiMetadata(ApiMetadata api) { this.api = checkNotNull(api, "api"); if (this.endpoint == null) this.endpoint = api.getDefaultEndpoint().orNull(); @@ -99,7 +98,7 @@ public abstract class BaseProviderMetadata endpoint(String endpoint) { + public Builder endpoint(String endpoint) { this.endpoint = checkNotNull(endpoint, "endpoint"); return this; } @@ -108,7 +107,7 @@ public abstract class BaseProviderMetadata defaultProperties(Properties defaultProperties) { + public Builder defaultProperties(Properties defaultProperties) { this.defaultProperties = checkNotNull(defaultProperties, "defaultProperties"); return this; } @@ -117,7 +116,7 @@ public abstract class BaseProviderMetadata console(@Nullable URI console) { + public Builder console(@Nullable URI console) { this.console = console; return this; } @@ -126,7 +125,7 @@ public abstract class BaseProviderMetadata homepage(URI homepage) { + public Builder homepage(URI homepage) { this.homepage = homepage; return this; } @@ -135,7 +134,7 @@ public abstract class BaseProviderMetadata linkedServices(Iterable linkedServices) { + public Builder linkedServices(Iterable linkedServices) { addAll(this.linkedServices, checkNotNull(linkedServices, "linkedServices")); return this; } @@ -144,7 +143,7 @@ public abstract class BaseProviderMetadata linkedServices(String... linkedServices) { + public Builder linkedServices(String... linkedServices) { return linkedServices(ImmutableSet.copyOf(checkNotNull(linkedServices, "linkedServices"))); } @@ -152,7 +151,7 @@ public abstract class BaseProviderMetadata linkedService(String linkedService) { + public Builder linkedService(String linkedService) { this.linkedServices.add(checkNotNull(linkedService, "linkedService")); return this; } @@ -161,7 +160,7 @@ public abstract class BaseProviderMetadata iso3166Codes(Iterable iso3166Codes) { + public Builder iso3166Codes(Iterable iso3166Codes) { addAll(this.iso3166Codes, checkNotNull(iso3166Codes, "iso3166Codes")); return this; } @@ -170,7 +169,7 @@ public abstract class BaseProviderMetadata iso3166Codes(String... iso3166Codes) { + public Builder iso3166Codes(String... iso3166Codes) { return iso3166Codes(ImmutableSet.copyOf(checkNotNull(iso3166Codes, "iso3166Codes"))); } @@ -178,7 +177,7 @@ public abstract class BaseProviderMetadata iso3166Code(String iso3166Code) { + public Builder iso3166Code(String iso3166Code) { this.iso3166Codes.add(checkNotNull(iso3166Code, "iso3166Code")); return this; } @@ -187,22 +186,25 @@ public abstract class BaseProviderMetadata fromProviderMetadata(ProviderMetadata in) { + public Builder fromProviderMetadata(ProviderMetadata in) { return id(in.getId()).name(in.getName()).apiMetadata(in.getApiMetadata()).endpoint(in.getEndpoint()) - .defaultProperties(in.getDefaultProperties()).console(in.getConsole().orNull()) - .homepage(in.getHomepage().orNull()).linkedServices(in.getLinkedServices()) - .iso3166Codes(in.getIso3166Codes()); + .defaultProperties(in.getDefaultProperties()).console(in.getConsole().orNull()).homepage( + in.getHomepage().orNull()).linkedServices(in.getLinkedServices()).iso3166Codes( + in.getIso3166Codes()); } @Override - public ProviderMetadata build() { - return new BaseProviderMetadata(this){}; + public ProviderMetadata build() { + return new BaseProviderMetadata(this) { + /** The serialVersionUID */ + private static final long serialVersionUID = 562451792167711326L; + }; } } protected final String id; protected final String name; - protected final M api; + protected final ApiMetadata api; protected final String endpoint; protected final Properties defaultProperties; protected final Optional homepage; @@ -210,14 +212,14 @@ public abstract class BaseProviderMetadata linkedServices; protected final Set iso3166Codes; - public BaseProviderMetadata(Builder builder) { + public BaseProviderMetadata(Builder builder) { this(builder.id, builder.name, builder.api, builder.endpoint, builder.defaultProperties, Optional - .fromNullable(builder.homepage), Optional.fromNullable(builder.console), builder.linkedServices, - builder.iso3166Codes); + .fromNullable(builder.homepage), Optional.fromNullable(builder.console), builder.linkedServices, + builder.iso3166Codes); } - public BaseProviderMetadata(String id, String name, M api, String endpoint, Properties defaultProperties, - Optional homepage, Optional console, Set linkedServices, Set iso3166Codes) { + public BaseProviderMetadata(String id, String name, ApiMetadata api, String endpoint, Properties defaultProperties, + Optional homepage, Optional console, Set linkedServices, Set iso3166Codes) { this.id = checkNotNull(id, "id"); this.name = checkNotNull(name, "name"); this.api = checkNotNull(api, "api"); @@ -237,9 +239,9 @@ public abstract class BaseProviderMetadata that = ProviderMetadata.class.cast(o); + ProviderMetadata that = ProviderMetadata.class.cast(o); return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) - && equal(this.getApiMetadata(), that.getApiMetadata()) && equal(this.getEndpoint(), that.getEndpoint()); + && equal(this.getApiMetadata(), that.getApiMetadata()) && equal(this.getEndpoint(), that.getEndpoint()); } @Override @@ -253,9 +255,9 @@ public abstract class BaseProviderMetadata extends BaseRestApiMetadata, AnonymousRestApiMetadata> { +public class AnonymousRestApiMetadata extends BaseRestApiMetadata { - public static AnonymousRestApiMetadata forClientMappedToAsyncClient(Class client, Class asyncClient) { - return new AnonymousRestApiMetadata(client, asyncClient); + /** The serialVersionUID */ + private static final long serialVersionUID = 5297549599879474202L; + + public static AnonymousRestApiMetadata forClientMappedToAsyncClient(Class client, Class asyncClient) { + return new AnonymousRestApiMetadata(client, asyncClient); } @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - public AnonymousRestApiMetadata(Class client, Class asyncClient) { - super(new Builder(client, asyncClient)); + public AnonymousRestApiMetadata(Class client, Class asyncClient) { + super(new Builder(client, asyncClient)); } - protected AnonymousRestApiMetadata(Builder builder) { + protected AnonymousRestApiMetadata(Builder builder) { super(builder); } - public static class Builder extends BaseRestApiMetadata.Builder, AnonymousRestApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { - public Builder(Class client, Class asyncClient) { + public Builder(Class client, Class asyncClient) { super(client, asyncClient); id(client.getSimpleName()) - .type(ApiType.UNRECOGNIZED) - .name(String.format("%s->%s", client.getSimpleName(), asyncClient.getSimpleName())) .identityName("unused") .defaultIdentity("foo") .version("1") @@ -64,12 +65,12 @@ public class AnonymousRestApiMetadata extends BaseRestApiMetadata build() { - return new AnonymousRestApiMetadata(this); + public AnonymousRestApiMetadata build() { + return new AnonymousRestApiMetadata(this); } @Override - public Builder fromApiMetadata(AnonymousRestApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/core/src/main/java/org/jclouds/rest/Providers.java b/core/src/main/java/org/jclouds/rest/Providers.java index fe395b9374..7056cfceec 100644 --- a/core/src/main/java/org/jclouds/rest/Providers.java +++ b/core/src/main/java/org/jclouds/rest/Providers.java @@ -20,11 +20,12 @@ package org.jclouds.rest; import java.io.Closeable; +import org.jclouds.Wrapper; import org.jclouds.apis.Apis; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; import com.google.common.reflect.TypeToken; /** @@ -39,7 +40,7 @@ public class Providers { * Gets a set of supported providers. Idea stolen from pallets (supported-clouds). */ public static Iterable getSupportedProviders() { - return getSupportedProvidersOfType(TypeToken.of(Closeable.class)); + return getSupportedProvidersOfType(TypeToken.of(Wrapper.class)); } /** @@ -47,10 +48,10 @@ public class Providers { * (supported-clouds). * */ - public static Iterable getSupportedProvidersOfType(TypeToken type) { + public static Iterable getSupportedProvidersOfType(TypeToken type) { Builder builder = ImmutableSet. builder(); - builder.addAll(Iterables.transform(Apis.contextAssignableFrom(type), Apis.idFunction())); - builder.addAll(Iterables.transform(org.jclouds.providers.Providers.contextAssignableFrom(type), + builder.addAll(Iterables.transform(Apis.contextWrappableAs(type), Apis.idFunction())); + builder.addAll(Iterables.transform(org.jclouds.providers.Providers.contextWrappableAs(type), org.jclouds.providers.Providers.idFunction())); return builder.build(); } diff --git a/core/src/main/java/org/jclouds/rest/RestApiMetadata.java b/core/src/main/java/org/jclouds/rest/RestApiMetadata.java index 84bd50d2f0..0fb450b674 100644 --- a/core/src/main/java/org/jclouds/rest/RestApiMetadata.java +++ b/core/src/main/java/org/jclouds/rest/RestApiMetadata.java @@ -21,6 +21,7 @@ package org.jclouds.rest; import org.jclouds.apis.ApiMetadata; import com.google.common.annotations.Beta; +import com.google.common.util.concurrent.ListenableFuture; /** * @@ -28,11 +29,27 @@ import com.google.common.annotations.Beta; * @since 1.5 */ @Beta -public interface RestApiMetadata, M extends RestApiMetadata> extends - ApiMetadata { +public interface RestApiMetadata extends ApiMetadata { - public static interface Builder, M extends RestApiMetadata> extends - ApiMetadata.Builder { + public static interface Builder extends ApiMetadata.Builder { + + /** + * @see ApiMetadata#getApi() + * @see ApiMetadata#getAsyncApi() + */ + Builder javaApi(Class api, Class asyncApi); } + /** + * + * @return the type of the api which blocks on all requests + */ + Class getApi(); + + /** + * + * @return the type of the api, which is the same as {@link #getApi}, except + * all methods return {@link ListenableFuture} + */ + Class getAsyncApi(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java deleted file mode 100644 index 7d5475b244..0000000000 --- a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.jclouds.rest; -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.NoSuchElementException; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -/** - * @author Adrian Cole - */ -public class RestContextBuilder, M extends RestApiMetadata> - extends ContextBuilder { - - /** - * looks up a provider or api with the given id - * - * @param providerOrApi - * id of the provider or api - * @return means to build a context to that provider - * @throws NoSuchElementException - * if the id was not configured. - * @throws IllegalArgumentException - * if the api or provider isn't assignable from RestContext - */ - public static RestContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { - ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); - checkArgument(builder instanceof RestContextBuilder, - "type of providerOrApi[%s] is not RestContextBuilder: %s", providerOrApi, builder); - return RestContextBuilder.class.cast(builder); - } - - public RestContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public RestContextBuilder(M apiMetadata) { - super(apiMetadata); - } -} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/RestContextFactory.java b/core/src/main/java/org/jclouds/rest/RestContextFactory.java index fbdf38ee09..b1f3ff0f98 100644 --- a/core/src/main/java/org/jclouds/rest/RestContextFactory.java +++ b/core/src/main/java/org/jclouds/rest/RestContextFactory.java @@ -21,13 +21,15 @@ package org.jclouds.rest; import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.ContextBuilder; +import org.jclouds.Wrapper; import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; import com.google.inject.Module; /** @@ -106,9 +108,9 @@ public class RestContextFactory { @SuppressWarnings("unchecked") public RestContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - ContextBuilder builder = null; + ContextBuilder builder = null; try { - ProviderMetadata pm = Providers.withId(providerOrApi); + ProviderMetadata pm = Providers.withId(providerOrApi); builder = ContextBuilder.newBuilder(pm); } catch (NoSuchElementException e) { builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); @@ -120,8 +122,9 @@ public class RestContextFactory { Object context = builder.build(); if (context instanceof RestContext) { return RestContext.class.cast(context); - } else if (context instanceof BackedByRestContext) { - return BackedByRestContext.class.cast(context).getProviderSpecificContext(); + } else if (context instanceof Wrapper) { + Wrapper tctx = Wrapper.class.cast(context); + return (RestContext) tctx.unwrap(TypeToken.of(RestContext.class)); } else { throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " + context.getClass().getSimpleName()); diff --git a/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java b/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java index bec37c601c..658c8581f5 100644 --- a/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java @@ -34,10 +34,10 @@ import com.google.inject.Provider; public class AsyncClientProvider implements Provider { @Inject Injector injector; - private final Class asyncClientType; + private final Class asyncClientType; @Inject - AsyncClientProvider(Class asyncClientType) { + AsyncClientProvider(Class asyncClientType) { this.asyncClientType = asyncClientType; } diff --git a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java index d64723f6b8..e3741f5b97 100644 --- a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java +++ b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java @@ -52,7 +52,7 @@ public class BinderUtils { * @param asyncClientType * interface for the async client */ - public static void bindClientAndAsyncClient(Binder binder, Class syncClientType, Class asyncClientType) { + public static void bindClientAndAsyncClient(Binder binder, Class syncClientType, Class asyncClientType) { bindClientAndAsyncClient(binder, syncClientType, asyncClientType, ImmutableMap., Class> of()); } @@ -75,7 +75,7 @@ public class BinderUtils { * presuming your clients are annotated with @Delegate, contains the sync to async * classes relating to these methods */ - public static void bindClientAndAsyncClient(Binder binder, Class syncClientType, Class asyncClientType, + public static void bindClientAndAsyncClient(Binder binder, Class syncClientType, Class asyncClientType, Map, Class> sync2Async) { bindClient(binder, syncClientType, asyncClientType, sync2Async); bindAsyncClient(binder, asyncClientType); diff --git a/core/src/main/java/org/jclouds/rest/config/ClientProvider.java b/core/src/main/java/org/jclouds/rest/config/ClientProvider.java index 86bf395ecd..7c52f37108 100644 --- a/core/src/main/java/org/jclouds/rest/config/ClientProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/ClientProvider.java @@ -47,12 +47,12 @@ import com.google.inject.name.Names; public class ClientProvider implements Provider { @Inject Injector injector; - private final Class syncClientType; - private final Class asyncClientType; + private final Class syncClientType; + private final Class asyncClientType; private final Map, Class> sync2Async; @Inject - ClientProvider(Class syncClientType, Class asyncClientType, Map, Class> sync2Async) { + ClientProvider(Class syncClientType, Class asyncClientType, Map, Class> sync2Async) { this.asyncClientType = asyncClientType; this.syncClientType = syncClientType; this.sync2Async = sync2Async; diff --git a/core/src/main/java/org/jclouds/rest/config/RestClientModule.java b/core/src/main/java/org/jclouds/rest/config/RestClientModule.java index 6622bfeed5..cf0cc4b3ac 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestClientModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestClientModule.java @@ -18,31 +18,13 @@ */ package org.jclouds.rest.config; -import java.net.URI; import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.http.RequiresHttp; -import org.jclouds.internal.ClassMethodArgs; -import org.jclouds.internal.ClassMethodArgsAndReturnVal; -import org.jclouds.location.config.LocationModule; -import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestContext; -import org.jclouds.rest.functions.ImplicitOptionalConverter; import org.jclouds.rest.internal.RestContextImpl; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Supplier; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableMap; -import com.google.inject.AbstractModule; -import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.util.Types; @@ -52,38 +34,26 @@ import com.google.inject.util.Types; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp -public class RestClientModule extends AbstractModule { - public final static TypeLiteral> URI_SUPPLIER_TYPE = new TypeLiteral>() { - }; - +public class RestClientModule extends RestModule { protected final Class asyncClientType; protected final Class syncClientType; - protected final Map, Class> sync2Async; - protected final AtomicReference authException = new AtomicReference(); - + public RestClientModule(Class syncClientType, Class asyncClientType, Map, Class> sync2Async) { + super(sync2Async); this.asyncClientType = asyncClientType; this.syncClientType = syncClientType; - this.sync2Async = sync2Async; } public RestClientModule(Class syncClientType, Class asyncClientType) { this(syncClientType, asyncClientType, ImmutableMap ., Class> of(syncClientType, asyncClientType)); } - - protected void installLocations() { - install(new LocationModule()); - } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings( { "unchecked", "rawtypes" }) @Override protected void configure() { - bind(new TypeLiteral>>(){}).to(ImplicitOptionalConverter.class); - // this will help short circuit scenarios that can otherwise lock out users - bind(new TypeLiteral>(){}).toInstance(authException); + super.configure(); // Ensures the restcontext can be looked up without generic types. bind(new TypeLiteral() { }).to( @@ -97,7 +67,6 @@ public class RestClientModule extends AbstractModule { bindClient(); bindErrorHandlers(); bindRetryHandlers(); - installLocations(); } /** @@ -144,14 +113,4 @@ public class RestClientModule extends AbstractModule { sync2Async); } - - @Provides - @Singleton - @Named("sync") - LoadingCache provideSyncDelegateMap( - CreateClientForCaller createClientForCaller) { - createClientForCaller.sync2Async = sync2Async; - return CacheBuilder.newBuilder().build(createClientForCaller); - } - } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/config/RestModule.java b/core/src/main/java/org/jclouds/rest/config/RestModule.java index d2f69384b3..429fd59571 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestModule.java @@ -18,6 +18,10 @@ */ package org.jclouds.rest.config; +import java.net.URI; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; + import javax.inject.Named; import javax.inject.Singleton; import javax.ws.rs.core.UriBuilder; @@ -31,7 +35,9 @@ import org.jclouds.http.TransformingHttpCommandImpl; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.internal.ClassMethodArgs; import org.jclouds.json.config.GsonModule; +import org.jclouds.location.config.LocationModule; import org.jclouds.rest.AsyncClientFactory; +import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.HttpAsyncClient; import org.jclouds.rest.HttpClient; import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith; @@ -40,6 +46,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.SeedAnnotationCache; import com.google.common.base.Function; +import com.google.common.base.Supplier; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -56,12 +63,25 @@ import com.google.inject.name.Names; import com.google.inject.util.Types; import com.sun.jersey.api.uri.UriBuilderImpl; -/** - * - * @author Adrian Cole - */ public class RestModule extends AbstractModule { + public static final TypeLiteral> URI_SUPPLIER_TYPE = new TypeLiteral>() { + }; + protected final Map, Class> sync2Async; + protected final AtomicReference authException = new AtomicReference(); + + public RestModule() { + this(ImmutableMap., Class> of()); + } + + public RestModule(Map, Class> sync2Async) { + this.sync2Async = sync2Async; + } + + protected void installLocations() { + install(new LocationModule()); + } + @Override protected void configure() { install(new SaxParserModule()); @@ -73,6 +93,10 @@ public class RestModule extends AbstractModule { BinderUtils.bindAsyncClient(binder(), HttpAsyncClient.class); BinderUtils.bindClient(binder(), HttpClient.class, HttpAsyncClient.class, ImmutableMap., Class> of( HttpClient.class, HttpAsyncClient.class)); + // this will help short circuit scenarios that can otherwise lock out users + bind(new TypeLiteral>() { + }).toInstance(authException); + installLocations(); } @Provides @@ -129,4 +153,12 @@ public class RestModule extends AbstractModule { } + @Provides + @Singleton + @Named("sync") + LoadingCache provideSyncDelegateMap(CreateClientForCaller createClientForCaller) { + createClientForCaller.sync2Async = sync2Async; + return CacheBuilder.newBuilder().build(createClientForCaller); + } + } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java index bc0e52fef1..2f2478a8c4 100644 --- a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java +++ b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java @@ -20,55 +20,121 @@ package org.jclouds.rest.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.rest.RestApiMetadata; import org.jclouds.rest.RestContext; import com.google.common.annotations.Beta; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; /** - * Useful in creating rest clients. + * Useful in creating rest apis. * * @author Adrian Cole */ @Beta -public class BaseRestApiMetadata, M extends RestApiMetadata> extends BaseApiMetadata - implements RestApiMetadata { +public class BaseRestApiMetadata extends BaseApiMetadata implements RestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 564135477427872712L; + + protected final Class api; + protected final Class asyncApi; - @SuppressWarnings("unchecked") @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata((M) this); + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - public BaseRestApiMetadata(Class client, Class asyncClient) { - super(new Builder(client, asyncClient)); + public BaseRestApiMetadata(Class api, Class asyncApi) { + super(new Builder(api, asyncApi)); + this.api = checkNotNull(api, "api"); + this.asyncApi = checkNotNull(asyncApi, "asyncApi"); } - protected BaseRestApiMetadata(Builder builder) { + protected BaseRestApiMetadata(Builder builder) { super(builder); + this.api = checkNotNull(builder.api, "api"); + this.asyncApi = checkNotNull(builder.asyncApi, "asyncApi"); } + + public static Properties defaultProperties() { + Properties props = BaseApiMetadata.defaultProperties(); + return props; + } + + public static class Builder extends BaseApiMetadata.Builder implements RestApiMetadata.Builder { + protected Class api; + protected Class asyncApi; - public static class Builder, M extends RestApiMetadata > extends - BaseApiMetadata.Builder implements RestApiMetadata.Builder { - - public Builder(Class client, Class asyncClient) { - checkNotNull(client, "client"); - checkNotNull(asyncClient, "asyncClient"); - javaApi(client, asyncClient); - } - - @SuppressWarnings("unchecked") - @Override - public M build() { - return (M) new BaseRestApiMetadata(this); + + public Builder(Class api, Class asyncApi) { + checkNotNull(api, "api"); + checkNotNull(asyncApi, "asyncApi"); + javaApi(api, asyncApi) + .name(String.format("%s->%s", api.getSimpleName(), asyncApi.getSimpleName())) + .context(contextToken(TypeToken.of(api), TypeToken.of(asyncApi))) + .defaultProperties(BaseRestApiMetadata.defaultProperties()); } + protected TypeToken> contextToken(TypeToken apiToken, TypeToken asyncApiToken) { + return new TypeToken>() { + private static final long serialVersionUID = 1L; + }.where(new TypeParameter() { + }, apiToken).where(new TypeParameter() { + }, asyncApiToken); + } + + /** + * {@inheritDoc} + */ @Override - public Builder fromApiMetadata(M in) { + public Builder javaApi(Class api, Class asyncApi) { + this.api = checkNotNull(api, "api"); + this.asyncApi = checkNotNull(asyncApi, "asyncApi"); + return this; + } + + + @Override + public ApiMetadata build() { + return new BaseRestApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(ApiMetadata in) { + if (in instanceof RestApiMetadata) { + RestApiMetadata rest = RestApiMetadata.class.cast(in); + javaApi(rest.getApi(), rest.getAsyncApi()); + } super.fromApiMetadata(in); return this; } + } + /** + * {@inheritDoc} + */ + @Override + public Class getApi() { + return api; + } + + /** + * {@inheritDoc} + */ + @Override + public Class getAsyncApi() { + return asyncApi; + } + + @Override + protected ToStringHelper string() { + return super.string().add("api", getApi()).add("asyncApi", getAsyncApi()); + } } diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties deleted file mode 100644 index d46966ddcc..0000000000 --- a/core/src/main/resources/rest.properties +++ /dev/null @@ -1,244 +0,0 @@ - -azurequeue.contextbuilder=org.jclouds.azure.storage.AzureStorageContextBuilder -azurequeue.sync=org.jclouds.azurequeue.AzureQueueClient -azurequeue.async=org.jclouds.azurequeue.AzureQueueAsyncClient -azurequeue.api-version=2009-09-19 -azurequeue.endpoint=https://${jclouds.identity}.queue.core.windows.net - -azureblob.contextbuilder=org.jclouds.azureblob.AzureBlobContextBuilder -azureblob.propertiesbuilder=org.jclouds.azureblob.AzureBlobPropertiesBuilder - -pcs.contextbuilder=org.jclouds.mezeo.pcs.PCSContextBuilder -pcs.propertiesbuilder=org.jclouds.mezeo.pcs.PCSPropertiesBuilder - -sdn.contextbuilder=org.jclouds.nirvanix.sdn.SDNContextBuilder -sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder - -aws-simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder -aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.AWSSimpleDBPropertiesBuilder - -aws-sqs.contextbuilder=org.jclouds.sqs.SQSContextBuilder -aws-sqs.propertiesbuilder=org.jclouds.aws.sqs.AWSSQSPropertiesBuilder - -elb.contextbuilder=org.jclouds.elb.ELBContextBuilder -elb.propertiesbuilder=org.jclouds.elb.ELBPropertiesBuilder - -aws-elb.contextbuilder=org.jclouds.elb.ELBContextBuilder -aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder - -cloudwatch.contextbuilder=org.jclouds.cloudwatch.CloudWatchContextBuilder -cloudwatch.propertiesbuilder=org.jclouds.cloudwatch.CloudWatchPropertiesBuilder - -aws-cloudwatch.contextbuilder=org.jclouds.cloudwatch.CloudWatchContextBuilder -aws-cloudwatch.propertiesbuilder=org.jclouds.aws.cloudwatch.AWSCloudWatchPropertiesBuilder - -aws-s3.contextbuilder=org.jclouds.aws.s3.AWSS3ContextBuilder -aws-s3.propertiesbuilder=org.jclouds.aws.s3.AWSS3PropertiesBuilder - -rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder -rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingPropertiesBuilder - -slicehost.contextbuilder=org.jclouds.slicehost.SlicehostContextBuilder -slicehost.propertiesbuilder=org.jclouds.slicehost.SlicehostPropertiesBuilder - -trmk-vcloudexpress.contextbuilder=org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressContextBuilder -trmk-vcloudexpress.propertiesbuilder=org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressPropertiesBuilder - -trmk-ecloud.contextbuilder=org.jclouds.trmk.ecloud.TerremarkECloudContextBuilder -trmk-ecloud.propertiesbuilder=org.jclouds.trmk.ecloud.TerremarkECloudPropertiesBuilder - -chef.contextbuilder=org.jclouds.chef.ChefContextBuilder -chef.propertiesbuilder=org.jclouds.chef.ChefPropertiesBuilder - -transientchef.contextbuilder=org.jclouds.chef.test.TransientChefContextBuilder -transientchef.propertiesbuilder=org.jclouds.chef.ChefPropertiesBuilder - -opscodeplatform.contextbuilder=org.jclouds.opscodeplatform.OpscodePlatformContextBuilder -opscodeplatform.propertiesbuilder=org.jclouds.opscodeplatform.OpscodePlatformPropertiesBuilder - -vcloud.contextbuilder=org.jclouds.vcloud.VCloudContextBuilder -vcloud.propertiesbuilder=org.jclouds.vcloud.VCloudPropertiesBuilder - -vcloud-director.contextbuilder=org.jclouds.vcloud.director.v1_5.VCloudDirectorContextBuilder -vcloud-director.propertiesbuilder=org.jclouds.vcloud.director.v1_5.VCloudDirectorPropertiesBuilder - -eucalyptus.contextbuilder=org.jclouds.ec2.EC2ContextBuilder -eucalyptus.propertiesbuilder=org.jclouds.eucalyptus.EucalyptusPropertiesBuilder - -openstack-nova-ec2.contextbuilder=org.jclouds.openstack.nova.ec2.NovaEC2ContextBuilder -openstack-nova-ec2.propertiesbuilder=org.jclouds.openstack.nova.ec2.NovaEC2PropertiesBuilder - -eucalyptus-partnercloud-ec2.contextbuilder=org.jclouds.epc.EucalyptusPartnerCloudContextBuilder -eucalyptus-partnercloud-ec2.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudPropertiesBuilder - -nova.contextbuilder=org.jclouds.openstack.nova.NovaContextBuilder -nova.propertiesbuilder=org.jclouds.openstack.nova.NovaPropertiesBuilder - -openstack-nova.contextbuilder=org.jclouds.openstack.nova.v1_1.NovaContextBuilder -openstack-nova.propertiesbuilder=org.jclouds.openstack.nova.v1_1.NovaPropertiesBuilder - -cloudservers.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder -cloudservers.propertiesbuilder=org.jclouds.cloudservers.CloudServersPropertiesBuilder - -cloudservers-uk.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder -cloudservers-uk.propertiesbuilder=org.jclouds.rackspace.cloudservers.CloudServersUKPropertiesBuilder - -cloudservers-us.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder -cloudservers-us.propertiesbuilder=org.jclouds.rackspace.cloudservers.CloudServersUSPropertiesBuilder - -bluelock-vcloud-zone01.contextbuilder=org.jclouds.bluelock.vcloud.zone01.BluelockVCloudZone01ContextBuilder -bluelock-vcloud-zone01.propertiesbuilder=org.jclouds.bluelock.vcloud.zone01.BluelockVCloudZone01PropertiesBuilder - -stratogen-vcloud-mycloud.contextbuilder=org.jclouds.stratogen.vcloud.mycloud.StratoGenVCloudMyCloudContextBuilder -stratogen-vcloud-mycloud.propertiesbuilder=org.jclouds.stratogen.vcloud.mycloud.StratoGenVCloudMyCloudPropertiesBuilder - -greenhousedata-element-vcloud.contextbuilder=org.jclouds.greenhousedata.element.vcloud.GreenHouseDataElementVCloudContextBuilder -greenhousedata-element-vcloud.propertiesbuilder=org.jclouds.greenhousedata.element.vcloud.GreenHouseDataElementVCloudPropertiesBuilder - -gogrid.propertiesbuilder=org.jclouds.gogrid.GoGridPropertiesBuilder -gogrid.contextbuilder=org.jclouds.gogrid.GoGridContextBuilder - -deltacloud.propertiesbuilder=org.jclouds.deltacloud.DeltacloudPropertiesBuilder -deltacloud.contextbuilder=org.jclouds.deltacloud.DeltacloudContextBuilder - -elasticstack.propertiesbuilder=org.jclouds.elasticstack.ElasticStackPropertiesBuilder -elasticstack.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder -elasticstack.api-version=1.0 - -elastichosts-lon-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1LondonPropertiesBuilder -elastichosts-lon-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -elastichosts-lon-b.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsBlueSquareLondonPropertiesBuilder -elastichosts-lon-b.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -elastichosts-sat-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1SanAntonioPropertiesBuilder -elastichosts-sat-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -elastichosts-tor-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1TorontoPropertiesBuilder -elastichosts-tor-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -elastichosts-lax-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1LosAngelesPropertiesBuilder -elastichosts-lax-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -skalicloud-sdg-my.propertiesbuilder=org.jclouds.skalicloud.SkaliCloudMalaysiaPropertiesBuilder -skalicloud-sdg-my.contextbuilder=org.jclouds.skalicloud.SkaliCloudMalaysiaContextBuilder - -serverlove-z1-man.propertiesbuilder=org.jclouds.serverlove.ServerloveManchesterPropertiesBuilder -serverlove-z1-man.contextbuilder=org.jclouds.serverlove.ServerloveManchesterContextBuilder - -openhosting-east1.propertiesbuilder=org.jclouds.openhosting.OpenHostingEast1PropertiesBuilder -openhosting-east1.contextbuilder=org.jclouds.openhosting.OpenHostingEast1ContextBuilder - -go2cloud-jhb1.propertiesbuilder=org.jclouds.go2cloud.Go2CloudJohannesburg1PropertiesBuilder -go2cloud-jhb1.contextbuilder=org.jclouds.go2cloud.Go2CloudJohannesburg1ContextBuilder - -cloudsigma.propertiesbuilder=org.jclouds.cloudsigma.CloudSigmaPropertiesBuilder -cloudsigma.contextbuilder=org.jclouds.cloudsigma.CloudSigmaContextBuilder - -cloudsigma-zrh.propertiesbuilder=org.jclouds.cloudsigma.CloudSigmaZurichPropertiesBuilder -cloudsigma-zrh.contextbuilder=org.jclouds.cloudsigma.CloudSigmaZurichContextBuilder - -cloudsigma-lvs.propertiesbuilder=org.jclouds.cloudsigma.CloudSigmaLasVegasPropertiesBuilder -cloudsigma-lvs.contextbuilder=org.jclouds.cloudsigma.CloudSigmaContextBuilder - -ibm-smartcloud.propertiesbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudPropertiesBuilder -ibm-smartcloud.contextbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudContextBuilder - -virtacore-publiccloud-lax.propertiesbuilder=org.jclouds.virtacore.publiccloud.VirtacorePublicCloudLAXPropertiesBuilder -virtacore-publiccloud-lax.contextbuilder=org.jclouds.virtacore.publiccloud.VirtacorePublicCloudLAXContextBuilder - -dunkel-vcd.propertiesbuilder=org.jclouds.dunkel.vcd.DunkelVCloudDirectorPropertiesBuilder -dunkel-vcd.contextbuilder=org.jclouds.dunkel.vcd.DunkelVCloudDirectorContextBuilder - -# example of where to change your endpoint -# bluelock.endpoint=https://express3.bluelock.com/api - -atmos.contextbuilder=org.jclouds.atmos.AtmosContextBuilder -atmos.endpoint=https://accesspoint.atmosonline.com -atmos.api-version=1.3.0 - -synaptic-storage.contextbuilder=org.jclouds.atmos.AtmosContextBuilder -synaptic-storage.propertiesbuilder=org.jclouds.synaptic.storage.SynapticStoragePropertiesBuilder - -ninefold-storage.contextbuilder=org.jclouds.atmos.AtmosContextBuilder -ninefold-storage.propertiesbuilder=org.jclouds.ninefold.storage.NinefoldStoragePropertiesBuilder - -ninefold-compute.contextbuilder=org.jclouds.ninefold.compute.NinefoldComputeContextBuilder -ninefold-compute.propertiesbuilder=org.jclouds.ninefold.compute.NinefoldComputePropertiesBuilder - -cloudonestorage.contextbuilder=org.jclouds.atmos.AtmosContextBuilder -cloudonestorage.propertiesbuilder=org.jclouds.cloudonestorage.CloudOneStoragePropertiesBuilder - -# TODO hostedsolutions use atmos - -swift.contextbuilder=org.jclouds.openstack.swift.SwiftContextBuilder -swift.propertiesbuilder=org.jclouds.openstack.swift.SwiftPropertiesBuilder - -cloudstack.contextbuilder=org.jclouds.cloudstack.CloudStackContextBuilder -cloudstack.propertiesbuilder=org.jclouds.cloudstack.CloudStackPropertiesBuilder - -softlayer.contextbuilder=org.jclouds.softlayer.SoftLayerContextBuilder -softlayer.propertiesbuilder=org.jclouds.softlayer.SoftLayerPropertiesBuilder - -glesys.contextbuilder=org.jclouds.glesys.GleSYSContextBuilder -glesys.propertiesbuilder=org.jclouds.glesys.GleSYSPropertiesBuilder - -opsource-servers.contextbuilder=org.jclouds.opsource.servers.OpSourceServersContextBuilder -opsource-servers.propertiesbuilder=org.jclouds.opsource.servers.OpSourceServersPropertiesBuilder - -savvis-symphonyvpdc.contextbuilder=org.jclouds.savvis.vpdc.VPDCContextBuilder -savvis-symphonyvpdc.propertiesbuilder=org.jclouds.savvis.vpdc.VPDCPropertiesBuilder - -cloudloadbalancers.contextbuilder=org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder -cloudloadbalancers.propertiesbuilder=org.jclouds.cloudloadbalancers.CloudLoadBalancersPropertiesBuilder - -cloudloadbalancers-us.contextbuilder=org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder -cloudloadbalancers-us.propertiesbuilder=org.jclouds.rackspace.cloudloadbalancers.CloudLoadBalancersUSPropertiesBuilder - -cloudloadbalancers-uk.contextbuilder=org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder -cloudloadbalancers-uk.propertiesbuilder=org.jclouds.rackspace.cloudloadbalancers.CloudLoadBalancersUKPropertiesBuilder - -cloudfiles.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder -cloudfiles.propertiesbuilder=org.jclouds.cloudfiles.CloudFilesPropertiesBuilder - -cloudfiles-us.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder -cloudfiles-us.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUSPropertiesBuilder - -cloudfiles-uk.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder -cloudfiles-uk.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUKPropertiesBuilder - -walrus.contextbuilder=org.jclouds.walrus.WalrusContextBuilder -walrus.propertiesbuilder=org.jclouds.walrus.WalrusPropertiesBuilder - -eucalyptus-partnercloud-s3.contextbuilder=org.jclouds.walrus.WalrusContextBuilder -eucalyptus-partnercloud-s3.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudWalrusPropertiesBuilder - -googlestorage.contextbuilder=org.jclouds.googlestorage.GoogleStorageContextBuilder -googlestorage.propertiesbuilder=org.jclouds.googlestorage.GoogleStoragePropertiesBuilder - -scality-rs2.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder -scality-rs2.propertiesbuilder=org.jclouds.scality.rs2.ScalityRS2PropertiesBuilder - -scaleup-storage.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder -scaleup-storage.propertiesbuilder=org.jclouds.scaleup.storage.ScaleUpStoragePropertiesBuilder - -hosteurope-storage.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder -hosteurope-storage.propertiesbuilder=org.jclouds.hosteurope.storage.HostEuropeStoragePropertiesBuilder - -tiscali-storage.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder -tiscali-storage.propertiesbuilder=org.jclouds.tiscali.storage.TiscaliStoragePropertiesBuilder - -virtualbox.contextbuilder=org.jclouds.virtualbox.VirtualBoxContextBuilder -virtualbox.propertiesbuilder=org.jclouds.virtualbox.VirtualBoxPropertiesBuilder - -filesystem.contextbuilder=org.jclouds.filesystem.FilesystemBlobStoreContextBuilder -filesystem.propertiesbuilder=org.jclouds.filesystem.FilesystemBlobStorePropertiesBuilder - -hpcloud-objectstorage.contextbuilder=org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageContextBuilder -hpcloud-objectstorage.propertiesbuilder=org.jclouds.hpcloud.objectstorage.HPCloudObjectStoragePropertiesBuilder - -hpcloud-compute.contextbuilder=org.jclouds.hpcloud.compute.HPCloudComputeContextBuilder -hpcloud-compute.propertiesbuilder=org.jclouds.hpcloud.compute.HPCloudComputePropertiesBuilder - -trystack-nova.contextbuilder=org.jclouds.trystack.nova.TryStackNovaContextBuilder -trystack-nova.propertiesbuilder=org.jclouds.trystack.nova.TryStackNovaPropertiesBuilder diff --git a/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java b/core/src/test/java/org/jclouds/ContextBuilderTest.java similarity index 83% rename from core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java rename to core/src/test/java/org/jclouds/ContextBuilderTest.java index f8884dc320..3d2d4a2ae0 100644 --- a/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java +++ b/core/src/test/java/org/jclouds/ContextBuilderTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest.internal; +package org.jclouds; import static org.testng.Assert.assertEquals; @@ -28,7 +28,6 @@ import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.events.config.EventBusModule; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.config.LoggingModule; @@ -60,7 +59,7 @@ public class ContextBuilderTest { } } - private ContextBuilder testContextBuilder() { + private ContextBuilder testContextBuilder() { return ContextBuilder.newBuilder(AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost")); } @@ -122,7 +121,7 @@ public class ContextBuilderTest { modules.add(loggingModule); HttpModule httpModule = new HttpModule(); modules.add(httpModule); - ContextBuilder builder = testContextBuilder(); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); @@ -130,18 +129,6 @@ public class ContextBuilderTest { assertEquals(modules.remove(0), httpModule); } - @Test - public void testAddBothWhenDoesntRequireHttp() { - List modules = new ArrayList(); - modules.add(new ConfiguresClientModule()); - ContextBuilder builder = testContextBuilder(); - builder.addHttpModuleIfNeededAndNotPresent(modules); - builder.addLoggingModuleIfNotPresent(modules); - assertEquals(modules.size(), 2); - assert modules.remove(0) instanceof ConfiguresClientModule; - assert modules.remove(0) instanceof JDKLoggingModule; - } - @ConfiguresRestClient static class ConfiguresClientModule implements Module { @@ -153,7 +140,7 @@ public class ContextBuilderTest { @Test public void testAddBothWhenDefault() { List modules = new ArrayList(); - ContextBuilder builder = testContextBuilder(); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); @@ -161,23 +148,13 @@ public class ContextBuilderTest { assert modules.remove(0) instanceof JDKLoggingModule; } - @RequiresHttp - class RequiresHttpModule implements Module { - - public void configure(Binder arg0) { - } - - } - @Test public void testAddBothWhenLive() { List modules = new ArrayList(); - modules.add(new RequiresHttpModule()); - ContextBuilder builder = testContextBuilder(); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); - assertEquals(modules.size(), 3); - assert modules.remove(0) instanceof RequiresHttpModule; + assertEquals(modules.size(), 2); assert modules.remove(0) instanceof JavaUrlHttpCommandExecutorServiceModule; assert modules.remove(0) instanceof JDKLoggingModule; } @@ -196,7 +173,7 @@ public class ContextBuilderTest { protected void configure() { } }; - ContextBuilder builder = testContextBuilder(); + ContextBuilder builder = testContextBuilder(); builder.modules(Arrays.asList(module1, module2)); } diff --git a/core/src/test/java/org/jclouds/apis/ApisTest.java b/core/src/test/java/org/jclouds/apis/ApisTest.java index ba6d2f5e35..211837360c 100644 --- a/core/src/test/java/org/jclouds/apis/ApisTest.java +++ b/core/src/test/java/org/jclouds/apis/ApisTest.java @@ -40,7 +40,7 @@ public class ApisTest { @Test public void testWithId() { - ApiMetadata apiMetadata; + ApiMetadata apiMetadata; try { apiMetadata = Apis.withId("fake-id"); fail("Looking for a api with an id that doesn't exist should " + "throw an exceptoin."); @@ -54,16 +54,16 @@ public class ApisTest { } @Test - public void testOfType() { - Iterable> apisMetadata = Apis.ofType(ApiType.BLOBSTORE); + public void testTransformableTo() { + Iterable apisMetadata = Apis.contextWrappableAs(Storage.class); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { assertEquals(testBlobstoreApi, apiMetadata); } - apisMetadata = Apis.ofType(ApiType.COMPUTE); + apisMetadata = Apis.contextWrappableAs(Compute.class); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { if (apiMetadata.getName().equals(testComputeApi.getName())) { assertEquals(testComputeApi, apiMetadata); } else { @@ -71,16 +71,16 @@ public class ApisTest { } } - apisMetadata = Apis.ofType(ApiType.UNRECOGNIZED); + apisMetadata = Apis.contextWrappableAs(Balancer.class); assertEquals(false, apisMetadata.iterator().hasNext()); } @Test public void testAll() { - Iterable> apisMetadata = Apis.all(); + Iterable apisMetadata = Apis.all(); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { if (apiMetadata.getName().equals(testBlobstoreApi.getName())) { assertEquals(testBlobstoreApi, apiMetadata); } else if (apiMetadata.getName().equals(testComputeApi.getName())) { diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/config/BluelockVCloudZone01RestClientModule.java b/core/src/test/java/org/jclouds/apis/Balancer.java similarity index 64% rename from providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/config/BluelockVCloudZone01RestClientModule.java rename to core/src/test/java/org/jclouds/apis/Balancer.java index 07478f8f96..1b6fe0be48 100644 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/config/BluelockVCloudZone01RestClientModule.java +++ b/core/src/test/java/org/jclouds/apis/Balancer.java @@ -16,19 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.bluelock.vcloud.zone01.config; +package org.jclouds.apis; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.config.VCloudRestClientModule; +import java.io.Closeable; + +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; +import com.google.inject.Inject; /** - * Configures the VCloud authentication service connection, including logging and http transport. - * - * @author Adrian Cole + * For tests */ -@RequiresHttp -@ConfiguresRestClient -public class BluelockVCloudZone01RestClientModule extends VCloudRestClientModule { +public class Balancer extends BaseWrapper { + @Inject + public Balancer(@Provider Closeable ctx, @Provider TypeToken inputType) { + super(ctx, inputType); + } } diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java b/core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java similarity index 86% rename from core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java rename to core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java index edb136f225..f71ac1e121 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java +++ b/core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest.internal; +package org.jclouds.apis; import static com.google.common.base.Preconditions.checkNotNull; @@ -26,6 +26,7 @@ import java.util.Properties; import java.util.logging.Logger; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.Apis; import org.jclouds.logging.LoggingModules; @@ -37,6 +38,7 @@ import org.testng.annotations.BeforeClass; import com.google.common.collect.ImmutableSet; import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; import com.google.inject.Module; /** @@ -96,10 +98,9 @@ public abstract class BaseContextLiveTest { /** * @see org.jclouds.providers.Providers#withId */ - @SuppressWarnings("unchecked") - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { try { - return (ProviderMetadata) Providers.withId(provider); + return Providers.withId(provider); } catch (NoSuchElementException e) { return null; } @@ -108,24 +109,24 @@ public abstract class BaseContextLiveTest { /** * @see org.jclouds.apis.Apis#withId */ - @SuppressWarnings("unchecked") - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { try { - return (ApiMetadata) Apis.withId(provider); + return (ApiMetadata) Apis.withId(provider); } catch (NoSuchElementException e) { return null; } } + protected abstract TypeToken contextType(); + protected C createContext(Properties props, Iterable modules) { - return newBuilder().modules(modules).overrides(props).build(); + return newBuilder().modules(modules).overrides(props).build(contextType()); } - @SuppressWarnings("unchecked") - protected ContextBuilder newBuilder() { + protected ContextBuilder newBuilder() { if (provider != null) try { - return (ContextBuilder) ContextBuilder.newBuilder(provider); + return (ContextBuilder) ContextBuilder.newBuilder(provider); } catch (NoSuchElementException e){ Logger.getAnonymousLogger() .warning("provider [" @@ -133,9 +134,9 @@ public abstract class BaseContextLiveTest { + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata"); } - ProviderMetadata pm = createProviderMetadata(); + ProviderMetadata pm = createProviderMetadata(); - ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder + ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder .newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(), "either createApiMetadata or createProviderMetadata must be overridden"))); return builder; diff --git a/core/src/main/java/org/jclouds/rest/BackedByRestContext.java b/core/src/test/java/org/jclouds/apis/Compute.java similarity index 68% rename from core/src/main/java/org/jclouds/rest/BackedByRestContext.java rename to core/src/test/java/org/jclouds/apis/Compute.java index a595b334dc..41bbc31787 100644 --- a/core/src/main/java/org/jclouds/rest/BackedByRestContext.java +++ b/core/src/test/java/org/jclouds/apis/Compute.java @@ -16,22 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest; +package org.jclouds.apis; -import com.google.common.annotations.Beta; +import java.io.Closeable; + +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; /** - * - * - * @author Adrian Cole - * + * For tests */ -@Beta -public interface BackedByRestContext { - /** - * - * @return a context you can use to the access provider or vendor specific - * api underlying this context. - */ - RestContext getProviderSpecificContext(); -} \ No newline at end of file +public class Compute extends BaseWrapper { + + public Compute(@Provider Closeable ctx, @Provider TypeToken inputType) { + super(ctx, inputType); + } +} diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java index 21d2c88e4a..ad9fab58cd 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java @@ -20,19 +20,19 @@ package org.jclouds.apis; import java.net.URI; -import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock , Adrian Cole */ -public class JcloudsTestBlobStoreApiMetadata - extends - BaseApiMetadata, JcloudsTestBlobStoreApiMetadata> { +public class JcloudsTestBlobStoreApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1178177610797635012L; public static Builder builder() { return new Builder(); @@ -53,13 +53,13 @@ public class JcloudsTestBlobStoreApiMetadata public static class Builder extends - BaseApiMetadata.Builder, JcloudsTestBlobStoreApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder(){ + super(IntegrationTestClient.class, IntegrationTestAsyncClient.class); id("test-blobstore-api") - .type(ApiType.BLOBSTORE) + .wrapper(Storage.class) .name("Test Blobstore Api") - .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) .identityName("user") .credentialName("password") .documentation(URI.create("http://jclouds.org/documentation")); diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java index 99addc6a57..990ca48d01 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java @@ -20,17 +20,19 @@ package org.jclouds.apis; import java.net.URI; -import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock , Adrian Cole */ -public class JcloudsTestComputeApiMetadata extends BaseApiMetadata, JcloudsTestComputeApiMetadata>{ +public class JcloudsTestComputeApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 4781483190708679197L; public static Builder builder() { return new Builder(); @@ -49,15 +51,13 @@ public class JcloudsTestComputeApiMetadata extends BaseApiMetadata, JcloudsTestComputeApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder(){ + super(IntegrationTestClient.class, IntegrationTestAsyncClient.class); id("test-compute-api") - .type(ApiType.COMPUTE) + .wrapper(Compute.class) .name("Test Compute Api") - .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) .identityName("user") .credentialName("password") .documentation(URI.create("http://jclouds.org/documentation")); diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java index ad36f40fe4..530629d212 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java @@ -20,19 +20,19 @@ package org.jclouds.apis; import java.net.URI; -import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock */ -public class JcloudsTestYetAnotherComputeApiMetadata - extends - BaseApiMetadata, JcloudsTestYetAnotherComputeApiMetadata> { +public class JcloudsTestYetAnotherComputeApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3142126601795295510L; public static Builder builder() { return new Builder(); @@ -51,13 +51,13 @@ public class JcloudsTestYetAnotherComputeApiMetadata super(builder); } - public static class Builder extends BaseApiMetadata.Builder, JcloudsTestYetAnotherComputeApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder(){ + super(IntegrationTestClient.class, IntegrationTestAsyncClient.class); id("test-yet-another-compute-api") - .type(ApiType.COMPUTE) + .wrapper(Compute.class) .name("Test Yet Another Compute Api") - .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) .identityName("user") .credentialName("password") .documentation(URI.create("http://jclouds.org/documentation")); diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/config/StratoGenVCloudMyCloudRestClientModule.java b/core/src/test/java/org/jclouds/apis/Storage.java similarity index 64% rename from providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/config/StratoGenVCloudMyCloudRestClientModule.java rename to core/src/test/java/org/jclouds/apis/Storage.java index 27ffdbfd33..b16df9976e 100644 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/config/StratoGenVCloudMyCloudRestClientModule.java +++ b/core/src/test/java/org/jclouds/apis/Storage.java @@ -16,19 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.stratogen.vcloud.mycloud.config; +package org.jclouds.apis; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.config.VCloudRestClientModule; +import java.io.Closeable; + +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; +import com.google.inject.Inject; /** - * Configures the VCloud authentication service connection, including logging and http transport. - * - * @author Adrian Cole + * For tests */ -@RequiresHttp -@ConfiguresRestClient -public class StratoGenVCloudMyCloudRestClientModule extends VCloudRestClientModule { +public class Storage extends BaseWrapper { + @Inject + public Storage(@Provider Closeable ctx, @Provider TypeToken inputType) { + super(ctx, inputType); + } } diff --git a/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java b/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java index 95addda38b..e8c95de2ed 100644 --- a/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java +++ b/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java @@ -20,46 +20,51 @@ package org.jclouds.apis.internal; import static org.testng.Assert.assertEquals; +import java.util.Set; + +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.apis.Apis; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; /** * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "unit") public abstract class BaseApiMetadataTest { protected final ApiMetadata toTest; - protected final ApiType expectedType; + protected final Set> wrappers; - public BaseApiMetadataTest(ApiMetadata toTest, ApiType expectedType) { + public BaseApiMetadataTest(ApiMetadata toTest, Set> wrappers) { this.toTest = toTest; - this.expectedType = expectedType; + this.wrappers = wrappers; } @Test public void testWithId() { - ApiMetadata apiMetadata = Apis.withId(toTest.getId()); + ApiMetadata apiMetadata = Apis.withId(toTest.getId()); assertEquals(toTest, apiMetadata); } // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) @Test - public void testOfTypeContains() { - ImmutableSet> ofType = ImmutableSet.copyOf(Apis.ofType(expectedType)); - assert ofType.contains(toTest) : String.format("%s not found in %s", toTest, ofType); + public void testTransformableToContains() { + for (TypeToken wrapper : wrappers) { + ImmutableSet ofType = ImmutableSet.copyOf(Apis.contextWrappableAs(wrapper)); + assert ofType.contains(toTest) : String.format("%s not found in %s for %s", toTest, ofType, + wrapper); + } } @Test public void testAllContains() { - ImmutableSet> all = ImmutableSet.copyOf(Apis.all()); + ImmutableSet all = ImmutableSet.copyOf(Apis.all()); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index c08596437d..efff2057df 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -51,11 +51,11 @@ import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.crypto.CryptoStreams; import org.jclouds.io.InputSuppliers; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.util.Strings2; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; @@ -280,12 +280,10 @@ public abstract class BaseJettyTest { return temp; } - public static ContextBuilder, ?> newBuilder( - int testPort, Properties properties, Module... connectionModules) { + public static ContextBuilder newBuilder(int testPort, Properties properties, Module... connectionModules) { properties.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - return ContextBuilder - .newBuilder( + return ContextBuilder.newBuilder( AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost:" + testPort)) .modules(ImmutableSet. copyOf(connectionModules)) diff --git a/core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java b/core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java deleted file mode 100644 index ded537cd9c..0000000000 --- a/core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.http; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.testng.annotations.Test; - -/** - * Tests behavior of modules configured in HttpPropertiesBuilder - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class HttpPropertiesBuilderTest { - - public void testBuilder() { - int httpMaxRetries = 9875; - int poolIoWorkerThreads = 2727; - int poolMaxClientReuse = 3932; - int poolMaxClients = 3382; - int poolMaxSessionFailures = 857; - - PropertiesBuilder builder = new PropertiesBuilder(new Properties()); - builder.withMaxRetries(httpMaxRetries); - - builder.limitIoWorkerThreadsTo(poolIoWorkerThreads); - builder.withMaxClientReuse(poolMaxClientReuse); - builder.limitConnectionsPerHostTo(poolMaxClients); - builder.withMaxSessionFailures(poolMaxSessionFailures); - } -} diff --git a/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java b/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java index 1eed674207..989eaa25d4 100644 --- a/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java @@ -89,7 +89,7 @@ public class IntegrationTestClientExpectTest extends BaseRestClientExpectTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new JcloudsTestBlobStoreProviderMetadata(); } } diff --git a/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java b/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java index db921672db..0ddaa4d482 100644 --- a/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java +++ b/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java @@ -25,24 +25,22 @@ import static org.easymock.EasyMock.verify; import java.net.URI; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.ContextBuilder; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.config.RestModule; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; +import com.google.common.collect.ImmutableSet; import com.google.inject.Injector; -import com.google.inject.Provides; +import com.google.inject.Module; /** * Tests behavior of {@code RedirectionRetryHandler} @@ -51,19 +49,10 @@ import com.google.inject.Provides; */ @Test(groups = "unit") public class RedirectionRetryHandlerTest { - Injector injector = Guice.createInjector(new MockModule(), new RestModule(), new AbstractModule() { - @SuppressWarnings("unused") - @Provides - @Singleton - @Named("CONSTANTS") - protected Multimap constants() { - return LinkedHashMultimap.create(); - } - - @Override - protected void configure() { - } - }); + Injector injector = ContextBuilder.newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, + IntegrationTestAsyncClient.class, "http://localhost")).modules( + ImmutableSet. of(new MockModule())).buildInjector(); @Test public void test302DoesNotRetry() { diff --git a/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java b/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java new file mode 100644 index 0000000000..ebda6dfbbe --- /dev/null +++ b/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java @@ -0,0 +1,79 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.internal; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; + +import java.io.Closeable; + +import org.testng.annotations.Test; + +import com.google.common.base.Objects; +import com.google.common.reflect.TypeToken; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "BaseWrapperTest") +public class BaseWrapperTest { + private static class Water implements Closeable { + + @Override + public void close() { + } + @Override + public boolean equals(Object in){ + return Objects.equal(in.getClass(), getClass()); + } + } + + private static interface PeanutButter extends Closeable { + + @Override + void close(); + } + + private static class Wine extends BaseWrapper { + + protected Wine() { + super(new Water(), TypeToken.of(Water.class)); + } + } + + public void testWaterTurnedIntoWine() { + Wine wine = new Wine(); + assertEquals(wine.getWrappedType(), TypeToken.of(Water.class)); + assertEquals(wine.unwrap(TypeToken.of(Water.class)), new Water()); + assertEquals(wine.unwrap(), new Water()); + } + + public void testPeanutButterDidntTurnIntoWine() { + Wine wine = new Wine(); + assertNotEquals(wine.getWrappedType(), TypeToken.of(PeanutButter.class)); + try { + wine.unwrap(TypeToken.of(PeanutButter.class)); + assertFalse(true); + } catch (IllegalArgumentException e) { + assertEquals(e.getMessage(), "wrapped type: org.jclouds.internal.BaseWrapperTest$Water not assignable from org.jclouds.internal.BaseWrapperTest$PeanutButter"); + } + } + +} diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java index c04305de97..17e9eb6150 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestBlobStoreApiMetadata; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -33,9 +30,10 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestBlobStoreProviderMetadata - extends - BaseProviderMetadata, JcloudsTestBlobStoreApiMetadata> { +public class JcloudsTestBlobStoreProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3444555273226423853L; public static Builder builder() { return new Builder(); @@ -54,9 +52,7 @@ public class JcloudsTestBlobStoreProviderMetadata super(builder); } - public static class Builder - extends - BaseProviderMetadata.Builder, JcloudsTestBlobStoreApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("test-blobstore-api") diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java index 60fc513520..36f02db52a 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestComputeApiMetadata; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -33,10 +30,11 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestComputeProviderMetadata - extends - BaseProviderMetadata, JcloudsTestComputeApiMetadata> { +public class JcloudsTestComputeProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 424799830416415960L; + public static Builder builder() { return new Builder(); } @@ -54,9 +52,7 @@ public class JcloudsTestComputeProviderMetadata super(builder); } - public static class Builder - extends - BaseProviderMetadata.Builder, JcloudsTestComputeApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("test-compute-api") diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java index 388ebc9cc1..f72285fe9e 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestComputeApiMetadata; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -33,10 +30,11 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestYetAnotherComputeProviderMetadata - extends - BaseProviderMetadata, JcloudsTestComputeApiMetadata> { +public class JcloudsTestYetAnotherComputeProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } @@ -54,9 +52,7 @@ public class JcloudsTestYetAnotherComputeProviderMetadata super(builder); } - public static class Builder - extends - BaseProviderMetadata.Builder, JcloudsTestComputeApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("test-yet-another-compute-provider") diff --git a/core/src/test/java/org/jclouds/providers/ProvidersTest.java b/core/src/test/java/org/jclouds/providers/ProvidersTest.java index 5f6f841d75..465421ee62 100644 --- a/core/src/test/java/org/jclouds/providers/ProvidersTest.java +++ b/core/src/test/java/org/jclouds/providers/ProvidersTest.java @@ -24,7 +24,9 @@ import static org.testng.Assert.fail; import java.util.NoSuchElementException; -import org.jclouds.apis.ApiType; +import org.jclouds.apis.Balancer; +import org.jclouds.apis.Compute; +import org.jclouds.apis.Storage; import org.testng.annotations.Test; import com.google.common.collect.Iterables; @@ -43,7 +45,7 @@ public class ProvidersTest { @Test public void testWithId() { - ProviderMetadata providerMetadata; + ProviderMetadata providerMetadata; try { providerMetadata = Providers.withId("fake-id"); @@ -60,16 +62,16 @@ public class ProvidersTest { } @Test - public void testOfType() { - Iterable> providersMetadata = Providers.ofType(ApiType.BLOBSTORE); + public void testTransformableTo() { + Iterable providersMetadata = Providers.contextWrappableAs(Storage.class); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { assertEquals(testBlobstoreProvider, providerMetadata); } - providersMetadata = Providers.ofType(ApiType.COMPUTE); + providersMetadata = Providers.contextWrappableAs(Compute.class); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { if (providerMetadata.getName().equals(testComputeProvider.getName())) { assertEquals(testComputeProvider, providerMetadata); } else { @@ -77,16 +79,16 @@ public class ProvidersTest { } } - providersMetadata = Providers.ofType(ApiType.UNRECOGNIZED); + providersMetadata = Providers.contextWrappableAs(Balancer.class); assertEquals(false, providersMetadata.iterator().hasNext()); } - + @Test public void testAll() { - Iterable> providersMetadata = Providers.all(); + Iterable providersMetadata = Providers.all(); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { if (providerMetadata.getName().equals(testBlobstoreProvider.getName())) { assertEquals(testBlobstoreProvider, providerMetadata); } else if (providerMetadata.getName().equals(testComputeProvider.getName())) { @@ -108,14 +110,14 @@ public class ProvidersTest { assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE")), 0); // Test filtering by ISO 3166 code and type - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ApiType.BLOBSTORE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ApiType.COMPUTE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ApiType.BLOBSTORE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ApiType.COMPUTE)), 0); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ApiType.BLOBSTORE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ApiType.COMPUTE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ApiType.BLOBSTORE)), 0); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ApiType.COMPUTE)), 0); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", Storage.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", Compute.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", Storage.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", Compute.class)), 0); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", Storage.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", Compute.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", Storage.class)), 0); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", Compute.class)), 0); } @Test @@ -127,12 +129,12 @@ public class ProvidersTest { assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider)), 0); // Test filtering by collocation and type - assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ApiType.BLOBSTORE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ApiType.COMPUTE)), 1); - assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ApiType.COMPUTE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ApiType.BLOBSTORE)), 1); - assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.COMPUTE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.BLOBSTORE)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, Storage.class)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, Compute.class)), 1); + assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, Compute.class)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, Storage.class)), 1); + assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, Compute.class)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, Storage.class)), 0); } } diff --git a/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java b/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java index 23ba372edf..70d0e1d412 100644 --- a/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java +++ b/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java @@ -21,16 +21,16 @@ package org.jclouds.providers.internal; import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; +import java.util.Set; import java.util.logging.Logger; +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.google.common.reflect.TypeToken; /** @@ -38,22 +38,21 @@ import com.google.common.reflect.TypeToken; * @author Jeremy Whitlock */ @Test(groups = "unit") -@SuppressWarnings("rawtypes") public abstract class BaseProviderMetadataTest { private final ProviderMetadata toTest; - private final ApiType expectedType; private final ApiMetadata expectedApi; + private final Set> wrappers; public BaseProviderMetadataTest(ProviderMetadata toTest, ApiMetadata expectedApi) { this.toTest = checkNotNull(toTest, "toTest must be defined"); this.expectedApi = checkNotNull(expectedApi, "expectedApi must be defined"); - this.expectedType = expectedApi.getType(); + this.wrappers = expectedApi.getWrappers(); } @Test public void testWithId() { - ProviderMetadata providerMetadata = Providers.withId(toTest.getId()); + ProviderMetadata providerMetadata = Providers.withId(toTest.getId()); assertEquals(toTest, providerMetadata); assert providerMetadata.getLinkedServices().contains(toTest.getId()); @@ -63,27 +62,23 @@ public abstract class BaseProviderMetadataTest { public void testOfApiContains() { if (expectedApi == null) Logger.getAnonymousLogger().warning("please update your test class"); - ImmutableSet> ofApi = ImmutableSet.copyOf(Providers.apiMetadataAssignableFrom(TypeToken.of(expectedApi.getClass()))); + ImmutableSet ofApi = ImmutableSet.copyOf(Providers.apiMetadataAssignableFrom(TypeToken.of(expectedApi.getClass()))); assert ofApi.contains(toTest) : String.format("%s not found in %s", toTest, ofApi); } - // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) @Test - public void testOfTypeContains() { - ImmutableSet> ofType = ImmutableSet.copyOf(Providers.ofType(expectedType)); - assert ofType.contains(toTest) : String.format("%s not found in %s", toTest, ofType); + public void testTransformableToContains() { + for (TypeToken wrapper : wrappers) { + ImmutableSet ofType = ImmutableSet.copyOf(Providers.contextWrappableAs(wrapper)); + assert ofType.contains(toTest) : String.format("%s not found in %s for %s", toTest, ofType, + wrapper); + } } @Test public void testAllContains() { - ImmutableSet> all = ImmutableSet.copyOf(Providers.all()); + ImmutableSet all = ImmutableSet.copyOf(Providers.all()); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } - @Test - @Deprecated - public void testInRestProperties() { - Iterable providers = org.jclouds.rest.Providers.getSupportedProviders(); - assert Iterables.contains(providers, toTest.getId()) : providers; - } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java index 2859bb17da..81f051abf0 100644 --- a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java +++ b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import javax.ws.rs.POST; import javax.ws.rs.PathParam; +import org.jclouds.ContextBuilder; import org.jclouds.concurrent.Timeout; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; @@ -31,7 +32,6 @@ import org.jclouds.predicates.validators.AllLowerCaseValidator; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.TestException; import org.testng.annotations.BeforeClass; diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java index 712785970a..ea1b76fa66 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.IOException; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; @@ -75,22 +76,21 @@ public abstract class BaseAsyncClientTest extends BaseRestClientTest { /** * @see org.jclouds.providers.Providers#withId */ - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return null; } /** * @see org.jclouds.apis.Apis#withId */ - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return null; } protected Injector createInjector() { - ProviderMetadata pm = createProviderMetadata(); + ProviderMetadata pm = createProviderMetadata(); - @SuppressWarnings("unchecked") - ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder + ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder .newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(), "either createApiMetadata or createProviderMetadata must be overridden"))); diff --git a/core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java similarity index 79% rename from core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java rename to core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java index a6a3bec92b..702e9fe873 100644 --- a/core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java @@ -16,13 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.apis.internal; +package org.jclouds.rest.internal; import java.util.Set; +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.apis.Apis; +import org.jclouds.apis.internal.BaseApiMetadataTest; import org.jclouds.rest.RestApiMetadata; import org.jclouds.rest.RestContext; import org.testng.annotations.Test; @@ -37,14 +38,13 @@ import com.google.common.reflect.TypeToken; @Test(groups = "unit") public abstract class BaseRestApiMetadataTest extends BaseApiMetadataTest { - @SuppressWarnings("rawtypes") - public BaseRestApiMetadataTest(RestApiMetadata toTest, ApiType type) { - super(toTest, type); + public BaseRestApiMetadataTest(RestApiMetadata toTest, Set> wrappers) { + super(toTest, wrappers); } @Test public void testContextAssignableFromRestContext() { - Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(RestContext.class))); + Set all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(RestContext.class))); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java index 21c0f2e7c7..88e6758087 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java @@ -25,8 +25,8 @@ import java.io.IOException; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Map.Entry; import java.util.Properties; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; @@ -42,6 +42,7 @@ import org.custommonkey.xmlunit.DifferenceListener; import org.custommonkey.xmlunit.NodeDetail; import org.custommonkey.xmlunit.XMLUnit; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.apis.ApiMetadata; import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.SingleThreaded; @@ -60,6 +61,7 @@ import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.RestApiMetadata; import org.jclouds.util.Strings2; import org.testng.annotations.Test; import org.w3c.dom.Node; @@ -355,7 +357,8 @@ public abstract class BaseRestClientExpectTest { } /** - * Compare two requests as instructed by {@link #compareHttpRequestAsType(HttpRequest)} - default is to compare using Objects.equal + * Compare two requests as instructed by {@link #compareHttpRequestAsType(HttpRequest)} - default + * is to compare using Objects.equal */ public boolean httpRequestsAreEqual(HttpRequest a, HttpRequest b) { try { @@ -365,21 +368,22 @@ public abstract class BaseRestClientExpectTest { return false; } - Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()), - Strings2.toStringAndClose(b.getPayload().getInput())); - - // Ignoring whitespace in elements that have other children, xsi:schemaLocation and differences in namespace prefixes + Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()), Strings2 + .toStringAndClose(b.getPayload().getInput())); + + // Ignoring whitespace in elements that have other children, xsi:schemaLocation and + // differences in namespace prefixes diff.overrideDifferenceListener(new DifferenceListener() { @Override public int differenceFound(Difference diff) { - if (diff.getId() == DifferenceConstants.SCHEMA_LOCATION_ID || - diff.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) { + if (diff.getId() == DifferenceConstants.SCHEMA_LOCATION_ID + || diff.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) { return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; } if (diff.getId() == DifferenceConstants.TEXT_VALUE_ID) { for (NodeDetail detail : ImmutableSet.of(diff.getControlNodeDetail(), diff.getTestNodeDetail())) { - if (detail.getNode().getParentNode().getChildNodes().getLength() < 2 || - !detail.getValue().trim().isEmpty()) { + if (detail.getNode().getParentNode().getChildNodes().getLength() < 2 + || !detail.getValue().trim().isEmpty()) { return RETURN_ACCEPT_DIFFERENCE; } } @@ -392,7 +396,7 @@ public abstract class BaseRestClientExpectTest { public void skippedComparison(Node node, Node node1) { } }); - + return diff.identical() && Objects.equal(a.getHeaders(), b.getHeaders()); } case JSON: { @@ -416,8 +420,9 @@ public abstract class BaseRestClientExpectTest { public S requestsSendResponses(final Map requestToResponse, Module module) { return requestsSendResponses(requestToResponse, module, setupProperties()); } - - public S requestsSendResponses(final Map requestToResponse, Module module, Properties props) { + + public S requestsSendResponses(final Map requestToResponse, Module module, + Properties props) { return createClient(new Function() { ImmutableBiMap bimap = ImmutableBiMap.copyOf(requestToResponse); @@ -442,7 +447,7 @@ public abstract class BaseRestClientExpectTest { payload.append(renderRequest(request)); } response = HttpResponse.builder().statusCode(500).message("no response configured for request").payload( - Payloads.newStringPayload(payload.toString())).build(); + Payloads.newStringPayload(payload.toString())).build(); } else if (compareHttpRequestAsType(input) == HttpRequestComparisonType.DEFAULT) { // in case hashCode/equals doesn't do a full content check @@ -501,52 +506,51 @@ public abstract class BaseRestClientExpectTest { /** * @see org.jclouds.providers.Providers#withId */ - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return null; } - + /** * @see org.jclouds.apis.Apis#withId */ - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return null; } - - @SuppressWarnings("unchecked") + protected Injector createInjector(Function fn, Module module, Properties props) { - ContextBuilder builder = null; + ContextBuilder builder = null; if (provider != null) try { - builder = ContextBuilder.newBuilder(provider).credentials(identity, credential); - } catch (NoSuchElementException e){ - Logger.getAnonymousLogger() - .warning("provider [" - + provider - + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata"); + builder = ContextBuilder.newBuilder(provider).credentials(identity, credential); + } catch (NoSuchElementException e) { + Logger + .getAnonymousLogger() + .warning( + "provider [" + + provider + + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata"); } - if (builder == null){ - ProviderMetadata pm = createProviderMetadata(); - ApiMetadata am = (pm != null) ? pm.getApiMetadata() : checkNotNull(createApiMetadata(), - "either createApiMetadata or createProviderMetadata must be overridden"); - - builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder - .newBuilder(ApiMetadata.class.cast(am)); - } - - this.api = builder.getApiMetadata().getApi(); - - return builder.credentials(identity, credential) - .modules(ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), module)) - .overrides(setupProperties()).buildInjector(); - } + if (builder == null) { + ProviderMetadata pm = createProviderMetadata(); + ApiMetadata am = (pm != null) ? pm.getApiMetadata() : checkNotNull(createApiMetadata(), + "either createApiMetadata or createProviderMetadata must be overridden"); + builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(RestApiMetadata.class.cast(am)); + } + + this.api = RestApiMetadata.class.cast(builder.getApiMetadata()).getApi(); + + return builder.credentials(identity, credential).modules( + ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), module)).overrides(setupProperties()) + .buildInjector(); + } /** * override this to supply context-specific parameters during tests. */ protected Properties setupProperties() { - Properties props = new Properties(); - props.put(Constants.PROPERTY_MAX_RETRIES, 1); - return props; + Properties props = new Properties(); + props.put(Constants.PROPERTY_MAX_RETRIES, 1); + return props; } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index 92e4375380..1a97fda1a6 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -69,6 +69,7 @@ import javax.ws.rs.core.UriBuilder; import javax.xml.bind.annotation.XmlRootElement; import org.eclipse.jetty.http.HttpHeaders; +import org.jclouds.ContextBuilder; import org.jclouds.concurrent.Timeout; import org.jclouds.crypto.Crypto; import org.jclouds.date.DateService; @@ -80,7 +81,6 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpResponse; import org.jclouds.http.IOExceptionRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ParseJson; import org.jclouds.http.functions.ParseSax; @@ -173,7 +173,6 @@ import com.sun.jersey.api.uri.UriBuilderImpl; @Test(groups = "unit", testName = "RestAnnotationProcessorTest") public class RestAnnotationProcessorTest extends BaseRestClientTest { - @RequiresHttp @ConfiguresRestClient protected static class CallerModule extends RestClientModule { CallerModule() { diff --git a/core/src/test/java/org/jclouds/util/PatternsTest.java b/core/src/test/java/org/jclouds/util/PatternsTest.java index e10ae7e719..c34739e3a8 100644 --- a/core/src/test/java/org/jclouds/util/PatternsTest.java +++ b/core/src/test/java/org/jclouds/util/PatternsTest.java @@ -77,9 +77,9 @@ public class PatternsTest { public void testREST_CONTEXT_BUILDER() { Matcher matcher = Patterns.REST_CONTEXT_BUILDER - .matcher("org.jclouds.rest.RestContextBuilder"); + .matcher("org.jclouds.rest.ContextBuilder"); assert (matcher.find()); - assertEquals(matcher.group(1), "org.jclouds.rest.RestContextBuilder"); + assertEquals(matcher.group(1), "org.jclouds.rest.ContextBuilder"); assertEquals(matcher.group(2), "java.lang.String"); assertEquals(matcher.group(3), "java.lang.Integer"); @@ -87,9 +87,9 @@ public class PatternsTest { public void testREST_CONTEXT_BUILDERwithSpace() { Matcher matcher = Patterns.REST_CONTEXT_BUILDER - .matcher("org.jclouds.rest.RestContextBuilder"); + .matcher("org.jclouds.rest.ContextBuilder"); assert (matcher.find()); - assertEquals(matcher.group(1), "org.jclouds.rest.RestContextBuilder"); + assertEquals(matcher.group(1), "org.jclouds.rest.ContextBuilder"); assertEquals(matcher.group(2), "java.lang.String"); assertEquals(matcher.group(3), "java.lang.Integer"); } diff --git a/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java b/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java index a87df3ad1b..c3da90894b 100644 --- a/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java +++ b/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java @@ -24,11 +24,11 @@ import java.util.concurrent.ExecutorService; import javax.ws.rs.core.UriBuilder; import org.jclouds.Constants; -import org.jclouds.PropertiesBuilder; import org.jclouds.gae.GaeHttpCommandExecutorService; import org.jclouds.http.HttpCommandExecutorService; import org.jclouds.logging.Logger; import org.jclouds.logging.Logger.LoggerFactory; +import org.jclouds.rest.internal.BaseRestApiMetadata; import org.testng.annotations.Test; import com.google.inject.Guice; @@ -46,7 +46,7 @@ import com.sun.jersey.api.uri.UriBuilderImpl; public class GoogleAppEngineConfigurationModuleTest { public void testConfigureBindsClient() { - final Properties properties = new PropertiesBuilder().build(); + final Properties properties = BaseRestApiMetadata.defaultProperties(); Injector i = Guice.createInjector(new GoogleAppEngineConfigurationModule() { @Override diff --git a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java index 7878225240..5acb74a98a 100644 --- a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java +++ b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java @@ -33,9 +33,6 @@ import java.util.Properties; import org.jclouds.aws.domain.Region; import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.elb.ELBAsyncClient; -import org.jclouds.elb.ELBClient; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -45,8 +42,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class AWSELBProviderMetadata extends BaseProviderMetadata, ELBApiMetadata> { +public class AWSELBProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 7750012233546655021L; + public static Builder builder() { return new Builder(); } @@ -64,7 +64,7 @@ public class AWSELBProviderMetadata extends BaseProviderMetadata, ELBApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("aws-elb") @@ -95,13 +95,13 @@ public class AWSELBProviderMetadata extends BaseProviderMetadata()) + .apiMetadata(new ELBApiMetadata()) .defaultProperties(AWSELBProviderMetadata.defaultProperties()); } @Override public Builder fromProviderMetadata( - ProviderMetadata, ELBApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java index d7d92addb9..8ada4959d7 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java @@ -44,7 +44,7 @@ public class AWSELBAsyncClientTest extends ELBAsyncClientTest { } @Override - public ProviderMetadata createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new AWSELBProviderMetadata(); } diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java index 13a922b5d6..0eac0f13b0 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java @@ -19,8 +19,6 @@ package org.jclouds.aws.elb; import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.elb.ELBAsyncClient; -import org.jclouds.elb.ELBClient; import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; @@ -33,6 +31,6 @@ import org.testng.annotations.Test; public class AWSELBProviderTest extends BaseProviderMetadataTest { public AWSELBProviderTest() { - super(new AWSELBProviderMetadata(), new ELBApiMetadata()); + super(new AWSELBProviderMetadata(), new ELBApiMetadata()); } } \ No newline at end of file diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java index 690cfec465..0653d8022e 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java @@ -18,8 +18,6 @@ */ package org.jclouds.aws.elb.config; -import org.jclouds.elb.ELBAsyncClient; -import org.jclouds.elb.ELBClient; import org.jclouds.elb.loadbalancer.ELBLoadBalancerServiceLiveTest; import org.testng.annotations.Test; @@ -28,7 +26,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AWSELBLoadBalancerServiceLiveTest") -public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiveTest { +public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiveTest { public AWSELBLoadBalancerServiceLiveTest() { provider = "aws-elb"; diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java deleted file mode 100644 index 59fc2c56b9..0000000000 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.carrenza.vcloud.director; - -import java.util.List; - -import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorRestClientModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorContextBuilder; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; - -import com.google.inject.Module; - -/** - * {@inheritDoc} - * - * @author danikov - */ -public class CarrenzaVCloudDirectorContextBuilder extends VCloudDirectorContextBuilder { - - public CarrenzaVCloudDirectorContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public CarrenzaVCloudDirectorContextBuilder(VCloudDirectorApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { -// modules.add(new CarrenzaVCloudDirectorComputeServiceContextModule()); FIXME: enable when compute service done - } - - @Override - protected void addClientModule(List modules) { - modules.add(new CarrenzaVCloudDirectorRestClientModule()); - } - -} diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java index 27745f8cc0..604a30ff45 100644 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java +++ b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java @@ -19,19 +19,19 @@ package org.jclouds.carrenza.vcloud.director; import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_DEFAULT_NETWORK; import java.net.URI; import java.util.Properties; +import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorComputeServiceContextModule; +import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorRestClientModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Carrenza vCloud hosting @@ -39,9 +39,8 @@ import com.google.common.reflect.TypeToken; * @author Adrian Cole * @author grkvlt@apache.org */ -public class CarrenzaVCloudDirectorProviderMetadata - extends - BaseProviderMetadata { +@SuppressWarnings("serial") +public class CarrenzaVCloudDirectorProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -60,21 +59,21 @@ public class CarrenzaVCloudDirectorProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_BUILD_VERSION, "1.5.0.464915"); properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_DEFAULT_NETWORK, "orgNet-.*-External"); return properties; } - public static class Builder extends BaseProviderMetadata.Builder { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("carrenza-vcloud-director") .name("Carrenza vCloud Director") .apiMetadata(new VCloudDirectorApiMetadata().toBuilder() .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(CarrenzaVCloudDirectorContextBuilder.class)) + .defaultModules(ImmutableSet.>of(CarrenzaVCloudDirectorRestClientModule.class, CarrenzaVCloudDirectorComputeServiceContextModule.class)) .build()) .homepage(URI.create("http://carrenza.com/")) .console(URI.create("https://myvdc.carrenza.net/cloud/org/YOUR_ORG_HERE")) @@ -90,7 +89,7 @@ public class CarrenzaVCloudDirectorProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java index 9f1e72b0a7..6077df1516 100644 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java +++ b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java @@ -18,13 +18,20 @@ */ package org.jclouds.carrenza.vcloud.director.config; +import com.google.inject.AbstractModule; + /** * per docs, we are to use pool mode. * * @author danikov */ -public class CarrenzaVCloudDirectorComputeServiceContextModule { // FIXME: enable when compute serivce done +public class CarrenzaVCloudDirectorComputeServiceContextModule extends AbstractModule { + + @Override + protected void configure() { + + } // FIXME: enable when compute serivce done //extends VCloudDirectorComputeServiceContextModule { // // @Override diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java index 52d3647458..da74a8fea6 100644 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java +++ b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java @@ -18,7 +18,6 @@ */ package org.jclouds.carrenza.vcloud.director.config; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; @@ -27,7 +26,6 @@ import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; * * @author danikov */ -@RequiresHttp @ConfiguresRestClient public class CarrenzaVCloudDirectorRestClientModule extends VCloudDirectorRestClientModule { diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java index 7b03911274..b8b203be2d 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java @@ -23,7 +23,6 @@ import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java index c0c9df2ecf..53ed7685f9 100644 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java +++ b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java @@ -25,53 +25,54 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.elb.config.ELBRestClientModule; +import org.jclouds.elb.loadbalancer.config.ELBLoadBalancerContextModule; import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Amazon's Elastic Load Balancing api. - *

    note

    - *

    - * This class allows overriding of types {@code S}(client) and {@code A}(asyncClient), so that - * children can add additional methods not declared here, such as new features - * from AWS. - *

    - * - * This class is not setup to allow a different context than {@link LoadBalancerServiceContext} - * . By doing so, it reduces the type complexity. * * @author Adrian Cole */ -public class ELBApiMetadata extends - BaseLoadBalancerServiceApiMetadata, ELBApiMetadata> { +public class ELBApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -7077953935392202824L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } public ELBApiMetadata() { - this(new Builder(ELBClient.class, ELBAsyncClient.class)); + this(new Builder(ELBClient.class, ELBAsyncClient.class)); } - protected ELBApiMetadata(Builder builder) { + protected ELBApiMetadata(Builder builder) { super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); return properties; } - public static class Builder extends - BaseLoadBalancerServiceApiMetadata.Builder, ELBApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder(Class client, Class asyncClient) { + protected Builder(Class client, Class asyncClient) { + super(client, asyncClient); id("elb") .name("Amazon Elastic Load Balancing Api") .identityName("Access Key ID") @@ -80,19 +81,17 @@ public class ELBApiMetadata exten .defaultProperties(ELBApiMetadata.defaultProperties()) .defaultEndpoint("https://elasticloadbalancing.us-east-1.amazonaws.com") .documentation(URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference")) - .javaApi(client, asyncClient) - .contextBuilder(new TypeToken>(getClass()){ - private static final long serialVersionUID = 1L; - }); + .wrapper(LoadBalancerServiceContext.class) + .defaultModules(ImmutableSet.>of(ELBRestClientModule.class, ELBLoadBalancerContextModule.class)); } @Override - public ELBApiMetadata build() { - return new ELBApiMetadata(this); + public ELBApiMetadata build() { + return new ELBApiMetadata(this); } @Override - public Builder fromApiMetadata(ELBApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java b/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java deleted file mode 100644 index 256bd88f51..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elb; - -import java.util.List; - -import org.jclouds.elb.config.ELBRestClientModule; -import org.jclouds.elb.loadbalancer.config.ELBLoadBalancerContextModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link ELBContext} or {@link Injector} instances based on the most commonly requested - * arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

    - *

    - * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. - * - * @author Adrian Cole - * @see ELBContext - */ -public class ELBContextBuilder extends - LoadBalancerServiceContextBuilder, ELBApiMetadata> { - - public ELBContextBuilder(ProviderMetadata, ELBApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public ELBContextBuilder(ELBApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new ELBLoadBalancerContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new ELBRestClientModule()); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java b/labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java deleted file mode 100644 index 34766fe0a0..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.elb; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in ELB Clients - * - * @author Adrian Cole - */ -public class ELBPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_HEADER_TAG, "amz"); - properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION); - properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com"); - return properties; - } - - - public ELBPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java b/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java index f52fec0e0c..8319a6904c 100644 --- a/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java +++ b/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java @@ -21,7 +21,6 @@ package org.jclouds.elb.config; import org.jclouds.aws.config.FormSigningRestClientModule; import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBClient; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; /** @@ -29,7 +28,6 @@ import org.jclouds.rest.ConfiguresRestClient; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class ELBRestClientModule extends FormSigningRestClientModule { public ELBRestClientModule() { diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java index feb103b5b5..b0fc95098e 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java @@ -28,7 +28,6 @@ import org.testng.annotations.Test; @Test(groups = "unit", testName = "ELBApiMetadataTest") public class ELBApiMetadataTest extends BaseLoadBalancerServiceApiMetadataTest { - @SuppressWarnings("rawtypes") public ELBApiMetadataTest() { super(new ELBApiMetadata()); } diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java index dcb425dcb2..bd9a10a5e8 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java @@ -34,7 +34,6 @@ import org.jclouds.elb.xml.CreateLoadBalancerResponseHandler; import org.jclouds.elb.xml.DescribeLoadBalancersResponseHandler; import org.jclouds.elb.xml.RegisterInstancesWithLoadBalancerResponseHandler; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.rest.ConfiguresRestClient; @@ -155,7 +154,6 @@ public class ELBAsyncClientTest extends BaseAsyncClientTest { }; } - @RequiresHttp @ConfiguresRestClient private static final class TestELBRestClientModule extends ELBRestClientModule { @Override @@ -176,8 +174,8 @@ public class ELBAsyncClientTest extends BaseAsyncClientTest { } @Override - public ApiMetadata createApiMetadata() { - return new ELBApiMetadata(); + public ApiMetadata createApiMetadata() { + return new ELBApiMetadata(); } @Override diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java index 4ac5556e31..effd8e5171 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java @@ -23,33 +23,36 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.rest.internal.BaseContextLiveTest; -import org.testng.annotations.AfterGroups; +import org.jclouds.rest.RestContext; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; + /** * Tests behavior of {@code ELBClient} * * @author Lili Nader */ @Test(groups = "live", singleThreaded = true, testName = "ELBClientLiveTest") -public class ELBClientLiveTest extends BaseContextLiveTest> { +public class ELBClientLiveTest extends BaseContextLiveTest> { public ELBClientLiveTest() { provider = "elb"; } - private ELBClient client; + protected S client; protected String name = "TestLoadBalancer"; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi(); + client = context.getApi(); } @Test @@ -84,12 +87,21 @@ public class ELBClientLiveTest ex client.deleteLoadBalancerInRegion(region, name); } - @AfterGroups(groups = "live") - public void shutdown() { + @AfterClass(groups = { "integration", "live" }) + protected void tearDownContext() { try { testDeleteLoadBalancer(); } finally { - context.close(); + super.tearDownContext(); } } + + @SuppressWarnings({ "serial", "unchecked" }) + @Override + protected TypeToken> contextType() { + return new TypeToken>() { + }.where(new TypeParameter() { + }, (TypeToken) TypeToken.of(ELBClient.class)).where(new TypeParameter() { + }, (TypeToken) TypeToken.of(ELBAsyncClient.class)); + } } diff --git a/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java index 4ef29b2ae8..89334a26a1 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java @@ -29,7 +29,6 @@ import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBClient; import org.jclouds.elb.domain.LoadBalancer; import org.jclouds.loadbalancer.BaseLoadBalancerServiceLiveTest; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -39,7 +38,7 @@ import org.testng.annotations.Test; * @author Lili Nadar */ @Test(groups = "live", singleThreaded = true, testName = "ELBLoadBalancerServiceLiveTest") -public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest> { +public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest { public ELBLoadBalancerServiceLiveTest() { provider = "elb"; @@ -53,7 +52,7 @@ public class ELBLoadBalancerServiceLiveTest elbContext = context.getProviderSpecificContext(); + RestContext elbContext = context.unwrap(); // TODO create a LoadBalancer object and an appropriate list method so that this // does not have to be EC2 specific code ELBClient elbClient = elbContext.getApi(); @@ -69,4 +68,6 @@ public class ELBLoadBalancerServiceLiveTest, GleSYSApiMetadata> { +public class GleSYSApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -49,8 +59,8 @@ public class GleSYSApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty("jclouds.ssh.max-retries", "5"); properties.setProperty("jclouds.ssh.retry-auth", "true"); return properties; @@ -58,9 +68,10 @@ public class GleSYSApiMetadata public static class Builder extends - BaseComputeServiceApiMetadata.Builder, GleSYSApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(GleSYSClient.class, GleSYSAsyncClient.class); id("glesys") .name("GleSYS API") .identityName("Username") @@ -69,8 +80,8 @@ public class GleSYSApiMetadata .version("1") .defaultEndpoint("https://api.glesys.com") .defaultProperties(GleSYSApiMetadata.defaultProperties()) - .javaApi(GleSYSClient.class, GleSYSAsyncClient.class) - .contextBuilder(TypeToken.of(GleSYSContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(GleSYSComputeServiceContextModule.class, GleSYSRestClientModule.class)); } @Override @@ -79,7 +90,7 @@ public class GleSYSApiMetadata } @Override - public Builder fromApiMetadata(GleSYSApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java deleted file mode 100644 index 0f648dfe63..0000000000 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.glesys; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.glesys.compute.config.GleSYSComputeServiceContextModule; -import org.jclouds.glesys.config.GleSYSRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class GleSYSContextBuilder - extends - ComputeServiceContextBuilder, GleSYSApiMetadata> { - - public GleSYSContextBuilder( - ProviderMetadata, GleSYSApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public GleSYSContextBuilder(GleSYSApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new GleSYSComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new GleSYSRestClientModule()); - } - -} diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java index 871fe47d79..b2e3b56df6 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java @@ -26,7 +26,6 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,9 +33,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * Implementation of {@link org.jclouds.types.ProviderMetadata} for GleSYS. * @author Adrian Cole */ -public class GleSYSProviderMetadata - extends - BaseProviderMetadata, GleSYSApiMetadata> { +public class GleSYSProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 539076518401969165L; public static Builder builder() { return new Builder(); @@ -55,7 +55,7 @@ public class GleSYSProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_ZONES, "Amsterdam,Falkenberg,New York City,Stockholm"); properties.setProperty(PROPERTY_ZONE + ".Amsterdam." + ISO3166_CODES, "NL-NH"); @@ -66,9 +66,7 @@ public class GleSYSProviderMetadata return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, GleSYSApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("glesys") @@ -87,8 +85,7 @@ public class GleSYSProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, GleSYSApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java b/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java index 8027a90676..1fc9e28cea 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java @@ -22,8 +22,8 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.concurrent.FutureIterables.transformParallel; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/compute/config/GleSYSComputeServiceContextModule.java b/labs/glesys/src/main/java/org/jclouds/glesys/compute/config/GleSYSComputeServiceContextModule.java index 7affeedb3f..162a84e8a2 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/compute/config/GleSYSComputeServiceContextModule.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/compute/config/GleSYSComputeServiceContextModule.java @@ -34,8 +34,6 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.compute.GleSYSComputeServiceAdapter; import org.jclouds.glesys.compute.functions.DatacenterToLocation; import org.jclouds.glesys.compute.functions.OSTemplateToImage; @@ -55,13 +53,8 @@ import com.google.inject.name.Names; * * @author Adrian Cole */ -public class GleSYSComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public GleSYSComputeServiceContextModule() { - super(GleSYSClient.class, GleSYSAsyncClient.class); - } +public class GleSYSComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/OSTemplateToImage.java b/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/OSTemplateToImage.java index 8a10df36e7..3815ddef8f 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/OSTemplateToImage.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/OSTemplateToImage.java @@ -26,8 +26,8 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.glesys.domain.OSTemplate; import com.google.common.base.Function; diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java b/labs/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java index 5d66ddb4c1..a069b43876 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java @@ -35,7 +35,6 @@ import org.jclouds.glesys.features.ServerClient; import org.jclouds.glesys.handlers.GleSYSErrorHandler; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -53,7 +52,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class GleSYSRestClientModule extends RestClientModule { diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java index 3ddec09ef4..d71b9386f2 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java @@ -18,11 +18,8 @@ */ package org.jclouds.glesys.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -36,9 +33,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class GleSYSComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class GleSYSComputeServiceLiveTest extends BaseComputeServiceLiveTest { public GleSYSComputeServiceLiveTest() { provider = "glesys"; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java index 34824b495f..1dc7ca53e4 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java @@ -33,7 +33,7 @@ public class GleSYSExperimentExpectTest extends BaseGleSYSComputeServiceExpectTe @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { context = computeContextForKnownArgumentsAndConstantPassword(); diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java index 357ad48039..6a7eb4f2ab 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java @@ -20,11 +20,9 @@ package org.jclouds.glesys.compute; import static org.testng.Assert.assertEquals; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.GleSYSProviderMetadata; import org.testng.annotations.Test; @@ -35,9 +33,7 @@ import com.google.common.io.Closeables; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "GleSYSExperimentLiveTest") -public class GleSYSExperimentLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class GleSYSExperimentLiveTest extends BaseComputeServiceContextLiveTest { public GleSYSExperimentLiveTest() { provider = "glesys"; @@ -45,13 +41,13 @@ public class GleSYSExperimentLiveTest @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = ComputeServiceContextBuilder + context = ContextBuilder .newBuilder(new GleSYSProviderMetadata()) .overrides(setupProperties()) - .modules(setupModules()).build(); + .modules(setupModules()).build(ComputeServiceContext.class); assertEquals(context.getComputeService().listAssignableLocations().size(), 4); diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java index 55f19450e1..5f5844e624 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java @@ -25,14 +25,11 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.compute.options.GleSYSTemplateOptions; import org.testng.annotations.Test; @@ -45,9 +42,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "GleSYSTemplateBuilderLiveTest") -public class GleSYSTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public GleSYSTemplateBuilderLiveTest() { provider = "glesys"; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerSpecToHardwareTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerSpecToHardwareTest.java index 52a047fd53..bfb8500798 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerSpecToHardwareTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerSpecToHardwareTest.java @@ -31,7 +31,7 @@ public class ServerSpecToHardwareTest extends BaseGleSYSComputeServiceExpectTest @Test public void testHardwareRequest() { - ServerSpecToHardware toTest = injectorForKnownArgumentsAndConstantPassword().getInstance(ServerSpecToHardware.class); + injectorForKnownArgumentsAndConstantPassword().getInstance(ServerSpecToHardware.class); } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java index 4e7ee5251e..516d4342bd 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java @@ -50,7 +50,7 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new GleSYSApiMetadata(); } @@ -76,7 +76,7 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE return computeContextForKnownArgumentsAndConstantPassword(requestsResponses).utils().injector(); } - protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword( + protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword( Map requestsResponses) { return requestsSendResponses( ImmutableMap @@ -109,7 +109,7 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE }).getContext(); } - protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword() { + protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword() { return computeContextForKnownArgumentsAndConstantPassword(ImmutableMap. of()); } } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java index cd284e7c16..b7d165ff4f 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java @@ -33,8 +33,8 @@ import org.jclouds.glesys.domain.ArchiveDetails; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java index 50de7966df..f03e3ada48 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java @@ -33,8 +33,8 @@ import org.jclouds.glesys.domain.DomainRecord; import org.jclouds.glesys.options.AddDomainOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java index 17b3a01f73..c27bf7dd0d 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java @@ -36,8 +36,8 @@ import org.jclouds.glesys.domain.EmailOverviewSummary; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java index 53b2261dde..c6d591d19a 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java @@ -47,8 +47,8 @@ import org.jclouds.glesys.options.ServerStatusOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java index ae89a53dcc..eb767553ef 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java @@ -38,7 +38,7 @@ public abstract class BaseGleSYSAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new GleSYSProviderMetadata(); } } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java index 753d78c6cb..9c826505a0 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java @@ -26,7 +26,6 @@ import static org.testng.Assert.assertTrue; import java.util.UUID; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.glesys.GleSYSAsyncClient; import org.jclouds.glesys.GleSYSClient; @@ -50,9 +49,7 @@ import com.google.common.base.Predicate; * @author Adrian Cole, Adam Lowe */ @Test(groups = "live") -public class BaseGleSYSClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseGleSYSClientLiveTest extends BaseComputeServiceContextLiveTest { protected RestContext gleContext; @@ -64,7 +61,7 @@ public class BaseGleSYSClientLiveTest @Override public void setupContext() { super.setupContext(); - gleContext = context.getProviderSpecificContext(); + gleContext = context.unwrap(); } protected void createDomain(String domain) { diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java index b94c0faac3..c96b3d3beb 100644 --- a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java @@ -22,21 +22,24 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; +import org.jclouds.opsource.servers.config.OpSourceServersRestClientModule; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for API + * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class OpSourceServersApiMetadata - extends - BaseRestApiMetadata, OpSourceServersApiMetadata> { +public class OpSourceServersApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -50,14 +53,14 @@ public class OpSourceServersApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); return properties; } public static class Builder extends - BaseRestApiMetadata.Builder, OpSourceServersApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { super(OpSourceServersClient.class, OpSourceServersAsyncClient.class); @@ -68,8 +71,10 @@ public class OpSourceServersApiMetadata .documentation(URI.create("http://www.opsource.net/Services/Cloud-Hosting/Open-API")) .version("0.9") .defaultEndpoint("https://api.opsourcecloud.net/oec/${jclouds.api-version}") - .type(ApiType.COMPUTE) - .contextBuilder(TypeToken.of(OpSourceServersContextBuilder.class)); + .defaultProperties(OpSourceServersApiMetadata.defaultProperties()) + .defaultModule(OpSourceServersRestClientModule.class); +// .wrapper(TypeToken.of(ComputeServiceContext.class)) +// .defaultModules(ImmutableSet.>of(OpSourceServersRestClientModule.class, OpSourceServersComputeServiceContextModule.class)); } @Override @@ -78,7 +83,7 @@ public class OpSourceServersApiMetadata } @Override - public Builder fromApiMetadata(OpSourceServersApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java deleted file mode 100644 index ab7ef8b6e9..0000000000 --- a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.opsource.servers; - -import java.util.List; - -import org.jclouds.opsource.servers.config.OpSourceServersRestClientModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextBuilder; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class OpSourceServersContextBuilder - extends - RestContextBuilder, OpSourceServersApiMetadata> { - - public OpSourceServersContextBuilder( - ProviderMetadata, OpSourceServersApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public OpSourceServersContextBuilder(OpSourceServersApiMetadata apiMetadata) { - super(apiMetadata); - } -// -// @Override -// protected void addContextModule(List modules) { -// modules.add(new OpSourceServersComputeServiceContextModule()); -// } - - protected void addClientModule(List modules) { - modules.add(new OpSourceServersRestClientModule()); - } - -} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java index 98449c91a6..99cd087b7f 100644 --- a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.opsource.servers.config; import java.util.Map; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -46,7 +45,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class OpSourceServersRestClientModule extends RestClientModule { diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java index 3d6ee073f0..e3fef3bcf1 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java @@ -18,24 +18,24 @@ */ package org.jclouds.opsource.servers.internal; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.apis.BaseContextLiveTest; +import org.jclouds.opsource.servers.OpSourceServersApiMetadata; import org.jclouds.opsource.servers.OpSourceServersAsyncClient; import org.jclouds.opsource.servers.OpSourceServersClient; import org.jclouds.rest.RestContext; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; +import com.google.common.reflect.TypeToken; + /** - * Tests behavior of {@link OpSourceServersClient} and acts as parent for other - * client live tests. + * Tests behavior of {@link OpSourceServersClient} and acts as parent for other client live tests. * * @author Adrian Cole */ @Test(groups = "live") -public abstract class BaseOpSourceServersClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public abstract class BaseOpSourceServersClientLiveTest extends + BaseContextLiveTest> { protected BaseOpSourceServersClientLiveTest() { provider = "opsource-servers"; @@ -47,7 +47,12 @@ public abstract class BaseOpSourceServersClientLiveTest @Override public void setupContext() { super.setupContext(); - restContext = context.getProviderSpecificContext(); + restContext = context; + } + + @Override + protected TypeToken> contextType() { + return OpSourceServersApiMetadata.CONTEXT_TOKEN; } } diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java index 217fedf1e6..5ff428ffbf 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java @@ -37,7 +37,7 @@ public class BaseOpSourceServersRestClientExpectTest extends BaseRestClientExpec } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new OpSourceServersApiMetadata(); } } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java index cf25f6862e..912297047c 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java @@ -23,21 +23,31 @@ import static org.jclouds.savvis.vpdc.reference.VPDCConstants.PROPERTY_VPDC_TIME import java.net.URI; import java.util.Properties; -import org.jclouds.apis.ApiType; +import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.savvis.vpdc.compute.config.VPDCComputeServiceContextModule; +import org.jclouds.savvis.vpdc.config.VPDCRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ApiMetadata} for Savvis Symphony VPDC services. * * @author Kedar Dave */ -public class VPDCApiMetadata - extends - BaseComputeServiceApiMetadata, VPDCApiMetadata> { +public class VPDCApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -51,19 +61,19 @@ public class VPDCApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED, 600l * 1000l + ""); return properties; } public static class Builder extends - BaseComputeServiceApiMetadata.Builder, VPDCApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(VPDCClient.class, VPDCAsyncClient.class); id("savvis-symphonyvpdc") - .type(ApiType.COMPUTE) .name("Savvis Symphony VPDC API") .identityName("Username") .credentialName("Password") @@ -72,8 +82,9 @@ public class VPDCApiMetadata .buildVersion("2.3") .defaultEndpoint("https://api.savvis.net/vpdc") .defaultProperties(VPDCApiMetadata.defaultProperties()) - .javaApi(VPDCClient.class, VPDCAsyncClient.class) - .contextBuilder(TypeToken.of(VPDCContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(VPDCRestClientModule.class, VPDCComputeServiceContextModule.class)); + } @Override @@ -82,7 +93,7 @@ public class VPDCApiMetadata } @Override - public Builder fromApiMetadata(VPDCApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java deleted file mode 100644 index 6934caea2e..0000000000 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.savvis.vpdc; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.savvis.vpdc.compute.config.VPDCComputeServiceContextModule; -import org.jclouds.savvis.vpdc.config.VPDCRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class VPDCContextBuilder - extends - ComputeServiceContextBuilder, VPDCApiMetadata> { - - public VPDCContextBuilder( - ProviderMetadata, VPDCApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public VPDCContextBuilder(VPDCApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VPDCComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new VPDCRestClientModule()); - } - -} diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java deleted file mode 100644 index d2a678d286..0000000000 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.savvis.vpdc; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.savvis.vpdc.reference.VPDCConstants.PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Symphony VPDC Clients - * - * @author Adrian Cole - */ -public class VPDCPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - properties.setProperty(PROPERTY_BUILD_VERSION, "2.3"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.savvis.net/vpdc"); - properties.setProperty(PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED, 600l * 1000l + ""); - return properties; - } - - public VPDCPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java index 31bbf4ccc7..ad762aa89c 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.savvis.vpdc; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -30,9 +29,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Kedar Dave */ -public class VPDCProviderMetadata - extends - BaseProviderMetadata, VPDCApiMetadata> { +public class VPDCProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3438042651384066520L; public static Builder builder() { return new Builder(); @@ -51,14 +51,12 @@ public class VPDCProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, VPDCApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("savvis-symphonyvpdc") @@ -113,8 +111,7 @@ public class VPDCProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, VPDCApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java index 6a7cd4b9b6..8eabbc9101 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java @@ -26,8 +26,6 @@ import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.domain.Location; -import org.jclouds.savvis.vpdc.VPDCAsyncClient; -import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.savvis.vpdc.compute.functions.CIMOperatingSystemToImage; import org.jclouds.savvis.vpdc.compute.functions.NetworkToLocation; import org.jclouds.savvis.vpdc.compute.functions.VMSpecToHardware; @@ -46,11 +44,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class VPDCComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - public VPDCComputeServiceContextModule() { - super(VPDCClient.class, VPDCAsyncClient.class); - } + ComputeServiceAdapterContextModule { @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java index 68a0778e4f..98bd9e08fe 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java @@ -41,6 +41,7 @@ import org.jclouds.json.Json; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.ImplicitLocationSupplier; import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.savvis.vpdc.VPDCAsyncClient; @@ -78,6 +79,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole * */ +@ConfiguresRestClient public class VPDCRestClientModule extends RestClientModule { @Override protected void configure() { diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java index 2c56d36d61..d2fddffa66 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java @@ -21,11 +21,8 @@ package org.jclouds.savvis.vpdc.compute; import java.util.Properties; import org.jclouds.Constants; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.savvis.vpdc.VPDCAsyncClient; -import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -41,9 +38,7 @@ import com.google.inject.Module; * */ @Test(enabled = true, groups = "live") -public class VPDCComputeServiceLiveTestDisabled - extends - BaseComputeServiceLiveTest> { +public class VPDCComputeServiceLiveTestDisabled extends BaseComputeServiceLiveTest { public VPDCComputeServiceLiveTestDisabled() { provider = "savvis-symphonyvpdc"; diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java index f545316887..d37882e876 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java @@ -26,14 +26,11 @@ import java.io.IOException; import java.util.Properties; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.jclouds.domain.LocationScope; -import org.jclouds.savvis.vpdc.VPDCAsyncClient; -import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.savvis.vpdc.reference.VPDCConstants; import org.testng.annotations.Test; @@ -45,8 +42,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class VPDCTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { +public class VPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public VPDCTemplateBuilderLiveTest() { provider = "savvis-symphonyvpdc"; diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java index 6d3674979e..f8d9d4f297 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java @@ -28,7 +28,6 @@ import java.util.Set; import javax.inject.Named; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; @@ -53,7 +52,7 @@ import com.google.inject.Module; public abstract class BaseVPDCAsyncClientTest extends BaseAsyncClientTest { @Override - public ProviderMetadata createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new VPDCProviderMetadata(); } @@ -68,7 +67,6 @@ public abstract class BaseVPDCAsyncClientTest extends BaseAsyncClientTest return new VPDCRestClientModuleExtension(); } - @RequiresHttp @ConfiguresRestClient public static class VPDCRestClientModuleExtension extends VPDCRestClientModule { diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java index 9219137347..b4929beedb 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Properties; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; @@ -40,9 +39,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "BaseVPDCClientLiveTest") -public class BaseVPDCClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseVPDCClientLiveTest extends BaseComputeServiceContextLiveTest { public BaseVPDCClientLiveTest() { provider = "savvis-symphonyvpdc"; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java index 3d2e32edac..a4d70cd388 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java @@ -28,9 +28,8 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; @@ -41,11 +40,13 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -public class VCloudDirectorApiMetadata - extends -// BaseComputeServiceApiMetadata { - BaseRestApiMetadata { +public class VCloudDirectorApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken CONTEXT_TOKEN = TypeToken.of(VCloudDirectorContext.class); + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -59,8 +60,8 @@ public class VCloudDirectorApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); /** FIXME this should not be the default */ properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(30 * 60)); @@ -78,21 +79,21 @@ public class VCloudDirectorApiMetadata public static class Builder extends -// BaseComputeServiceApiMetadata.Builder { - BaseRestApiMetadata.Builder { + BaseRestApiMetadata.Builder { protected Builder() { super(VCloudDirectorClient.class, VCloudDirectorAsyncClient.class); id("vcloud-director") .name("vCloud Director 1.5 API") - .type(ApiType.COMPUTE) .identityName("User at Organization (user@org)") .credentialName("Password") .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) .version("1.5") .defaultProperties(VCloudDirectorApiMetadata.defaultProperties()) .context(TypeToken.of(VCloudDirectorContext.class)) - .contextBuilder(TypeToken.of(VCloudDirectorContextBuilder.class)); + .defaultModule(VCloudDirectorRestClientModule.class); +// .wrapper(TypeToken.of(ComputeServiceContext.class)) +// .defaultModules(ImmutableSet.>of(VCloudDirectorRestClientModule.class, VCloudDirectorComputeServiceContextModule.class)); } @Override @@ -101,7 +102,7 @@ public class VCloudDirectorApiMetadata } @Override - public Builder fromApiMetadata(VCloudDirectorApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java deleted file mode 100644 index 1417074df4..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5; - -import java.util.List; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.RestContextBuilder; -import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class VCloudDirectorContextBuilder - extends - // ComputeServiceContextBuilder { - RestContextBuilder { - - public VCloudDirectorContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public VCloudDirectorContextBuilder(VCloudDirectorApiMetadata apiMetadata) { - super(apiMetadata); - } - - // TODO - // @Override - // protected void addContextModule(List modules) { - // modules.add(new VCloudDirectorComputeServiceContextModule()); - // } - - @Override - protected void addClientModule(List modules) { - modules.add(new VCloudDirectorRestClientModule()); - } - -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorPropertiesBuilder.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorPropertiesBuilder.java deleted file mode 100644 index 67bbbfc732..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorPropertiesBuilder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.director.v1_5; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_VERSION_SCHEMA; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_XML_NAMESPACE; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_XML_SCHEMA; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in VCloudDirector clients - * - * @author Adrian Cole - */ -public class VCloudDirectorPropertiesBuilder extends PropertiesBuilder { - - @Override - public Properties defaultProperties() { - Properties properties = super.defaultProperties(); - - /** FIXME this should not be the default */ - properties.setProperty(PROPERTY_ENDPOINT, "https://vcloudbeta.bluelock.com/api"); - properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(30 * 60)); - properties.setProperty(PROPERTY_API_VERSION, "1.5"); - - properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_XML_NAMESPACE, - String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_DIRECTOR_VERSION_SCHEMA)); - properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(8 * 60)); - properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_XML_SCHEMA, PROPERTY_ENDPOINT + "/v1.5/schema/master.xsd"); - - // TODO integrate these with the {@link ComputeTimeouts} instead of having a single timeout for everything. - properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(300)); - properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED, Long.toString(1200l * 1000l)); - - return properties; - } - - public VCloudDirectorPropertiesBuilder() { - super(); - } - - public VCloudDirectorPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index 0e1b0dc750..f1826f900f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -31,7 +31,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -107,7 +106,6 @@ import com.google.inject.name.Named; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class VCloudDirectorRestClientModule extends RestClientModule { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java index 01a27187df..d924ddb906 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java @@ -32,6 +32,7 @@ import org.jclouds.http.HttpResponse; import org.jclouds.util.Strings2; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; +import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.xml.internal.JAXBParser; import org.testng.annotations.Test; @@ -110,4 +111,5 @@ public class HttpClientLiveTest extends BaseVCloudDirectorClientLiveTest { // TODO: asserting something about the schema } + } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java index 0b90278dca..75b501fd07 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java @@ -18,18 +18,22 @@ */ package org.jclouds.vcloud.director.v1_5; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.Wrapper; +import org.jclouds.rest.internal.BaseRestApiMetadataTest; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; + /** * * @author Adrian Cole */ @Test(groups = "unit", testName = "VCloudDirectorApiMetadataTest") -public class VCloudDirectorApiMetadataTest extends BaseApiMetadataTest { +//TODO: BaseComputeServiceApiMetadataTest +public class VCloudDirectorApiMetadataTest extends BaseRestApiMetadataTest { public VCloudDirectorApiMetadataTest() { - super(new VCloudDirectorApiMetadata(), ApiType.COMPUTE); + super(new VCloudDirectorApiMetadata(), ImmutableSet.>of()); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java index fbe9820376..e00957b263 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java @@ -23,25 +23,19 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.N import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE; -import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkError; -import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; import java.util.Collections; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.User; import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java index 4f66774cb0..12b093af8e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java @@ -35,13 +35,13 @@ import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; -import org.jclouds.Constants; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.date.DateService; import org.jclouds.logging.Logger; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.vcloud.director.testng.FormatApiResultsListener; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; @@ -49,8 +49,6 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; -import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; import org.jclouds.vcloud.director.v1_5.domain.RoleReferences; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; @@ -58,6 +56,8 @@ import org.jclouds.vcloud.director.v1_5.domain.User; import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; +import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; import org.jclouds.vcloud.director.v1_5.domain.network.Network; import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration; @@ -90,6 +90,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; import com.google.inject.Guice; /** @@ -492,4 +493,10 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe public static String name(String prefix) { return prefix + Integer.toString(random.nextInt(Integer.MAX_VALUE)); } + + @Override + protected TypeToken contextType() { + return VCloudDirectorApiMetadata.CONTEXT_TOKEN; + } + } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java index 0c9746dedd..858e98d7db 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java @@ -9,9 +9,9 @@ import java.io.Closeable; import java.net.URI; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient; @@ -80,7 +80,7 @@ public class VCloudDirectorTestSession implements Closeable { private User createdUser; private VCloudDirectorTestSession(String provider, String identity, String credential, Properties overrides, String endpoint) { - ContextBuilder builder = ContextBuilder.newBuilder(provider) + ContextBuilder builder = ContextBuilder.newBuilder(provider) .credentials(identity, credential) .endpoint(endpoint) .modules(ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule())) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java index 0a30ccd8c3..9e6c86a46c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java @@ -123,7 +123,7 @@ public class SessionClientExpectTest extends BaseRestClientExpectTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return AnonymousRestApiMetadata.forClientMappedToAsyncClient(SessionClient.class, SessionAsyncClient.class) .toBuilder().defaultEndpoint("https://vcloudbeta.bluelock.com/api").build(); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java index 78ab4aff81..f733e733d4 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java @@ -27,15 +27,17 @@ import java.util.Properties; import org.jclouds.Constants; import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.vcloud.director.testng.FormatApiResultsListener; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Listeners; import org.testng.annotations.Test; +import com.google.common.reflect.TypeToken; + /** * Tests behavior of {@code SessionClient}. Note this class is tested completely independently of * VCloudClient as it is a dependency of the VCloud context working. @@ -103,7 +105,15 @@ public class SessionClientLiveTest extends BaseContextLiveTest, ?> createApiMetadata() { + protected ApiMetadata createApiMetadata() { return AnonymousRestApiMetadata.forClientMappedToAsyncClient(SessionClient.class, SessionAsyncClient.class); } + + @Override + protected TypeToken> contextType() { + return new TypeToken>(){ + + /** The serialVersionUID */ + private static final long serialVersionUID = -3625362618882122604L;}; + } } diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java index dd9f02fada..7a6d3cdec3 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java @@ -31,25 +31,23 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; +import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.virtualbox.config.DefaultCacheNodeStoreModule; +import org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule; -import com.google.common.base.Supplier; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for VirtualBox API - * - *

    note

    - * - * This class is not setup to allow a subclasses to override the type of api, - * asyncapi, or context. This is an optimization for simplicity. - * + * @author Adrian Cole */ -@SuppressWarnings("rawtypes") -public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata, VirtualBoxApiMetadata> { +public class VirtualBoxApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -7039233043408808289L; @Override public Builder toBuilder() { @@ -64,8 +62,8 @@ public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata, VirtualBoxApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder() { id("virtualbox") - .type(ApiType.COMPUTE) .name("VirtualBox API") .identityName("User") .credentialName("Password") @@ -108,8 +105,8 @@ public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata>of(DefaultCacheNodeStoreModule.class, VirtualBoxComputeServiceContextModule.class)); } @Override @@ -118,7 +115,7 @@ public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata, VirtualBoxApiMetadata> { - - public VirtualBoxContextBuilder( - ProviderMetadata, VirtualBoxApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public VirtualBoxContextBuilder(VirtualBoxApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VirtualBoxComputeServiceContextModule()); - addHostModuleIfNotPresent(modules); - } - - protected void addHostModuleIfNotPresent(List modules) { - if (!Iterables.any(modules, new Predicate() { - public boolean apply(Module input) { - return input instanceof CacheNodeStoreModule; - } - })) { - CacheNodeStoreModule hostModule = new CacheNodeStoreModule(ImmutableMap.of( - "host", - Node.builder().id("host").name("host installing virtualbox").hostname("localhost") - .osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name")) - .osVersion(System.getProperty("os.version")).group("ssh") - .username(System.getProperty("user.name")) - .credentialUrl(URI.create("file://" + System.getProperty("user.home") + "/.ssh/id_rsa")) - .build())); - modules.add(hostModule); - } - } - -} diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/DefaultCacheNodeStoreModule.java similarity index 50% rename from apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java rename to labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/DefaultCacheNodeStoreModule.java index 3b443dca18..14b2165d6a 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/DefaultCacheNodeStoreModule.java @@ -1,47 +1,36 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.openstack.nova; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Openstack Nova Clients - * - * @author Dmitri Babaev - */ -public class NovaPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.1"); - return properties; - } - - public NovaPropertiesBuilder(Properties properties) { - super(properties); - } - - public NovaPropertiesBuilder() { - super(); - } -} +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.virtualbox.config; + +import java.net.URI; + +import org.jclouds.byon.Node; +import org.jclouds.byon.config.CacheNodeStoreModule; +import org.jclouds.compute.domain.OsFamily; + +import com.google.common.collect.ImmutableMap; + +public class DefaultCacheNodeStoreModule extends CacheNodeStoreModule { + public DefaultCacheNodeStoreModule() { + super(ImmutableMap.of("host", Node.builder().id("host").name("host installing virtualbox").hostname("localhost") + .osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name")).osVersion( + System.getProperty("os.version")).group("ssh").username(System.getProperty("user.name")) + .credentialUrl(URI.create("file://" + System.getProperty("user.home") + "/.ssh/id_rsa")).build())); + } +} diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java index 7882a130b6..55160e8a7b 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java @@ -34,14 +34,14 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; import org.eclipse.jetty.server.Server; +import org.jclouds.ContextBuilder; import org.jclouds.byon.BYONApiMetadata; import org.jclouds.byon.Node; import org.jclouds.byon.functions.NodeToNodeMetadata; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; @@ -103,13 +103,9 @@ import com.google.inject.TypeLiteral; /** * @author Mattias Holmqvist, Andrea Turli */ -@SuppressWarnings({ "unchecked", "rawtypes" }) +@SuppressWarnings("unchecked") public class VirtualBoxComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - public VirtualBoxComputeServiceContextModule() { - super(Supplier.class, Supplier.class); - } + ComputeServiceAdapterContextModule { @Override protected void configure() { @@ -170,10 +166,10 @@ public class VirtualBoxComputeServiceContextModule extends @Host @Singleton protected ComputeServiceContext provideHostController() { - return ComputeServiceContextBuilder.newBuilder(new BYONApiMetadata()) + return ContextBuilder.newBuilder(new BYONApiMetadata()) .credentials("", "") .modules(ImmutableSet. of(new SLF4JLoggingModule(), new SshjSshClientModule())) - .build(); + .build(ComputeServiceContext.class); } @Provides diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java index 6b22c1944b..fe6cf54609 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java @@ -30,7 +30,6 @@ import java.util.concurrent.ExecutorService; import javax.inject.Inject; import javax.inject.Named; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; @@ -39,6 +38,7 @@ import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.config.ValueOfConfigurationKeyOrNull; +import org.jclouds.rest.annotations.BuildVersion; import org.jclouds.virtualbox.config.VirtualBoxConstants; import org.jclouds.virtualbox.domain.HardDisk; import org.jclouds.virtualbox.domain.IsoSpec; @@ -76,6 +76,7 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Injector; +import com.google.inject.Key; import com.google.inject.Module; /** @@ -84,8 +85,7 @@ import com.google.inject.Module; * @author Adrian Cole, David Alves */ @Test(groups = "live", singleThreaded = true, testName = "BaseVirtualBoxClientLiveTest") -public class BaseVirtualBoxClientLiveTest extends - BaseComputeServiceContextLiveTest> { +public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveTest { public static final String DONT_DESTROY_MASTER = "jclouds.virtualbox.keep-test-master"; @@ -144,7 +144,7 @@ public class BaseVirtualBoxClientLiveTest extends masterVmName = VIRTUALBOX_IMAGE_PREFIX + image.id; isosDir = workingDir + File.separator + "isos"; - hostVersion = Iterables.get(Splitter.on('r').split(context.getProviderSpecificContext().getBuildVersion()), 0); + hostVersion = Iterables.get(Splitter.on('r').split(context.utils().injector().getInstance(Key.get(String.class, BuildVersion.class))), 0); operatingSystemIso = String.format("%s/%s.iso", isosDir, image.name); guestAdditionsIso = String.format("%s/VBoxGuestAdditions_%s.iso", isosDir, hostVersion); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java index 6aec98fb30..c61d80cd64 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.virtualbox; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "VirtualBoxApiMetadataTest") -public class VirtualBoxApiMetadataTest extends BaseApiMetadataTest { +public class VirtualBoxApiMetadataTest extends BaseComputeServiceApiMetadataTest { public VirtualBoxApiMetadataTest() { - super(new VirtualBoxApiMetadata(), ApiType.COMPUTE); + super(new VirtualBoxApiMetadata()); } } diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java index a13cf5655c..e88cb47f87 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java @@ -27,8 +27,8 @@ import java.util.Set; import javax.annotation.Resource; import javax.inject.Named; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; @@ -62,8 +62,9 @@ public class VirtualBoxExperimentLiveTest extends BaseVirtualBoxClientLiveTest { @BeforeClass public void setUp() { - context = new ComputeServiceContextFactory().createContext("virtualbox", "", "", - ImmutableSet. of(new SLF4JLoggingModule(), new SshjSshClientModule())); + context = ContextBuilder.newBuilder("virtualbox").modules( + ImmutableSet. of(new SLF4JLoggingModule(), new SshjSshClientModule())).build( + ComputeServiceContext.class); } @Test diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java index d7c81dab49..d475cd8c14 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java @@ -27,7 +27,6 @@ import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTA import java.util.Map; import org.jclouds.compute.config.BaseComputeServiceContextModule; -import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.config.ValueOfConfigurationKeyOrNull; diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java index 3e17be9400..4933f7d5d2 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java @@ -20,13 +20,10 @@ package org.jclouds.virtualbox.functions; import static org.jclouds.virtualbox.functions.RetrieveActiveBridgedInterfaces.retrieveBridgedInterfaceNames; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; import java.util.List; -import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest; import org.jclouds.virtualbox.domain.BridgedIf; -import org.jclouds.virtualbox.domain.BridgedIf.Builder; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java index 611fff821f..bbc6a1a9f5 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java @@ -49,7 +49,7 @@ public interface LoadBalancerService { /** * @return a reference to the context that created this LoadBalancerService. */ - LoadBalancerServiceContext getContext(); + LoadBalancerServiceContext getContext(); /** * @param location diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java deleted file mode 100644 index 32806f5163..0000000000 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jclouds.loadbalancer; - -import org.jclouds.apis.ApiMetadata; - -import com.google.common.annotations.Beta; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public interface LoadBalancerServiceApiMetadata, M extends LoadBalancerServiceApiMetadata> - extends ApiMetadata { - - public static interface Builder, M extends LoadBalancerServiceApiMetadata> - extends ApiMetadata.Builder { - } - -} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java index 4f82ccce50..4940137d9f 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java @@ -20,8 +20,9 @@ package org.jclouds.loadbalancer; import java.io.Closeable; +import org.jclouds.Wrapper; import org.jclouds.loadbalancer.internal.LoadBalancerServiceContextImpl; -import org.jclouds.rest.BackedByRestContext; +import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; import com.google.inject.ImplementedBy; @@ -34,7 +35,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(LoadBalancerServiceContextImpl.class) -public interface LoadBalancerServiceContext extends Closeable, BackedByRestContext { +public interface LoadBalancerServiceContext extends Closeable, Wrapper { LoadBalancerService getLoadBalancerService(); @@ -45,6 +46,15 @@ public interface LoadBalancerServiceContext extends Closeable, BackedByRes * @see #getUtils */ Utils utils(); + + /** + * will be removed in jclouds 1.6 + * + * @see Wrapper#getInputType + * @see Wrapper#unwrap + */ + @Deprecated + RestContext getProviderSpecificContext(); @Override void close(); diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java deleted file mode 100644 index cd8bee81c7..0000000000 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.loadbalancer; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.NoSuchElementException; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -/** - * @author Adrian Cole - */ -public abstract class LoadBalancerServiceContextBuilder, M extends LoadBalancerServiceApiMetadata> extends - ContextBuilder { - -// TODO: -// public static ContextBuilder forTests() { -// return ContextBuilder.newBuilder(new StubApiMetadata()); -// } - - /** - * looks up a provider or api with the given id - * - * @param providerOrApi - * id of the provider or api - * @return means to build a context to that provider - * @throws NoSuchElementException - * if the id was not configured. - * @throws IllegalArgumentException - * if the api or provider isn't assignable from LoadBalancerServiceContext - */ - public static LoadBalancerServiceContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { - ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); - checkArgument(builder instanceof LoadBalancerServiceContextBuilder, - "type of providerOrApi[%s] is not LoadBalancerServiceContextBuilder: %s", providerOrApi, builder); - return LoadBalancerServiceContextBuilder.class.cast(builder); - } - - public LoadBalancerServiceContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public LoadBalancerServiceContextBuilder(M apiMetadata) { - super(apiMetadata); - } - -} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java index d42cce256b..4ddc31a067 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java @@ -21,11 +21,11 @@ package org.jclouds.loadbalancer; import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -54,21 +54,21 @@ public class LoadBalancerServiceContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, String identity, String credential) { + public LoadBalancerServiceContext createContext(String providerOrApi, String identity, String credential) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** * @see #createContext(String, String, String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, Properties overrides) { + public LoadBalancerServiceContext createContext(String providerOrApi, Properties overrides) { return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** * @see #createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, Iterable wiring, + public LoadBalancerServiceContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { return createContext(providerOrApi, null, null, wiring, overrides); } @@ -76,7 +76,7 @@ public class LoadBalancerServiceContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Properties overrides) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); } @@ -84,7 +84,7 @@ public class LoadBalancerServiceContextFactory { /** * @see createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring) { return createContext(providerOrApi, identity, credential, wiring, new Properties()); } @@ -104,28 +104,20 @@ public class LoadBalancerServiceContextFactory { * properties to override defaults with. * @return initialized context ready for use */ - @SuppressWarnings("unchecked") - public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - ContextBuilder builder = null; + ContextBuilder builder = null; try { - ProviderMetadata pm = Providers.withId(providerOrApi); - builder = LoadBalancerServiceContextBuilder.newBuilder(pm); + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = ContextBuilder.newBuilder(pm); } catch (NoSuchElementException e) { builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } - builder.modules(Iterable.class.cast(wiring)); + builder.modules(wiring); builder.overrides(overrides); if (identity != null) builder.credentials(identity, credential); - Object context = builder.build(); - if (context instanceof LoadBalancerServiceContext) { - return LoadBalancerServiceContext.class.cast(context); - } else { - throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " - + context.getClass().getSimpleName()); - } - + return builder.build(LoadBalancerServiceContext.class); } } diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java index b0e32f723e..1083898581 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java @@ -63,7 +63,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { protected Logger logger = Logger.NULL; protected final Supplier defaultLocationSupplier; - protected final LoadBalancerServiceContext context; + protected final LoadBalancerServiceContext context; protected final LoadBalanceNodesStrategy loadBalancerStrategy; protected final GetLoadBalancerMetadataStrategy getLoadBalancerMetadataStrategy; protected final DestroyLoadBalancerStrategy destroyLoadBalancerStrategy; @@ -71,7 +71,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { protected final Supplier> locations; @Inject - protected BaseLoadBalancerService(Supplier defaultLocationSupplier, @SuppressWarnings("rawtypes") LoadBalancerServiceContext context, + protected BaseLoadBalancerService(Supplier defaultLocationSupplier, LoadBalancerServiceContext context, LoadBalanceNodesStrategy loadBalancerStrategy, GetLoadBalancerMetadataStrategy getLoadBalancerMetadataStrategy, DestroyLoadBalancerStrategy destroyLoadBalancerStrategy, ListLoadBalancersStrategy listLoadBalancersStrategy, @@ -98,7 +98,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { * {@inheritDoc} */ @Override - public LoadBalancerServiceContext getContext() { + public LoadBalancerServiceContext getContext() { return context; } diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java deleted file mode 100644 index e4f7d3b383..0000000000 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.loadbalancer.internal; - -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; - -import com.google.common.annotations.Beta; -import com.google.common.reflect.TypeParameter; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public abstract class BaseLoadBalancerServiceApiMetadata, M extends LoadBalancerServiceApiMetadata> - extends BaseApiMetadata implements LoadBalancerServiceApiMetadata { - - public static class Builder, M extends LoadBalancerServiceApiMetadata> - extends BaseApiMetadata.Builder implements LoadBalancerServiceApiMetadata.Builder { - public Builder() { - type(ApiType.LOADBALANCER); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); - } - } - - protected BaseLoadBalancerServiceApiMetadata(BaseLoadBalancerServiceApiMetadata.Builder builder) { - super(builder); - } - -} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java deleted file mode 100644 index a134d63a68..0000000000 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.loadbalancer.internal; - -import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -/** - * @author Adrian Cole - */ -public abstract class BaseLoadBalancerServiceContextBuilder, M extends LoadBalancerServiceApiMetadata> - extends ContextBuilder { - - public BaseLoadBalancerServiceContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public BaseLoadBalancerServiceContextBuilder(M apiMetadata) { - super(apiMetadata); - } -} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java index 4353253c15..022a7b116d 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java @@ -20,42 +20,37 @@ package org.jclouds.loadbalancer.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.io.Closeable; + import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.internal.BaseWrapper; import org.jclouds.loadbalancer.LoadBalancerService; import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; +import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class LoadBalancerServiceContextImpl implements LoadBalancerServiceContext { +public class LoadBalancerServiceContextImpl extends BaseWrapper implements LoadBalancerServiceContext { private final LoadBalancerService loadBalancerService; - private final RestContext providerSpecificContext; private final Utils utils; - @SuppressWarnings({ "unchecked" }) @Inject - public LoadBalancerServiceContextImpl(LoadBalancerService loadBalancerService, Utils utils, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { + public LoadBalancerServiceContextImpl(@Provider Closeable wrapped, + @Provider TypeToken wrappedType, LoadBalancerService loadBalancerService, Utils utils) { + super(wrapped, wrappedType); this.utils = utils; - this.providerSpecificContext = providerSpecificContext; this.loadBalancerService = checkNotNull(loadBalancerService, "loadBalancerService"); } - @Override - public RestContext getProviderSpecificContext() { - return providerSpecificContext; - } - - @Override - public void close() { - providerSpecificContext.close(); - } - @Override public LoadBalancerService getLoadBalancerService() { return loadBalancerService; @@ -71,18 +66,29 @@ public class LoadBalancerServiceContextImpl implements LoadBalancerService return utils; } + @SuppressWarnings("unchecked") + @Override + public RestContext getProviderSpecificContext() { + return (RestContext) getWrapped(); + } + + @Override + public void close() { + Closeables.closeQuietly(getWrapped()); + } + public int hashCode() { - return providerSpecificContext.hashCode(); + return getWrapped().hashCode(); } @Override public String toString() { - return providerSpecificContext.toString(); + return getWrapped().toString(); } @Override public boolean equals(Object obj) { - return providerSpecificContext.equals(obj); + return getWrapped().equals(obj); } } diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java index 9bbfdb8b9f..f814e722e8 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java @@ -29,8 +29,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; @@ -41,7 +42,6 @@ import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.ssh.SshClient; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; @@ -49,6 +49,7 @@ import org.testng.annotations.Test; import com.google.common.base.Splitter; import com.google.common.collect.Iterables; +import com.google.common.reflect.TypeToken; import com.google.inject.Guice; import com.google.inject.Module; @@ -57,7 +58,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public abstract class BaseLoadBalancerServiceLiveTest> extends BaseContextLiveTest { +public abstract class BaseLoadBalancerServiceLiveTest extends BaseContextLiveTest { protected String imageId; protected String loginUser; @@ -100,7 +101,7 @@ public abstract class BaseLoadBalancerServiceLiveTest keyPair; protected LoadBalancerMetadata loadbalancer; - protected LoadBalancerServiceContext context; + protected LoadBalancerServiceContext context; protected String computeProvider; protected String computeIdentity; @@ -108,7 +109,7 @@ public abstract class BaseLoadBalancerServiceLiveTest computeContext; + protected ComputeServiceContext computeContext; @BeforeGroups(groups = { "integration", "live" }) @Override @@ -132,8 +133,8 @@ public abstract class BaseLoadBalancerServiceLiveTest contextType() { + return TypeToken.of(LoadBalancerServiceContext.class); + } } diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java index f55b210d32..4f054772ea 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java @@ -1,12 +1,26 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.loadbalancer.internal; -import java.util.Set; - +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.Apis; import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.testng.annotations.Test; @@ -20,15 +34,8 @@ import com.google.common.reflect.TypeToken; @Test(groups = "unit") public abstract class BaseLoadBalancerServiceApiMetadataTest extends BaseApiMetadataTest { - @SuppressWarnings("rawtypes") - public BaseLoadBalancerServiceApiMetadataTest(LoadBalancerServiceApiMetadata toTest) { - super(toTest, ApiType.LOADBALANCER); - } - - @Test - public void testContextAssignableFromLoadBalancerServiceContext() { - Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(LoadBalancerServiceContext.class))); - assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); + public BaseLoadBalancerServiceApiMetadataTest(ApiMetadata toTest) { + super(toTest, ImmutableSet.>of(TypeToken.of(LoadBalancerServiceContext.class))); } } \ No newline at end of file diff --git a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java index 56d4a634dd..7d2f8e2c48 100644 --- a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java +++ b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java @@ -25,11 +25,8 @@ import java.util.Properties; import org.jclouds.aws.domain.Region; import org.jclouds.cloudwatch.CloudWatchApiMetadata; -import org.jclouds.cloudwatch.CloudWatchAsyncClient; -import org.jclouds.cloudwatch.CloudWatchClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rest.RestContext; /** * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's CloudWatch @@ -37,8 +34,11 @@ import org.jclouds.rest.RestContext; * * @author Adrian Cole */ -public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata, CloudWatchApiMetadata> { +public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 2394954723306943404L; + public static Builder builder() { return new Builder(); } @@ -56,7 +56,7 @@ public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata, CloudWatchApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("aws-cloudwatch") @@ -87,7 +87,7 @@ public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata().toBuilder() + new CloudWatchApiMetadata().toBuilder() .version("2010-08-01").build()) .defaultProperties(AWSCloudWatchProviderMetadata.defaultProperties()); } @@ -98,8 +98,7 @@ public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata, CloudWatchApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java index 34e534042c..76b5a03b44 100644 --- a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java +++ b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java @@ -19,8 +19,6 @@ package org.jclouds.aws.cloudwatch; import org.jclouds.cloudwatch.CloudWatchApiMetadata; -import org.jclouds.cloudwatch.CloudWatchAsyncClient; -import org.jclouds.cloudwatch.CloudWatchClient; import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; @@ -33,6 +31,6 @@ import org.testng.annotations.Test; public class AWSCloudWatchProviderTest extends BaseProviderMetadataTest { public AWSCloudWatchProviderTest() { - super(new AWSCloudWatchProviderMetadata(), new CloudWatchApiMetadata()); + super(new AWSCloudWatchProviderMetadata(), new CloudWatchApiMetadata()); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java index 8fec86622d..e89fe71a64 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java @@ -24,16 +24,30 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.compute.config.AWSEC2ComputeServiceContextModule; +import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; import org.jclouds.ec2.EC2ApiMetadata; +import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; +import org.jclouds.rest.RestContext; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the Amazon-specific EC2 API * * @author Adrian Cole */ -public class AWSEC2ApiMetadata extends EC2ApiMetadata { +public class AWSEC2ApiMetadata extends EC2ApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1492951757032303845L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -51,7 +65,7 @@ public class AWSEC2ApiMetadata extends EC2ApiMetadata { + public static class Builder extends EC2ApiMetadata.Builder { protected Builder(){ super(AWSEC2Client.class, AWSEC2AsyncClient.class); id("aws-ec2") .version(AWSEC2AsyncClient.VERSION) .name("Amazon-specific EC2 API") - .context(TypeToken.of(AWSEC2ComputeServiceContext.class)) + .wrapper(AWSEC2ComputeServiceContext.class) .defaultProperties(AWSEC2ApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(AWSEC2ContextBuilder.class)); + .defaultModules(ImmutableSet.>of(AWSEC2RestClientModule.class, EC2ResolveImagesModule.class, AWSEC2ComputeServiceContextModule.class)); } @Override @@ -78,7 +92,7 @@ public class AWSEC2ApiMetadata extends EC2ApiMetadata { - public AWSEC2ContextBuilder() { - this(new AWSEC2ProviderMetadata()); - } - - public AWSEC2ContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public AWSEC2ContextBuilder(AWSEC2ApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - public AWSEC2ContextBuilder overrides(Properties overrides) { - super.overrides(warnAndReplaceIfUsingOldImageKey(overrides)); - return this; - } - - // TODO: determine how to do conditional manipulation w/rocoto - static Properties warnAndReplaceIfUsingOldImageKey(Properties props) { - if (props.containsKey(PROPERTY_EC2_AMI_OWNERS)) { - StringBuilder query = new StringBuilder(); - String owners = props.remove(PROPERTY_EC2_AMI_OWNERS).toString(); - if ("*".equals(owners)) - query.append("state=available;image-type=machine"); - else if (!"".equals(owners)) - query.append("owner-id=").append(owners).append(";state=available;image-type=machine"); - else if ("".equals(owners)) - query = new StringBuilder(); - props.setProperty(PROPERTY_EC2_AMI_QUERY, query.toString()); - Logger.getAnonymousLogger().warning( - String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS, - PROPERTY_EC2_AMI_QUERY, query.toString())); - } - return props; - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AWSEC2RestClientModule()); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new AWSEC2ComputeServiceContextModule()); - } - - @VisibleForTesting - public Properties getOverrides() { - return overrides; - } - -} 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 46a34a8212..07504d4c1e 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 @@ -28,7 +28,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -38,7 +37,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class AWSEC2ProviderMetadata extends BaseProviderMetadata { +public class AWSEC2ProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -57,7 +56,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("aws-ec2") @@ -98,7 +97,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java index 753ab0302b..758f66c13e 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java @@ -34,8 +34,8 @@ import org.jclouds.rest.Binder; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; /** * diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java index 758630b61c..d54c7ed19d 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java @@ -92,7 +92,7 @@ public class AWSEC2ComputeService extends EC2ComputeService { private final boolean generateInstanceNames; @Inject - protected AWSEC2ComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected AWSEC2ComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java index 2b1642a084..61507a9fe8 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java @@ -18,8 +18,6 @@ */ package org.jclouds.aws.ec2.compute; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.compute.internal.AWSEC2ComputeServiceContextImpl; import org.jclouds.ec2.compute.EC2ComputeServiceContext; @@ -29,7 +27,7 @@ import com.google.inject.ImplementedBy; * @author Adrian Cole */ @ImplementedBy(AWSEC2ComputeServiceContextImpl.class) -public interface AWSEC2ComputeServiceContext extends EC2ComputeServiceContext { +public interface AWSEC2ComputeServiceContext extends EC2ComputeServiceContext { @Override AWSEC2ComputeService getComputeService(); } \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java index c46cacd2ad..654078797a 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java @@ -21,6 +21,7 @@ package org.jclouds.aws.ec2.compute.config; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX; +import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicReference; @@ -38,7 +39,6 @@ import org.jclouds.aws.ec2.compute.strategy.AWSEC2ListNodesStrategy; import org.jclouds.aws.ec2.compute.strategy.AWSEC2ReviseParsedImage; import org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions; import org.jclouds.aws.ec2.compute.suppliers.AWSEC2HardwareSupplier; -import org.jclouds.aws.ec2.reference.AWSEC2Constants; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.TemplateBuilder; @@ -72,7 +72,6 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; /** * @@ -105,10 +104,8 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext @Override protected boolean shouldParseImagesOnDemand(Injector injector) { // If no queries defined, then will never lookup all images - String amiQuery = injector.getInstance(Key.get(String.class, Names.named(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY))); - String amiCcQuery = injector.getInstance(Key.get(String.class, Names.named(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY))); - - return !(amiQuery.isEmpty() && amiCcQuery.isEmpty()); + return injector.getInstance(Key.get(new TypeLiteral>() { + }, ImageQuery.class)).size() > 0; } // duplicates EC2ComputeServiceContextModule; but that's easiest thing to do with guice; could extract to common util diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java index c123d18db4..e62a5c49cd 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java @@ -18,14 +18,17 @@ */ package org.jclouds.aws.ec2.compute.config; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.*; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; + +import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.compute.AWSEC2ComputeService; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.aws.ec2.compute.suppliers.CallForImages; @@ -36,11 +39,10 @@ import org.jclouds.aws.ec2.functions.ImportOrReturnExistingKeypair; import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable; import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.config.ValueOfConfigurationKeyOrNull; import org.jclouds.domain.Credentials; import org.jclouds.ec2.compute.config.EC2ComputeServiceDependenciesModule; import org.jclouds.ec2.compute.domain.RegionAndName; @@ -53,17 +55,17 @@ import org.jclouds.ec2.compute.loaders.RegionAndIdToImage; import org.jclouds.ec2.domain.KeyPair; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.RestContextImpl; import com.google.common.base.Function; import com.google.common.base.Predicate; +import com.google.common.base.Strings; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Provides; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.assistedinject.FactoryModuleBuilder; import com.google.inject.name.Names; @@ -73,7 +75,6 @@ import com.google.inject.name.Names; * @author Adrian Cole */ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDependenciesModule { - @SuppressWarnings("rawtypes") @Override protected void configure() { bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class); @@ -91,15 +92,37 @@ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDep }).to(ImportOrReturnExistingKeypair.class); bind(new TypeLiteral>() { }).to(RegionAndIdToImage.class); - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); - bind(new TypeLiteral>() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); install(new FactoryModuleBuilder().build(CallForImages.Factory.class)); } + @Provides + @Singleton + @ImageQuery + protected Map imageQuery(ValueOfConfigurationKeyOrNull config) { + String amiQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_AMI_QUERY)); + if (config.apply(PROPERTY_EC2_AMI_OWNERS) != null) { + StringBuilder query = new StringBuilder(); + String owners = config.apply(PROPERTY_EC2_AMI_OWNERS).toString(); + if ("*".equals(owners)) + query.append("state=available;image-type=machine"); + else if (!"".equals(owners)) + query.append("owner-id=").append(owners).append(";state=available;image-type=machine"); + else if ("".equals(owners)) + query = new StringBuilder(); + Logger.getAnonymousLogger().warning( + String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS, + PROPERTY_EC2_AMI_QUERY, query.toString())); + amiQuery = query.toString(); + } + Builder builder = ImmutableMap. builder(); + if (amiQuery != null) + builder.put(PROPERTY_EC2_AMI_QUERY, amiQuery); + String ccQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_CC_AMI_QUERY)); + if (ccQuery != null) + builder.put(PROPERTY_EC2_CC_AMI_QUERY, ccQuery); + return builder.build(); + } + @Provides @Singleton @Named("AVAILABLE") diff --git a/core/src/main/java/org/jclouds/http/RequiresHttp.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java similarity index 71% rename from core/src/main/java/org/jclouds/http/RequiresHttp.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java index 21f188bd39..18f84958ea 100644 --- a/core/src/main/java/org/jclouds/http/RequiresHttp.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java @@ -16,22 +16,24 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.http; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +package org.jclouds.aws.ec2.compute.config; +import java.lang.annotation.ElementType; import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.inject.Qualifier; + /** - * designates the cloud has an HTTP API + * Related to an Image Query * * @author Adrian Cole * */ -@Retention(RUNTIME) -@Target(TYPE) -public @interface RequiresHttp { +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface ImageQuery { -} +} \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java index 4ed9c3fba1..bdff743e5d 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java @@ -18,29 +18,30 @@ */ package org.jclouds.aws.ec2.compute.internal; +import java.io.Closeable; import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.compute.AWSEC2ComputeService; import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.compute.Utils; import org.jclouds.domain.Credentials; import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl; -import org.jclouds.rest.RestContext; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; /** * @author Adrian Cole */ @Singleton -public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements AWSEC2ComputeServiceContext { +public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements AWSEC2ComputeServiceContext { @Inject - public AWSEC2ComputeServiceContextImpl(AWSEC2ComputeService computeService, Map credentialStore, - Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { - super(computeService, credentialStore, utils, providerSpecificContext); + public AWSEC2ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + AWSEC2ComputeService computeService, Map credentialStore, Utils utils){ + super(wrapped, wrappedType, computeService, credentialStore, utils); } @Override diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java index 277bc0a18c..e4cf5b0618 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java @@ -36,6 +36,7 @@ import javax.inject.Singleton; import org.jclouds.Constants; import org.jclouds.aws.ec2.compute.config.ClusterCompute; +import org.jclouds.aws.ec2.compute.config.ImageQuery; import org.jclouds.compute.domain.Image; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.ec2.compute.domain.RegionAndName; @@ -73,31 +74,31 @@ public class AWSEC2ImageSupplier implements Supplier> { private final ExecutorService executor; private final Supplier> regions; - private final String amiQuery; + private final Map queries; private final Iterable clusterRegions; - private final String ccAmiQuery; private final Supplier> cache; @Inject protected AWSEC2ImageSupplier(@Region Supplier> regions, - @Named(PROPERTY_EC2_AMI_QUERY) String amiQuery, @Named(PROPERTY_EC2_CC_REGIONS) String clusterRegions, - @Named(PROPERTY_EC2_CC_AMI_QUERY) String ccAmiQuery, + @ImageQuery Map queries, @Named(PROPERTY_EC2_CC_REGIONS) String clusterRegions, Supplier> cache, CallForImages.Factory factory, @ClusterCompute Set clusterComputeIds, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) { this.factory = factory; this.regions = regions; - this.amiQuery = amiQuery; + this.queries = queries; this.clusterRegions = Splitter.on(',').split(clusterRegions); - this.ccAmiQuery = ccAmiQuery; this.cache = cache; this.clusterComputeIds = clusterComputeIds; this.executor = executor; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("unchecked") @Override public Set get() { + String amiQuery = queries.get(PROPERTY_EC2_AMI_QUERY); + String ccAmiQuery= queries.get(PROPERTY_EC2_CC_AMI_QUERY); + Future> normalImages = images(regions.get(), amiQuery, PROPERTY_EC2_AMI_QUERY); ImmutableSet clusterImages; try { @@ -124,7 +125,7 @@ public class AWSEC2ImageSupplier implements Supplier> { final Map imageMap = ImagesToRegionAndIdMap.imagesToMap(parsedImages); cache.get().invalidateAll(); - cache.get().asMap().putAll((Map)imageMap); + cache.get().asMap().putAll((Map) imageMap); logger.debug("<< images(%d)", imageMap.size()); // TODO Used to be mutable; was this assumed anywhere? @@ -136,7 +137,7 @@ public class AWSEC2ImageSupplier implements Supplier> { } private Future> images(Iterable regions, String query, String tag) { - if (query.equals("")) { + if (query == null) { logger.debug(">> no %s specified, skipping image parsing", tag); return Futures.> immediateFuture(ImmutableSet. of()); } else { diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java index fa4559c7d1..9fb8b9cf19 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java @@ -39,9 +39,9 @@ import org.jclouds.logging.Logger; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.assistedinject.Assisted; /** diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java index a5b4c7105f..90072be664 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java @@ -61,7 +61,6 @@ import org.jclouds.ec2.services.SecurityGroupAsyncClient; import org.jclouds.ec2.services.SecurityGroupClient; import org.jclouds.ec2.services.WindowsAsyncClient; import org.jclouds.ec2.services.WindowsClient; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import com.google.common.collect.ImmutableMap; @@ -72,7 +71,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class AWSEC2RestClientModule extends EC2RestClientModule { diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java index cd2d12c99a..bd2e719c94 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java @@ -22,38 +22,50 @@ import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUE import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; import static org.testng.Assert.assertEquals; +import java.util.Map; import java.util.Properties; +import org.jclouds.ContextBuilder; +import org.jclouds.aws.ec2.compute.config.ImageQuery; import org.testng.annotations.Test; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; + /** * @author Adrian Cole */ @Test(groups = "unit", testName = "AWSEC2ContextBuilderTest") public class AWSEC2ContextBuilderTest { + private Map queriesForProperties(Properties input) { + return ContextBuilder.newBuilder(new AWSEC2ProviderMetadata()).overrides(input).credentials("foo", "bar") + .buildInjector().getInstance(Key.get(new TypeLiteral>() { + }, ImageQuery.class)); + } public void testConvertImageSyntax() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317"); - Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), + Map queries = queriesForProperties(input); + assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY), "owner-id=137112412989,063491364108,099720109477,411009282317;state=available;image-type=machine"); } public void testConvertImageSyntaxWhenStar() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); - Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), "state=available;image-type=machine"); + Map queries = queriesForProperties(input); + assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY), "state=available;image-type=machine"); } - public void testConvertImageSyntaxWhenBlank() { + public void testStaysPutWhenBlank() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, ""); - Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), ""); + Map queries = queriesForProperties(input); + assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY), new AWSEC2ProviderMetadata().getDefaultProperties() + .getProperty(PROPERTY_EC2_AMI_QUERY)); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index 8ebe24b440..a57c2801a5 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -31,8 +31,9 @@ import java.util.Date; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.jclouds.ContextBuilder; import org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.MonitoringState; @@ -56,7 +57,6 @@ import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.ec2.services.InstanceClient; import org.jclouds.ec2.services.KeyPairClient; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.scriptbuilder.domain.Statements; import org.testng.annotations.Test; @@ -73,7 +73,7 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AWSEC2ComputeServiceLiveTest") -public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { +public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public AWSEC2ComputeServiceLiveTest() { provider = "aws-ec2"; @@ -93,12 +93,12 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest destroyer) throws Exception { - AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()) + AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getSecurityGroupServices(); - KeyPairClient keyPairClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) + KeyPairClient keyPairClient = EC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getKeyPairServices(); - InstanceClient instanceClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) + InstanceClient instanceClient = EC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getInstanceServices(); String group = this.group + "incidental"; diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index f32ff4875e..b02b379c7f 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -28,8 +28,6 @@ import java.util.Properties; import java.util.Set; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.reference.AWSEC2Constants; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; @@ -60,7 +58,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { +public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { public AWSEC2TemplateBuilderLiveTest() { provider = "aws-ec2"; @@ -239,7 +237,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set owners to nothing @@ -273,7 +271,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set owners to nothing @@ -307,7 +305,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set regions to only 1 diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java index fd7ece9fa4..556426ad44 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java @@ -29,9 +29,7 @@ import java.util.Iterator; import java.util.Set; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.compute.ComputeService; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.NodeMetadata; @@ -40,11 +38,11 @@ import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.predicates.ImagePredicates; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.Snapshot; +import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.services.AMIClient; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; @@ -63,7 +61,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { public AMIClientLiveTest() { provider = "aws-ec2"; // TODO: parameterize this. @@ -81,7 +79,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest allResults = client.describeImagesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); @@ -186,10 +184,10 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest nodes = computeService.createNodesInGroup("jcloudstest", 1, options); try { String instanceId = Iterables.getOnlyElement(nodes).getProviderId(); - Reservation reservation = Iterables.getOnlyElement(context.getProviderSpecificContext().getApi().getInstanceServices().describeInstancesInRegion(null, instanceId)); + Reservation reservation = Iterables.getOnlyElement(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices().describeInstancesInRegion(null, instanceId)); RunningInstance instance = Iterables.getOnlyElement(reservation); BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1"); - Snapshot snapshot = context.getProviderSpecificContext().getApi().getElasticBlockStoreServices().createSnapshotInRegion(null, device.getVolumeId()); + Snapshot snapshot = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices().createSnapshotInRegion(null, device.getVolumeId()); snapshotsToDelete.add(snapshot.getId()); return snapshot; } finally { @@ -271,7 +269,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AWSAMIClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSAMIClientLiveTest() { provider = "aws-ec2"; // TODO: parameterize this. @@ -65,7 +63,7 @@ public class AWSAMIClientLiveTest extends BaseComputeServiceContextLiveTest allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java index 068e7dec17..de125a3107 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java @@ -22,9 +22,7 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; @@ -37,7 +35,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSInstanceClientLiveTest() { provider = "aws-ec2"; } @@ -50,12 +48,12 @@ public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi().getInstanceServices(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices(); } @Test void testDescribeInstances() { - for (String region : context.getProviderSpecificContext().getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set> allResults = client.describeInstancesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 0 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java index 5a915fb7aa..3ba56147d3 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java @@ -35,9 +35,8 @@ import java.util.Set; import java.util.SortedSet; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.compute.ComputeServiceContext; @@ -61,7 +60,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSKeyPairClientLiveTest() { provider = "aws-ec2"; } @@ -72,14 +71,14 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest< @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi().getKeyPairServices(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices(); } public void testNoSsh() throws Exception { Map keyPair = ComputeTestUtils.setupKeyPair(); - AWSInstanceClient instanceClient = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()).getInstanceServices(); + AWSInstanceClient instanceClient = AWSEC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()).getInstanceServices(); String group = PREFIX + "unssh"; context.getComputeService().destroyNodesMatching(inGroup(group)); @@ -88,7 +87,7 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest< options.authorizePublicKey(keyPair.get("public")).as(AWSEC2TemplateOptions.class); - ComputeServiceContext noSshContext = null; + ComputeServiceContext noSshContext = null; try { noSshContext = createContext(setupProperties(), ImmutableSet. of(new Log4JLoggingModule())); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java index fc3b2a0966..7c86695f43 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java @@ -23,9 +23,6 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.ec2.domain.IpPermission; import org.jclouds.ec2.domain.IpProtocol; import org.jclouds.ec2.domain.SecurityGroup; @@ -41,7 +38,7 @@ import com.google.common.collect.ImmutableMultimap; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { +public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { public AWSSecurityGroupClientLiveTest() { provider = "aws-ec2"; } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java index 3e184ba397..add38e4eca 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java @@ -36,7 +36,6 @@ import org.jclouds.compute.domain.Image; import org.jclouds.date.DateService; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; @@ -61,8 +60,7 @@ import com.google.inject.Provides; @Test(groups = "unit") public abstract class BaseAWSEC2AsyncClientTest extends BaseAsyncClientTest { - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient protected static class StubAWSEC2RestClientModule extends AWSEC2RestClientModule { @Override diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java index a1333fa1bb..595dec84b6 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java @@ -22,9 +22,7 @@ import static org.testng.Assert.assertEquals; import java.util.Map; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.domain.MonitoringState; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.testng.annotations.BeforeClass; @@ -36,7 +34,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class MonitoringClientLiveTest extends BaseComputeServiceContextLiveTest { +public class MonitoringClientLiveTest extends BaseComputeServiceContextLiveTest { public MonitoringClientLiveTest() { provider = "aws-ec2"; } @@ -49,7 +47,7 @@ public class MonitoringClientLiveTest extends BaseComputeServiceContextLiveTest< @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi().getMonitoringServices(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getMonitoringServices(); } @Test(enabled = false) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index 0899b6ce28..1e5662434a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -29,9 +29,8 @@ import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.aws.ec2.domain.PlacementGroup.State; import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable; @@ -59,7 +58,7 @@ import com.google.common.base.Throwables; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "PlacementGroupClientLiveTest") -public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest { +public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest { public PlacementGroupClientLiveTest() { provider = "aws-ec2"; } @@ -73,7 +72,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); availableTester = new RetryablePredicate(new PlacementGroupAvailable(client), 60, 1, TimeUnit.SECONDS); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java index 32c895b320..36726832a7 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java @@ -31,9 +31,8 @@ import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.LaunchSpecification; import org.jclouds.aws.ec2.domain.Spot; @@ -55,7 +54,7 @@ import com.google.common.collect.ImmutableSortedSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { +public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { public SpotInstanceClientLiveTest() { provider = "aws-ec2"; } @@ -71,7 +70,7 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); activeTester = new RetryablePredicate(new SpotInstanceRequestActive(client), SPOT_DELAY_SECONDS, 1, 1, TimeUnit.SECONDS); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java index 3f554f7f34..13723dc0e8 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java @@ -24,9 +24,7 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.Tag; import org.jclouds.aws.ec2.util.TagFilters; @@ -46,7 +44,7 @@ import com.google.common.collect.Iterables; * @author grkvlt@apache.org */ @Test(groups = "live", singleThreaded = true) -public class TagClientLiveTest extends BaseComputeServiceContextLiveTest { +public class TagClientLiveTest extends BaseComputeServiceContextLiveTest { public TagClientLiveTest() { provider = "aws-ec2"; } @@ -58,22 +56,22 @@ public class TagClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AWSS3ApiMetadata extends S3ApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1572520638079261710L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -49,19 +62,19 @@ public class AWSS3ApiMetadata extends S3ApiMetadata { + public static class Builder extends S3ApiMetadata.Builder { protected Builder(){ super(AWSS3Client.class, AWSS3AsyncClient.class); id("aws-s3") .name("Amazon-specific S3 API") .defaultProperties(AWSS3ApiMetadata.defaultProperties()) - .context(TypeToken.of(AWSS3BlobStoreContext.class)) - .contextBuilder(TypeToken.of(AWSS3ContextBuilder.class)); + .wrapper(TypeToken.of(AWSS3BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(AWSS3RestClientModule.class, AWSS3BlobStoreContextModule.class)); } @Override @@ -70,7 +83,7 @@ public class AWSS3ApiMetadata extends S3ApiMetadata { - public AWSS3ContextBuilder() { - this(new AWSS3ProviderMetadata()); - } - - public AWSS3ContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public AWSS3ContextBuilder(AWSS3ApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new AWSS3BlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AWSS3RestClientModule()); - } - -} 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 7dafc9d487..24e9d6234c 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 @@ -32,7 +32,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -42,8 +41,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class AWSS3ProviderMetadata extends BaseProviderMetadata { +public class AWSS3ProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 3727028894286338406L; + public static Builder builder() { return new Builder(); } @@ -61,7 +63,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("aws-s3") @@ -97,7 +99,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java index 7f8476d7c8..6d54d71953 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java @@ -28,6 +28,7 @@ import javax.inject.Named; import javax.inject.Provider; import org.jclouds.Constants; +import org.jclouds.aws.s3.AWSS3ApiMetadata; import org.jclouds.aws.s3.AWSS3AsyncClient; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.options.AWSS3PutObjectOptions; @@ -41,7 +42,6 @@ import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; -import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.blobstore.S3AsyncBlobStore; import org.jclouds.s3.blobstore.functions.BlobToObject; import org.jclouds.s3.blobstore.functions.BucketToResourceList; @@ -69,7 +69,7 @@ public class AWSS3AsyncBlobStore extends S3AsyncBlobStore { private final BlobToObject blob2Object; @Inject - public AWSS3AsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + public AWSS3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AWSS3AsyncClient async, AWSS3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, @@ -112,8 +112,8 @@ public class AWSS3AsyncBlobStore extends S3AsyncBlobStore { } catch (CacheLoader.InvalidCacheLoadException e) { // nulls not permitted from cache loader } - return S3AsyncClient.class.cast(getContext().getProviderSpecificContext().getApi()) - .putObject(container, blob2Object.apply(blob), options); - } + return getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getAsyncApi().putObject(container, + blob2Object.apply(blob), options); + } } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java index 8fc842687d..89cc7e5ac1 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java @@ -25,6 +25,7 @@ import java.util.Set; import javax.inject.Inject; import javax.inject.Provider; +import org.jclouds.aws.s3.AWSS3ApiMetadata; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.options.AWSS3PutObjectOptions; import org.jclouds.aws.s3.blobstore.options.AWSS3PutOptions; @@ -37,7 +38,6 @@ import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; -import org.jclouds.s3.S3Client; import org.jclouds.s3.blobstore.S3BlobStore; import org.jclouds.s3.blobstore.functions.BlobToObject; import org.jclouds.s3.blobstore.functions.BucketToResourceList; @@ -65,7 +65,7 @@ public class AWSS3BlobStore extends S3BlobStore { private final BlobToObject blob2Object; @Inject - AWSS3BlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AWSS3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AWSS3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob, @@ -108,7 +108,7 @@ public class AWSS3BlobStore extends S3BlobStore { } catch (CacheLoader.InvalidCacheLoadException e) { // nulls not permitted from cache loader } - return S3Client.class.cast(getContext().getProviderSpecificContext().getApi()) - .putObject(container, blob2Object.apply(blob), options); + return getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi().putObject(container, blob2Object.apply(blob), + options); } } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java index a95e175ab0..ed1c859440 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java @@ -18,8 +18,6 @@ */ package org.jclouds.aws.s3.blobstore; -import org.jclouds.aws.s3.AWSS3AsyncClient; -import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.internal.AWSS3BlobStoreContextImpl; import org.jclouds.s3.blobstore.S3BlobStoreContext; @@ -29,7 +27,7 @@ import com.google.inject.ImplementedBy; * @author Adrian Cole */ @ImplementedBy(AWSS3BlobStoreContextImpl.class) -public interface AWSS3BlobStoreContext extends S3BlobStoreContext { +public interface AWSS3BlobStoreContext extends S3BlobStoreContext { @Override AWSS3BlobStore getBlobStore(); diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/config/AWSS3BlobStoreContextModule.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/config/AWSS3BlobStoreContextModule.java index 71c85e2eec..4b8a2f5316 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/config/AWSS3BlobStoreContextModule.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/config/AWSS3BlobStoreContextModule.java @@ -18,22 +18,17 @@ */ package org.jclouds.aws.s3.blobstore.config; -import org.jclouds.aws.s3.AWSS3AsyncClient; -import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.AWSS3AsyncBlobStore; import org.jclouds.aws.s3.blobstore.AWSS3BlobStore; import org.jclouds.aws.s3.blobstore.strategy.AsyncMultipartUploadStrategy; import org.jclouds.aws.s3.blobstore.strategy.MultipartUploadStrategy; import org.jclouds.aws.s3.blobstore.strategy.internal.ParallelMultipartUploadStrategy; import org.jclouds.aws.s3.blobstore.strategy.internal.SequentialMultipartUploadStrategy; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.s3.blobstore.S3AsyncBlobStore; import org.jclouds.s3.blobstore.S3BlobStore; import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * @@ -51,10 +46,4 @@ public class AWSS3BlobStoreContextModule extends S3BlobStoreContextModule { bind(AsyncMultipartUploadStrategy.class).to(ParallelMultipartUploadStrategy.class); } - @Override - protected void bindContext() { - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); - } - } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java index 640f7431d1..4ba96d14a2 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java @@ -18,35 +18,39 @@ */ package org.jclouds.aws.s3.blobstore.internal; +import java.io.Closeable; + import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.aws.s3.AWSS3AsyncClient; -import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.AWSS3AsyncBlobStore; import org.jclouds.aws.s3.blobstore.AWSS3BlobStore; import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; +import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.InputStreamMap; import org.jclouds.blobstore.attr.ConsistencyModel; -import org.jclouds.rest.RestContext; +import org.jclouds.location.Provider; import org.jclouds.rest.Utils; import org.jclouds.s3.blobstore.internal.S3BlobStoreContextImpl; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class AWSS3BlobStoreContextImpl extends S3BlobStoreContextImpl implements - AWSS3BlobStoreContext { +public class AWSS3BlobStoreContextImpl extends S3BlobStoreContextImpl implements AWSS3BlobStoreContext { @Inject - public AWSS3BlobStoreContextImpl(BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, - InputStreamMap.Factory inputStreamMapFactory, AWSS3AsyncBlobStore ablobStore, AWSS3BlobStore blobStore, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext, BlobRequestSigner blobRequestSigner) { - super(blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, blobStore, providerSpecificContext, - blobRequestSigner); + public AWSS3BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, + InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, + BlobRequestSigner blobRequestSigner) { + super(wrapped, wrappedType, blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, + blobStore, blobRequestSigner); } @Override diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java index fdfbcfc48b..d16cca3c5d 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java @@ -39,6 +39,7 @@ import javax.annotation.Resource; import javax.inject.Named; import org.jclouds.Constants; +import org.jclouds.aws.s3.AWSS3ApiMetadata; import org.jclouds.aws.s3.AWSS3AsyncClient; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.AWSS3AsyncBlobStore; @@ -118,8 +119,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra latch.countDown(); return; } - final AWSS3AsyncClient client = (AWSS3AsyncClient) ablobstore.getContext() - .getProviderSpecificContext().getAsyncApi(); + final AWSS3AsyncClient client = ablobstore.getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getAsyncApi(); Payload chunkedPart = slicer.slice(payload, offset, size); logger.debug(String.format("async uploading part %s of %s to container %s with uploadId %s", part, key, container, uploadId)); final long start = System.currentTimeMillis(); @@ -169,7 +169,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra long remaining = algorithm.getRemaining(); if (parts > 0) { AWSS3Client client = (AWSS3Client) ablobstore - .getContext().getProviderSpecificContext().getApi(); + .getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi(); String uploadId = null; final Map> futureParts = new ConcurrentHashMap>(); diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java index b7bd47030a..e262186854 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java @@ -25,6 +25,7 @@ import java.util.SortedMap; import javax.annotation.Resource; import javax.inject.Named; +import org.jclouds.aws.s3.AWSS3ApiMetadata; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.AWSS3BlobStore; import org.jclouds.aws.s3.blobstore.strategy.MultipartUploadStrategy; @@ -69,8 +70,7 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg protected void prepareUploadPart(String container, String key, String uploadId, int part, Payload payload, long offset, long size, SortedMap etags) { - AWSS3Client client = (AWSS3Client) ablobstore.getContext() - .getProviderSpecificContext().getApi(); + AWSS3Client client = ablobstore.getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi(); Payload chunkedPart = slicer.slice(payload, offset, size); String eTag = null; try { @@ -100,7 +100,7 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg long chunkSize = algorithm.getChunkSize(); if (parts > 0) { AWSS3Client client = (AWSS3Client) ablobstore.getContext() - .getProviderSpecificContext().getApi(); + .unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi(); String uploadId = client.initiateMultipartUpload(container, ObjectMetadataBuilder.create().key(key).build()); // TODO md5 try { diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java index f003e5c57d..f46844114d 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java @@ -30,7 +30,6 @@ import javax.inject.Singleton; import org.jclouds.aws.s3.AWSS3AsyncClient; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.binders.AssignCorrectHostnameAndBindAsHostPrefixIfConfigured; -import org.jclouds.http.RequiresHttp; import org.jclouds.location.Region; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestContext; @@ -49,7 +48,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class AWSS3RestClientModule extends S3RestClientModule { diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java index 70020caa99..6a2aa034bc 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java @@ -29,7 +29,6 @@ import org.jclouds.aws.s3.functions.UploadIdFromHttpResponseViaRegex; import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -40,6 +39,7 @@ import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.s3.S3AsyncClientTest; import org.jclouds.s3.domain.ObjectMetadata; import org.jclouds.s3.domain.ObjectMetadataBuilder; import org.jclouds.s3.domain.S3Object; @@ -61,7 +61,7 @@ import com.google.inject.TypeLiteral; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", testName = "AWSS3AsyncClientTest") -public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest { +public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testGetBucketLocationEU() throws SecurityException, NoSuchMethodException, IOException { Method method = AWSS3AsyncClient.class.getMethod("getBucketLocation", String.class); @@ -250,8 +250,7 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest psc = createMock(RestContextImpl.class); + RestContext psc = createMock(RestContextImpl.class); AWSS3Client client = createMock(AWSS3Client.class); ObjectMetadata ometa = createMock(ObjectMetadata.class); String uploadId = "uploadId"; @@ -83,7 +84,7 @@ public class SequentialMultipartUploadStrategyTest { expect(payload.getContentMetadata()).andReturn(contentMeta).atLeastOnce(); expect(contentMeta.getContentLength()).andReturn(new Long(chunkSize + remaining)); expect(ablobStore.getContext()).andReturn(context).atLeastOnce(); - expect(context.getProviderSpecificContext()).andReturn(psc).atLeastOnce(); + expect(context.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN)).andReturn(psc).atLeastOnce(); expect(psc.getApi()).andReturn(client).atLeastOnce(); expect(client.initiateMultipartUpload(container, new ObjectMetadataBuilder().key(key).build())).andReturn("uploadId").atLeastOnce(); expect(slicer.slice(payload, 0, chunkSize)).andReturn(payload).atLeastOnce(); @@ -129,9 +130,8 @@ public class SequentialMultipartUploadStrategyTest { MutableBlobMetadata blobMeta = createMock(MutableBlobMetadata.class); Payload payload = createMock(Payload.class); MutableContentMetadata contentMeta = createMock(MutableContentMetadata.class); - @SuppressWarnings("rawtypes") BlobStoreContext context = createMock(BlobStoreContext.class); - RestContext psc = createMock(RestContextImpl.class); + RestContext psc = createMock(RestContextImpl.class); AWSS3Client client = createMock(AWSS3Client.class); ObjectMetadata ometa = createMock(ObjectMetadata.class); String uploadId = "uploadId"; @@ -147,7 +147,7 @@ public class SequentialMultipartUploadStrategyTest { expect(payload.getContentMetadata()).andReturn(contentMeta).atLeastOnce(); expect(contentMeta.getContentLength()).andReturn(new Long(chunkSize + remaining)); expect(ablobStore.getContext()).andReturn(context).atLeastOnce(); - expect(context.getProviderSpecificContext()).andReturn(psc).atLeastOnce(); + expect(context.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN)).andReturn(psc).atLeastOnce(); expect(psc.getApi()).andReturn(client).atLeastOnce(); expect(client.initiateMultipartUpload(container, new ObjectMetadataBuilder().key(key).build())).andReturn("uploadId").atLeastOnce(); expect(slicer.slice(payload, 0, chunkSize)).andReturn(payload).atLeastOnce(); diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java index 671c1712b8..30fe827560 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java @@ -22,7 +22,6 @@ import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.AWSS3ProviderMetadata; import org.jclouds.aws.s3.config.AWSS3RestClientModule; import org.jclouds.date.TimeStamp; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseRestClientExpectTest; @@ -45,12 +44,11 @@ public class BaseAWSS3ClientExpectTest extends BaseRestClientExpectTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new AWSS3ProviderMetadata(); } - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient private static final class TestAWSS3RestClientModule extends AWSS3RestClientModule { @Override protected String provideTimeStamp(@TimeStamp Supplier cache) { diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java index e0d21bee2a..4dcf4de114 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java @@ -24,19 +24,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.azureblob.blobstore.config.AzureBlobStoreContextModule; +import org.jclouds.azureblob.config.AzureBlobRestClientModule; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Microsoft Azure Blob Service API * * @author Adrian Cole */ -public class AzureBlobApiMetadata - extends - BaseBlobStoreApiMetadata, AzureBlobApiMetadata> { +public class AzureBlobApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 8067252472547486854L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -54,25 +64,26 @@ public class AzureBlobApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-ms-meta-"); return properties; } - public static class Builder extends BaseBlobStoreApiMetadata.Builder, AzureBlobApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder(){ - id("azureblob") - .name("Microsoft Azure Blob Service API") - .identityName("Account Name") - .credentialName("Access Key") - .version("2009-09-19") - .defaultEndpoint("https://${jclouds.identity}.blob.core.windows.net") - .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx")) - .contextBuilder(TypeToken.of(AzureBlobContextBuilder.class)) - .javaApi(AzureBlobClient.class, AzureBlobAsyncClient.class) - .defaultProperties(AzureBlobApiMetadata.defaultProperties()); - } + super(AzureBlobClient.class, AzureBlobAsyncClient.class); + id("azureblob") + .name("Microsoft Azure Blob Service API") + .identityName("Account Name") + .credentialName("Access Key") + .version("2009-09-19") + .defaultEndpoint("https://${jclouds.identity}.blob.core.windows.net") + .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx")) + .defaultProperties(AzureBlobApiMetadata.defaultProperties()) + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(AzureBlobRestClientModule.class, AzureBlobStoreContextModule.class)); + } @Override public AzureBlobApiMetadata build() { @@ -80,7 +91,7 @@ public class AzureBlobApiMetadata } @Override - public Builder fromApiMetadata(AzureBlobApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java deleted file mode 100644 index e3492de627..0000000000 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.azureblob; - -import java.util.List; - -import org.jclouds.azureblob.blobstore.config.AzureBlobStoreContextModule; -import org.jclouds.azureblob.config.AzureBlobRestClientModule; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link AzureBlobStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see AzureBlobStoreContext - */ -public class AzureBlobContextBuilder - extends - BlobStoreContextBuilder, AzureBlobApiMetadata> { - - public AzureBlobContextBuilder() { - this(new AzureBlobProviderMetadata()); - } - - public AzureBlobContextBuilder( - ProviderMetadata, AzureBlobApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public AzureBlobContextBuilder(AzureBlobApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new AzureBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AzureBlobRestClientModule()); - } -} diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java index 446b44aabb..7a12bd5851 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.azureblob; import java.net.URI; import java.util.Properties; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -30,7 +29,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class AzureBlobProviderMetadata extends BaseProviderMetadata, AzureBlobApiMetadata> { +public class AzureBlobProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8271570736207734777L; public static Builder builder() { return new Builder(); @@ -49,11 +51,11 @@ public class AzureBlobProviderMetadata extends BaseProviderMetadata, AzureBlobApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("azureblob") @@ -74,7 +76,7 @@ public class AzureBlobProviderMetadata extends BaseProviderMetadata, AzureBlobApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java index 43b85e60b2..3b2d41242a 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java @@ -33,8 +33,8 @@ import org.jclouds.http.utils.ModifyRequest; import org.jclouds.rest.Binder; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; @Singleton public class BindAzureBlobMetadataToRequest implements Binder { diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java index 10adc18057..dc8980bae4 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java @@ -80,7 +80,7 @@ public class AzureAsyncBlobStore extends BaseAsyncBlobStore { private final BlobToHttpGetOptions blob2ObjectGetOptions; @Inject - AzureAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + AzureAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AzureBlobAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java index bc51aa5b22..629f176ca7 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java @@ -72,7 +72,7 @@ public class AzureBlobStore extends BaseBlobStore { private final BlobToHttpGetOptions blob2ObjectGetOptions; @Inject - AzureBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AzureBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AzureBlobClient sync, ContainerToResourceMetadata container2ResourceMd, ListOptionsToListBlobsOptions blobStore2AzureContainerListOptions, diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreContextModule.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreContextModule.java index ff30670a2c..1dc34215b9 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreContextModule.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreContextModule.java @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; -import org.jclouds.azureblob.AzureBlobAsyncClient; import org.jclouds.azureblob.AzureBlobClient; import org.jclouds.azureblob.blobstore.AzureAsyncBlobStore; import org.jclouds.azureblob.blobstore.AzureBlobRequestSigner; @@ -32,10 +31,8 @@ import org.jclouds.azureblob.domain.PublicAccess; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import com.google.common.cache.CacheBuilder; @@ -44,7 +41,6 @@ import com.google.common.cache.LoadingCache; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * Configures the {@link AzureBlobStoreContext}; requires {@link AzureAsyncBlobStore} bound. @@ -59,8 +55,6 @@ public class AzureBlobStoreContextModule extends AbstractModule { bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); bind(AsyncBlobStore.class).to(AzureAsyncBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(AzureBlobStore.class).in(Scopes.SINGLETON); - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(ContainsValueInListStrategy.class).to(FindMD5InBlobProperties.class); bind(BlobRequestSigner.class).to(AzureBlobRequestSigner.class); } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/config/AzureBlobRestClientModule.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/config/AzureBlobRestClientModule.java index a0862b3bd5..c94667f515 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/config/AzureBlobRestClientModule.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/config/AzureBlobRestClientModule.java @@ -23,7 +23,6 @@ import org.jclouds.azureblob.AzureBlobAsyncClient; import org.jclouds.azureblob.AzureBlobClient; import org.jclouds.azureblob.handlers.ParseAzureBlobErrorFromXmlContent; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -35,7 +34,6 @@ import org.jclouds.rest.ConfiguresRestClient; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class AzureBlobRestClientModule extends AzureStorageRestClientModule { public AzureBlobRestClientModule() { diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java index cded63bf98..d010bf7332 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java @@ -65,7 +65,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { } public AzureBlobClient getApi() { - return (AzureBlobClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(AzureBlobApiMetadata.CONTEXT_TOKEN).getApi(); } @Test @@ -99,8 +99,8 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { long containerCount = response.size(); assertTrue(containerCount >= 1); ListBlobsResponse list = getApi().listBlobs(privateContainer); - assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/%s", context - .getProviderSpecificContext().getIdentity(), privateContainer))); + assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/%s", context.unwrap( + AzureBlobApiMetadata.CONTEXT_TOKEN).getIdentity(), privateContainer))); // TODO .. check to see the container actually exists } @@ -155,8 +155,8 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { } } ListBlobsResponse list = getApi().listBlobs(); - assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/$root", context - .getProviderSpecificContext().getIdentity()))); + assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/$root", context.unwrap( + AzureBlobApiMetadata.CONTEXT_TOKEN).getIdentity()))); } @Test diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java index d8d54451b8..03036714cc 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java @@ -30,7 +30,6 @@ import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; @@ -121,8 +120,7 @@ public class AzureBlobRequestSignerTest extends BaseAsyncClientTest - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - */ -public class BluelockVCloudZone01ContextBuilder extends VCloudContextBuilder { - public BluelockVCloudZone01ContextBuilder( - ProviderMetadata, VCloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public BluelockVCloudZone01ContextBuilder(VCloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new BluelockVCloudZone01RestClientModule()); - } - -} diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java index eca1705bbf..f040b048f8 100644 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java +++ b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java @@ -23,23 +23,19 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAU import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; - -import com.google.common.reflect.TypeToken; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Bluelock vCloud Zone 1. * * @author Adrian Cole */ -public class BluelockVCloudZone01ProviderMetadata - extends - BaseProviderMetadata, VCloudApiMetadata> { +public class BluelockVCloudZone01ProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -2931858111365760610L; public static Builder builder() { return new Builder(); @@ -58,21 +54,19 @@ public class BluelockVCloudZone01ProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01-.*"); return properties; } - public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("bluelock-vcloud-zone01") .name("Bluelock vCloud Zone 1") .apiMetadata( - new VCloudApiMetadata().toBuilder() - .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(BluelockVCloudZone01ContextBuilder.class)).build()) + new VCloudApiMetadata().toBuilder().buildVersion("1.5.0.464915").build()) .homepage(URI.create("http://www.bluelock.com/bluelock-cloud-hosting")) .console(URI.create("https://zone01.bluelock.com/cloud/org/YOUR_ORG_HERE")) .iso3166Codes("US-IN") @@ -86,8 +80,7 @@ public class BluelockVCloudZone01ProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, VCloudApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java index ce95f91059..2c3a037763 100644 --- a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java +++ b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "BluelockVCloudZone01TemplateBuilderLiveTest") -public class BluelockVCloudZone01TemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class BluelockVCloudZone01TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public BluelockVCloudZone01TemplateBuilderLiveTest() { provider = "bluelock-vcloud-zone01"; diff --git a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java index 53be4911e0..65c9722d26 100644 --- a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java +++ b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java @@ -23,10 +23,7 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.net.URI; import java.util.Properties; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.cloudfiles.CloudFilesApiMetadata; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,7 +32,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudFilesUKProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { +public class CloudFilesUKProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 7285715683919401020L; public static Builder builder() { return new Builder(); @@ -54,12 +54,12 @@ public class CloudFilesUKProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudfiles-uk") @@ -79,7 +79,7 @@ public class CloudFilesUKProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java index 703c3a3d00..b774ef1f4e 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.rackspace.cloudfiles; import static org.testng.Assert.assertEquals; +import org.jclouds.cloudfiles.CloudFilesApiMetadata; import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.cloudfiles.CloudFilesClientLiveTest; import org.jclouds.openstack.swift.domain.SwiftObject; @@ -40,7 +41,7 @@ public class CloudFilesUKClientLiveTest extends CloudFilesClientLiveTest { @Override public CloudFilesClient getApi() { - return (CloudFilesClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi(); } @Override diff --git a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java index 2b5c581e9a..6075e97252 100644 --- a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java +++ b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java @@ -23,10 +23,7 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.net.URI; import java.util.Properties; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.cloudfiles.CloudFilesApiMetadata; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,8 +32,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudFilesUSProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { +public class CloudFilesUSProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -106955085607133771L; + public static Builder builder() { return new Builder(); } @@ -54,13 +54,13 @@ public class CloudFilesUSProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudfiles-us") @@ -80,7 +80,7 @@ public class CloudFilesUSProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java index f211ad45c8..7867c833fb 100644 --- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java +++ b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java @@ -31,9 +31,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -42,7 +39,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { +public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -61,7 +58,7 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudloadbalancers-uk") @@ -91,7 +88,7 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java index 04f2018d5e..1a7164ed8c 100644 --- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java +++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java @@ -32,9 +32,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -45,7 +42,7 @@ import com.google.common.base.Joiner; * * @author Adrian Cole */ -public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { +public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -65,7 +62,7 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudloadbalancers-us") @@ -101,7 +98,7 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java index 55e5452be9..cfb4fcef46 100644 --- a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java +++ b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java @@ -22,9 +22,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.atmos.AtmosAsyncClient; -import org.jclouds.atmos.AtmosClient; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,7 +31,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class CloudOneStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { +public class CloudOneStorageProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -53,12 +50,12 @@ public class CloudOneStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudonestorage") @@ -78,7 +75,7 @@ public class CloudOneStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java index 0bed8a3b5d..fcfb0f0808 100644 --- a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java +++ b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java @@ -24,9 +24,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudservers.CloudServersApiMetadata; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,7 +32,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudServersUKProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { +public class CloudServersUKProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 4295911433196692746L; public static Builder builder() { return new Builder(); @@ -54,12 +54,12 @@ public class CloudServersUKProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudservers-uk") @@ -78,7 +78,7 @@ public class CloudServersUKProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index da6f4a3450..82af2d5621 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -23,9 +23,6 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class CloudServersUKTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public CloudServersUKTemplateBuilderLiveTest() { provider = "cloudservers-uk"; diff --git a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java index 16f85b88ae..76791ba5e5 100644 --- a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java +++ b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java @@ -24,9 +24,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudservers.CloudServersApiMetadata; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,8 +32,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudServersUSProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { +public class CloudServersUSProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 8728307961498165226L; + public static Builder builder() { return new Builder(); } @@ -54,13 +54,13 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudservers-us") @@ -79,7 +79,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java index 1dc74d846f..efa7594281 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -23,9 +23,6 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class CloudServersUSTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public CloudServersUSTemplateBuilderLiveTest() { provider = "cloudservers-us"; diff --git a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java index 83ada1c0b4..af76f6b037 100644 --- a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java +++ b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.cloudsigma; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,7 +32,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class CloudSigmaLasVegasProviderMetadata extends - BaseProviderMetadata, CloudSigmaApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -52,14 +51,14 @@ public class CloudSigmaLasVegasProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, CloudSigmaApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("cloudsigma-lvs") @@ -79,7 +78,7 @@ public class CloudSigmaLasVegasProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, CloudSigmaApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java index ada7600380..23ea49b737 100644 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java @@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live", testName = "CloudSigmaLasVegasTemplateBuilderLiveTest") public class CloudSigmaLasVegasTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public CloudSigmaLasVegasTemplateBuilderLiveTest() { provider = "cloudsigma-lvs"; diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java index 7f18af9aa2..df6afde0e9 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.cloudsigma; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,7 +32,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class CloudSigmaZurichProviderMetadata extends - BaseProviderMetadata, CloudSigmaApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -52,14 +51,14 @@ public class CloudSigmaZurichProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, CloudSigmaApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("cloudsigma-zrh") @@ -79,7 +78,7 @@ public class CloudSigmaZurichProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, CloudSigmaApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java index b85002b3b9..79391351c9 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java @@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live", singleThreaded = true, testName = "CloudSigmaZurichTemplateBuilderLiveTest") public class CloudSigmaZurichTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public CloudSigmaZurichTemplateBuilderLiveTest() { provider = "cloudsigma-zrh"; diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java index 3082c24b96..0d7b1caeea 100644 --- a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java +++ b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -36,7 +33,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class ElasticHostsPeer1LosAngelesProviderMetadata extends - BaseProviderMetadata, ElasticStackApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -55,14 +52,14 @@ public class ElasticHostsPeer1LosAngelesProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-lax-p") @@ -82,7 +79,7 @@ public class ElasticHostsPeer1LosAngelesProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java index ca8d2a2d37..c62a93e7f3 100644 --- a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live") public class ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest() { provider = "elastichosts-lax-p"; diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java index 337650cc65..0174d908c0 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,7 +31,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class ElasticHostsBlueSquareLondonProviderMetadata extends - BaseProviderMetadata, ElasticStackApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -53,14 +50,14 @@ public class ElasticHostsBlueSquareLondonProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-lon-b") @@ -80,7 +77,7 @@ public class ElasticHostsBlueSquareLondonProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java index c530f30205..9285774c86 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live") public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public ElasticHostsBlueSquareLondonTemplateBuilderLiveTest() { provider = "elastichosts-lon-b"; diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java index 2987ee2cab..c8dc1ccce5 100644 --- a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java +++ b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,7 +32,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class ElasticHostsPeer1LondonProviderMetadata extends - BaseProviderMetadata, ElasticStackApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -54,14 +51,14 @@ public class ElasticHostsPeer1LondonProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-lon-p") @@ -81,7 +78,7 @@ public class ElasticHostsPeer1LondonProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java index 32dbc5fcc4..c8a12e0f30 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live") public class ElasticHostsPeer1LondonTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public ElasticHostsPeer1LondonTemplateBuilderLiveTest() { provider = "elastichosts-lon-p"; diff --git a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java index b79332d3f0..e338b24980 100644 --- a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java +++ b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class ElasticHostsPeer1SanAntonioProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class ElasticHostsPeer1SanAntonioProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -8914180153534735692L; public static Builder builder() { return new Builder(); @@ -54,14 +52,12 @@ public class ElasticHostsPeer1SanAntonioProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-sat-p") @@ -80,8 +76,7 @@ public class ElasticHostsPeer1SanAntonioProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java index a33e8475ce..499dc1826d 100644 --- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest() { provider = "elastichosts-sat-p"; diff --git a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java index e857445271..901c88340b 100644 --- a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java +++ b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class ElasticHostsPeer1TorontoProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class ElasticHostsPeer1TorontoProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3573428301472783315L; public static Builder builder() { return new Builder(); @@ -54,14 +52,12 @@ public class ElasticHostsPeer1TorontoProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-tor-p") @@ -81,7 +77,7 @@ public class ElasticHostsPeer1TorontoProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java index f98bb35b5d..9bce8c72a2 100644 --- a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java +++ b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1TorontoTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class ElasticHostsPeer1TorontoTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ElasticHostsPeer1TorontoTemplateBuilderLiveTest() { provider = "elastichosts-tor-p"; diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java deleted file mode 100644 index 97b22136f1..0000000000 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.epc; - -import java.util.List; - -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.EC2ContextBuilder; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; -import org.jclouds.epc.config.EucalyptusPartnerCloudComputeServiceContextModule; -import org.jclouds.eucalyptus.EucalyptusApiMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class EucalyptusPartnerCloudContextBuilder extends EC2ContextBuilder, EucalyptusApiMetadata> { - - public EucalyptusPartnerCloudContextBuilder(ProviderMetadata, EucalyptusApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public EucalyptusPartnerCloudContextBuilder(EucalyptusApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new EucalyptusPartnerCloudComputeServiceContextModule()); - } - -} diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java index 1f9b118e77..efe710e50b 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java @@ -25,22 +25,26 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.net.URI; import java.util.Properties; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; +import org.jclouds.ec2.config.EC2RestClientModule; +import org.jclouds.epc.config.EucalyptusPartnerCloudComputeServiceContextModule; import org.jclouds.eucalyptus.EucalyptusApiMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.providers.ProviderMetadata} for Eucalyptus Partner Cloud EC2. * * @author Adrian Cole */ -public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetadata, EucalyptusApiMetadata> { +public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 7625722444851538962L; + public static Builder builder() { return new Builder(); } @@ -58,7 +62,7 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_REGIONS, "Eucalyptus"); properties.setProperty(PROPERTY_REGION + ".Eucalyptus." + ISO3166_CODES, "US-CA"); @@ -66,14 +70,15 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad return properties; } - public static class Builder extends BaseProviderMetadata.Builder, EucalyptusApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("eucalyptus-partnercloud-ec2") .name("Eucalyptus Partner Cloud (EC2)") .apiMetadata( new EucalyptusApiMetadata().toBuilder() - .contextBuilder(TypeToken.of(EucalyptusPartnerCloudContextBuilder.class)).build()) + .defaultModules(ImmutableSet.>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EucalyptusPartnerCloudComputeServiceContextModule.class)) + .build()) .homepage(URI.create("http://www.eucalyptus.com/partners")) .console(URI.create("https://partnercloud.eucalyptus.com:8443")) .linkedServices("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3") @@ -89,7 +94,7 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad @Override public Builder fromProviderMetadata( - ProviderMetadata, EucalyptusApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java index 8dc7b80f28..9849146e67 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java @@ -25,14 +25,11 @@ import java.io.IOException; import java.util.Set; import org.jclouds.aws.util.AWSUtils; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.jclouds.domain.LocationScope; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.util.EC2ComputeUtils; import org.testng.annotations.Test; @@ -45,8 +42,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { +public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest() { provider = "eucalyptus-partnercloud-ec2"; diff --git a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java index 5664afa0b5..7be125d98d 100644 --- a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java @@ -29,9 +29,6 @@ import java.util.Properties; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.s3.S3AsyncClient; -import org.jclouds.s3.S3Client; -import org.jclouds.s3.blobstore.S3BlobStoreContext; import org.jclouds.walrus.WalrusApiMetadata; /** @@ -39,8 +36,11 @@ import org.jclouds.walrus.WalrusApiMetadata; * * @author Adrian Cole */ -public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetadata, WalrusApiMetadata> { +public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } @@ -58,7 +58,7 @@ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetada super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_REGIONS, "Walrus"); properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); @@ -67,7 +67,7 @@ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetada return properties; } - public static class Builder extends BaseProviderMetadata.Builder, WalrusApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("eucalyptus-partnercloud-s3") @@ -88,7 +88,7 @@ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetada @Override public Builder fromProviderMetadata( - ProviderMetadata, WalrusApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java index 9b3afed0b6..8cf42b413d 100644 --- a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java +++ b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java @@ -21,22 +21,20 @@ package org.jclouds.go2cloud; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Go2Cloud's - * Johannesburg1 provider. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Go2Cloud's Johannesburg1 + * provider. * * @author Adrian Cole */ -public class Go2CloudJohannesburg1ProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class Go2CloudJohannesburg1ProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 5737728330686182812L; public static Builder builder() { return new Builder(); @@ -55,14 +53,14 @@ public class Go2CloudJohannesburg1ProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("go2cloud-jhb1") @@ -82,7 +80,7 @@ public class Go2CloudJohannesburg1ProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java index 65175537f3..0b5bc44fb3 100644 --- a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java +++ b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class Go2CloudJohannesburg1TemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class Go2CloudJohannesburg1TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public Go2CloudJohannesburg1TemplateBuilderLiveTest() { provider = "go2cloud-jhb1"; diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java index 7733c419de..b85d260968 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java @@ -23,19 +23,28 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule; +import org.jclouds.gogrid.config.GoGridRestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class GoGridApiMetadata - extends - BaseComputeServiceApiMetadata, GoGridApiMetadata> { +public class GoGridApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -49,18 +58,17 @@ public class GoGridApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty("jclouds.ssh.max-retries", "5"); properties.setProperty("jclouds.ssh.retry-auth", "true"); return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, GoGridApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(GoGridClient.class, GoGridAsyncClient.class); id("gogrid") .name("GoGrid API") .identityName("API Key") @@ -68,8 +76,9 @@ public class GoGridApiMetadata .documentation(URI.create("https://wiki.gogrid.com/wiki/index.php/API")) .version(GoGridAsyncClient.VERSION) .defaultEndpoint("https://api.gogrid.com/api") - .javaApi(GoGridClient.class, GoGridAsyncClient.class) - .contextBuilder(TypeToken.of(GoGridContextBuilder.class)); + .defaultProperties(GoGridApiMetadata.defaultProperties()) + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(GoGridRestClientModule.class, GoGridComputeServiceContextModule.class)); } @Override @@ -78,7 +87,7 @@ public class GoGridApiMetadata } @Override - public Builder fromApiMetadata(GoGridApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java deleted file mode 100644 index 0318c28952..0000000000 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.gogrid; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule; -import org.jclouds.gogrid.config.GoGridRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class GoGridContextBuilder - extends - ComputeServiceContextBuilder, GoGridApiMetadata> { - - public GoGridContextBuilder( - ProviderMetadata, GoGridApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public GoGridContextBuilder(GoGridApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new GoGridComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new GoGridRestClientModule()); - } - -} diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java index c78a719162..051b96eee6 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java @@ -27,7 +27,6 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,9 +34,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * Implementation of {@link org.jclouds.types.ProviderMetadata} for GoGrid. * @author Adrian Cole */ -public class GoGridProviderMetadata - extends - BaseProviderMetadata, GoGridApiMetadata> { +public class GoGridProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 503149209800711396L; public static Builder builder() { return new Builder(); @@ -56,7 +56,7 @@ public class GoGridProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_ZONES, "1,2,3"); properties.setProperty(PROPERTY_ZONE + ".1." + ISO3166_CODES, "US-CA"); @@ -67,9 +67,7 @@ public class GoGridProviderMetadata return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, GoGridApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("gogrid") @@ -88,8 +86,7 @@ public class GoGridProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, GoGridApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java index 879880a23d..b03aadf71d 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java @@ -62,7 +62,7 @@ import com.google.common.base.Supplier; @Singleton public class GoGridComputeService extends BaseComputeService { @Inject - protected GoGridComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected GoGridComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java index a1b7e405e4..01db87430d 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java @@ -36,8 +36,6 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -import org.jclouds.gogrid.GoGridAsyncClient; -import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.compute.functions.OptionToLocation; import org.jclouds.gogrid.compute.functions.ServerImageToImage; import org.jclouds.gogrid.compute.functions.ServerToNodeMetadata; @@ -61,10 +59,7 @@ import com.google.inject.TypeLiteral; * @author Andrew Kennedy */ public class GoGridComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - public GoGridComputeServiceContextModule() { - super(GoGridClient.class, GoGridAsyncClient.class); - } + ComputeServiceAdapterContextModule { @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java index ba34fedc33..8e97f212e1 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java @@ -41,7 +41,6 @@ import org.jclouds.gogrid.services.GridLoadBalancerClient; import org.jclouds.gogrid.services.GridServerAsyncClient; import org.jclouds.gogrid.services.GridServerClient; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -61,7 +60,6 @@ import com.google.inject.Scopes; * @author Adrian Cole * @author Oleksiy Yarmula */ -@RequiresHttp @ConfiguresRestClient public class GoGridRestClientModule extends RestClientModule { public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java index 31017c0ebe..5ceffc0066 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java @@ -34,9 +34,9 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.Credentials; +import org.jclouds.domain.LoginCredentials; import org.jclouds.gogrid.domain.Ip; import org.jclouds.gogrid.domain.IpPortPair; import org.jclouds.gogrid.domain.Job; @@ -70,14 +70,12 @@ import com.google.common.collect.Iterables; /** * End to end live test for GoGrid *

    - * Takes too long to execute. Please split into multiple tests + * Takes too long to execute. Please split into multiple tests * * @author Oleksiy Yarmula */ @Test(enabled = false, groups = "live", singleThreaded = true, testName = "GoGridLiveTestDisabled") -public class GoGridLiveTestDisabled - extends - BaseComputeServiceContextLiveTest> { +public class GoGridLiveTestDisabled extends BaseComputeServiceContextLiveTest { public GoGridLiveTestDisabled() { provider = "gogrid"; @@ -99,7 +97,7 @@ public class GoGridLiveTestDisabled @Override public void setupContext() { super.setupContext(); - gocontext = context.getProviderSpecificContext(); + gocontext = context.unwrap(); client = gocontext.getApi(); serverLatestJobCompleted = new RetryablePredicate(new ServerLatestJobCompleted(client.getJobServices()), @@ -340,7 +338,7 @@ public class GoGridLiveTestDisabled createdServer = Iterables.getOnlyElement(response); Map credsMap = client.getServerServices().getServerCredentialsList(); - Credentials instanceCredentials = credsMap.get(createdServer.getName()); + LoginCredentials instanceCredentials = LoginCredentials.fromCredentials(credsMap.get(createdServer.getName())); assertNotNull(instanceCredentials); IPSocket socket = new IPSocket(createdServer.getIp().getIp(), 22); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java index c2359cb42f..b633266c28 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java @@ -25,7 +25,6 @@ import static org.testng.Assert.assertNotNull; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; @@ -48,9 +47,7 @@ import com.google.inject.Module; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "live", singleThreaded = true, testName = "GoGridComputeServiceLiveTest") -public class GoGridComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { public GoGridComputeServiceLiveTest() { provider = "gogrid"; @@ -74,7 +71,7 @@ public class GoGridComputeServiceLiveTest public void testResizeRam() throws Exception { String group = this.group + "ram"; - RestContext providerContext = context.getProviderSpecificContext(); + RestContext providerContext = context.unwrap(); try { client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java index 1773206435..45a751bdd1 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.gogrid.GoGridAsyncClient; -import org.jclouds.gogrid.GoGridClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -43,9 +40,7 @@ import com.google.common.collect.ImmutableSet; */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "live", singleThreaded = true, testName = "GoGridTemplateBuilderLiveTest") -public class GoGridTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class GoGridTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public GoGridTemplateBuilderLiveTest() { provider = "gogrid"; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java index ef95d93eb5..0d40acc104 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java @@ -25,7 +25,6 @@ import org.jclouds.gogrid.GoGridProviderMetadata; import org.jclouds.gogrid.config.GoGridRestClientModule; import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; @@ -46,8 +45,7 @@ public abstract class BaseGoGridAsyncClientTest extends BaseAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new GoGridProviderMetadata(); } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java index e070cc5571..ebe8a1daa8 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.gogrid.services; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.gogrid.GoGridAsyncClient; import org.jclouds.gogrid.GoGridClient; @@ -32,9 +31,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "BaseGoGridClientLiveTest") -public class BaseGoGridClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseGoGridClientLiveTest extends BaseComputeServiceContextLiveTest { public BaseGoGridClientLiveTest() { provider = "gogrid"; @@ -46,7 +43,7 @@ public class BaseGoGridClientLiveTest @Override public void setupContext() { super.setupContext(); - restContext = context.getProviderSpecificContext(); + restContext = context.unwrap(); } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java index 25fd8a968f..6700eae72e 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java @@ -3,9 +3,8 @@ package org.jclouds.gogrid.services; import org.jclouds.date.TimeStamp; import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.config.GoGridRestClientModule; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import com.google.common.base.Supplier; import com.google.inject.Module; @@ -20,8 +19,7 @@ public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest, VCloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public GreenHouseDataElementVCloudContextBuilder(VCloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new GreenHouseDataElementVCloudRestClientModule()); - } - -} diff --git a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java index 0bf19f4964..68315893ac 100644 --- a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java +++ b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java @@ -23,23 +23,24 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAU import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.greenhousedata.element.vcloud.config.GreenHouseDataElementVCloudComputeServiceContextModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.config.VCloudRestClientModule; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Green House Data Element vCloud * * @author Adrian Cole */ -public class GreenHouseDataElementVCloudProviderMetadata - extends - BaseProviderMetadata, VCloudApiMetadata> { +public class GreenHouseDataElementVCloudProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8503534430849704022L; public static Builder builder() { return new Builder(); @@ -58,13 +59,13 @@ public class GreenHouseDataElementVCloudProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); return properties; } - public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("greenhousedata-element-vcloud") @@ -72,7 +73,8 @@ public class GreenHouseDataElementVCloudProviderMetadata .apiMetadata( new VCloudApiMetadata().toBuilder() .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(GreenHouseDataElementVCloudContextBuilder.class)).build()) + .defaultModules(ImmutableSet.>of(VCloudRestClientModule.class, GreenHouseDataElementVCloudComputeServiceContextModule.class)) + .build()) .homepage(URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/")) .console(URI.create("https://mycloud.greenhousedata.com/cloud/org/YOUR_ORG_HERE")) .iso3166Codes("US-WY") @@ -87,7 +89,7 @@ public class GreenHouseDataElementVCloudProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, VCloudApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java deleted file mode 100644 index eed0785010..0000000000 --- a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.greenhousedata.element.vcloud.config; - -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.config.VCloudRestClientModule; - -/** - * Configures the VCloud authentication service connection, including logging and http transport. - * - * @author Adrian Cole - */ -@RequiresHttp -@ConfiguresRestClient -public class GreenHouseDataElementVCloudRestClientModule extends VCloudRestClientModule { - -} diff --git a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java index efb4394359..0276f110f9 100644 --- a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java +++ b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "GreenHouseDataElementVCloudTemplateBuilderLiveTest") -public class GreenHouseDataElementVCloudTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class GreenHouseDataElementVCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public GreenHouseDataElementVCloudTemplateBuilderLiveTest() { provider = "greenhousedata-element-vcloud"; diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java deleted file mode 100644 index cdaccddb03..0000000000 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.hpcloud.compute; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.hpcloud.compute.config.HPCloudComputeServiceContextModule; -import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.NovaContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class HPCloudComputeContextBuilder extends NovaContextBuilder { - - public HPCloudComputeContextBuilder( - ProviderMetadata, NovaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public HPCloudComputeContextBuilder(NovaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new HPCloudComputeServiceContextModule()); - } - -} diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java index 44e48865a9..91fe9a394b 100644 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java +++ b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java @@ -26,23 +26,24 @@ import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERAT import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.hpcloud.compute.config.HPCloudComputeServiceContextModule; import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for HP Cloud Compute Services. * * @author Adrian Cole */ -public class HPCloudComputeProviderMetadata - extends - BaseProviderMetadata, NovaApiMetadata> { +public class HPCloudComputeProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -300987074165012648L; public static Builder builder() { return new Builder(); @@ -61,7 +62,7 @@ public class HPCloudComputeProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); // deallocating ip addresses can take a while properties.setProperty(TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); @@ -72,14 +73,16 @@ public class HPCloudComputeProviderMetadata return properties; } - public static class Builder extends BaseProviderMetadata.Builder, NovaApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("hpcloud-compute") .name("HP Cloud Compute Services") - .apiMetadata(new NovaApiMetadata().toBuilder().identityName("tenantId:accessKey") - .credentialName("secretKey") - .contextBuilder(TypeToken.of(HPCloudComputeContextBuilder.class)).build()) + .apiMetadata(new NovaApiMetadata().toBuilder() + .identityName("tenantId:accessKey") + .credentialName("secretKey") + .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, HPCloudComputeServiceContextModule.class)) + .build()) .homepage(URI.create("http://hpcloud.com")) .console(URI.create("https://manage.hpcloud.com/compute")) .linkedServices("hpcloud-compute", "hpcloud-objectstorage") @@ -92,10 +95,9 @@ public class HPCloudComputeProviderMetadata public HPCloudComputeProviderMetadata build() { return new HPCloudComputeProviderMetadata(this); } - + @Override - public Builder fromProviderMetadata( - ProviderMetadata, NovaApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java index 29664b45f4..23531f1a8c 100644 --- a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java +++ b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.compute.options.NovaTemplateOptions; import org.testng.annotations.Test; @@ -42,8 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "HPCloudComputeTemplateBuilderLiveTest") -public class HPCloudComputeTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { +public class HPCloudComputeTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public HPCloudComputeTemplateBuilderLiveTest() { provider = "hpcloud-compute"; diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java index 8ff3b49aad..dee1981245 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java @@ -24,20 +24,32 @@ import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERV import java.net.URI; import java.util.Properties; +import org.jclouds.apis.ApiMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.hpcloud.objectstorage.blobstore.config.HPCloudObjectStorageBlobStoreContextModule; +import org.jclouds.hpcloud.objectstorage.config.HPCloudObjectStorageRestClientModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.swift.SwiftApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.providers.ProviderMetadata} for HP Cloud Services Object Storage * * @author Jeremy Daggett */ -public class HPCloudObjectStorageApiMetadata - extends - BaseBlobStoreApiMetadata, HPCloudObjectStorageApiMetadata> { +public class HPCloudObjectStorageApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 820062881469203616L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; private static Builder builder() { return new Builder(); @@ -56,8 +68,8 @@ public class HPCloudObjectStorageApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = SwiftApiMetadata.defaultProperties(); properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); // TODO: this doesn't actually do anything yet. properties.setProperty(KeystoneProperties.VERSION, "2.0"); @@ -65,20 +77,19 @@ public class HPCloudObjectStorageApiMetadata return properties; } - public static class Builder - extends - BaseBlobStoreApiMetadata.Builder, HPCloudObjectStorageApiMetadata> { - + public static class Builder extends BaseRestApiMetadata.Builder { + protected Builder() { + super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class); id("hpcloud-objectstorage") .name("HP Cloud Services Object Storage API") .identityName("tenantId:accessKey") .credentialName("secretKey") .version("1.0") .documentation(URI.create("https://build.hpcloud.com/object-storage/api")) - .javaApi(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class) - .contextBuilder(TypeToken.of(HPCloudObjectStorageContextBuilder.class)) - .defaultProperties(HPCloudObjectStorageApiMetadata.defaultProperties()); + .defaultProperties(HPCloudObjectStorageApiMetadata.defaultProperties()) + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(HPCloudObjectStorageRestClientModule.class, HPCloudObjectStorageBlobStoreContextModule.class)); } @Override @@ -87,7 +98,7 @@ public class HPCloudObjectStorageApiMetadata } @Override - public Builder fromApiMetadata(HPCloudObjectStorageApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java deleted file mode 100644 index f51bc37aae..0000000000 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.hpcloud.objectstorage; - -import java.util.List; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.hpcloud.objectstorage.blobstore.config.HPCloudObjectStorageBlobStoreContextModule; -import org.jclouds.hpcloud.objectstorage.config.HPCloudObjectStorageRestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link HPCloudObjectStorageStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see HPCloudObjectStorageStoreContext - */ -public class HPCloudObjectStorageContextBuilder - extends - BlobStoreContextBuilder, HPCloudObjectStorageApiMetadata> { - - public HPCloudObjectStorageContextBuilder( - ProviderMetadata, HPCloudObjectStorageApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public HPCloudObjectStorageContextBuilder(HPCloudObjectStorageApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new HPCloudObjectStorageBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new HPCloudObjectStorageRestClientModule()); - } -} \ No newline at end of file diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java index 65dea7c5a8..e464575931 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java @@ -23,7 +23,6 @@ import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; import java.net.URI; import java.util.Properties; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -32,9 +31,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class HPCloudObjectStorageProviderMetadata - extends - BaseProviderMetadata, HPCloudObjectStorageApiMetadata> { +public class HPCloudObjectStorageProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3735142654912867384L; public static Builder builder() { return new Builder(); @@ -53,14 +53,14 @@ public class HPCloudObjectStorageProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_BUILD_VERSION, "???"); //FIXME // properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); FIXME: needed? return properties; } - public static class Builder extends BaseProviderMetadata.Builder, HPCloudObjectStorageApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("hpcloud-objectstorage") @@ -80,8 +80,7 @@ public class HPCloudObjectStorageProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, HPCloudObjectStorageApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java index a9516d6f9c..ed305371de 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java @@ -59,7 +59,7 @@ public class HPCloudObjectStorageAsyncBlobStore extends SwiftAsyncBlobStore { private final EnableCDNAndCache enableCDNAndCache; @Inject - protected HPCloudObjectStorageAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected HPCloudObjectStorageAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, HPCloudObjectStorageClient sync, HPCloudObjectStorageAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java index fc9acef141..e05119ed8c 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java @@ -53,7 +53,7 @@ public class HPCloudObjectStorageBlobStore extends SwiftBlobStore { private EnableCDNAndCache enableCDNAndCache; @Inject - protected HPCloudObjectStorageBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected HPCloudObjectStorageBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, HPCloudObjectStorageClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java index 1a0304bd2e..a6ab3272c9 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java @@ -32,7 +32,6 @@ import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient; import org.jclouds.hpcloud.services.HPExtensionCDN; import org.jclouds.hpcloud.services.HPExtensionServiceType; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -62,7 +61,6 @@ import com.google.inject.Scopes; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class HPCloudObjectStorageRestClientModule extends RestClientModule { public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder().put( diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java index bda812354e..816d02f6d1 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java @@ -43,7 +43,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes @Override public HPCloudObjectStorageClient getApi() { - return (HPCloudObjectStorageClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(HPCloudObjectStorageApiMetadata.CONTEXT_TOKEN).getApi(); } @Override diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java index 0e0b6fa748..352efdeafb 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java @@ -59,7 +59,7 @@ public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest createProviderMetadata(){ + @Override public ProviderMetadata createProviderMetadata(){ return new HPCloudObjectStorageProviderMetadata(); } } diff --git a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java index 46da1fbdeb..681220b4cb 100644 --- a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java +++ b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java @@ -4,9 +4,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudstack.CloudStackApiMetadata; -import org.jclouds.cloudstack.CloudStackAsyncClient; -import org.jclouds.cloudstack.CloudStackClient; -import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -15,9 +12,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * Compute. * @author Adrian Cole */ -public class NinefoldComputeProviderMetadata - extends - BaseProviderMetadata { +public class NinefoldComputeProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -4496340915519024L; public static Builder builder() { return new Builder(); @@ -36,7 +34,7 @@ public class NinefoldComputeProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty("ninefold-compute.image-id", "1215"); properties.setProperty("ninefold-compute.image.login-user", "user:Password01"); @@ -46,7 +44,7 @@ public class NinefoldComputeProviderMetadata public static class Builder extends - BaseProviderMetadata.Builder { + BaseProviderMetadata.Builder { protected Builder() { id("ninefold-compute") @@ -66,7 +64,7 @@ public class NinefoldComputeProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java index 5368814810..7cbb42aec5 100644 --- a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java +++ b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java @@ -24,9 +24,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.cloudstack.CloudStackAsyncClient; -import org.jclouds.cloudstack.CloudStackClient; -import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class NinefoldComputeTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest { +public class NinefoldComputeTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public NinefoldComputeTemplateBuilderLiveTest() { provider = "ninefold-compute"; diff --git a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java index 152c46df77..55acd16933 100644 --- a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java +++ b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java @@ -22,9 +22,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.atmos.AtmosAsyncClient; -import org.jclouds.atmos.AtmosClient; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,8 +31,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class NinefoldStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { +public class NinefoldStorageProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } @@ -53,12 +53,12 @@ public class NinefoldStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("ninefold-storage") @@ -78,7 +78,7 @@ public class NinefoldStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java index b1e33c13ca..37c01aa1de 100644 --- a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java +++ b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.openhosting; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class OpenHostingEast1ProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class OpenHostingEast1ProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; public static Builder builder() { return new Builder(); @@ -54,14 +52,14 @@ public class OpenHostingEast1ProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("openhosting-east1") @@ -81,7 +79,7 @@ public class OpenHostingEast1ProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java index 50a86d8a3a..841a737a00 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class OpenHostingEast1TemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class OpenHostingEast1TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public OpenHostingEast1TemplateBuilderLiveTest() { provider = "openhosting-east1"; diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java index 1ea439a161..a18b127a65 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java @@ -25,23 +25,32 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.config.ComputeServiceProperties; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.rimuhosting.miro.compute.config.RimuHostingComputeServiceContextModule; +import org.jclouds.rimuhosting.miro.config.RimuHostingRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for RimuHosting API * * @author Adrian Cole */ -public class RimuHostingApiMetadata - extends - BaseComputeServiceApiMetadata, RimuHostingApiMetadata> { +public class RimuHostingApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -55,8 +64,8 @@ public class RimuHostingApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); Timeout timeout = RimuHostingClient.class.getAnnotation(Timeout.class); long timeoutMillis = timeout.timeUnit().toMillis(timeout.duration()); properties.setProperty(PROPERTY_SO_TIMEOUT, timeoutMillis + ""); @@ -67,18 +76,20 @@ public class RimuHostingApiMetadata public static class Builder extends - BaseComputeServiceApiMetadata.Builder, RimuHostingApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(RimuHostingClient.class, RimuHostingAsyncClient.class); id("rimuhosting") - .type(ApiType.COMPUTE) .name("RimuHosting API") .identityName("API Key") .documentation(URI.create("http://apidocs.rimuhosting.com")) .version("1") .defaultEndpoint("https://api.rimuhosting.com/r") - .javaApi(RimuHostingClient.class, RimuHostingAsyncClient.class) - .contextBuilder(TypeToken.of(RimuHostingContextBuilder.class)); + .defaultProperties(RimuHostingApiMetadata.defaultProperties()) + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(RimuHostingRestClientModule.class, RimuHostingComputeServiceContextModule.class)); + } @Override @@ -87,7 +98,7 @@ public class RimuHostingApiMetadata } @Override - public Builder fromApiMetadata(RimuHostingApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java deleted file mode 100644 index e01c11d97b..0000000000 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.rimuhosting.miro; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rimuhosting.miro.compute.config.RimuHostingComputeServiceContextModule; -import org.jclouds.rimuhosting.miro.config.RimuHostingRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class RimuHostingContextBuilder - extends - ComputeServiceContextBuilder, RimuHostingApiMetadata> { - - public RimuHostingContextBuilder( - ProviderMetadata, RimuHostingApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public RimuHostingContextBuilder(RimuHostingApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new RimuHostingComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new RimuHostingRestClientModule()); - } - -} diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java index 5d32459a2f..b1850e5928 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java @@ -26,7 +26,6 @@ import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPER import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,9 +33,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * Implementation of {@link org.jclouds.types.ProviderMetadata} for RimuHosting. * @author Adrian Cole */ -public class RimuHostingProviderMetadata - extends - BaseProviderMetadata, RimuHostingApiMetadata> { +public class RimuHostingProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8802226645589501365L; public static Builder builder() { return new Builder(); @@ -55,7 +55,7 @@ public class RimuHostingProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_ZONES, "DCAUCKLAND,DCLONDON,DCDALLAS,DCSYDNEY"); properties.setProperty(PROPERTY_ZONE + ".DCAUCKLAND." + ISO3166_CODES, "NZ-AUK"); @@ -66,9 +66,7 @@ public class RimuHostingProviderMetadata return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, RimuHostingApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("rimuhosting") @@ -87,8 +85,7 @@ public class RimuHostingProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, RimuHostingApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java index f9142d555b..c1669347f9 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java @@ -22,12 +22,8 @@ import java.util.Map; import javax.inject.Singleton; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; -import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; -import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.jclouds.rimuhosting.miro.compute.functions.ServerToNodeMetadata; import org.jclouds.rimuhosting.miro.domain.Server; import org.jclouds.rimuhosting.miro.domain.internal.RunningState; @@ -40,7 +36,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.AbstractModule; import com.google.inject.Provides; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; /** @@ -55,12 +50,8 @@ public class RimuHostingComputeServiceDependenciesModule extends AbstractModule protected void configure() { bind(new TypeLiteral>() { }).to(ServerToNodeMetadata.class); - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(new TypeLiteral>>() { }).to(ServerToPublicAddresses.class); - } @VisibleForTesting diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java index 56c500501a..e572fd615b 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java @@ -25,7 +25,6 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.date.DateService; -import org.jclouds.http.RequiresHttp; import org.jclouds.json.config.GsonModule; import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.PropertiesAdapter; @@ -46,7 +45,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class RimuHostingRestClientModule extends RestClientModule { diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/location/RimuHostingLocationSupplier.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/location/RimuHostingLocationSupplier.java index f2b8b3c1c6..dd10add093 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/location/RimuHostingLocationSupplier.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/location/RimuHostingLocationSupplier.java @@ -42,8 +42,8 @@ import com.google.common.base.Function; import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; /** * diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java index 8e08b5b83a..6fb6462581 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java @@ -94,7 +94,7 @@ public class RimuHostingAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new RimuHostingProviderMetadata(); } } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java index 22fd52dc70..46d76aa8c6 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java @@ -24,7 +24,6 @@ import static org.testng.Assert.assertTrue; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.rest.RestContext; import org.jclouds.rimuhosting.miro.domain.Image; @@ -44,7 +43,7 @@ import org.testng.annotations.Test; @Test(groups = "live", singleThreaded = true, testName = "RimuHostingClientLiveTest") public class RimuHostingClientLiveTest extends - BaseComputeServiceContextLiveTest> { + BaseComputeServiceContextLiveTest { public RimuHostingClientLiveTest() { provider = "rimuhosting"; @@ -57,7 +56,7 @@ public class RimuHostingClientLiveTest @Override public void setupContext() { super.setupContext(); - restContext = context.getProviderSpecificContext(); + restContext = context.unwrap(); this.connection = restContext.getApi(); } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java index e03c5759e1..55fbaa3046 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java @@ -18,11 +18,8 @@ */ package org.jclouds.rimuhosting.miro.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; -import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -33,9 +30,7 @@ import com.google.common.collect.ImmutableMap; * @author Ivan Meredith */ @Test(groups = "live", sequential = true) -public class RimuHostingComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTest { public RimuHostingComputeServiceLiveTest() { provider = "rimuhosting"; diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java index b67a5acc72..de99137bfd 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; -import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -40,9 +37,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class RimuHostingTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class RimuHostingTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public RimuHostingTemplateBuilderLiveTest() { provider = "rimuhosting"; diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java index f360e54b53..8364751353 100644 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.serverlove; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class ServerloveManchesterProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class ServerloveManchesterProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -8799752320729476294L; public static Builder builder() { return new Builder(); @@ -54,14 +52,14 @@ public class ServerloveManchesterProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("serverlove-z1-man") @@ -81,7 +79,7 @@ public class ServerloveManchesterProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java index a2bc867767..7e461a3f5e 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ServerloveManchesterTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ServerloveManchesterTemplateBuilderLiveTest() { provider = "serverlove-z1-man"; diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java index ba9e4c69c3..8063fac0b3 100644 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java +++ b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.skalicloud; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class SkaliCloudMalaysiaProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class SkaliCloudMalaysiaProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 102653451946303901L; public static Builder builder() { return new Builder(); @@ -54,14 +52,14 @@ public class SkaliCloudMalaysiaProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("skalicloud-sdg-my") @@ -81,7 +79,7 @@ public class SkaliCloudMalaysiaProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java index a35ea5fe04..6e47b62efd 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -44,7 +41,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live") public class SkaliCloudMalaysiaTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public SkaliCloudMalaysiaTemplateBuilderLiveTest() { provider = "skalicloud-sdg-my"; diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java index 8d9edb2b04..8ca75dbdc3 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java @@ -22,21 +22,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.slicehost.compute.config.SlicehostComputeServiceContextModule; +import org.jclouds.slicehost.config.SlicehostRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Slicehost 1.0 API * * @author Adrian Cole */ -public class SlicehostApiMetadata - extends - BaseComputeServiceApiMetadata, SlicehostApiMetadata> { +public class SlicehostApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -50,27 +58,27 @@ public class SlicehostApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty("jclouds.ssh.max-retries", "8"); return properties; } public static class Builder extends - BaseComputeServiceApiMetadata.Builder, SlicehostApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(SlicehostClient.class, SlicehostAsyncClient.class); id("slicehost") - .type(ApiType.COMPUTE) .name("Slicehost API") .identityName("API password") .documentation(URI.create("http://articles.slicehost.com/api")) .version("https://api.slicehost.com") .defaultEndpoint("https://api.slicehost.com") - .javaApi(SlicehostClient.class, SlicehostAsyncClient.class) .defaultProperties(SlicehostApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(SlicehostContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(SlicehostRestClientModule.class, SlicehostComputeServiceContextModule.class)); } @Override @@ -79,7 +87,7 @@ public class SlicehostApiMetadata } @Override - public Builder fromApiMetadata(SlicehostApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java deleted file mode 100644 index 57cdaf2a38..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.slicehost; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.slicehost.compute.config.SlicehostComputeServiceContextModule; -import org.jclouds.slicehost.config.SlicehostRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class SlicehostContextBuilder - extends - ComputeServiceContextBuilder, SlicehostApiMetadata> { - - public SlicehostContextBuilder( - ProviderMetadata, SlicehostApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public SlicehostContextBuilder(SlicehostApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new SlicehostComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new SlicehostRestClientModule()); - } - -} \ No newline at end of file diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java index b0aba661e7..b2f2b3e4c0 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java @@ -3,7 +3,6 @@ package org.jclouds.slicehost; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -12,8 +11,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class SlicehostProviderMetadata extends BaseProviderMetadata, SlicehostApiMetadata> { +public class SlicehostProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -5260230633956988685L; + public static Builder builder() { return new Builder(); } @@ -31,12 +33,12 @@ public class SlicehostProviderMetadata extends BaseProviderMetadata, SlicehostApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("slicehost") @@ -54,7 +56,7 @@ public class SlicehostProviderMetadata extends BaseProviderMetadata, SlicehostApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java index c08a56afa6..80729c2969 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java @@ -35,8 +35,6 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -import org.jclouds.slicehost.SlicehostAsyncClient; -import org.jclouds.slicehost.SlicehostClient; import org.jclouds.slicehost.compute.functions.FlavorToHardware; import org.jclouds.slicehost.compute.functions.SliceToNodeMetadata; import org.jclouds.slicehost.compute.functions.SlicehostImageToImage; @@ -57,12 +55,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class SlicehostComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public SlicehostComputeServiceContextModule() { - super(SlicehostClient.class, SlicehostAsyncClient.class); - } +public class SlicehostComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java index 816190b52d..b1e5ef93a5 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java @@ -19,7 +19,6 @@ package org.jclouds.slicehost.config; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -34,7 +33,6 @@ import org.jclouds.slicehost.handlers.ParseSlicehostErrorFromHttpResponse; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class SlicehostRestClientModule extends RestClientModule { public SlicehostRestClientModule() { diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java index 692b324ca5..ac4eadd951 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java @@ -251,7 +251,7 @@ public class SlicehostAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new SlicehostProviderMetadata(); } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java index 6d0b9e3480..48cac3fca5 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java @@ -28,7 +28,6 @@ import java.security.SecureRandom; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpResponseException; @@ -55,9 +54,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "SlicehostClientLiveTest") -public class SlicehostClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class SlicehostClientLiveTest extends BaseComputeServiceContextLiveTest { public SlicehostClientLiveTest() { provider = "slicehost"; diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java index 79c960841c..ef37640c50 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java @@ -18,11 +18,8 @@ */ package org.jclouds.slicehost.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.slicehost.SlicehostAsyncClient; -import org.jclouds.slicehost.SlicehostClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -35,9 +32,7 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class SlicehostComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest { public SlicehostComputeServiceLiveTest() { provider = "slicehost"; diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java index ff8b08c660..73db547fb9 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.slicehost.SlicehostAsyncClient; -import org.jclouds.slicehost.SlicehostClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class SlicehostTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public SlicehostTemplateBuilderLiveTest() { provider = "slicehost"; diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java index e9347a4861..311d7b5b15 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java @@ -22,21 +22,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.softlayer.compute.config.SoftLayerComputeServiceContextModule; +import org.jclouds.softlayer.config.SoftLayerRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** - * Implementation of {@link ApiMetadata} for API + * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class SoftLayerApiMetadata - extends - BaseComputeServiceApiMetadata, SoftLayerApiMetadata> { +public class SoftLayerApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -50,8 +58,8 @@ public class SoftLayerApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty("jclouds.ssh.max-retries", "5"); properties.setProperty("jclouds.ssh.retry-auth", "true"); return properties; @@ -59,11 +67,11 @@ public class SoftLayerApiMetadata public static class Builder extends - BaseComputeServiceApiMetadata.Builder, SoftLayerApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(SoftLayerClient.class, SoftLayerAsyncClient.class); id("softlayer") - .type(ApiType.COMPUTE) .name("SoftLayer API") .identityName("API Username") .credentialName("API Key") @@ -71,8 +79,8 @@ public class SoftLayerApiMetadata .version("3") .defaultEndpoint("https://api.softlayer.com/rest") .defaultProperties(SoftLayerApiMetadata.defaultProperties()) - .javaApi(SoftLayerClient.class, SoftLayerAsyncClient.class) - .contextBuilder(TypeToken.of(SoftLayerContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(SoftLayerRestClientModule.class, SoftLayerComputeServiceContextModule.class)); } @Override @@ -81,7 +89,7 @@ public class SoftLayerApiMetadata } @Override - public Builder fromApiMetadata(SoftLayerApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java deleted file mode 100644 index 86519a9cfc..0000000000 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.softlayer; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.softlayer.compute.config.SoftLayerComputeServiceContextModule; -import org.jclouds.softlayer.config.SoftLayerRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class SoftLayerContextBuilder - extends - ComputeServiceContextBuilder, SoftLayerApiMetadata> { - - public SoftLayerContextBuilder( - ProviderMetadata, SoftLayerApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public SoftLayerContextBuilder(SoftLayerApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new SoftLayerComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new SoftLayerRestClientModule()); - } - -} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java index 141bd163ae..97cfefc51c 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java @@ -28,7 +28,6 @@ import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLA import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -39,9 +38,10 @@ import com.google.common.collect.ImmutableSet; * Implementation of {@link org.jclouds.types.ProviderMetadata} for SoftLayer. * @author Adrian Cole */ -public class SoftLayerProviderMetadata - extends - BaseProviderMetadata, SoftLayerApiMetadata> { +public class SoftLayerProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 2196535609684739834L; public static Builder builder() { return new Builder(); @@ -60,7 +60,7 @@ public class SoftLayerProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY, "" + 60 * 60 * 1000); properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME, "Cloud Server"); @@ -87,9 +87,7 @@ public class SoftLayerProviderMetadata return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, SoftLayerApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("softlayer") @@ -108,8 +106,7 @@ public class SoftLayerProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, SoftLayerApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java index 31edee90f4..c2f19a7845 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java @@ -40,7 +40,6 @@ import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Location; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; -import org.jclouds.softlayer.SoftLayerAsyncClient; import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.softlayer.compute.functions.DatacenterToLocation; import org.jclouds.softlayer.compute.functions.ProductItemToImage; @@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class SoftLayerComputeServiceContextModule - extends - ComputeServiceAdapterContextModule, ProductItem, Datacenter> { - - public SoftLayerComputeServiceContextModule() { - super(SoftLayerClient.class, SoftLayerAsyncClient.class); - } +public class SoftLayerComputeServiceContextModule extends + ComputeServiceAdapterContextModule, ProductItem, Datacenter> { @Override protected void configure() { diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java index 787c74244e..03e07d12fd 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java @@ -22,7 +22,6 @@ import java.util.Map; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -52,7 +51,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class SoftLayerRestClientModule extends RestClientModule { diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java index ffd7da5e2c..8a848c1fa1 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java @@ -18,12 +18,8 @@ */ package org.jclouds.softlayer.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.rest.RestContext; -import org.jclouds.softlayer.SoftLayerAsyncClient; -import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -37,9 +33,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, sequential = true) -public class SoftLayerComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest { public SoftLayerComputeServiceLiveTest() { provider = "softlayer"; @@ -50,11 +44,6 @@ public class SoftLayerComputeServiceLiveTest protected Module getSshModule() { return new SshjSshClientModule(); } - - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = context.getProviderSpecificContext(); - } // softlayer does not support metadata @Override diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java index 8e90948446..c98091b8a4 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java @@ -20,11 +20,9 @@ package org.jclouds.softlayer.compute; import static org.testng.Assert.assertEquals; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.softlayer.SoftLayerAsyncClient; -import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.softlayer.SoftLayerProviderMetadata; import org.testng.annotations.Test; @@ -35,9 +33,7 @@ import com.google.common.io.Closeables; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "SoftLayerExperimentLiveTest") -public class SoftLayerExperimentLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class SoftLayerExperimentLiveTest extends BaseComputeServiceContextLiveTest { public SoftLayerExperimentLiveTest() { provider = "glesys"; @@ -45,13 +41,13 @@ public class SoftLayerExperimentLiveTest @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = ComputeServiceContextBuilder + context = ContextBuilder .newBuilder(new SoftLayerProviderMetadata()) .overrides(setupProperties()) - .modules(setupModules()).build(); + .modules(setupModules()).build(ComputeServiceContext.class); assertEquals(context.getComputeService().listAssignableLocations().size(), 6); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java index 79ab1ddf01..da61c86bc6 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java @@ -35,8 +35,6 @@ import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.softlayer.SoftLayerAsyncClient; -import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions; import org.testng.annotations.Test; @@ -49,10 +47,8 @@ import com.google.common.collect.ImmutableSet; * @author Jason King */ @Test(groups = "live") -public class SoftLayerTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { - +public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + public SoftLayerTemplateBuilderLiveTest() { provider = "softlayer"; } @@ -102,7 +98,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testTemplateBuilderFindsGigabitUplink() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "1000"); @@ -120,7 +116,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testTemplateBuilderFindsMegabitUplink() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "100"); @@ -138,7 +134,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testBiggestTemplateBuilderWhenBootIsSAN() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "SAN"); @@ -158,7 +154,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testDefaultTemplateBuilderWhenPrivateNetwork() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); @@ -178,7 +174,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testBiggestTemplateBuilderWhenPrivateNetwork() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java index 02d8dd7acf..c8420e0e65 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java @@ -38,7 +38,7 @@ public abstract class BaseSoftLayerAsyncClientTest extends BaseAsyncClientTes } @Override - public ProviderMetadata createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new SoftLayerProviderMetadata(); } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java index 0febeb7087..43268d1d5c 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.softlayer.features; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.rest.RestContext; import org.jclouds.softlayer.SoftLayerAsyncClient; @@ -32,9 +31,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live") -public class BaseSoftLayerClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseSoftLayerClientLiveTest extends BaseComputeServiceContextLiveTest { protected RestContext socontext; @@ -42,7 +39,7 @@ public class BaseSoftLayerClientLiveTest @Override public void setupContext() { super.setupContext(); - socontext = context.getProviderSpecificContext(); + socontext = context.unwrap(); } } diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java deleted file mode 100644 index c4c50fb035..0000000000 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.stratogen.vcloud.mycloud; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.stratogen.vcloud.mycloud.config.StratoGenVCloudMyCloudRestClientModule; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; -import org.jclouds.vcloud.VCloudContextBuilder; -import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; - -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -public class StratoGenVCloudMyCloudContextBuilder extends VCloudContextBuilder { - public StratoGenVCloudMyCloudContextBuilder( - ProviderMetadata, VCloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public StratoGenVCloudMyCloudContextBuilder(VCloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new StratoGenVCloudMyCloudRestClientModule()); - } - -} diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java index 07a245e950..2f2e8bb15a 100644 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java +++ b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java @@ -23,23 +23,24 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAU import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.stratogen.vcloud.mycloud.config.StratoGenVCloudMyCloudComputeServiceContextModule; import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.config.VCloudRestClientModule; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for StratoGen VMware hosting * * @author Adrian Cole */ -public class StratoGenVCloudMyCloudProviderMetadata - extends - BaseProviderMetadata, VCloudApiMetadata> { +public class StratoGenVCloudMyCloudProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -113107768473491412L; public static Builder builder() { return new Builder(); @@ -58,13 +59,13 @@ public class StratoGenVCloudMyCloudProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "Direct Internet"); return properties; } - public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("stratogen-vcloud-mycloud") @@ -72,7 +73,8 @@ public class StratoGenVCloudMyCloudProviderMetadata .apiMetadata( new VCloudApiMetadata().toBuilder() .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(StratoGenVCloudMyCloudContextBuilder.class)).build()) + .defaultModules(ImmutableSet.>of(VCloudRestClientModule.class, StratoGenVCloudMyCloudComputeServiceContextModule.class)) + .build()) .homepage(URI.create("http://www.stratogen.net")) .console(URI.create("https://mycloud.stratogen.net/cloud/org/YOUR_ORG_HERE")) .iso3166Codes("GB") @@ -87,7 +89,7 @@ public class StratoGenVCloudMyCloudProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, VCloudApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java index fb4590393d..d43aad1b79 100644 --- a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java +++ b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "StratoGenVCloudMyCloudTemplateBuilderLiveTest") -public class StratoGenVCloudMyCloudTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class StratoGenVCloudMyCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public StratoGenVCloudMyCloudTemplateBuilderLiveTest() { provider = "stratogen-vcloud-mycloud"; diff --git a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java index f472292fc4..fe87784fa8 100644 --- a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java +++ b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java @@ -4,9 +4,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.atmos.AtmosAsyncClient; -import org.jclouds.atmos.AtmosClient; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -16,8 +13,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class SynapticStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { +public class SynapticStorageProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } @@ -35,12 +35,12 @@ public class SynapticStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("synaptic-storage") @@ -60,7 +60,7 @@ public class SynapticStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java index dfae1bf49f..944acf2257 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java @@ -7,18 +7,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.trmk.ecloud.compute.config.TerremarkECloudComputeServiceContextModule; +import org.jclouds.trmk.ecloud.config.TerremarkECloudRestClientModule; import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Terremark eCloud v2.8 API * * @author Adrian Cole */ -public class TerremarkECloudApiMetadata extends - TerremarkVCloudApiMetadata { +public class TerremarkECloudApiMetadata extends TerremarkVCloudApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -6212626084139698761L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -32,26 +43,24 @@ public class TerremarkECloudApiMetadata extends super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = TerremarkVCloudApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "eCloudExtensions"); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.8"); return properties; } - public static class Builder - extends - TerremarkVCloudApiMetadata.Builder { + public static class Builder extends TerremarkVCloudApiMetadata.Builder { protected Builder() { super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class); id("trmk-ecloud") .name("Terremark Enterprise Cloud v2.8 API") .version("0.8b-ext2.8") - .defaultProperties(TerremarkECloudApiMetadata.defaultProperties()) .defaultEndpoint("https://services.enterprisecloud.terremark.com/api") - .contextBuilder(TypeToken.of(TerremarkECloudContextBuilder.class)) - .documentation(URI.create("http://support.theenterprisecloud.com/kb/default.asp?id=533&Lang=1&SID=")); + .documentation(URI.create("http://support.theenterprisecloud.com/kb/default.asp?id=533&Lang=1&SID=")) + .defaultProperties(TerremarkECloudApiMetadata.defaultProperties()) + .defaultModules(ImmutableSet.>of(TerremarkECloudRestClientModule.class, TerremarkECloudComputeServiceContextModule.class)); } @Override @@ -60,7 +69,7 @@ public class TerremarkECloudApiMetadata extends } @Override - public Builder fromApiMetadata(TerremarkECloudApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java deleted file mode 100644 index da4b9fe1bd..0000000000 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.trmk.ecloud; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.trmk.ecloud.compute.config.TerremarkECloudComputeServiceContextModule; -import org.jclouds.trmk.ecloud.config.TerremarkECloudRestClientModule; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudContextBuilder; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link TerremarkVCloudComputeServiceContext} or {@link Injector} - * instances based on the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see TerremarkVCloudComputeServiceContext - */ -public class TerremarkECloudContextBuilder - extends - TerremarkVCloudContextBuilder, TerremarkECloudApiMetadata> { - public TerremarkECloudContextBuilder() { - this(new TerremarkECloudProviderMetadata()); - } - - public TerremarkECloudContextBuilder( - ProviderMetadata, TerremarkECloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public TerremarkECloudContextBuilder(TerremarkECloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new TerremarkECloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new TerremarkECloudRestClientModule()); - } - -} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java index e1c562ea88..dd33f5852c 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.trmk.ecloud; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -30,8 +29,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class TerremarkECloudProviderMetadata extends BaseProviderMetadata, TerremarkECloudApiMetadata> { +public class TerremarkECloudProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -759809591681141530L; + public static Builder builder() { return new Builder(); } @@ -49,12 +51,12 @@ public class TerremarkECloudProviderMetadata extends BaseProviderMetadata, TerremarkECloudApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("trmk-ecloud") @@ -73,7 +75,7 @@ public class TerremarkECloudProviderMetadata extends BaseProviderMetadata, TerremarkECloudApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/config/TerremarkECloudRestClientModule.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/config/TerremarkECloudRestClientModule.java index 73f739fcff..c777657c95 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/config/TerremarkECloudRestClientModule.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/config/TerremarkECloudRestClientModule.java @@ -25,7 +25,6 @@ import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.trmk.ecloud.TerremarkECloudAsyncClient; import org.jclouds.trmk.ecloud.TerremarkECloudClient; @@ -52,7 +51,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class TerremarkECloudRestClientModule extends TerremarkVCloudRestClientModule { diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java index c97038565f..c4af0d6710 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java @@ -30,7 +30,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; @@ -73,7 +72,7 @@ public abstract class BaseTerremarkECloudAsyncClientTest extends BaseAsyncCli } @Override - public ProviderMetadata createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new TerremarkECloudProviderMetadata(); } @@ -127,8 +126,7 @@ public abstract class BaseTerremarkECloudAsyncClientTest extends BaseAsyncCli .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap. of(NETWORK_REF.getName(), NETWORK_REF)); - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient protected static class TerremarkECloudRestClientModuleExtension extends TerremarkECloudRestClientModule { @Override diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java index 57d9e41f7f..804aca0846 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java @@ -28,7 +28,8 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class BaseTerremarkECloudClientLiveTest extends BaseTerremarkClientLiveTest { +public class BaseTerremarkECloudClientLiveTest extends + BaseTerremarkClientLiveTest { @Override protected Properties setupProperties() { Properties props = super.setupProperties(); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java index 8ed4c60713..0476d839dc 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java @@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Image; @@ -49,9 +48,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class TerremarkECloudComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Override protected Properties setupProperties() { @@ -107,7 +104,7 @@ public class TerremarkECloudComputeServiceLiveTest assert node.getLocation() != null; assertEquals(node.getType(), ComputeType.NODE); NodeMetadata allData = client.getNodeMetadata(node.getId()); - RestContext tmContext = context.getProviderSpecificContext(); + RestContext tmContext = context.unwrap(); VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(allData.getLocation().getParent().getDescription(), allData.getLocation().getDescription(), allData.getName()); assertEquals(vApp.getName(), allData.getName()); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java index 2426a7d444..7c7090835d 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java @@ -25,13 +25,10 @@ import java.io.IOException; import java.util.Properties; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.trmk.ecloud.TerremarkECloudAsyncClient; -import org.jclouds.trmk.ecloud.TerremarkECloudClient; import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants; import org.testng.annotations.Test; @@ -43,9 +40,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class TerremarkECloudTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Override protected Properties setupProperties() { Properties props = super.setupProperties(); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsClientLiveTest.java index 42bbbffc66..13b4d20cf2 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsClientLiveTest.java @@ -33,12 +33,12 @@ import org.testng.annotations.Test; public class DataCenterOperationsClientLiveTest extends BaseTerremarkECloudClientLiveTest { @Test public void testListDataCentersInOrg() throws Exception { - for (ReferenceType response : getApi().listOrgs().values()) { - ECloudOrg org = getApi().getOrg(response.getHref()); + for (ReferenceType response : connection.listOrgs().values()) { + ECloudOrg org = connection.getOrg(response.getHref()); assertNotNull(response); assertNotNull(response.getName()); assertNotNull(response.getHref()); - assertEquals(getApi().getDataCenterOperationsClient().listDataCentersInOrg(org.getHref()), getApi() + assertEquals(connection.getDataCenterOperationsClient().listDataCentersInOrg(org.getHref()), connection .getDataCenterOperationsClient().listDataCenters(org.getDataCenters().getHref())); } } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsClientLiveTest.java index dd5fe73d4a..3620c2b90c 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsClientLiveTest.java @@ -33,12 +33,12 @@ import org.testng.annotations.Test; public class TagOperationsClientLiveTest extends BaseTerremarkECloudClientLiveTest { @Test public void testListTagsInOrg() throws Exception { - for (ReferenceType response : getApi().listOrgs().values()) { - ECloudOrg org = getApi().getOrg(response.getHref()); + for (ReferenceType response : connection.listOrgs().values()) { + ECloudOrg org = connection.getOrg(response.getHref()); assertNotNull(response); assertNotNull(response.getName()); assertNotNull(response.getHref()); - assertEquals(getApi().getTagOperationsClient().getTagNameToUsageCountInOrg(org.getHref()), getApi() + assertEquals(connection.getTagOperationsClient().getTagNameToUsageCountInOrg(org.getHref()), connection .getTagOperationsClient().getTagNameToUsageCount(org.getTags().getHref())); } } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/ECloudOrgHandlerTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/ECloudOrgHandlerTest.java index b61206bd4a..1a03416cde 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/ECloudOrgHandlerTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/ECloudOrgHandlerTest.java @@ -18,19 +18,17 @@ */ package org.jclouds.trmk.ecloud.xml; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; -import java.util.Properties; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.trmk.ecloud.TerremarkECloudApiMetadata; import org.jclouds.trmk.ecloud.TerremarkECloudMediaType; import org.jclouds.trmk.ecloud.domain.ECloudOrg; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -55,9 +53,7 @@ public class ECloudOrgHandlerTest extends BaseHandlerTest { @Override public void configure() { super.configure(); - Properties props = new Properties(); - Names.bindProperties(binder(), - checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + Names.bindProperties(binder(),TerremarkECloudApiMetadata.defaultProperties()); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandlerTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandlerTest.java index 3ac18c4204..17b9559408 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandlerTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandlerTest.java @@ -18,17 +18,15 @@ */ package org.jclouds.trmk.ecloud.xml; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.util.Map; -import java.util.Properties; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; +import org.jclouds.trmk.ecloud.TerremarkECloudApiMetadata; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -52,9 +50,7 @@ public class TagNameToUsageCountHandlerTest extends BaseHandlerTest { @Override public void configure() { super.configure(); - Properties props = new Properties(); - Names.bindProperties(binder(), - checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + Names.bindProperties(binder(),TerremarkECloudApiMetadata.defaultProperties()); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java index 605a93fc10..cb2e234a99 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java @@ -25,18 +25,28 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.rest.RestContext; import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; +import org.jclouds.trmk.vcloudexpress.compute.TerremarkVCloudExpressComputeServiceContextModule; +import org.jclouds.trmk.vcloudexpress.config.TerremarkVCloudExpressRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the Terremark vCloud Express API * * @author Adrian Cole */ -public class TerremarkVCloudExpressApiMetadata extends - TerremarkVCloudApiMetadata { +public class TerremarkVCloudExpressApiMetadata extends TerremarkVCloudApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -6212626084139698761L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -50,7 +60,7 @@ public class TerremarkVCloudExpressApiMetadata extends super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = TerremarkVCloudApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "vCloudExpressExtensions"); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "1.6"); @@ -59,7 +69,7 @@ public class TerremarkVCloudExpressApiMetadata extends public static class Builder extends - TerremarkVCloudApiMetadata.Builder { + TerremarkVCloudApiMetadata.Builder { protected Builder() { super(TerremarkVCloudExpressClient.class, TerremarkVCloudExpressAsyncClient.class); @@ -67,11 +77,11 @@ public class TerremarkVCloudExpressApiMetadata extends .name("Terremark vCloud Express API") .identityName("Email") .credentialName("Password") - .defaultProperties(TerremarkVCloudExpressApiMetadata.defaultProperties()) + .version("0.8a-ext1.6") .defaultEndpoint("https://services.vcloudexpress.terremark.com/api") + .documentation(URI.create("https://community.vcloudexpress.terremark.com/en-us/product_docs/m/vcefiles/2342.aspx")) .defaultProperties(TerremarkVCloudExpressApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(TerremarkVCloudExpressContextBuilder.class)) - .documentation(URI.create("https://community.vcloudexpress.terremark.com/en-us/product_docs/m/vcefiles/2342.aspx")); + .defaultModules(ImmutableSet.>of(TerremarkVCloudExpressRestClientModule.class, TerremarkVCloudExpressComputeServiceContextModule.class)); } @Override @@ -80,7 +90,7 @@ public class TerremarkVCloudExpressApiMetadata extends } @Override - public Builder fromApiMetadata(TerremarkVCloudExpressApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java deleted file mode 100644 index 6a365fbbaa..0000000000 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.trmk.vcloudexpress; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudContextBuilder; -import org.jclouds.trmk.vcloudexpress.compute.TerremarkVCloudExpressComputeServiceContextModule; -import org.jclouds.trmk.vcloudexpress.config.TerremarkVCloudExpressRestClientModule; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link TerremarkVCloudComputeServiceContext} or {@link Injector} - * instances based on the most commonly requested arguments. - *

    - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

    - *

    - * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see TerremarkVCloudComputeServiceContext - */ -public class TerremarkVCloudExpressContextBuilder - extends - TerremarkVCloudContextBuilder, TerremarkVCloudExpressApiMetadata> { - public TerremarkVCloudExpressContextBuilder() { - this(new TerremarkVCloudExpressProviderMetadata()); - } - - public TerremarkVCloudExpressContextBuilder( - ProviderMetadata, TerremarkVCloudExpressApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public TerremarkVCloudExpressContextBuilder(TerremarkVCloudExpressApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new TerremarkVCloudExpressComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new TerremarkVCloudExpressRestClientModule()); - } - -} diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressPropertiesBuilder.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressPropertiesBuilder.java deleted file mode 100644 index 5c798c9b8b..0000000000 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressPropertiesBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.trmk.vcloudexpress; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; - -import java.util.Properties; - -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; - -/** - * Builds properties used in Terremark VCloud Clients - * - * @author Adrian Cole - */ -public class TerremarkVCloudExpressPropertiesBuilder extends TerremarkVCloudPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "0.8a-ext1.6"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-FL"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "vCloudExpressExtensions"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "1.6"); - properties.setProperty(PROPERTY_ENDPOINT, "https://services.vcloudexpress.terremark.com/api"); - return properties; - } - - public TerremarkVCloudExpressPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java index a36e53a0d8..8b64e1b407 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.trmk.vcloudexpress; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -30,8 +29,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata, TerremarkVCloudExpressApiMetadata> { +public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -7993337019540975194L; + public static Builder builder() { return new Builder(); } @@ -49,12 +51,12 @@ public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } - public static class Builder extends BaseProviderMetadata.Builder, TerremarkVCloudExpressApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("trmk-vcloudexpress") @@ -74,7 +76,7 @@ public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, TerremarkVCloudExpressApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/config/TerremarkVCloudExpressRestClientModule.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/config/TerremarkVCloudExpressRestClientModule.java index e6f35b8109..6a618b5cf4 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/config/TerremarkVCloudExpressRestClientModule.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/config/TerremarkVCloudExpressRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.trmk.vcloudexpress.config; import javax.inject.Singleton; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; @@ -36,7 +35,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class TerremarkVCloudExpressRestClientModule extends TerremarkVCloudRestClientModule { diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java index a25f499e91..87d95fed58 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java @@ -23,7 +23,6 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.trmk.vcloud_0_8.domain.InternetService; import org.jclouds.trmk.vcloud_0_8.domain.Node; @@ -42,7 +41,7 @@ import com.google.common.collect.Sets; @Test(groups = "live", singleThreaded = true, testName = "InternetServiceLiveTest") public class InternetServiceLiveTest extends - BaseComputeServiceContextLiveTest> { + BaseComputeServiceContextLiveTest { public InternetServiceLiveTest() { provider = "trmk-vcloudexpress"; } @@ -89,7 +88,7 @@ public class InternetServiceLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - tmClient = context.getProviderSpecificContext().getApi(); + tmClient = context.unwrap(TerremarkVCloudExpressApiMetadata.CONTEXT_TOKEN).getApi(); } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java index aeccab9a00..45a8ca271a 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java @@ -38,7 +38,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.providers.ProviderMetadata; @@ -621,7 +620,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new TerremarkVCloudExpressProviderMetadata(); } @@ -667,8 +666,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest of(NETWORK_REF.getName(), NETWORK_REF)); - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient protected static class TerremarkVCloudRestClientModuleExtension extends TerremarkVCloudExpressRestClientModule { @Override diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java index 3038f72cdd..4fe542a463 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java @@ -20,7 +20,6 @@ package org.jclouds.trmk.vcloudexpress.compute; import static org.testng.Assert.assertEquals; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Image; @@ -45,9 +44,7 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class TerremarkVCloudExpressComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeServiceLiveTest { public TerremarkVCloudExpressComputeServiceLiveTest() { provider = "trmk-vcloudexpress"; @@ -99,7 +96,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest assertEquals(node.getType(), ComputeType.NODE); NodeMetadata allData = client.getNodeMetadata(node.getId()); System.out.println(allData.getHardware()); - RestContext tmContext = context.getProviderSpecificContext(); + RestContext tmContext = context.unwrap(); VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); assertEquals(vApp.getName(), allData.getName()); } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java index f8a59be4f9..109305fd13 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressAsyncClient; -import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class TerremarkVCloudExpressTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class TerremarkVCloudExpressTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public TerremarkVCloudExpressTemplateBuilderLiveTest() { provider = "trmk-vcloudexpress"; diff --git a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java deleted file mode 100644 index d015b534ba..0000000000 --- a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.trystack.nova; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.NovaContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.trystack.nova.config.TryStackNovaServiceContextModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class TryStackNovaContextBuilder extends NovaContextBuilder { - - public TryStackNovaContextBuilder( - ProviderMetadata, NovaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public TryStackNovaContextBuilder(NovaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new TryStackNovaServiceContextModule()); - } - -} diff --git a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java index 1a974e1dee..b67eecf5be 100644 --- a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java +++ b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java @@ -25,23 +25,24 @@ import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERAT import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.trystack.nova.config.TryStackNovaServiceContextModule; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for TryStack Nova * * @author Adrian Cole */ -public class TryStackNovaProviderMetadata - extends - BaseProviderMetadata, NovaApiMetadata> { +public class TryStackNovaProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -8567407993297259224L; public static Builder builder() { return new Builder(); @@ -60,7 +61,7 @@ public class TryStackNovaProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(CREDENTIAL_TYPE, "passwordCredentials"); @@ -68,14 +69,15 @@ public class TryStackNovaProviderMetadata return properties; } - public static class Builder extends BaseProviderMetadata.Builder, NovaApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("trystack-nova") .name("TryStack.org (Nova)") .apiMetadata( - new NovaApiMetadata().toBuilder().contextBuilder(TypeToken.of(TryStackNovaContextBuilder.class)) - .build()) + new NovaApiMetadata().toBuilder() + .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, TryStackNovaServiceContextModule.class)) + .build()) .homepage(URI.create("https://trystack.org")) .console(URI.create("https://trystack.org/dash")) .iso3166Codes("US-CA") @@ -90,7 +92,7 @@ public class TryStackNovaProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, NovaApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java index ed4ae1e715..a23f3e92ff 100644 --- a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java +++ b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.compute.options.NovaTemplateOptions; import org.testng.annotations.Test; @@ -42,8 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "TryStackNovaTemplateBuilderLiveTest") -public class TryStackNovaTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { +public class TryStackNovaTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public TryStackNovaTemplateBuilderLiveTest() { provider = "trystack-nova"; diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java index 350cb0fcf9..496f679901 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java @@ -18,14 +18,8 @@ */ package org.jclouds.dunkel.vcd; -import java.util.List; -import java.util.Properties; - -import org.jclouds.vcloud.VCloudContextBuilder; -import org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorComputeServiceContextModule; -import org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorRestClientModule; - -import com.google.inject.Module; +import src.main.java.org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorComputeServiceContextModule; +import src.main.java.org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorRestClientModule; /** * diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java index 29521af599..e246599839 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java @@ -18,14 +18,6 @@ */ package org.jclouds.dunkel.vcd; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; - -import java.util.Properties; - -import org.jclouds.vcloud.VCloudPropertiesBuilder; /** * diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java index 3fa940cfeb..f657fe5d55 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java @@ -18,13 +18,6 @@ */ package org.jclouds.dunkel.vcd; -import com.google.common.collect.ImmutableSet; - -import java.net.URI; -import java.util.Set; - -import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Dunkel vCloud Director diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java index f73cd4c0a4..210e5a1f23 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java @@ -18,15 +18,6 @@ */ package org.jclouds.dunkel.vcd.config; -import static org.jclouds.compute.domain.OsFamily.RHEL; - -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; -import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; -import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; - -import com.google.inject.Injector; /** * diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java index 1c6aba2d37..9bb92e1c1f 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java @@ -18,15 +18,11 @@ */ package org.jclouds.dunkel.vcd.config; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.config.VCloudRestClientModule; /** * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class DunkelVCloudDirectorRestClientModule extends VCloudRestClientModule { diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java index ad1043bff2..5589905127 100644 --- a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java @@ -18,10 +18,7 @@ */ package org.jclouds.dunkel.vcd; -import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.dunkel.vcd.DunkelVCloudDirectorProviderMetadata; -import org.testng.annotations.Test; +import src.main.java.org.jclouds.dunkel.vcd.DunkelVCloudDirectorProviderMetadata; /** * diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java index d5e46c831b..9f43601cd5 100644 --- a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java @@ -18,8 +18,6 @@ */ package org.jclouds.dunkel.vcd.compute; -import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; -import org.testng.annotations.Test; /** * diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java index fc67f05871..0025def75d 100644 --- a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java @@ -18,20 +18,6 @@ */ package org.jclouds.dunkel.vcd.compute; -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Set; - -import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; /** * diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java index b858a0fe7a..a8fa9e5f35 100644 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java @@ -3,18 +3,20 @@ package org.jclouds.servermanager; import java.net.URI; import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; -import org.jclouds.servermanager.compute.ServerManagerComputeServiceContextBuilder; - -import com.google.common.reflect.TypeToken; +import org.jclouds.servermanager.compute.config.ServerManagerComputeServiceContextModule; /** * Implementation of {@link ApiMetadata} for an example of library integration (ServerManager) * * @author Adrian Cole */ -public class ServerManagerApiMetadata extends BaseComputeServiceApiMetadata, ServerManagerApiMetadata> { +public class ServerManagerApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3606170564482119304L; + public static Builder builder() { return new Builder(); } @@ -32,7 +34,7 @@ public class ServerManagerApiMetadata extends BaseComputeServiceApiMetadata, ServerManagerApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder(){ id("servermanager") @@ -41,12 +43,9 @@ public class ServerManagerApiMetadata extends BaseComputeServiceApiMetadata>(getClass()){ - private static final long serialVersionUID = 1L; - }) - .javaApi(ServerManager.class, ServerManager.class) .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute")) - .contextBuilder(TypeToken.of(ServerManagerComputeServiceContextBuilder.class)); + .wrapper(ComputeServiceContext.class) + .defaultModule(ServerManagerComputeServiceContextModule.class); } @Override diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java deleted file mode 100644 index f10174a8f0..0000000000 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you 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.servermanager.compute; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.StandaloneComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.servermanager.ServerManager; -import org.jclouds.servermanager.ServerManagerApiMetadata; -import org.jclouds.servermanager.compute.config.ServerManagerComputeServiceContextModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class ServerManagerComputeServiceContextBuilder - extends - StandaloneComputeServiceContextBuilder, ServerManagerApiMetadata> { - - public ServerManagerComputeServiceContextBuilder() { - super(new ServerManagerApiMetadata()); - } - - public ServerManagerComputeServiceContextBuilder( - ProviderMetadata, ServerManagerApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public ServerManagerComputeServiceContextBuilder(ServerManagerApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new ServerManagerComputeServiceContextModule()); - } -} diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/config/ServerManagerComputeServiceContextModule.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/config/ServerManagerComputeServiceContextModule.java index 778a5446f7..efcce8aa61 100644 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/config/ServerManagerComputeServiceContextModule.java +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/config/ServerManagerComputeServiceContextModule.java @@ -26,7 +26,6 @@ import org.jclouds.servermanager.Datacenter; import org.jclouds.servermanager.Hardware; import org.jclouds.servermanager.Image; import org.jclouds.servermanager.Server; -import org.jclouds.servermanager.ServerManager; import org.jclouds.servermanager.compute.functions.DatacenterToLocation; import org.jclouds.servermanager.compute.functions.ServerManagerHardwareToHardware; import org.jclouds.servermanager.compute.functions.ServerManagerImageToImage; @@ -41,11 +40,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class ServerManagerComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - public ServerManagerComputeServiceContextModule() { - super(ServerManager.class, ServerManager.class); - } + ComputeServiceAdapterContextModule { @Override protected void configure() { diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java index ba0eeb06ff..87b85a2f84 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java @@ -22,10 +22,9 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.rest.RestContext; -import org.jclouds.servermanager.ServerManager; +import org.jclouds.lifecycle.Closer; import org.jclouds.servermanager.ServerManagerApiMetadata; import org.testng.annotations.Test; @@ -34,26 +33,20 @@ import org.testng.annotations.Test; * @author Adrian Cole * */ -@Test(groups = "unit", testName = "ServerManagerComputeServiceContextBuilderTest") +@Test(groups = "unit", testName = "ServerManagerContextBuilderTest") public class ServerManagerComputeServiceContextBuilderTest { - @Test - public void testCanBuildDirectly() { - ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() - .build(); - context.close(); - } @Test public void testCanBuildWithApiMetadata() { - ComputeServiceContext context = ComputeServiceContextBuilder.newBuilder( - new ServerManagerApiMetadata()).build(); + ComputeServiceContext context = ContextBuilder.newBuilder( + new ServerManagerApiMetadata()).build(ComputeServiceContext.class); context.close(); } @Test public void testCanBuildById() { - ComputeServiceContext context = ComputeServiceContextBuilder.newBuilder("servermanager").build(); + ComputeServiceContext context = ContextBuilder.newBuilder("servermanager").build(ComputeServiceContext.class); context.close(); } @@ -63,20 +56,17 @@ public class ServerManagerComputeServiceContextBuilderTest { overrides.setProperty("servermanager.endpoint", "http://host"); overrides.setProperty("servermanager.api-version", "1"); - ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() - .overrides(overrides).build(); + ComputeServiceContext context = ContextBuilder.newBuilder("servermanager") + .overrides(overrides).build(ComputeServiceContext.class); context.close(); } @Test - public void testProviderSpecificContextIsCorrectType() { - ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() - .build(); + public void testUnwrapIsCorrectType() { + ComputeServiceContext context = ContextBuilder.newBuilder("servermanager").build(ComputeServiceContext.class); - RestContext providerContext = context.getProviderSpecificContext(); - - assertEquals(providerContext.getApi().getClass(), ServerManager.class); + assertEquals(context.unwrap().getClass(), Closer.class); context.close(); } diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java index e194d09a23..1d1fc7c376 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java @@ -21,12 +21,10 @@ package org.jclouds.servermanager.compute; import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.servermanager.ServerManager; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.Test; @@ -36,8 +34,7 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class ServerManagerComputeServiceLiveTest extends - BaseComputeServiceLiveTest> { +public class ServerManagerComputeServiceLiveTest extends BaseComputeServiceLiveTest { public ServerManagerComputeServiceLiveTest() { provider = "servermanager"; diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java index fefa7e3879..38c5a503f9 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java @@ -18,10 +18,9 @@ */ package org.jclouds.servermanager.compute; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.servermanager.ServerManager; import org.jclouds.servermanager.ServerManagerApiMetadata; import org.testng.annotations.Test; @@ -30,9 +29,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ServerManagerExperimentLiveTest") -public class ServerManagerExperimentLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class ServerManagerExperimentLiveTest extends BaseComputeServiceContextLiveTest { public ServerManagerExperimentLiveTest() { provider = "servermanager"; @@ -40,9 +37,9 @@ public class ServerManagerExperimentLiveTest @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = ComputeServiceContextBuilder.newBuilder(new ServerManagerApiMetadata()).build(); + context = ContextBuilder.newBuilder(new ServerManagerApiMetadata()).build(ComputeServiceContext.class); context.getComputeService().listNodes(); From 767cb984593c57902922283dec332e708a73aa4a Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Mon, 16 Apr 2012 19:12:32 +0200 Subject: [PATCH 65/69] Added module to configure an ScheduledExecutorService --- core/src/main/java/org/jclouds/Constants.java | 7 + .../apis/internal/BaseApiMetadata.java | 2 + .../config/ExecutorServiceModule.java | 6 +- .../ScheduledExecutorServiceModule.java | 121 ++++++++++++ .../lifecycle/config/LifeCycleModule.java | 10 +- .../config/ExecutorServiceModuleTest.java | 8 +- .../ScheduledExecutorServiceModuleTest.java | 172 ++++++++++++++++++ 7 files changed, 318 insertions(+), 8 deletions(-) create mode 100644 core/src/main/java/org/jclouds/concurrent/config/ScheduledExecutorServiceModule.java create mode 100644 core/src/test/java/org/jclouds/concurrent/config/ScheduledExecutorServiceModuleTest.java diff --git a/core/src/main/java/org/jclouds/Constants.java b/core/src/main/java/org/jclouds/Constants.java index 3ec3293779..753d96a11a 100644 --- a/core/src/main/java/org/jclouds/Constants.java +++ b/core/src/main/java/org/jclouds/Constants.java @@ -41,6 +41,13 @@ public interface Constants { */ public static final String PROPERTY_IO_WORKER_THREADS = "jclouds.io-worker-threads"; + /** + * Integer property. default (10) + *

    + * Amount of threads servicing scheduled tasks. + */ + public static final String PROPERTY_SCHEDULER_THREADS = "jclouds.scheduler-threads"; + /** * Integer property. default (20) *

    diff --git a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java index ac87f3641b..861948c39e 100644 --- a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java @@ -31,6 +31,7 @@ import static org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; import static org.jclouds.Constants.PROPERTY_USER_THREADS; +import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; import java.io.Closeable; import java.net.URI; @@ -71,6 +72,7 @@ public abstract class BaseApiMetadata implements ApiMetadata { props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); props.setProperty(PROPERTY_USER_THREADS, 0 + ""); + props.setProperty(PROPERTY_SCHEDULER_THREADS, 10 + ""); props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); diff --git a/core/src/main/java/org/jclouds/concurrent/config/ExecutorServiceModule.java b/core/src/main/java/org/jclouds/concurrent/config/ExecutorServiceModule.java index e61c7fc824..f9400a121b 100644 --- a/core/src/main/java/org/jclouds/concurrent/config/ExecutorServiceModule.java +++ b/core/src/main/java/org/jclouds/concurrent/config/ExecutorServiceModule.java @@ -124,7 +124,7 @@ public class ExecutorServiceModule extends AbstractModule { static class DescribingExecutorService implements ExecutorService { - private final ExecutorService delegate; + protected final ExecutorService delegate; public DescribingExecutorService(ExecutorService delegate) { this.delegate = checkNotNull(delegate, "delegate"); @@ -216,7 +216,7 @@ public class ExecutorServiceModule extends AbstractModule { } static class DescribedFuture implements Future { - private final Future delegate; + protected final Future delegate; private final String description; private StackTraceElement[] submissionTrace; @@ -340,7 +340,7 @@ public class ExecutorServiceModule extends AbstractModule { } @VisibleForTesting - static ExecutorService shutdownOnClose(final ExecutorService service, Closer closer) { + static T shutdownOnClose(final T service, Closer closer) { closer.addToClose(new ShutdownExecutorOnClose(service)); return service; } diff --git a/core/src/main/java/org/jclouds/concurrent/config/ScheduledExecutorServiceModule.java b/core/src/main/java/org/jclouds/concurrent/config/ScheduledExecutorServiceModule.java new file mode 100644 index 0000000000..c3d53ce56d --- /dev/null +++ b/core/src/main/java/org/jclouds/concurrent/config/ScheduledExecutorServiceModule.java @@ -0,0 +1,121 @@ +package org.jclouds.concurrent.config; + +import static org.jclouds.concurrent.config.ExecutorServiceModule.shutdownOnClose; +import static org.jclouds.concurrent.config.ExecutorServiceModule.getStackTraceHere; + +import java.util.concurrent.Callable; +import java.util.concurrent.Delayed; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.Constants; +import org.jclouds.concurrent.config.ExecutorServiceModule.DescribedFuture; +import org.jclouds.concurrent.config.ExecutorServiceModule.DescribingExecutorService; +import org.jclouds.lifecycle.Closer; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.google.inject.AbstractModule; +import com.google.inject.Provides; + +/** + * Provides an {@link ScheduledExecutorService} to run periodical tasks such as virtual machine monitoring, etc. + *

    + * This module is not registered by default in the context because some providers do not allow to spawn threads. + * + * @author Ignasi Barrera + * + * @see ExecutorServiceModule + * + */ +public class ScheduledExecutorServiceModule extends AbstractModule { + + static class DescribingScheduledExecutorService extends DescribingExecutorService implements ScheduledExecutorService { + + public DescribingScheduledExecutorService(ScheduledExecutorService delegate) { + super(delegate); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + return new DescribedScheduledFuture(((ScheduledExecutorService) delegate) + .schedule(command, delay, unit), command.toString(), getStackTraceHere()); + } + + @Override + public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) { + return new DescribedScheduledFuture(((ScheduledExecutorService) delegate) + .schedule(callable, delay, unit), callable.toString(), getStackTraceHere()); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public ScheduledFuture scheduleAtFixedRate(Runnable command, long initialDelay, + long period, TimeUnit unit) { + return new DescribedScheduledFuture(((ScheduledExecutorService) delegate) + .scheduleAtFixedRate(command, initialDelay, period, unit), command.toString(), getStackTraceHere()); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public ScheduledFuture scheduleWithFixedDelay(Runnable command, long initialDelay, + long delay, TimeUnit unit) { + return new DescribedScheduledFuture(((ScheduledExecutorService) delegate) + .scheduleWithFixedDelay(command, initialDelay, delay, unit), command.toString(), getStackTraceHere()); + } + } + + static class DescribedScheduledFuture extends DescribedFuture implements ScheduledFuture { + + public DescribedScheduledFuture(ScheduledFuture delegate, String description, + StackTraceElement[] submissionTrace) { + super(delegate, description, submissionTrace); + } + + @Override + public long getDelay(TimeUnit unit) { + return ((ScheduledFuture) delegate).getDelay(unit); + } + + @Override + public int compareTo(Delayed o) { + return ((ScheduledFuture) delegate).compareTo(o); + } + } + + static ScheduledExecutorService addToStringOnSchedule(ScheduledExecutorService executor) { + if (executor != null) { + return new DescribingScheduledExecutorService(executor); + } + return executor; + } + + @Provides + @Singleton + @Named(Constants.PROPERTY_SCHEDULER_THREADS) + ScheduledExecutorService provideScheduledExecutor(@Named(Constants.PROPERTY_SCHEDULER_THREADS) final int count, + final Closer closer) { + return shutdownOnClose(addToStringOnSchedule(newScheduledThreadPoolNamed("scheduler thread %d", count)), closer); + } + + @VisibleForTesting + static ScheduledExecutorService newScheduledThreadPoolNamed(String name, int maxCount) { + ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat(name) + .setThreadFactory(Executors.defaultThreadFactory()).build(); + return maxCount == 0 ? Executors.newSingleThreadScheduledExecutor(factory) + : Executors.newScheduledThreadPool(maxCount, factory); + } + + @Override + protected void configure() { + + } + +} diff --git a/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java b/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java index 6f5e85c7f4..5ecc35fd13 100644 --- a/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java +++ b/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java @@ -28,10 +28,10 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.concurrent.ExecutorService; +import java.util.concurrent.ScheduledExecutorService; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import javax.inject.Inject; import javax.inject.Named; import org.jclouds.Constants; @@ -41,6 +41,7 @@ import org.jclouds.lifecycle.Closer; import com.google.common.base.Throwables; import com.google.common.util.concurrent.ExecutionList; import com.google.inject.AbstractModule; +import com.google.inject.Inject; import com.google.inject.Stage; import com.google.inject.TypeLiteral; import com.google.inject.spi.InjectionListener; @@ -74,12 +75,19 @@ public class LifeCycleModule extends AbstractModule { @Inject @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioExecutor; + // ScheduledExecutor is defined in an optional module + @Inject(optional = true) + @Named(Constants.PROPERTY_SCHEDULER_THREADS) + ScheduledExecutorService scheduledExecutor; public void close() throws IOException { assert userExecutor != null; userExecutor.shutdownNow(); assert ioExecutor != null; ioExecutor.shutdownNow(); + // ScheduledExecutor is defined in an optional module + if (scheduledExecutor != null) + scheduledExecutor.shutdownNow(); } }; diff --git a/core/src/test/java/org/jclouds/concurrent/config/ExecutorServiceModuleTest.java b/core/src/test/java/org/jclouds/concurrent/config/ExecutorServiceModuleTest.java index 77784d6740..1e7a70b79f 100644 --- a/core/src/test/java/org/jclouds/concurrent/config/ExecutorServiceModuleTest.java +++ b/core/src/test/java/org/jclouds/concurrent/config/ExecutorServiceModuleTest.java @@ -230,7 +230,7 @@ Caused by: java.lang.IllegalStateException: foo return io.submit((Runnable)t1, (Object)"shouldn't happen"); } - static void checkFutureGetFailsWith(Future task, String ...requiredPhrases) throws Exception { + static void checkFutureGetFailsWith(Future task, String ...requiredPhrases) throws Exception { try { task.get(); assert false : "task should have failed"; @@ -242,9 +242,9 @@ Caused by: java.lang.IllegalStateException: foo } } - private static class ConfigurableRunner implements Runnable, Callable { - private Object result; - private String failMessage; + static class ConfigurableRunner implements Runnable, Callable { + Object result; + String failMessage; @Override public void run() { diff --git a/core/src/test/java/org/jclouds/concurrent/config/ScheduledExecutorServiceModuleTest.java b/core/src/test/java/org/jclouds/concurrent/config/ScheduledExecutorServiceModuleTest.java new file mode 100644 index 0000000000..990798dbcb --- /dev/null +++ b/core/src/test/java/org/jclouds/concurrent/config/ScheduledExecutorServiceModuleTest.java @@ -0,0 +1,172 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you 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.concurrent.config; + +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.jclouds.concurrent.config.ExecutorServiceModuleTest.checkFutureGetFailsWith; + +import java.io.IOException; +import java.util.concurrent.Callable; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import org.easymock.EasyMock; +import org.jclouds.Constants; +import org.jclouds.concurrent.config.ExecutorServiceModuleTest.ConfigurableRunner; +import org.jclouds.lifecycle.Closer; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.name.Names; + +/** + * Unit tests for the {@link ScheduledExecutorServiceModule} class. + * + * @author Ignasi Barrera + * + * @see ExecutorServiceModuleTest + */ +@Test(groups = "unit") +public class ScheduledExecutorServiceModuleTest { + + @Test(groups = "unit") + public void testShutdownOnClose() throws IOException { + Injector i = Guice.createInjector(); + + Closer closer = i.getInstance(Closer.class); + ScheduledExecutorService executor = EasyMock.createMock(ScheduledExecutorService.class); + ExecutorServiceModule.shutdownOnClose(executor, closer); + + expect(executor.shutdownNow()).andReturn(ImmutableList. of()).atLeastOnce(); + + replay(executor); + closer.close(); + + verify(executor); + } + + @Test(groups = "unit") + public void testShutdownOnCloseThroughModule() throws IOException { + + ScheduledExecutorServiceModule module = new ScheduledExecutorServiceModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Names.named(Constants.PROPERTY_SCHEDULER_THREADS)).to(1); + super.configure(); + } + }; + + Injector i = Guice.createInjector(module); + Closer closer = i.getInstance(Closer.class); + + ScheduledExecutorService sched = i.getInstance(Key.get(ScheduledExecutorService.class, Names + .named(Constants.PROPERTY_SCHEDULER_THREADS))); + + assert !sched.isShutdown(); + + closer.close(); + + assert sched.isShutdown(); + } + + @Test(groups = "unit") + public void testDescribedFutureToString() throws Exception { + + ScheduledExecutorServiceModule module = new ScheduledExecutorServiceModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Names.named(Constants.PROPERTY_SCHEDULER_THREADS)).to(1); + super.configure(); + } + }; + + Injector i = Guice.createInjector(module); + Closer closer = i.getInstance(Closer.class); + + ScheduledExecutorService sched = i.getInstance(Key.get(ScheduledExecutorService.class, Names + .named(Constants.PROPERTY_SCHEDULER_THREADS))); + + ConfigurableRunner t1 = new ConfigurableRunner(); + t1.result = "okay"; + + ScheduledFuture esc = performScheduleInSeparateMethod1(sched, t1); + assert esc.toString().indexOf("ConfigurableRunner") >= 0; + assert esc.get().equals("okay"); + + closer.close(); + } + + @Test(groups = "unit") + public void testDescribedFutureExceptionIncludesSubmissionTrace() throws Exception { + + ScheduledExecutorServiceModule module = new ScheduledExecutorServiceModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Names.named(Constants.PROPERTY_SCHEDULER_THREADS)).to(1); + super.configure(); + } + }; + + Injector i = Guice.createInjector(module); + Closer closer = i.getInstance(Closer.class); + + ScheduledExecutorService sched = i.getInstance(Key.get(ScheduledExecutorService.class, Names + .named(Constants.PROPERTY_SCHEDULER_THREADS))); + + ConfigurableRunner t1 = new ConfigurableRunner(); + t1.failMessage = "foo"; + t1.result = "shouldn't happen"; + + ScheduledFuture esc = performScheduleInSeparateMethod1(sched, t1); + checkFutureGetFailsWith(esc, "foo", "testDescribedFutureExceptionIncludesSubmissionTrace", "performScheduleInSeparateMethod1"); + + ScheduledFuture esr = performScheduleInSeparateMethod2(sched, t1); + checkFutureGetFailsWith(esr, "foo", "testDescribedFutureExceptionIncludesSubmissionTrace", "performScheduleInSeparateMethod2"); + + ScheduledFuture esfr = performScheduleInSeparateMethod3(sched, t1); + checkFutureGetFailsWith(esfr, "foo", "testDescribedFutureExceptionIncludesSubmissionTrace", "performScheduleInSeparateMethod3"); + + ScheduledFuture esfd = performScheduleInSeparateMethod4(sched, t1); + checkFutureGetFailsWith(esfd, "foo", "testDescribedFutureExceptionIncludesSubmissionTrace", "performScheduleInSeparateMethod4"); + + closer.close(); + } + + static ScheduledFuture performScheduleInSeparateMethod1(ScheduledExecutorService sched, ConfigurableRunner t1) { + return sched.schedule((Callable)t1, 0, TimeUnit.SECONDS); + } + + static ScheduledFuture performScheduleInSeparateMethod2(ScheduledExecutorService sched, ConfigurableRunner t1) { + return sched.schedule((Runnable)t1, 0, TimeUnit.SECONDS); + } + + static ScheduledFuture performScheduleInSeparateMethod3(ScheduledExecutorService sched, ConfigurableRunner t1) { + return sched.scheduleAtFixedRate((Runnable)t1, 0, 1, TimeUnit.SECONDS); + } + + static ScheduledFuture performScheduleInSeparateMethod4(ScheduledExecutorService sched, ConfigurableRunner t1) { + return sched.scheduleWithFixedDelay((Runnable)t1, 0, 1, TimeUnit.SECONDS); + } +} From 9267ac29bad105a09ab28794790a370b2b988b19 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 16 Apr 2012 11:08:36 -0700 Subject: [PATCH 66/69] allow chef to extend this --- .../json/internal/NullHackJsonLiteralAdapter.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/jclouds/json/internal/NullHackJsonLiteralAdapter.java b/core/src/main/java/org/jclouds/json/internal/NullHackJsonLiteralAdapter.java index 6efba01b76..e37815c43f 100644 --- a/core/src/main/java/org/jclouds/json/internal/NullHackJsonLiteralAdapter.java +++ b/core/src/main/java/org/jclouds/json/internal/NullHackJsonLiteralAdapter.java @@ -72,7 +72,7 @@ public abstract class NullHackJsonLiteralAdapter extends TypeAdapter { try { // we are using an implementation hack which depends on replacing null with the raw json // supplied as a parameter. In this case, we must ensure we indeed serialize nulls. - NullReplacingWriter nullReplacingWriter = new NullReplacingWriter(writer, value.toString()); + NullReplacingWriter nullReplacingWriter = new NullReplacingWriter(writer, toString(value)); setWriter(jsonWriter, nullReplacingWriter); jsonWriter.setSerializeNulls(true); jsonWriter.nullValue(); @@ -83,7 +83,11 @@ public abstract class NullHackJsonLiteralAdapter extends TypeAdapter { } - private Writer getWriter(JsonWriter arg0) { + protected String toString(L value) { + return value.toString(); + } + + protected Writer getWriter(JsonWriter arg0) { try { return Writer.class.cast(outField.get(arg0)); } catch (IllegalAccessException e) { @@ -99,7 +103,7 @@ public abstract class NullHackJsonLiteralAdapter extends TypeAdapter { } } - private final class NullReplacingWriter extends Writer { + public final class NullReplacingWriter extends Writer { private final Writer delegate; private final String nullReplacement; From 1d85435fe8d947585ace80ae25969f70a975124f Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 16 Apr 2012 11:14:13 -0700 Subject: [PATCH 67/69] missing unwrap class arg --- core/src/main/java/org/jclouds/Wrapper.java | 10 ++++++++-- .../main/java/org/jclouds/internal/BaseWrapper.java | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/jclouds/Wrapper.java b/core/src/main/java/org/jclouds/Wrapper.java index e5a740a46c..d80839f894 100644 --- a/core/src/main/java/org/jclouds/Wrapper.java +++ b/core/src/main/java/org/jclouds/Wrapper.java @@ -51,8 +51,14 @@ public interface Wrapper { * if the wrapped context is not assignable from the specified class. * @see #getWrappedType() */ - C unwrap(TypeToken type); - + C unwrap(TypeToken type) throws IllegalArgumentException; + + /** + * shortcut for {@code unwrap(TypeToken.of(clazz))} + * @see #unwrap(TypeToken) + */ + C unwrap(Class clazz) throws IllegalArgumentException; + /** * shortcut for {@code unwrap(getWrappedType())} * diff --git a/core/src/main/java/org/jclouds/internal/BaseWrapper.java b/core/src/main/java/org/jclouds/internal/BaseWrapper.java index b28208c5f9..d93ac915a7 100644 --- a/core/src/main/java/org/jclouds/internal/BaseWrapper.java +++ b/core/src/main/java/org/jclouds/internal/BaseWrapper.java @@ -53,7 +53,12 @@ public abstract class BaseWrapper implements Wrapper { checkArgument(checkNotNull(type, "type").isAssignableFrom(wrappedType), "wrapped type: %s not assignable from %s", wrappedType, type); return (C) wrapped; } - + + @Override + public C unwrap(Class clazz) { + return unwrap (TypeToken.of(checkNotNull(clazz, "clazz"))); + } + @Override public TypeToken getWrappedType() { return wrappedType; From a3161ba7baf6b64d8de2be3a2c8843a933b9b7bb Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 16 Apr 2012 13:42:10 -0700 Subject: [PATCH 68/69] Throw return value instead of returning null Throwables.propagate always throws its argument and throwing its impossible return value better represents our intent than returning null. --- .../SupplyFromProviderURIOrNodesProperty.java | 5 ++--- .../java/org/jclouds/collect/InputSupplierMap.java | 9 +++------ .../main/java/org/jclouds/crypto/CryptoStreams.java | 12 ++++-------- core/src/main/java/org/jclouds/crypto/Pems.java | 3 +-- .../main/java/org/jclouds/http/config/SSLModule.java | 3 +-- core/src/main/java/org/jclouds/io/Payloads.java | 6 ++---- .../org/jclouds/io/internal/BasePayloadSlicer.java | 3 +-- .../java/org/jclouds/io/payloads/FilePayload.java | 5 ++--- .../io/payloads/InputStreamSupplierPayload.java | 3 +-- .../rest/internal/RestAnnotationProcessor.java | 3 +-- .../test/java/org/jclouds/json/BaseParserTest.java | 3 +-- ...GaeHttpCommandExecutorServiceIntegrationTest.java | 3 +-- .../vpdc/binders/BaseBindVMSpecToXmlPayload.java | 3 +-- .../functions/admin/FileDownloadFromURI.java | 3 +-- .../scriptbuilder/statements/login/AdminAccess.java | 3 +-- 15 files changed, 23 insertions(+), 44 deletions(-) diff --git a/apis/byon/src/main/java/org/jclouds/byon/suppliers/SupplyFromProviderURIOrNodesProperty.java b/apis/byon/src/main/java/org/jclouds/byon/suppliers/SupplyFromProviderURIOrNodesProperty.java index 106a7efed8..d6f2df5c0c 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/suppliers/SupplyFromProviderURIOrNodesProperty.java +++ b/apis/byon/src/main/java/org/jclouds/byon/suppliers/SupplyFromProviderURIOrNodesProperty.java @@ -81,9 +81,8 @@ public class SupplyFromProviderURIOrNodesProperty implements Supplier extends AbstractMap { try { return (value != null || toMap.containsKey(key)) ? value.getInput() : null; } catch (IOException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } @@ -80,8 +79,7 @@ public class InputSupplierMap extends AbstractMap { try { return toMap.containsKey(key) ? toMap.remove(key).getInput() : null; } catch (IOException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } @@ -124,8 +122,7 @@ public class InputSupplierMap extends AbstractMap { try { return entry.getValue().getInput(); } catch (IOException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } }; diff --git a/core/src/main/java/org/jclouds/crypto/CryptoStreams.java b/core/src/main/java/org/jclouds/crypto/CryptoStreams.java index 9b650dfc74..59c25a6012 100644 --- a/core/src/main/java/org/jclouds/crypto/CryptoStreams.java +++ b/core/src/main/java/org/jclouds/crypto/CryptoStreams.java @@ -176,8 +176,7 @@ public class CryptoStreams { try { return digest(supplier, MessageDigest.getInstance("SHA1")); } catch (NoSuchAlgorithmException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } @@ -185,8 +184,7 @@ public class CryptoStreams { try { return sha1(ByteStreams.newInputStreamSupplier(in)); } catch (IOException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } @@ -207,8 +205,7 @@ public class CryptoStreams { try { return digest(supplier, MessageDigest.getInstance("MD5")); } catch (NoSuchAlgorithmException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } @@ -216,8 +213,7 @@ public class CryptoStreams { try { return md5(ByteStreams.newInputStreamSupplier(in)); } catch (IOException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } diff --git a/core/src/main/java/org/jclouds/crypto/Pems.java b/core/src/main/java/org/jclouds/crypto/Pems.java index bcde3deb91..ebeadd8304 100644 --- a/core/src/main/java/org/jclouds/crypto/Pems.java +++ b/core/src/main/java/org/jclouds/crypto/Pems.java @@ -169,8 +169,7 @@ public class Pems { try { return privateKeySpec(InputSuppliers.of(pem)); } catch (IOException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } diff --git a/core/src/main/java/org/jclouds/http/config/SSLModule.java b/core/src/main/java/org/jclouds/http/config/SSLModule.java index f530d7571f..df1e5803d2 100644 --- a/core/src/main/java/org/jclouds/http/config/SSLModule.java +++ b/core/src/main/java/org/jclouds/http/config/SSLModule.java @@ -91,8 +91,7 @@ public class SSLModule extends AbstractModule { sc.init(null, new TrustManager[] { trustAllCerts }, new SecureRandom()); return sc; } catch (Exception e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } diff --git a/core/src/main/java/org/jclouds/io/Payloads.java b/core/src/main/java/org/jclouds/io/Payloads.java index d305c15a01..ca2a6ed7b0 100644 --- a/core/src/main/java/org/jclouds/io/Payloads.java +++ b/core/src/main/java/org/jclouds/io/Payloads.java @@ -131,8 +131,7 @@ public class Payloads { try { return calculateMD5(payload, MessageDigest.getInstance("MD5")); } catch (NoSuchAlgorithmException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } @@ -160,8 +159,7 @@ public class Payloads { try { return calculateMD5(payloadEnclosing, MessageDigest.getInstance("MD5")); } catch (NoSuchAlgorithmException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } } diff --git a/core/src/main/java/org/jclouds/io/internal/BasePayloadSlicer.java b/core/src/main/java/org/jclouds/io/internal/BasePayloadSlicer.java index 364938ca1f..df04541ef5 100644 --- a/core/src/main/java/org/jclouds/io/internal/BasePayloadSlicer.java +++ b/core/src/main/java/org/jclouds/io/internal/BasePayloadSlicer.java @@ -76,8 +76,7 @@ public class BasePayloadSlicer implements PayloadSlicer { try { return doSlice(new FileInputStream(content), offset, length); } catch (FileNotFoundException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } diff --git a/core/src/main/java/org/jclouds/io/payloads/FilePayload.java b/core/src/main/java/org/jclouds/io/payloads/FilePayload.java index 65be4ffebd..65e461ae8f 100644 --- a/core/src/main/java/org/jclouds/io/payloads/FilePayload.java +++ b/core/src/main/java/org/jclouds/io/payloads/FilePayload.java @@ -47,9 +47,8 @@ public class FilePayload extends BasePayload { try { return new FileInputStream(content); } catch (FileNotFoundException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/jclouds/io/payloads/InputStreamSupplierPayload.java b/core/src/main/java/org/jclouds/io/payloads/InputStreamSupplierPayload.java index d700e5f734..29ffe285c2 100644 --- a/core/src/main/java/org/jclouds/io/payloads/InputStreamSupplierPayload.java +++ b/core/src/main/java/org/jclouds/io/payloads/InputStreamSupplierPayload.java @@ -48,8 +48,7 @@ public class InputStreamSupplierPayload extends BasePayload { utils.checkRequestHasRequiredProperties(request); return request; } catch (ExecutionException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } diff --git a/core/src/test/java/org/jclouds/json/BaseParserTest.java b/core/src/test/java/org/jclouds/json/BaseParserTest.java index c65e80172c..27d6828b26 100644 --- a/core/src/test/java/org/jclouds/json/BaseParserTest.java +++ b/core/src/test/java/org/jclouds/json/BaseParserTest.java @@ -58,8 +58,7 @@ public abstract class BaseParserTest { return (Function) RestAnnotationProcessor.getTransformerForMethod(getClass() .getMethod("expected"), i); } catch (Exception e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } diff --git a/drivers/gae/src/test/java/org/jclouds/gae/AsyncGaeHttpCommandExecutorServiceIntegrationTest.java b/drivers/gae/src/test/java/org/jclouds/gae/AsyncGaeHttpCommandExecutorServiceIntegrationTest.java index 2971e88031..175863962d 100644 --- a/drivers/gae/src/test/java/org/jclouds/gae/AsyncGaeHttpCommandExecutorServiceIntegrationTest.java +++ b/drivers/gae/src/test/java/org/jclouds/gae/AsyncGaeHttpCommandExecutorServiceIntegrationTest.java @@ -90,8 +90,7 @@ public class AsyncGaeHttpCommandExecutorServiceIntegrationTest extends BaseHttpC try { return Futures.makeListenable(service.fetchAsync(fetch.toURL()), MoreExecutors.sameThreadExecutor()); } catch (MalformedURLException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/binders/BaseBindVMSpecToXmlPayload.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/binders/BaseBindVMSpecToXmlPayload.java index f21e4934a8..5aa9d9d60e 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/binders/BaseBindVMSpecToXmlPayload.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/binders/BaseBindVMSpecToXmlPayload.java @@ -74,8 +74,7 @@ public abstract class BaseBindVMSpecToXmlPayload extends BindToStringPayload outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); return rootBuilder.asString(outputProperties); } catch (Exception e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/admin/FileDownloadFromURI.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/admin/FileDownloadFromURI.java index 013da783dd..2f25c3c35a 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/admin/FileDownloadFromURI.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/admin/FileDownloadFromURI.java @@ -84,8 +84,7 @@ public class FileDownloadFromURI implements Function { return file; } } catch (Exception e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } } diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java index 4c7237e830..273c106c0e 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java @@ -201,8 +201,7 @@ public class AdminAccess implements Statement { grantSudoToAdminUser, authorizeAdminPublicKey, installAdminPrivateKey, resetLoginPassword, cryptFunction); } catch (IOException e) { - Throwables.propagate(e); - return null; + throw Throwables.propagate(e); } } } From 004c160aacc4a762f6e6e3217979e88639855ff1 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 16 Apr 2012 13:47:50 -0700 Subject: [PATCH 69/69] Prefer checkNotNull when appropriate Calling checkNotNull on parameters better captures our intent. --- .../strategy/impl/AdaptingComputeServiceStrategies.java | 8 ++++---- core/src/main/java/org/jclouds/io/Payloads.java | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java index 88a91a9722..2e232caf11 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java @@ -162,10 +162,10 @@ public class AdaptingComputeServiceStrategies implements CreateNodeW */ @Override public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) { - checkState(group != null, "group (that which groups identical nodes together) must be specified"); - checkState(name != null && name.indexOf(group) != -1, "name should have %s encoded into it", group); - checkState(template != null, "template was null"); - checkState(template.getOptions() != null, "template options was null"); + checkNotNull(group, "group (that which groups identical nodes together) must be specified"); + checkNotNull(name, "name should have %s encoded into it", group); + checkNotNull(template, "template was null"); + checkNotNull(template.getOptions(), "template options was null"); NodeAndInitialCredentials from = client.createNodeWithGroupEncodedIntoName(group, name, template); LoginCredentials fromNode = from.getCredentials(); diff --git a/core/src/main/java/org/jclouds/io/Payloads.java b/core/src/main/java/org/jclouds/io/Payloads.java index ca2a6ed7b0..0fe038fb74 100644 --- a/core/src/main/java/org/jclouds/io/Payloads.java +++ b/core/src/main/java/org/jclouds/io/Payloads.java @@ -19,7 +19,6 @@ package org.jclouds.io; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; import static com.google.common.io.ByteStreams.toByteArray; import java.io.File; @@ -141,7 +140,7 @@ public class Payloads { * @see #calculateMD5(Payload, MessageDigest) */ public static T calculateMD5(T payloadEnclosing, MessageDigest md5) throws IOException { - checkState(payloadEnclosing != null, "payloadEnclosing"); + checkNotNull(payloadEnclosing, "payloadEnclosing"); Payload newPayload = calculateMD5(payloadEnclosing.getPayload(), md5); if (newPayload != payloadEnclosing.getPayload()) payloadEnclosing.setPayload(newPayload);