This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-24189 in repository https://gitbox.apache.org/repos/asf/camel.git
commit f9fbd2ea0d79bf6dcb66e7bcb846089602434a79 Author: Claus Ibsen <[email protected]> AuthorDate: Thu Jul 16 22:41:08 2026 +0200 CAMEL-24189: camel-smb - Fix SmbStreamDownloadIT reading stream after close Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../camel/component/smb/SmbStreamDownloadIT.java | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbStreamDownloadIT.java b/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbStreamDownloadIT.java index 1bdae8487152..79ced2ef9638 100644 --- a/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbStreamDownloadIT.java +++ b/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbStreamDownloadIT.java @@ -22,10 +22,10 @@ import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.util.IOHelper; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; public class SmbStreamDownloadIT extends SmbServerTestSupport { @@ -43,19 +43,13 @@ public class SmbStreamDownloadIT extends SmbServerTestSupport { @Test public void testStreamDownload() throws Exception { MockEndpoint mock = getMockEndpoint("mock:received_send"); - mock.message(0).body().isInstanceOf(SmbFile.class); - mock.message(0).predicate(e -> { - Object b = e.getMessage().getBody(SmbFile.class).getBody(); - return b instanceof InputStream; - }); mock.expectedMessageCount(1); mock.assertIsSatisfied(); - InputStream is = mock.getExchanges().get(0).getIn().getBody(InputStream.class); - assertNotNull(is); - String text = IOHelper.loadText(is); - Assertions.assertEquals("World\n", text); + Exchange exchange = mock.getExchanges().get(0); + String text = exchange.getIn().getHeader("StreamContent", String.class); + assertEquals("World\n", text); } private void prepareSmbServer() { @@ -67,6 +61,14 @@ public class SmbStreamDownloadIT extends SmbServerTestSupport { return new RouteBuilder() { public void configure() { from(getSmbUrl()).streamCache("false") + .process(e -> { + Object body = e.getMessage().getBody(SmbFile.class); + assertInstanceOf(SmbFile.class, body); + Object inner = ((SmbFile) body).getBody(); + assertInstanceOf(InputStream.class, inner); + String text = IOHelper.loadText((InputStream) inner); + e.getMessage().setHeader("StreamContent", text); + }) .to("mock:received_send"); } };
