I want to test a live component which as a result of execution sends a message in a SNS topic.
Is there a way how to create an "inline" client subscription with Java SDK?
Something line this (pseudocode):
@Test
public void testProcessingResult() throws Exception {
final Box<Object> resultBox = new Box();
snsClient.subscribe(new SubscribeRequest(topicArn,
msg -> resultBox.setValue(extractResult(msg))
));
...
httpClient.post(endpoint, params); // send the request
Thread.sleep(2000); // wait for eventual processing
assertEquals(expected, resultBox.getValue());
}
One way, how to achieve this, could be to create an Amazon SQS queue and register the test client to it, then to get the result via polling.
Is there an easier way?