This is an automated email from the ASF dual-hosted git repository. oalsafi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 8e60b07 CAMEL-15477: Integration Tests in camel-minio polish (#4141) 8e60b07 is described below commit 8e60b07cc5de3659c3b0af2c0fbdc20503004ca1 Author: Omar Al-Safi <omars...@gmail.com> AuthorDate: Fri Aug 28 11:19:33 2020 +0200 CAMEL-15477: Integration Tests in camel-minio polish (#4141) --- ...ntegrationTest.java => MinioComponentTest.java} | 4 +- ...IntegrationTest.java => MinioConsumerTest.java} | 4 +- ...Test.java => MinioCopyObjectOperationTest.java} | 6 +- ...st.java => MinioDeleteBucketOperationTest.java} | 4 +- ...est.java => MinioListObjectsOperationTest.java} | 6 +- ...est.java => MinioObjectRangeOperationTest.java} | 8 +- .../MinioTestContainerSupport.java | 2 +- .../remoteTests/MinioComponentIntegrationTest.java | 123 --------------- .../remoteTests/MinioConsumerIntegrationTest.java | 87 ----------- ...yObjectCustomerKeyOperationIntegrationTest.java | 171 --------------------- .../MinioCopyObjectOperationIntegrationTest.java | 85 ---------- .../MinioDeleteBucketOperationIntegrationTest.java | 81 ---------- .../MinioListObjectsOperationIntegrationTest.java | 120 --------------- .../MinioObjectRangeOperationIntegrationTest.java | 102 ------------ .../src/test/resources/minio_key.properties | 5 +- 15 files changed, 19 insertions(+), 789 deletions(-) diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioComponentIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioComponentTest.java similarity index 97% rename from components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioComponentIntegrationTest.java rename to components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioComponentTest.java index 88da95c..61832c2 100644 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioComponentIntegrationTest.java +++ b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioComponentTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.minio.integration.localTests; +package org.apache.camel.component.minio.integration; import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; @@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -class MinioComponentIntegrationTest extends MinioTestContainerSupport { +class MinioComponentTest extends MinioTestContainerSupport { @EndpointInject("direct:start") private ProducerTemplate template; diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioConsumerIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioConsumerTest.java similarity index 95% rename from components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioConsumerIntegrationTest.java rename to components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioConsumerTest.java index d0b74fd..a89d4c5 100644 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioConsumerIntegrationTest.java +++ b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioConsumerTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.minio.integration.localTests; +package org.apache.camel.component.minio.integration; import io.minio.MinioClient; import org.apache.camel.BindToRegistry; @@ -25,7 +25,7 @@ import org.apache.camel.component.minio.MinioConstants; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; -class MinioConsumerIntegrationTest extends MinioTestContainerSupport { +class MinioConsumerTest extends MinioTestContainerSupport { @BindToRegistry("minioClient") MinioClient client = MinioClient.builder() diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioCopyObjectOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioCopyObjectOperationTest.java similarity index 93% rename from components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioCopyObjectOperationIntegrationTest.java rename to components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioCopyObjectOperationTest.java index ee4dc67..f06ee3c 100644 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioCopyObjectOperationIntegrationTest.java +++ b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioCopyObjectOperationTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.minio.integration.localTests; +package org.apache.camel.component.minio.integration; import java.io.IOException; @@ -28,7 +28,7 @@ import org.apache.camel.component.minio.MinioOperations; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; -class MinioCopyObjectOperationIntegrationTest extends MinioTestContainerSupport { +class MinioCopyObjectOperationTest extends MinioTestContainerSupport { @BindToRegistry("minioClient") MinioClient client = MinioClient.builder() @@ -42,7 +42,7 @@ class MinioCopyObjectOperationIntegrationTest extends MinioTestContainerSupport @EndpointInject("mock:result") private MockEndpoint result; - MinioCopyObjectOperationIntegrationTest() throws IOException { + MinioCopyObjectOperationTest() throws IOException { } @Test diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioDeleteBucketOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioDeleteBucketOperationTest.java similarity index 94% rename from components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioDeleteBucketOperationIntegrationTest.java rename to components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioDeleteBucketOperationTest.java index fc2969b..9ac8002 100644 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioDeleteBucketOperationIntegrationTest.java +++ b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioDeleteBucketOperationTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.minio.integration.localTests; +package org.apache.camel.component.minio.integration; import io.minio.MinioClient; import org.apache.camel.BindToRegistry; @@ -26,7 +26,7 @@ import org.apache.camel.component.minio.MinioOperations; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; -class MinioDeleteBucketOperationIntegrationTest extends MinioTestContainerSupport { +class MinioDeleteBucketOperationTest extends MinioTestContainerSupport { @BindToRegistry("minioClient") MinioClient client = MinioClient.builder() diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioListObjectsOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioListObjectsOperationTest.java similarity index 95% rename from components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioListObjectsOperationIntegrationTest.java rename to components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioListObjectsOperationTest.java index d63ae1e..64deecd 100644 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioListObjectsOperationIntegrationTest.java +++ b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioListObjectsOperationTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.minio.integration.localTests; +package org.apache.camel.component.minio.integration; import java.io.IOException; import java.util.Iterator; @@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -class MinioListObjectsOperationIntegrationTest extends MinioTestContainerSupport { +class MinioListObjectsOperationTest extends MinioTestContainerSupport { @BindToRegistry("minioClient") MinioClient client = MinioClient.builder() @@ -50,7 +50,7 @@ class MinioListObjectsOperationIntegrationTest extends MinioTestContainerSupport @EndpointInject("mock:result") private MockEndpoint result; - MinioListObjectsOperationIntegrationTest() throws IOException { + MinioListObjectsOperationTest() throws IOException { } @SuppressWarnings("unchecked") diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioObjectRangeOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioObjectRangeOperationTest.java similarity index 93% rename from components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioObjectRangeOperationIntegrationTest.java rename to components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioObjectRangeOperationTest.java index 14a2633..1ccd568 100644 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioObjectRangeOperationIntegrationTest.java +++ b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioObjectRangeOperationTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.minio.integration.localTests; +package org.apache.camel.component.minio.integration; import java.io.BufferedReader; import java.io.IOException; @@ -35,9 +35,9 @@ import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -class MinioObjectRangeOperationIntegrationTest extends MinioTestContainerSupport { +class MinioObjectRangeOperationTest extends MinioTestContainerSupport { - private static final Logger LOG = LoggerFactory.getLogger(MinioObjectRangeOperationIntegrationTest.class); + private static final Logger LOG = LoggerFactory.getLogger(MinioObjectRangeOperationTest.class); @BindToRegistry("minioClient") MinioClient client = MinioClient.builder() @@ -51,7 +51,7 @@ class MinioObjectRangeOperationIntegrationTest extends MinioTestContainerSupport @EndpointInject("mock:result") private MockEndpoint result; - MinioObjectRangeOperationIntegrationTest() throws IOException { + MinioObjectRangeOperationTest() throws IOException { } @Test diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioTestContainerSupport.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioTestContainerSupport.java similarity index 97% rename from components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioTestContainerSupport.java rename to components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioTestContainerSupport.java index 32de07f..3e80606 100644 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/localTests/MinioTestContainerSupport.java +++ b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/MinioTestContainerSupport.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.minio.integration.localTests; +package org.apache.camel.component.minio.integration; import java.io.IOException; import java.time.Duration; diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioComponentIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioComponentIntegrationTest.java deleted file mode 100644 index 5392901..0000000 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioComponentIntegrationTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.minio.integration.remoteTests; - -import java.io.IOException; -import java.util.Properties; - -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.Message; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.minio.MinioConstants; -import org.apache.camel.component.minio.MinioTestUtils; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -class MinioComponentIntegrationTest extends CamelTestSupport { - final Properties properties = MinioTestUtils.loadMinioPropertiesFile(); - - @EndpointInject("direct:start") - private ProducerTemplate template; - - @EndpointInject("mock:result") - private MockEndpoint result; - - MinioComponentIntegrationTest() throws IOException { - } - - @Test - void sendInOnly() throws Exception { - result.expectedMessageCount(2); - - Exchange exchange1 = template.send("direct:start", ExchangePattern.InOnly, exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "CamelUnitTest"); - exchange.getIn().setBody("This is my bucket content."); - }); - - Exchange exchange2 = template.send("direct:start", ExchangePattern.InOnly, exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "CamelUnitTest"); - exchange.getIn().setBody("This is my bucket content."); - }); - - assertMockEndpointsSatisfied(); - - assertResultExchange(result.getExchanges().get(0)); - assertResultExchange(result.getExchanges().get(1)); - - assertResponseMessage(exchange1.getIn()); - assertResponseMessage(exchange2.getIn()); - } - - @Test - void sendInOut() throws Exception { - result.expectedMessageCount(1); - - Exchange exchange = template.send("direct:start", ExchangePattern.InOut, exchange1 -> { - exchange1.getIn().setHeader(MinioConstants.OBJECT_NAME, "CamelUnitTest"); - exchange1.getIn().setBody("This is my bucket content."); - }); - - assertMockEndpointsSatisfied(); - - assertResultExchange(result.getExchanges().get(0)); - - assertResponseMessage(exchange.getMessage()); - } - - private void assertResultExchange(Exchange resultExchange) { - assertEquals("This is my bucket content.", resultExchange.getIn().getBody(String.class)); - assertEquals("mycamelbucket", resultExchange.getIn().getHeader(MinioConstants.BUCKET_NAME)); - assertTrue(resultExchange.getIn().getHeader(MinioConstants.OBJECT_NAME, String.class).startsWith("CamelUnitTest")); - assertNull(resultExchange.getIn().getHeader(MinioConstants.VERSION_ID)); // not enabled on this bucket - assertNotNull(resultExchange.getIn().getHeader(MinioConstants.LAST_MODIFIED)); - assertEquals("application/octet-stream", resultExchange.getIn().getHeader(MinioConstants.CONTENT_TYPE)); - assertNull(resultExchange.getIn().getHeader(MinioConstants.CONTENT_ENCODING)); - assertEquals(26L, resultExchange.getIn().getHeader(MinioConstants.CONTENT_LENGTH)); - assertNull(resultExchange.getIn().getHeader(MinioConstants.CONTENT_DISPOSITION)); - assertNull(resultExchange.getIn().getHeader(MinioConstants.CONTENT_MD5)); - assertNull(resultExchange.getIn().getHeader(MinioConstants.CACHE_CONTROL)); - } - - private void assertResponseMessage(Message message) { - assertNull(message.getHeader(MinioConstants.VERSION_ID)); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - String minioEndpointUri - = "minio://mycamelbucket?accessKey=" + properties.getProperty("accessKey") - + "&secretKey=RAW(" + properties.getProperty("secretKey") - + ")®ion=us-west-1&autoCreateBucket=false&endpoint=https://play.min.io&deleteAfterRead=false"; - from("direct:start").to(minioEndpointUri); - from(minioEndpointUri).to("mock:result"); - - } - }; - } -} diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioConsumerIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioConsumerIntegrationTest.java deleted file mode 100644 index f09ba43..0000000 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioConsumerIntegrationTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.minio.integration.remoteTests; - -import java.util.Properties; - -import io.minio.MinioClient; -import org.apache.camel.BindToRegistry; -import org.apache.camel.EndpointInject; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.minio.MinioConstants; -import org.apache.camel.component.minio.MinioTestUtils; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; - -class MinioConsumerIntegrationTest extends CamelTestSupport { - final Properties properties = MinioTestUtils.loadMinioPropertiesFile(); - - @BindToRegistry("minioClient") - MinioClient client = MinioClient.builder() - .endpoint(properties.getProperty("endpoint")) - .credentials(properties.getProperty("accessKey"), properties.getProperty("secretKey")) - .region(properties.getProperty("region")) - .build(); - - @EndpointInject - private ProducerTemplate template; - - @EndpointInject("mock:result") - private MockEndpoint result; - - MinioConsumerIntegrationTest() throws Exception { - } - - @Test - void sendIn() throws Exception { - result.expectedMessageCount(3); - - template.send("direct:putObject", exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "test1.txt"); - exchange.getIn().setBody("Test1"); - }); - - template.send("direct:putObject", exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "test2.txt"); - exchange.getIn().setBody("Test2"); - }); - - template.send("direct:putObject", exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "test3.txt"); - exchange.getIn().setBody("Test3"); - }); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - String minioEndpoint = "minio://mycamel?autoCreateBucket=false"; - - from("direct:putObject").startupOrder(1).to(minioEndpoint); - from("minio://mycamel?moveAfterRead=true&destinationBucketName=camel-kafka-connector&autoCreateBucket=false") - .startupOrder(2).to("mock:result"); - - } - }; - } -} diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioCopyObjectCustomerKeyOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioCopyObjectCustomerKeyOperationIntegrationTest.java deleted file mode 100644 index aa75e77..0000000 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioCopyObjectCustomerKeyOperationIntegrationTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.minio.integration.remoteTests; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.security.SecureRandom; -import java.util.Properties; -import java.util.UUID; - -import javax.crypto.KeyGenerator; - -import io.minio.CopyObjectArgs; -import io.minio.CopySource; -import io.minio.GetObjectArgs; -import io.minio.MinioClient; -import io.minio.PutObjectArgs; -import io.minio.ServerSideEncryption; -import io.minio.ServerSideEncryptionCustomerKey; -import org.apache.camel.BindToRegistry; -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.minio.MinioConstants; -import org.apache.camel.component.minio.MinioOperations; -import org.apache.camel.component.minio.MinioTestUtils; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; - -class MinioCopyObjectCustomerKeyOperationIntegrationTest extends CamelTestSupport { - - final Properties properties = MinioTestUtils.loadMinioPropertiesFile(); - final ServerSideEncryptionCustomerKey secretKey = generateSecretKey(); - String key = UUID.randomUUID().toString(); - - @BindToRegistry("minioClient") - MinioClient minioClient = MinioClient.builder() - .endpoint(properties.getProperty("endpoint")) - .credentials(properties.getProperty("accessKey"), properties.getProperty("secretKey")) - .build(); - - @EndpointInject - private ProducerTemplate template; - - @EndpointInject("mock:result") - private MockEndpoint result; - - MinioCopyObjectCustomerKeyOperationIntegrationTest() throws IOException { - } - - @Test - void sendIn() throws Exception { - - result.expectedMessageCount(1); - - template.send("direct:putObject", exchange -> { - String string = "Test"; - - //use ByteArrayInputStream to get the bytes of the String and convert them to InputStream. - InputStream inputStream = new ByteArrayInputStream(string.getBytes(StandardCharsets.UTF_8)); - - PutObjectArgs.Builder putObjectRequest = PutObjectArgs.builder() - .stream(inputStream, inputStream.available(), -1) - .bucket("mycamel") - .object("test.txt") - .sse(secretKey); - - exchange.getIn().setBody(putObjectRequest); - }); - - template.send("direct:copyObject", exchange -> { - - CopySource.Builder copySourceBuilder = CopySource.builder() - .bucket("mycamel") - .object("test.txt") - .ssec(secretKey); - - CopyObjectArgs.Builder copyObjectRequest = CopyObjectArgs.builder() - .bucket("mycamel1") - .object("test1.txt") - .source(copySourceBuilder.build()) - .sse(secretKey); - - exchange.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.copyObject); - exchange.getIn().setBody(copyObjectRequest); - }); - - Exchange respond = template.request("direct:getObject", exchange -> { - GetObjectArgs.Builder getObjectRequest = GetObjectArgs.builder() - .object("test1.txt") - .bucket("mycamel1") - .ssec(secretKey); - - exchange.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.getObject); - exchange.getIn().setBody(getObjectRequest); - }); - - InputStream minio = respond.getIn().getBody(InputStream.class); - - assertEquals("Test", readInputStream(minio)); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - String minioEndpoint = "minio://mycamel?autoCreateBucket=false&pojoRequest=true"; - String minioEndpoint1 = "minio://mycamel1?autoCreateBucket=false&pojoRequest=true"; - - from("direct:putObject").to(minioEndpoint); - - from("direct:copyObject").to(minioEndpoint); - - from("direct:getObject").to(minioEndpoint1).to("mock:result"); - - } - }; - } - - protected static ServerSideEncryptionCustomerKey generateSecretKey() { - KeyGenerator generator; - try { - generator = KeyGenerator.getInstance("AES"); - generator.init(256, new SecureRandom()); - return ServerSideEncryption.withCustomerKey(generator.generateKey()); - } catch (Exception e) { - fail("Unable to generate symmetric key: " + e.getMessage()); - return null; - } - } - - private String readInputStream(InputStream minioObject) throws IOException { - StringBuilder textBuilder = new StringBuilder(); - try (Reader reader - = new BufferedReader(new InputStreamReader(minioObject, Charset.forName(StandardCharsets.UTF_8.name())))) { - int c; - while ((c = reader.read()) != -1) { - textBuilder.append((char) c); - } - } - return textBuilder.toString(); - } -} diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioCopyObjectOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioCopyObjectOperationIntegrationTest.java deleted file mode 100644 index c061cb2..0000000 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioCopyObjectOperationIntegrationTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.minio.integration.remoteTests; - -import java.io.IOException; -import java.util.Properties; - -import io.minio.MinioClient; -import org.apache.camel.BindToRegistry; -import org.apache.camel.EndpointInject; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.minio.MinioConstants; -import org.apache.camel.component.minio.MinioOperations; -import org.apache.camel.component.minio.MinioTestUtils; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; - -class MinioCopyObjectOperationIntegrationTest extends CamelTestSupport { - final Properties properties = MinioTestUtils.loadMinioPropertiesFile(); - - @BindToRegistry("minioClient") - MinioClient minioClient = MinioClient.builder() - .endpoint(properties.getProperty("endpoint")) - .credentials(properties.getProperty("accessKey"), properties.getProperty("secretKey")) - .build(); - - @EndpointInject - private ProducerTemplate template; - - @EndpointInject("mock:result") - private MockEndpoint result; - - MinioCopyObjectOperationIntegrationTest() throws IOException { - } - - @Test - void sendIn() throws Exception { - result.expectedMessageCount(1); - - template.send("direct:putObject", exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "test.txt"); - exchange.getIn().setBody("Test"); - }); - - template.send("direct:copyObject", exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "test.txt"); - exchange.getIn().setHeader(MinioConstants.DESTINATION_OBJECT_NAME, "test1.txt"); - exchange.getIn().setHeader(MinioConstants.DESTINATION_BUCKET_NAME, "mycamel1"); - exchange.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.copyObject); - }); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - String minioEndpoint = "minio://mycamel?autoCreateBucket=false"; - - from("direct:putObject").to(minioEndpoint); - - from("direct:copyObject").to(minioEndpoint).to("mock:result"); - - } - }; - } -} diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioDeleteBucketOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioDeleteBucketOperationIntegrationTest.java deleted file mode 100644 index f175c3c..0000000 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioDeleteBucketOperationIntegrationTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.minio.integration.remoteTests; - -import java.io.IOException; -import java.util.Properties; - -import io.minio.MinioClient; -import org.apache.camel.BindToRegistry; -import org.apache.camel.EndpointInject; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.minio.MinioConstants; -import org.apache.camel.component.minio.MinioOperations; -import org.apache.camel.component.minio.MinioTestUtils; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; - -class MinioDeleteBucketOperationIntegrationTest extends CamelTestSupport { - final Properties properties = MinioTestUtils.loadMinioPropertiesFile(); - - @BindToRegistry("minioClient") - MinioClient minioClient = MinioClient.builder() - .endpoint(properties.getProperty("endpoint")) - .credentials(properties.getProperty("accessKey"), properties.getProperty("secretKey")) - .build(); - - @EndpointInject - private ProducerTemplate template; - - @EndpointInject("mock:result") - private MockEndpoint result; - - MinioDeleteBucketOperationIntegrationTest() throws IOException { - } - - @Test - void sendIn() throws Exception { - result.expectedMessageCount(1); - - template.send("direct:listBuckets", - exchange -> exchange.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.listBuckets)); - - template.send("direct:deleteBucket", exchange -> { - exchange.getIn().setHeader(MinioConstants.BUCKET_NAME, "mycamel2"); - exchange.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.deleteBucket); - }); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - String minioEndpoint = "minio://mycamel2?autoCreateBucket=true"; - - from("direct:listBuckets").to(minioEndpoint); - - from("direct:deleteBucket").to(minioEndpoint).to("mock:result"); - - } - }; - } -} diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioListObjectsOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioListObjectsOperationIntegrationTest.java deleted file mode 100644 index ae191ba..0000000 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioListObjectsOperationIntegrationTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.minio.integration.remoteTests; - -import java.io.IOException; -import java.util.Iterator; -import java.util.Properties; - -import com.google.common.collect.Iterators; -import io.minio.MinioClient; -import io.minio.Result; -import io.minio.messages.Item; -import org.apache.camel.BindToRegistry; -import org.apache.camel.EndpointInject; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.minio.MinioConstants; -import org.apache.camel.component.minio.MinioOperations; -import org.apache.camel.component.minio.MinioTestUtils; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -class MinioListObjectsOperationIntegrationTest extends CamelTestSupport { - final Properties properties = MinioTestUtils.loadMinioPropertiesFile(); - - @BindToRegistry("minioClient") - MinioClient minioClient = MinioClient.builder() - .endpoint(properties.getProperty("endpoint")) - .credentials(properties.getProperty("accessKey"), properties.getProperty("secretKey")) - .build(); - - @EndpointInject - private ProducerTemplate template; - - @EndpointInject("mock:result") - private MockEndpoint result; - - MinioListObjectsOperationIntegrationTest() throws IOException { - } - - @SuppressWarnings("unchecked") - @Test - void sendIn() throws Exception { - result.expectedMessageCount(1); - - template.send("direct:listBuckets", - exchange -> exchange.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.listBuckets)); - - template.send("direct:addObject", ExchangePattern.InOnly, exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "CamelUnitTest2"); - exchange.getIn().setBody("This is my bucket content."); - exchange.getIn().removeHeader(MinioConstants.MINIO_OPERATION); - }); - - Exchange exchange = template.request("direct:listObjects", exchange13 -> { - exchange13.getIn().setHeader(MinioConstants.BUCKET_NAME, "mycamel2"); - exchange13.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.listObjects); - }); - - Iterable<Result<Item>> respond = (Iterable<Result<Item>>) exchange.getMessage().getBody(); - Iterator<Result<Item>> respondSize = respond.iterator(); - Iterator<Result<Item>> respondIterator = respond.iterator(); - - assertEquals(1, Iterators.size(respondSize)); - assertEquals("CamelUnitTest2", respondIterator.next().get().objectName()); - - template.send("direct:deleteObject", ExchangePattern.InOnly, exchange12 -> { - exchange12.getIn().setHeader(MinioConstants.OBJECT_NAME, "CamelUnitTest2"); - exchange12.getIn().setHeader(MinioConstants.BUCKET_NAME, "mycamel2"); - exchange12.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.deleteObject); - }); - - template.send("direct:deleteBucket", exchange1 -> { - exchange1.getIn().setHeader(MinioConstants.BUCKET_NAME, "mycamel2"); - exchange1.getIn().setHeader(MinioConstants.MINIO_OPERATION, MinioOperations.deleteBucket); - }); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - String minioEndpoint = "minio://mycamel2?autoCreateBucket=true"; - - from("direct:listBucket").to(minioEndpoint); - - from("direct:addObject").to(minioEndpoint); - - from("direct:deleteObject").to(minioEndpoint); - - from("direct:listObjects").to(minioEndpoint); - - from("direct:deleteBucket").to(minioEndpoint).to("mock:result"); - - } - }; - } -} diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioObjectRangeOperationIntegrationTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioObjectRangeOperationIntegrationTest.java deleted file mode 100644 index 3adb059..0000000 --- a/components/camel-minio/src/test/java/org/apache/camel/component/minio/integration/remoteTests/MinioObjectRangeOperationIntegrationTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.minio.integration.remoteTests; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Properties; - -import io.minio.MinioClient; -import org.apache.camel.BindToRegistry; -import org.apache.camel.EndpointInject; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.minio.MinioConstants; -import org.apache.camel.component.minio.MinioTestUtils; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -class MinioObjectRangeOperationIntegrationTest extends CamelTestSupport { - - private static final Logger LOG = LoggerFactory.getLogger(MinioObjectRangeOperationIntegrationTest.class); - final Properties properties = MinioTestUtils.loadMinioPropertiesFile(); - - @BindToRegistry("minioClient") - MinioClient minioClient = MinioClient.builder() - .endpoint(properties.getProperty("endpoint")) - .credentials(properties.getProperty("accessKey"), properties.getProperty("secretKey")) - .build(); - - @EndpointInject - private ProducerTemplate template; - - @EndpointInject("mock:result") - private MockEndpoint result; - - MinioObjectRangeOperationIntegrationTest() throws IOException { - } - - @Test - void sendIn() throws Exception { - result.expectedMessageCount(1); - - template.send("direct:getPartialObject", exchange -> { - exchange.getIn().setHeader(MinioConstants.OBJECT_NAME, "element.txt"); - exchange.getIn().setHeader(MinioConstants.OFFSET, 0); - exchange.getIn().setHeader(MinioConstants.LENGTH, 9); - }); - assertMockEndpointsSatisfied(); - - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - String minioEndpoint = "minio://mycamelbucket?operation=getPartialObject&autoCreateBucket=false"; - - from("direct:getPartialObject").to(minioEndpoint).process(exchange -> { - InputStream minioPartialObject = exchange.getIn().getBody(InputStream.class); - LOG.info(readInputStream(minioPartialObject)); - - }).to("mock:result"); - - } - }; - } - - private String readInputStream(InputStream minioObject) throws IOException { - StringBuilder textBuilder = new StringBuilder(); - try (Reader reader - = new BufferedReader(new InputStreamReader(minioObject, Charset.forName(StandardCharsets.UTF_8.name())))) { - int c; - while ((c = reader.read()) != -1) { - textBuilder.append((char) c); - } - } - return textBuilder.toString(); - } -} diff --git a/components/camel-minio/src/test/resources/minio_key.properties b/components/camel-minio/src/test/resources/minio_key.properties index 07be599..5b43f82 100644 --- a/components/camel-minio/src/test/resources/minio_key.properties +++ b/components/camel-minio/src/test/resources/minio_key.properties @@ -15,6 +15,5 @@ ## limitations under the License. ## --------------------------------------------------------------------------- endpoint=https://play.min.io -accessKey=Q3AM3UQ867SPQQA43P2F -secretKey=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG -region=us-west-1 +accessKey=testAccessKey +secretKey=testSecretKey \ No newline at end of file