Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/camel-aws/camel-aws2-ses/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@
<artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ private software.amazon.awssdk.services.ses.model.Message createMessage(Exchange
= software.amazon.awssdk.services.ses.model.Message.builder();
String content;
if (exchange.getIn().getBody() instanceof RawMessage raw) {
content = raw.data().toString();
// SdkBytes.toString() is a debug descriptor (SdkBytes(bytes=0x...)), not the payload
content = raw.data().asUtf8String();
} else {
content = exchange.getIn().getBody(String.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,30 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.services.ses.model.MessageTag;
import software.amazon.awssdk.services.ses.model.RawMessage;
import software.amazon.awssdk.services.ses.model.SendEmailRequest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;

public class SesComponentTest extends CamelTestSupport {

@BindToRegistry("amazonSESClient")
private AmazonSESClientMock sesClient = new AmazonSESClientMock();

@Test
void rawMessageBodyIsSentAsItsContentNotTheSdkBytesDescriptor() {
String mime = "From: from@example.com\r\nSubject: Subject\r\n\r\nThis is my message text.";
template.send("direct:start", exchange -> exchange.getIn().setBody(
RawMessage.builder().data(SdkBytes.fromUtf8String(mime)).build()));

// SdkBytes.toString() would yield "SdkBytes(bytes=0x...)" rather than the message content
String sent = sesClient.getSendEmailRequest().message().body().text().data();
assertThat(sent).isEqualTo(mime);
}

@Test
public void sendInOnlyMessageUsingUrlOptions() {
Exchange exchange = template.send("direct:start", new Processor() {
Expand Down
Loading