Search in sources :

Example 11 with AmazonSNS

use of com.amazonaws.services.sns.AmazonSNS in project beam by apache.

the class SnsIOTest method getAmazonSnsMockErrors.

private static AmazonSNS getAmazonSnsMockErrors() {
    final AmazonSNS amazonSNS = Mockito.mock(AmazonSNS.class);
    configureAmazonSnsMock(amazonSNS);
    Mockito.when(amazonSNS.publish(Mockito.any())).thenThrow(new InternalErrorException("Service unavailable"));
    return amazonSNS;
}
Also used : InternalErrorException(com.amazonaws.services.sns.model.InternalErrorException) AmazonSNS(com.amazonaws.services.sns.AmazonSNS)

Example 12 with AmazonSNS

use of com.amazonaws.services.sns.AmazonSNS in project aws-xray-sdk-java by aws.

the class TracingHandlerTest method testSNSPublish.

@Test
void testSNSPublish() {
    // Setup test
    // reference : https://docs.aws.amazon.com/sns/latest/api/API_Publish.html
    final String publishResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<PublishResponse xmlns=\"http://sns.amazonaws.com/doc/2010-03-31/\">" + "<PublishResult><MessageId>94f20ce6-13c5-43a0-9a9e-ca52d816e90b</MessageId>" + "</PublishResult>" + "</PublishResponse>";
    final String topicArn = "testTopicArn";
    AmazonSNS sns = AmazonSNSClientBuilder.standard().withRequestHandlers(new TracingHandler()).withRegion(Regions.US_EAST_1).withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))).build();
    mockHttpClient(sns, publishResponse);
    // Test logic
    Segment segment = AWSXRay.beginSegment("test");
    sns.publish(new PublishRequest(topicArn, "testMessage"));
    Assertions.assertEquals(1, segment.getSubsegments().size());
    Assertions.assertEquals("Publish", segment.getSubsegments().get(0).getAws().get("operation"));
    Assertions.assertEquals(topicArn, segment.getSubsegments().get(0).getAws().get("topic_arn"));
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) PublishRequest(com.amazonaws.services.sns.model.PublishRequest) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) Segment(com.amazonaws.xray.entities.Segment) AmazonSNS(com.amazonaws.services.sns.AmazonSNS) Test(org.junit.jupiter.api.Test)

Example 13 with AmazonSNS

use of com.amazonaws.services.sns.AmazonSNS in project tutorials by eugenp.

the class SpringCloudSNSIntegrationTest method setupAwsResources.

@BeforeClass
public static void setupAwsResources() {
    topicName = UUID.randomUUID().toString();
    AmazonSNS amazonSNS = SpringCloudAwsTestUtil.amazonSNS();
    CreateTopicResult result = amazonSNS.createTopic(topicName);
    topicArn = result.getTopicArn();
}
Also used : CreateTopicResult(com.amazonaws.services.sns.model.CreateTopicResult) AmazonSNS(com.amazonaws.services.sns.AmazonSNS) BeforeClass(org.junit.BeforeClass)

Aggregations

AmazonSNS (com.amazonaws.services.sns.AmazonSNS)13 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)4 PublishRequest (com.amazonaws.services.sns.model.PublishRequest)4 PublishResult (com.amazonaws.services.sns.model.PublishResult)4 Test (org.junit.Test)4 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)3 TupleTag (org.apache.beam.sdk.values.TupleTag)3 AWSCredentials (com.amazonaws.auth.AWSCredentials)2 PCollectionTuple (org.apache.beam.sdk.values.PCollectionTuple)2 AmazonSQSExtendedClient (com.amazon.sqs.javamessaging.AmazonSQSExtendedClient)1 ExtendedClientConfiguration (com.amazon.sqs.javamessaging.ExtendedClientConfiguration)1 ClientConfiguration (com.amazonaws.ClientConfiguration)1 SdkHttpMetadata (com.amazonaws.http.SdkHttpMetadata)1 Regions (com.amazonaws.regions.Regions)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 AmazonSNSClient (com.amazonaws.services.sns.AmazonSNSClient)1 CreateTopicRequest (com.amazonaws.services.sns.model.CreateTopicRequest)1 CreateTopicResult (com.amazonaws.services.sns.model.CreateTopicResult)1 InternalErrorException (com.amazonaws.services.sns.model.InternalErrorException)1 SetSubscriptionAttributesRequest (com.amazonaws.services.sns.model.SetSubscriptionAttributesRequest)1