You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/02/07 07:53:16 UTC

[camel] branch master updated: CAMEL-13166 - ArrayBlockingQueueFactory ignores capacity argument, thanks to Jan Bednar for the patch

This is an automated email from the ASF dual-hosted git repository.

acosentino 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 6d9bcfd  CAMEL-13166 - ArrayBlockingQueueFactory ignores capacity argument, thanks to Jan Bednar for the patch
6d9bcfd is described below

commit 6d9bcfdb806cc20fccc6fb8fa9801223a3c42b0c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Feb 7 08:27:30 2019 +0100

    CAMEL-13166 - ArrayBlockingQueueFactory ignores capacity argument, thanks to Jan Bednar for the patch
---
 .../camel/component/seda/ArrayBlockingQueueFactory.java       |  2 +-
 .../org/apache/camel/component/seda/SedaQueueFactoryTest.java | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/components/camel-seda/src/main/java/org/apache/camel/component/seda/ArrayBlockingQueueFactory.java b/components/camel-seda/src/main/java/org/apache/camel/component/seda/ArrayBlockingQueueFactory.java
index 0b67117..36cab6d 100644
--- a/components/camel-seda/src/main/java/org/apache/camel/component/seda/ArrayBlockingQueueFactory.java
+++ b/components/camel-seda/src/main/java/org/apache/camel/component/seda/ArrayBlockingQueueFactory.java
@@ -69,6 +69,6 @@ public class ArrayBlockingQueueFactory<E> implements BlockingQueueFactory<E> {
     @Override
     public ArrayBlockingQueue<E> create(int capacity) {
         return fair == null
-            ? new ArrayBlockingQueue<>(defaultCapacity) : new ArrayBlockingQueue<>(defaultCapacity, fair);
+                ? new ArrayBlockingQueue<>(capacity) : new ArrayBlockingQueue<>(capacity, fair);
     }
 }
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaQueueFactoryTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaQueueFactoryTest.java
index 2347cdc..2234d47 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaQueueFactoryTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaQueueFactoryTest.java
@@ -25,6 +25,7 @@ import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.SimpleRegistry;
+import org.apache.camel.util.SedaConstants;
 import org.junit.Test;
 
 /**
@@ -40,26 +41,26 @@ public class SedaQueueFactoryTest extends ContextTestSupport {
         return new DefaultCamelContext(simpleRegistry);
     }
 
-   
+
     @Test
     public void testArrayBlockingQueueFactory() throws Exception {
         SedaEndpoint endpoint = resolveMandatoryEndpoint("seda:arrayQueue?queueFactory=#arrayQueueFactory", SedaEndpoint.class);
 
         BlockingQueue<Exchange> queue = endpoint.getQueue();
-        assertIsInstanceOf(ArrayBlockingQueue.class, queue);
+        ArrayBlockingQueue<Exchange> blockingQueue = assertIsInstanceOf(ArrayBlockingQueue.class, queue);
+        assertEquals("remainingCapacity - default", SedaConstants.QUEUE_SIZE, blockingQueue.remainingCapacity());
     }
 
     @SuppressWarnings("unchecked")
     @Test
     public void testArrayBlockingQueueFactoryAndSize() throws Exception {
-        SedaEndpoint endpoint = resolveMandatoryEndpoint("seda:arrayQueue50?queueFactory=#arrayQueueFactory&size=50", SedaEndpoint.class);
+        SedaEndpoint endpoint = resolveMandatoryEndpoint("seda:arrayQueue100?queueFactory=#arrayQueueFactory&size=100", SedaEndpoint.class);
 
         BlockingQueue<Exchange> queue = endpoint.getQueue();
         ArrayBlockingQueue<Exchange> blockingQueue = assertIsInstanceOf(ArrayBlockingQueue.class, queue);
-        assertEquals("remainingCapacity", 50, blockingQueue.remainingCapacity());
+        assertEquals("remainingCapacity - custom", 100, blockingQueue.remainingCapacity());
     }
 
-    
     @Test
     public void testDefaultBlockingQueueFactory() throws Exception {
         SedaEndpoint endpoint = resolveMandatoryEndpoint("seda:linkedQueue", SedaEndpoint.class);