Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I mock an Amazon SQS endpoint when testing a Camel application

I am writing a Spring Boot application that uses Camel to listen to an SQS queue. Route definition:

from("aws-sqs://my-s3-notification-queue" +
    "?amazonSQSClient=#sqsClient" +
    "&deleteAfterRead=false")
    .unmarshal().json(JsonLibrary.Jackson, S3EventNotification.class)
    .bean(s3NotificationHandler);

sqsClient is defined as a @Bean in a @Configuration file.

When running tests, I would like to mock the SQS endpoint so that I don't actually connect to AWS. How do I do this? I've tried writing my tests like

@RunWith(CamelSpringBootRunner.class)
@SpringBootTest
@MockEndpoints
public class ApplicationTests {

    @Test
    public void contextLoads() {
    }

}

This should work if I'm reading the docs correctly, but it still tries to connect to AWS. What am I missing?

like image 630
Imre Kerr Avatar asked Oct 17 '25 18:10

Imre Kerr


1 Answers

You can use Localstack using this you can mock multiple AWS service from your local system, without connecting AWS.

like image 117
sanjay mishra Avatar answered Oct 19 '25 09:10

sanjay mishra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!