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;
}
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"));
}
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();
}
Aggregations