From fe16fc533d3eab78fccc8149625ac06b723f5684 Mon Sep 17 00:00:00 2001 From: Mark Dietz Date: Fri, 24 Jan 2014 13:45:33 -0600 Subject: [PATCH 1/2] Update to aws-java-sdk 1.6.12 --- pom.xml | 6 +- readme.md | 2 + .../autoscaling/AmazonAutoScalingStub.java | 19 +++ .../AmazonElasticLoadBalancingStub.java | 15 +++ .../AmazonElasticMapReduceStub.java | 20 +++ .../AmazonIdentityManagementStub.java | 42 ++++++ .../awsstubs/services/sns/AmazonSNSStub.java | 120 ++++++++++++++++++ 7 files changed, 221 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 5d16f1d..9e48db8 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.bizo aws-java-sdk-stubs - 1.2.0 + 1.3.0 jar aws-java-sdk-stubs stubs for the aws-java-sdk services @@ -45,7 +45,7 @@ com.amazonaws aws-java-sdk - 1.6.4 + 1.6.12 junit @@ -93,4 +93,4 @@ - \ No newline at end of file + diff --git a/readme.md b/readme.md index f0d0dd2..9f54d62 100644 --- a/readme.md +++ b/readme.md @@ -18,5 +18,7 @@ This project provides stub classes for the [aws-sdk-java](https://github.com/aws `mvn clean package` to build the jar +Make sure M2_REPO is defined in java build path classpath variables + ## License [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.html) \ No newline at end of file diff --git a/src/main/java/com/bizo/awsstubs/services/autoscaling/AmazonAutoScalingStub.java b/src/main/java/com/bizo/awsstubs/services/autoscaling/AmazonAutoScalingStub.java index 766dfb6..40c0471 100644 --- a/src/main/java/com/bizo/awsstubs/services/autoscaling/AmazonAutoScalingStub.java +++ b/src/main/java/com/bizo/awsstubs/services/autoscaling/AmazonAutoScalingStub.java @@ -1,5 +1,7 @@ package com.bizo.awsstubs.services.autoscaling; +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; import com.amazonaws.AmazonWebServiceRequest; import com.amazonaws.ResponseMetadata; import com.amazonaws.regions.Region; @@ -266,4 +268,21 @@ public TerminateInstanceInAutoScalingGroupResult terminateInstanceInAutoScalingG public ResponseMetadata getCachedResponseMetadata(final AmazonWebServiceRequest arg0) { throw new UnsupportedOperationException(); } + + @Override + public void attachInstances(final AttachInstancesRequest arg0) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public DescribeAccountLimitsResult describeAccountLimits() throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public DescribeAccountLimitsResult describeAccountLimits(final DescribeAccountLimitsRequest arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } } \ No newline at end of file diff --git a/src/main/java/com/bizo/awsstubs/services/elasticloadbalancing/AmazonElasticLoadBalancingStub.java b/src/main/java/com/bizo/awsstubs/services/elasticloadbalancing/AmazonElasticLoadBalancingStub.java index f7c34c5..562cf1f 100644 --- a/src/main/java/com/bizo/awsstubs/services/elasticloadbalancing/AmazonElasticLoadBalancingStub.java +++ b/src/main/java/com/bizo/awsstubs/services/elasticloadbalancing/AmazonElasticLoadBalancingStub.java @@ -1,5 +1,7 @@ package com.bizo.awsstubs.services.elasticloadbalancing; +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; import com.amazonaws.AmazonWebServiceRequest; import com.amazonaws.ResponseMetadata; import com.amazonaws.regions.Region; @@ -168,4 +170,17 @@ public ResponseMetadata getCachedResponseMetadata(final AmazonWebServiceRequest throw new UnsupportedOperationException(); } + @Override + public DescribeLoadBalancerAttributesResult describeLoadBalancerAttributes( + final DescribeLoadBalancerAttributesRequest arg0) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ModifyLoadBalancerAttributesResult modifyLoadBalancerAttributes(final ModifyLoadBalancerAttributesRequest arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + } \ No newline at end of file diff --git a/src/main/java/com/bizo/awsstubs/services/elasticmapreduce/AmazonElasticMapReduceStub.java b/src/main/java/com/bizo/awsstubs/services/elasticmapreduce/AmazonElasticMapReduceStub.java index 29a2206..76c2e00 100644 --- a/src/main/java/com/bizo/awsstubs/services/elasticmapreduce/AmazonElasticMapReduceStub.java +++ b/src/main/java/com/bizo/awsstubs/services/elasticmapreduce/AmazonElasticMapReduceStub.java @@ -162,4 +162,24 @@ public ListInstancesResult listInstances() throws AmazonServiceException, Amazon public DescribeClusterResult describeCluster() throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException(); } + + @Override + public AddTagsResult addTags() throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public AddTagsResult addTags(final AddTagsRequest arg0) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public RemoveTagsResult removeTags() throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public RemoveTagsResult removeTags(final RemoveTagsRequest arg0) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } } \ No newline at end of file diff --git a/src/main/java/com/bizo/awsstubs/services/identitymanagement/AmazonIdentityManagementStub.java b/src/main/java/com/bizo/awsstubs/services/identitymanagement/AmazonIdentityManagementStub.java index f4cbacb..cec9955 100644 --- a/src/main/java/com/bizo/awsstubs/services/identitymanagement/AmazonIdentityManagementStub.java +++ b/src/main/java/com/bizo/awsstubs/services/identitymanagement/AmazonIdentityManagementStub.java @@ -1,5 +1,7 @@ package com.bizo.awsstubs.services.identitymanagement; +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; import com.amazonaws.AmazonWebServiceRequest; import com.amazonaws.ResponseMetadata; import com.amazonaws.regions.Region; @@ -447,4 +449,44 @@ public ResponseMetadata getCachedResponseMetadata(final AmazonWebServiceRequest throw new UnsupportedOperationException(); } + @Override + public CreateSAMLProviderResult createSAMLProvider(final CreateSAMLProviderRequest arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void deleteSAMLProvider(final DeleteSAMLProviderRequest arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public GetSAMLProviderResult getSAMLProvider(final GetSAMLProviderRequest arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListSAMLProvidersResult listSAMLProviders() throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListSAMLProvidersResult listSAMLProviders(final ListSAMLProvidersRequest arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public UpdateSAMLProviderResult updateSAMLProvider(final UpdateSAMLProviderRequest arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + } \ No newline at end of file diff --git a/src/main/java/com/bizo/awsstubs/services/sns/AmazonSNSStub.java b/src/main/java/com/bizo/awsstubs/services/sns/AmazonSNSStub.java index 2814314..cab40a5 100644 --- a/src/main/java/com/bizo/awsstubs/services/sns/AmazonSNSStub.java +++ b/src/main/java/com/bizo/awsstubs/services/sns/AmazonSNSStub.java @@ -1,5 +1,7 @@ package com.bizo.awsstubs.services.sns; +import java.util.List; + import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonServiceException; import com.amazonaws.AmazonWebServiceRequest; @@ -196,4 +198,122 @@ public ListPlatformApplicationsResult listPlatformApplications() throws AmazonSe throw new UnsupportedOperationException(); } + @Override + public void addPermission(final String arg0, final String arg1, final List arg2, final List arg3) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ConfirmSubscriptionResult confirmSubscription(final String arg0, final String arg1) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ConfirmSubscriptionResult confirmSubscription(final String arg0, final String arg1, final String arg2) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public CreateTopicResult createTopic(final String arg0) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void deleteTopic(final String arg0) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public GetSubscriptionAttributesResult getSubscriptionAttributes(final String arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public GetTopicAttributesResult getTopicAttributes(final String arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListSubscriptionsResult listSubscriptions(final String arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListSubscriptionsByTopicResult listSubscriptionsByTopic(final String arg0) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListSubscriptionsByTopicResult listSubscriptionsByTopic(final String arg0, final String arg1) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListTopicsResult listTopics(final String arg0) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public PublishResult publish(final String arg0, final String arg1) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public PublishResult publish(final String arg0, final String arg1, final String arg2) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void removePermission(final String arg0, final String arg1) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void setSubscriptionAttributes(final String arg0, final String arg1, final String arg2) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void setTopicAttributes(final String arg0, final String arg1, final String arg2) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public SubscribeResult subscribe(final String arg0, final String arg1, final String arg2) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void unsubscribe(final String arg0) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + } \ No newline at end of file From 4ef0ebc6428430b9644cc629557a990c333ac00f Mon Sep 17 00:00:00 2001 From: Mark Dietz Date: Fri, 24 Jan 2014 13:51:04 -0600 Subject: [PATCH 2/2] add stubs for kinesis client --- .../kinesis/AmazonKinesisClientStub.java | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 src/main/java/com/bizo/awsstubs/services/kinesis/AmazonKinesisClientStub.java diff --git a/src/main/java/com/bizo/awsstubs/services/kinesis/AmazonKinesisClientStub.java b/src/main/java/com/bizo/awsstubs/services/kinesis/AmazonKinesisClientStub.java new file mode 100644 index 0000000..01276f2 --- /dev/null +++ b/src/main/java/com/bizo/awsstubs/services/kinesis/AmazonKinesisClientStub.java @@ -0,0 +1,231 @@ +package com.bizo.awsstubs.services.kinesis; + +import java.nio.ByteBuffer; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.atomic.AtomicInteger; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; +import com.amazonaws.AmazonWebServiceRequest; +import com.amazonaws.ResponseMetadata; +import com.amazonaws.regions.Region; +import com.amazonaws.services.kinesis.AmazonKinesis; +import com.amazonaws.services.kinesis.model.*; + +/** + * This should be kept threadsafe so that off thread writes can be tested + */ +public class AmazonKinesisClientStub implements AmazonKinesis { + + public ConcurrentHashMap streams = new ConcurrentHashMap(); + + public void reset() { + streams.clear(); + } + + @Override + public void createStream(final CreateStreamRequest createStreamRequest) + throws AmazonServiceException, + AmazonClientException { + streams.putIfAbsent(createStreamRequest.getStreamName(), new Stream()); + } + + @Override + public void createStream(final String streamName, final Integer shardCount) + throws AmazonServiceException, + AmazonClientException { + createStream(new CreateStreamRequest().withStreamName(streamName).withShardCount(shardCount)); + } + + @Override + public void deleteStream(final DeleteStreamRequest deleteStreamRequest) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void deleteStream(final String streamName) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public DescribeStreamResult describeStream(final DescribeStreamRequest describeStreamRequest) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public DescribeStreamResult describeStream(final String streamName) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public DescribeStreamResult describeStream(final String streamName, final String exclusiveStartShardId) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public DescribeStreamResult describeStream( + final String streamName, + final Integer limit, + final String exclusiveStartShardId) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ResponseMetadata getCachedResponseMetadata(final AmazonWebServiceRequest request) { + throw new UnsupportedOperationException(); + } + + @Override + public GetRecordsResult getRecords(final GetRecordsRequest request) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public GetShardIteratorResult getShardIterator(final GetShardIteratorRequest getShardIteratorRequest) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public GetShardIteratorResult getShardIterator( + final String streamName, + final String shardId, + final String shardIteratorType) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public GetShardIteratorResult getShardIterator( + final String streamName, + final String shardId, + final String shardIteratorType, + final String startingSequenceNumber) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListStreamsResult listStreams() throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListStreamsResult listStreams(final ListStreamsRequest listStreamsRequest) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListStreamsResult listStreams(final String exclusiveStartStreamName) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public ListStreamsResult listStreams(final Integer limit, final String exclusiveStartStreamName) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void mergeShards(final MergeShardsRequest mergeShardsRequest) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void mergeShards(final String streamName, final String shardToMerge, final String adjacentShardToMerge) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public PutRecordResult putRecord(final PutRecordRequest putRecordRequest) + throws AmazonServiceException, + AmazonClientException { + if (putRecordRequest.getData().array().length > 50 * 1024) { + throw new InvalidArgumentException("Payload exceeds 50 KB"); + } + + final Stream stream = streams.get(putRecordRequest.getStreamName()); + final String nextSequenceNumber = + String.valueOf(streams.get(putRecordRequest.getStreamName()).sequenceNumber.incrementAndGet()); + + stream.records.add(new Record() + .withData(putRecordRequest.getData()) + .withPartitionKey(putRecordRequest.getPartitionKey()) + .withSequenceNumber(nextSequenceNumber)); + return new PutRecordResult().withSequenceNumber(nextSequenceNumber).withShardId("hard-coded-only-stub-shard"); + } + + @Override + public PutRecordResult putRecord(final String streamName, final ByteBuffer data, final String partitionKey) + throws AmazonServiceException, + AmazonClientException { + return putRecord(new PutRecordRequest().withStreamName(streamName).withData(data).withPartitionKey(partitionKey)); + } + + @Override + public PutRecordResult putRecord( + final String streamName, + final ByteBuffer data, + final String partitionKey, + final String exclusiveMinimumSequenceNumber) throws AmazonServiceException, AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void setEndpoint(final String endpoint) throws IllegalArgumentException { + throw new UnsupportedOperationException(); + } + + @Override + public void setRegion(final Region region) throws IllegalArgumentException { + throw new UnsupportedOperationException(); + } + + @Override + public void shutdown() { + throw new UnsupportedOperationException(); + } + + @Override + public void splitShard(final SplitShardRequest splitShardRequest) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + @Override + public void splitShard(final String streamName, final String shardToSplit, final String newStartingHashKey) + throws AmazonServiceException, + AmazonClientException { + throw new UnsupportedOperationException(); + } + + public static class Stream { + public AtomicInteger sequenceNumber = new AtomicInteger(0); + public BlockingQueue records = new LinkedBlockingQueue(); + } + + public BlockingQueue getRecordsForStream(final String streamName) { + return streams.get(streamName).records; + } +}