You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/12/02 17:33:12 UTC

[GitHub] [camel] bvahdat opened a new pull request #4712: Fix the disabled test and some minor cleanups

bvahdat opened a new pull request #4712:
URL: https://github.com/apache/camel/pull/4712


   - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
   - [x] Each commit in the pull request should have a meaningful subject line and body.
   - [x] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
   Below are the contribution guidelines:
   https://github.com/apache/camel/blob/master/CONTRIBUTING.md


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] bvahdat commented on a change in pull request #4712: Fix the disabled test and some minor cleanups

Posted by GitBox <gi...@apache.org>.
bvahdat commented on a change in pull request #4712:
URL: https://github.com/apache/camel/pull/4712#discussion_r534456681



##########
File path: components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/integration/BlobConsumerITTest.java
##########
@@ -128,42 +132,35 @@ void testBatchFilePolling() throws InterruptedException, IOException {
             exchange.getIn().setHeader(BlobConstants.BLOB_NAME, "test_batch_blob_2");
         });
 
-        // test output stream based
-        final MockEndpoint mockEndpoint = getMockEndpoint("mock:resultBatch");
-        mockEndpoint.expectedMessageCount(2);
-        mockEndpoint.assertIsSatisfied(100);
+        MockEndpoint.assertIsSatisfied(context());
 
         final BlobInputStream blobInputStream = mockEndpoint.getExchanges().get(0).getIn().getBody(BlobInputStream.class);
         final BlobInputStream blobInputStream2 = mockEndpoint.getExchanges().get(1).getIn().getBody(BlobInputStream.class);
 
         assertNotNull(blobInputStream, "BlobInputStream must be set");
         assertNotNull(blobInputStream2, "BlobInputStream must be set");
 
-        final String bufferedText = new BufferedReader(new InputStreamReader(blobInputStream)).readLine();
-        final String bufferedText2 = new BufferedReader(new InputStreamReader(blobInputStream2)).readLine();
+        final String bufferedText = context().getTypeConverter().convertTo(String.class, blobInputStream);
+        final String bufferedText2 = context().getTypeConverter().convertTo(String.class, blobInputStream2);
 
         assertEquals("Block Batch Blob 1", bufferedText);
         assertEquals("Block Batch Blob 2", bufferedText2);
 
-        // test file based
-        final MockEndpoint mockEndpointFile = getMockEndpoint("mock:resultBatchFile");
-        mockEndpointFile.expectedMessageCount(2);
-        mockEndpointFile.assertIsSatisfied(100);
-
         final File file = mockEndpointFile.getExchanges().get(0).getIn().getBody(File.class);
         final File file2 = mockEndpointFile.getExchanges().get(1).getIn().getBody(File.class);
 
         assertNotNull(file, "File must be set");
         assertNotNull(file2, "File must be set");
 
-        assertEquals("Block Batch Blob 1", FileUtils.readFileToString(file, Charset.defaultCharset()));
-        assertEquals("Block Batch Blob 2", FileUtils.readFileToString(file2, Charset.defaultCharset()));
+        assertEquals("Block Batch Blob 1", context().getTypeConverter().convertTo(String.class, file));
+        assertEquals("Block Batch Blob 2", context().getTypeConverter().convertTo(String.class, file2));
     }
 
     @Test
-    @Disabled("This test should be fixed to use mock:resultRegex endpoint instead of mock:resultBatch")
-    void testRegexPolling() throws InterruptedException {
-        Pattern pattern = Pattern.compile(regex);
+    void testRegexPolling() throws Exception {
+        // test regex based
+        final MockEndpoint mockEndpoint = getMockEndpoint("mock:resultRegex");
+        mockEndpoint.expectedMessageCount(15);

Review comment:
       Thanks for your feedback. It should be fixed now.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] asfgit merged pull request #4712: Fix the disabled test and some minor cleanups

Posted by GitBox <gi...@apache.org>.
asfgit merged pull request #4712:
URL: https://github.com/apache/camel/pull/4712


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] DenisIstomin commented on a change in pull request #4712: Fix the disabled test and some minor cleanups

Posted by GitBox <gi...@apache.org>.
DenisIstomin commented on a change in pull request #4712:
URL: https://github.com/apache/camel/pull/4712#discussion_r534388473



##########
File path: components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/integration/BlobConsumerITTest.java
##########
@@ -128,42 +132,35 @@ void testBatchFilePolling() throws InterruptedException, IOException {
             exchange.getIn().setHeader(BlobConstants.BLOB_NAME, "test_batch_blob_2");
         });
 
-        // test output stream based
-        final MockEndpoint mockEndpoint = getMockEndpoint("mock:resultBatch");
-        mockEndpoint.expectedMessageCount(2);
-        mockEndpoint.assertIsSatisfied(100);
+        MockEndpoint.assertIsSatisfied(context());
 
         final BlobInputStream blobInputStream = mockEndpoint.getExchanges().get(0).getIn().getBody(BlobInputStream.class);
         final BlobInputStream blobInputStream2 = mockEndpoint.getExchanges().get(1).getIn().getBody(BlobInputStream.class);
 
         assertNotNull(blobInputStream, "BlobInputStream must be set");
         assertNotNull(blobInputStream2, "BlobInputStream must be set");
 
-        final String bufferedText = new BufferedReader(new InputStreamReader(blobInputStream)).readLine();
-        final String bufferedText2 = new BufferedReader(new InputStreamReader(blobInputStream2)).readLine();
+        final String bufferedText = context().getTypeConverter().convertTo(String.class, blobInputStream);
+        final String bufferedText2 = context().getTypeConverter().convertTo(String.class, blobInputStream2);
 
         assertEquals("Block Batch Blob 1", bufferedText);
         assertEquals("Block Batch Blob 2", bufferedText2);
 
-        // test file based
-        final MockEndpoint mockEndpointFile = getMockEndpoint("mock:resultBatchFile");
-        mockEndpointFile.expectedMessageCount(2);
-        mockEndpointFile.assertIsSatisfied(100);
-
         final File file = mockEndpointFile.getExchanges().get(0).getIn().getBody(File.class);
         final File file2 = mockEndpointFile.getExchanges().get(1).getIn().getBody(File.class);
 
         assertNotNull(file, "File must be set");
         assertNotNull(file2, "File must be set");
 
-        assertEquals("Block Batch Blob 1", FileUtils.readFileToString(file, Charset.defaultCharset()));
-        assertEquals("Block Batch Blob 2", FileUtils.readFileToString(file2, Charset.defaultCharset()));
+        assertEquals("Block Batch Blob 1", context().getTypeConverter().convertTo(String.class, file));
+        assertEquals("Block Batch Blob 2", context().getTypeConverter().convertTo(String.class, file2));
     }
 
     @Test
-    @Disabled("This test should be fixed to use mock:resultRegex endpoint instead of mock:resultBatch")
-    void testRegexPolling() throws InterruptedException {
-        Pattern pattern = Pattern.compile(regex);
+    void testRegexPolling() throws Exception {
+        // test regex based
+        final MockEndpoint mockEndpoint = getMockEndpoint("mock:resultRegex");
+        mockEndpoint.expectedMessageCount(15);

Review comment:
       I think that if `15` will be increased to `16` (or larger number) test will still pass.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] bvahdat commented on pull request #4712: Fix the disabled test and some minor cleanups

Posted by GitBox <gi...@apache.org>.
bvahdat commented on pull request #4712:
URL: https://github.com/apache/camel/pull/4712#issuecomment-737385204


   I guess [CAMEL-15747](https://issues.apache.org/jira/browse/CAMEL-15747) can be closed as `BlobContainerOperations#listBlobs` API is used both by the consumer as well as the producer with the corresponding regex support.
   
   The main issue in the tests (including the `@Disabled` one) was that we asserted on different `MockEndpoint`s _after_ sending messages using the corresponding `ProducerTemplate` instead of _before_ which caused race condition.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] bvahdat edited a comment on pull request #4712: Fix the disabled test and some minor cleanups

Posted by GitBox <gi...@apache.org>.
bvahdat edited a comment on pull request #4712:
URL: https://github.com/apache/camel/pull/4712#issuecomment-737385204


   I guess [CAMEL-15747](https://issues.apache.org/jira/browse/CAMEL-15747) can be closed as `BlobContainerOperations#listBlobs` API is used both by the consumer as well as the producer with the corresponding regex support.
   
   The main issue in the tests (including the `@Disabled` one) was that we asserted on different `MockEndpoint`s _after_ sending exchanges using the corresponding `ProducerTemplate` instead of _before_ it, which caused race condition.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org