This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch camel-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 61e909de1243ec3c0527e0d141408634a147497e Author: Jiri Ondrusek <ondrusek.j...@gmail.com> AuthorDate: Mon Jan 6 10:28:40 2025 +0100 Fixed smb + enabled CamelAutowiredDisabledTest --- docs/modules/ROOT/examples/components/smb.yml | 2 +- .../deployment/main/CamelAutowiredDisabledTest.java | 2 -- .../camel/quarkus/component/smb/it/SmbResource.java | 2 +- .../camel/quarkus/component/smb/it/SmbRoute.java | 19 +++++++++++++------ .../camel/quarkus/component/smb/it/SmbTest.java | 8 ++------ 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/modules/ROOT/examples/components/smb.yml b/docs/modules/ROOT/examples/components/smb.yml index b8e248a80c..3b9548dd39 100644 --- a/docs/modules/ROOT/examples/components/smb.yml +++ b/docs/modules/ROOT/examples/components/smb.yml @@ -9,5 +9,5 @@ cqJvmSince: 3.7.0 cqNativeSince: 3.7.0 cqCamelPartName: smb cqCamelPartTitle: SMB -cqCamelPartDescription: Receive files from SMB (Server Message Block) shares. +cqCamelPartDescription: Read and write files to Server Message Block (SMB) file shares. cqExtensionPageTitle: SMB diff --git a/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/main/CamelAutowiredDisabledTest.java b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/main/CamelAutowiredDisabledTest.java index b03472f39d..a36ed57d10 100644 --- a/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/main/CamelAutowiredDisabledTest.java +++ b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/main/CamelAutowiredDisabledTest.java @@ -34,13 +34,11 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.Asset; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import static org.assertj.core.api.Assertions.assertThat; -@Disabled //https://github.com/apache/camel-quarkus/issues/6884 public class CamelAutowiredDisabledTest { @RegisterExtension static final QuarkusUnitTest CONFIG = new QuarkusUnitTest() diff --git a/integration-tests/smb/src/main/java/org/apache/camel/quarkus/component/smb/it/SmbResource.java b/integration-tests/smb/src/main/java/org/apache/camel/quarkus/component/smb/it/SmbResource.java index 17794d116f..5eca5899c4 100644 --- a/integration-tests/smb/src/main/java/org/apache/camel/quarkus/component/smb/it/SmbResource.java +++ b/integration-tests/smb/src/main/java/org/apache/camel/quarkus/component/smb/it/SmbResource.java @@ -89,7 +89,7 @@ public class SmbResource { String uri = String.format("smb:%s:%s/%s?username=%s&password=%s&searchPattern=%s&path=/", host, port, share, username, password, fileName); var shareFile = consumer.receiveBody(uri, SmbFile.class); - return new String(shareFile.getInputStream().readAllBytes(), "UTF-8"); + return new String((byte[]) shareFile.getBody(), "UTF-8"); } @POST diff --git a/integration-tests/smb/src/main/java/org/apache/camel/quarkus/component/smb/it/SmbRoute.java b/integration-tests/smb/src/main/java/org/apache/camel/quarkus/component/smb/it/SmbRoute.java index e6a566520a..ce7d67d09b 100644 --- a/integration-tests/smb/src/main/java/org/apache/camel/quarkus/component/smb/it/SmbRoute.java +++ b/integration-tests/smb/src/main/java/org/apache/camel/quarkus/component/smb/it/SmbRoute.java @@ -28,6 +28,8 @@ import jakarta.inject.Singleton; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.smb.SmbConstants; import org.apache.camel.component.smb.SmbFile; +import org.apache.camel.spi.IdempotentRepository; +import org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository; import org.eclipse.microprofile.config.inject.ConfigProperty; @ApplicationScoped @@ -54,19 +56,18 @@ public class SmbRoute extends RouteBuilder { @Override public void configure() throws Exception { - from("smb:{{smb.host}}:{{smb.port}}/{{smb.share}}?username={{smb.username}}&password={{smb.password}}&path=/&repeatCount=1&searchPattern=*.txt") + from("smb:{{smb.host}}:{{smb.port}}/{{smb.share}}?username={{smb.username}}&password={{smb.password}}&path=/&repeatCount=1&searchPattern=*.txt&idempotent=true&idempotentRepository=#myRepo") .to("mock:result"); from("direct:send") .toF("smb:%s:%s/%s?username=%s&password=%s&path=/", host, port, share, username, password); - from("smb:{{smb.host}}:{{smb.port}}/{{smb.share}}?username={{smb.username}}&password={{smb.password}}&path=/&searchPattern=*.tx1") + from("smb:{{smb.host}}:{{smb.port}}/{{smb.share}}?username={{smb.username}}&password={{smb.password}}&path=/&searchPattern=*.tx1&idempotent=true&idempotentRepository=#myRepo") .process(e -> { receivedContents.add(Map.of( - "path", e.getIn().getBody(SmbFile.class).getPath(), - "content", new String(e.getIn().getBody(SmbFile.class).getInputStream().readAllBytes(), "UTF-8"), - SmbConstants.SMB_FILE_PATH, e.getIn().getHeader(SmbConstants.SMB_FILE_PATH, String.class), - SmbConstants.SMB_UNC_PATH, e.getIn().getHeader(SmbConstants.SMB_UNC_PATH, String.class))); + "path", e.getIn().getBody(SmbFile.class).getAbsoluteFilePath(), + "content", new String((byte[]) e.getIn().getBody(SmbFile.class).getBody(), "UTF-8"), + SmbConstants.FILE_PATH, e.getIn().getHeader(SmbConstants.FILE_PATH, String.class))); }); } @@ -80,4 +81,10 @@ public class SmbRoute extends RouteBuilder { } } + @Produces + @Named("myRepo") + public IdempotentRepository myRepo() { + return MemoryIdempotentRepository.memoryIdempotentRepository(2000); + } + } diff --git a/integration-tests/smb/src/test/java/org/apache/camel/quarkus/component/smb/it/SmbTest.java b/integration-tests/smb/src/test/java/org/apache/camel/quarkus/component/smb/it/SmbTest.java index 46dcad6604..d11856e8f0 100644 --- a/integration-tests/smb/src/test/java/org/apache/camel/quarkus/component/smb/it/SmbTest.java +++ b/integration-tests/smb/src/test/java/org/apache/camel/quarkus/component/smb/it/SmbTest.java @@ -24,7 +24,6 @@ import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import org.apache.camel.component.smb.SmbConstants; import org.apache.camel.quarkus.test.DisabledIfFipsMode; -import org.eclipse.microprofile.config.ConfigProvider; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import org.testcontainers.shaded.org.awaitility.Awaitility; @@ -126,13 +125,10 @@ public class SmbTest { Set<String> set = Set.of(body.split(",")); - String host = ConfigProvider.getConfig().getValue("smb.host", String.class); - assertThat(set) - .contains("path=msg1.tx1") + .contains("path=/msg1.tx1") .contains("content=Hello1") - .contains(SmbConstants.SMB_FILE_PATH + "=msg1.tx1") - .contains(SmbConstants.SMB_UNC_PATH + "=\\\\%s\\data-rw\\msg1.tx1".formatted(host)); + .contains(SmbConstants.FILE_PATH + "=/msg1.tx1"); }); }