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

aldettinger 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 319c217  CAMEL-12295: Added an option to Jms Endpoints so that they 
format JMS date properties according to the ISO 8601 standard
319c217 is described below

commit 319c217731069d9aecde0c7b3fe904e0161cd5a2
Author: aldettinger <aldettin...@gmail.com>
AuthorDate: Thu Mar 1 21:19:19 2018 +0100

    CAMEL-12295: Added an option to Jms Endpoints so that they format JMS date 
properties according to the ISO 8601 standard
---
 .../camel-amqp/src/main/docs/amqp-component.adoc   |  6 ++-
 components/camel-jms/pom.xml                       |  5 ++
 .../camel-jms/src/main/docs/jms-component.adoc     |  6 ++-
 .../org/apache/camel/component/jms/JmsBinding.java |  8 ++-
 .../apache/camel/component/jms/JmsComponent.java   | 16 ++++++
 .../camel/component/jms/JmsConfiguration.java      | 20 ++++++++
 .../apache/camel/component/jms/JmsEndpoint.java    | 10 ++++
 .../apache/camel/component/jms/JmsBindingTest.java | 55 ++++++++++++++++----
 .../camel/component/jms/JmsComponentTest.java      |  2 +-
 .../jms/JmsEndpointConfigurationTest.java          |  4 ++
 ...java => JmsFormatDateHeadersToIso8601Test.java} | 58 ++++++++--------------
 .../component/jms/JmsStreamMessageTypeTest.java    |  1 +
 .../springboot/AMQPComponentConfiguration.java     | 13 +++++
 .../jms/springboot/JmsComponentConfiguration.java  | 27 ++++++++++
 14 files changed, 180 insertions(+), 51 deletions(-)

diff --git a/components/camel-amqp/src/main/docs/amqp-component.adoc 
b/components/camel-amqp/src/main/docs/amqp-component.adoc
index 230c7cc..ff345b2 100644
--- a/components/camel-amqp/src/main/docs/amqp-component.adoc
+++ b/components/camel-amqp/src/main/docs/amqp-component.adoc
@@ -39,7 +39,7 @@ link:../../../../camel-jms/src/main/docs/readme.html[JMS] 
component after the de
 
 
 // component options: START
-The AMQP component supports 79 options which are listed below.
+The AMQP component supports 80 options which are listed below.
 
 
 
@@ -123,6 +123,7 @@ The AMQP component supports 79 options which are listed 
below.
 | *subscriptionShared* (consumer) | Set whether to make the subscription 
shared. The shared subscription name to be used can be specified through the 
subscriptionName property. Default is false. Set this to true to register a 
shared subscription, typically in combination with a subscriptionName value 
(unless your message listener class name is good enough as subscription name). 
Note that shared subscriptions may also be durable, so this flag can (and often 
will) be combined with subscrip [...]
 | *subscriptionName* (consumer) | Set the name of a subscription to create. To 
be applied in case of a topic (pub-sub domain) with a shared or durable 
subscription. The subscription name needs to be unique within this client's JMS 
client id. Default is the class name of the specified message listener. Note: 
Only 1 concurrent consumer (which is the default of this message listener 
container) is allowed for each subscription, except for a shared subscription 
(which requires JMS 2.0). |  | String
 | *streamMessageType Enabled* (producer) | Sets whether StreamMessage type is 
enabled or not. Message payloads of streaming kind such as files, InputStream, 
etc will either by sent as BytesMessage or StreamMessage. This option controls 
which kind will be used. By default BytesMessage is used which enforces the 
entire message payload to be read into memory. By enabling this option the 
message payload is read into memory in chunks and each chunk is then written to 
the StreamMessage until n [...]
+| *formatDateHeadersTo Iso8601* (producer) | Sets whether date headers should 
be formatted according to the ISO 8601 standard. | false | boolean
 | *headerFilterStrategy* (filter) | To use a custom 
org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel 
message. |  | HeaderFilterStrategy
 | *resolveProperty Placeholders* (advanced) | Whether the component should 
resolve property placeholders on itself when starting. Only properties which 
are of String type can use property placeholders. | true | boolean
 |===
@@ -154,7 +155,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (90 parameters):
+==== Query Parameters (91 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -193,6 +194,7 @@ with the following path and query parameters:
 | *deliveryMode* (producer) | Specifies the delivery mode to be used. 
Possibles values are those defined by javax.jms.DeliveryMode. NON_PERSISTENT = 
1 and PERSISTENT = 2. |  | Integer
 | *deliveryPersistent* (producer) | Specifies whether persistent delivery is 
used by default. | true | boolean
 | *explicitQosEnabled* (producer) | Set if the deliveryMode, priority or 
timeToLive qualities of service should be used when sending messages. This 
option is based on Spring's JmsTemplate. The deliveryMode, priority and 
timeToLive options are applied to the current endpoint. This contrasts with the 
preserveMessageQos option, which operates at message granularity, reading QoS 
properties exclusively from the Camel In message headers. | false | Boolean
+| *formatDateHeadersToIso8601* (producer) | Sets whether JMS date properties 
should be formatted according to the ISO 8601 standard. | false | boolean
 | *preserveMessageQos* (producer) | Set to true, if you want to send message 
using the QoS settings specified on the message, instead of the QoS settings on 
the JMS endpoint. The following three headers are considered JMSPriority, 
JMSDeliveryMode, and JMSExpiration. You can provide all or only some of them. 
If not provided, Camel will fall back to use the values from the endpoint 
instead. So, when using this option, the headers override the values from the 
endpoint. The explicitQosEnable [...]
 | *priority* (producer) | Values greater than 1 specify the message priority 
when sending (where 0 is the lowest priority and 9 is the highest). The 
explicitQosEnabled option must also be enabled in order for this option to have 
any effect. | 4 | int
 | *replyToConcurrentConsumers* (producer) | Specifies the default number of 
concurrent consumers when doing request/reply over JMS. See also the 
maxMessagesPerTask option to control dynamic scaling up/down of threads. | 1 | 
int
diff --git a/components/camel-jms/pom.xml b/components/camel-jms/pom.xml
index 2e4b7bc..b2a4db1 100644
--- a/components/camel-jms/pom.xml
+++ b/components/camel-jms/pom.xml
@@ -164,6 +164,11 @@
       <artifactId>log4j-slf4j-impl</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/components/camel-jms/src/main/docs/jms-component.adoc 
b/components/camel-jms/src/main/docs/jms-component.adoc
index 0fba007..4d68192 100644
--- a/components/camel-jms/src/main/docs/jms-component.adoc
+++ b/components/camel-jms/src/main/docs/jms-component.adoc
@@ -198,7 +198,7 @@ about these properties by consulting the relevant Spring 
documentation.
 
 
 // component options: START
-The JMS component supports 79 options which are listed below.
+The JMS component supports 80 options which are listed below.
 
 
 
@@ -282,6 +282,7 @@ The JMS component supports 79 options which are listed 
below.
 | *subscriptionShared* (consumer) | Set whether to make the subscription 
shared. The shared subscription name to be used can be specified through the 
subscriptionName property. Default is false. Set this to true to register a 
shared subscription, typically in combination with a subscriptionName value 
(unless your message listener class name is good enough as subscription name). 
Note that shared subscriptions may also be durable, so this flag can (and often 
will) be combined with subscrip [...]
 | *subscriptionName* (consumer) | Set the name of a subscription to create. To 
be applied in case of a topic (pub-sub domain) with a shared or durable 
subscription. The subscription name needs to be unique within this client's JMS 
client id. Default is the class name of the specified message listener. Note: 
Only 1 concurrent consumer (which is the default of this message listener 
container) is allowed for each subscription, except for a shared subscription 
(which requires JMS 2.0). |  | String
 | *streamMessageType Enabled* (producer) | Sets whether StreamMessage type is 
enabled or not. Message payloads of streaming kind such as files, InputStream, 
etc will either by sent as BytesMessage or StreamMessage. This option controls 
which kind will be used. By default BytesMessage is used which enforces the 
entire message payload to be read into memory. By enabling this option the 
message payload is read into memory in chunks and each chunk is then written to 
the StreamMessage until n [...]
+| *formatDateHeadersTo Iso8601* (producer) | Sets whether date headers should 
be formatted according to the ISO 8601 standard. | false | boolean
 | *headerFilterStrategy* (filter) | To use a custom 
org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel 
message. |  | HeaderFilterStrategy
 | *resolveProperty Placeholders* (advanced) | Whether the component should 
resolve property placeholders on itself when starting. Only properties which 
are of String type can use property placeholders. | true | boolean
 |===
@@ -324,7 +325,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (90 parameters):
+==== Query Parameters (91 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -363,6 +364,7 @@ with the following path and query parameters:
 | *deliveryMode* (producer) | Specifies the delivery mode to be used. 
Possibles values are those defined by javax.jms.DeliveryMode. NON_PERSISTENT = 
1 and PERSISTENT = 2. |  | Integer
 | *deliveryPersistent* (producer) | Specifies whether persistent delivery is 
used by default. | true | boolean
 | *explicitQosEnabled* (producer) | Set if the deliveryMode, priority or 
timeToLive qualities of service should be used when sending messages. This 
option is based on Spring's JmsTemplate. The deliveryMode, priority and 
timeToLive options are applied to the current endpoint. This contrasts with the 
preserveMessageQos option, which operates at message granularity, reading QoS 
properties exclusively from the Camel In message headers. | false | Boolean
+| *formatDateHeadersToIso8601* (producer) | Sets whether date headers should 
be formatted according to the ISO 8601 standard. | false | boolean
 | *preserveMessageQos* (producer) | Set to true, if you want to send message 
using the QoS settings specified on the message, instead of the QoS settings on 
the JMS endpoint. The following three headers are considered JMSPriority, 
JMSDeliveryMode, and JMSExpiration. You can provide all or only some of them. 
If not provided, Camel will fall back to use the values from the endpoint 
instead. So, when using this option, the headers override the values from the 
endpoint. The explicitQosEnable [...]
 | *priority* (producer) | Values greater than 1 specify the message priority 
when sending (where 0 is the lowest priority and 9 is the highest). The 
explicitQosEnabled option must also be enabled in order for this option to have 
any effect. | 4 | int
 | *replyToConcurrentConsumers* (producer) | Specifies the default number of 
concurrent consumers when doing request/reply over JMS. See also the 
maxMessagesPerTask option to control dynamic scaling up/down of threads. | 1 | 
int
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
index 0de72fe..c9c781a 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
@@ -24,6 +24,8 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -488,7 +490,11 @@ public class JmsBinding {
         } else if (headerValue instanceof Boolean) {
             return headerValue;
         } else if (headerValue instanceof Date) {
-            return headerValue.toString();
+            if 
(this.endpoint.getConfiguration().isFormatDateHeadersToIso8601()) {
+                return 
ZonedDateTime.ofInstant(((Date)headerValue).toInstant(), 
ZoneOffset.UTC).toString();
+            } else {
+                return headerValue.toString();
+            }
         }
         return null;
     }
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
index 134f8fa..b8b2d6a 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
@@ -1232,6 +1232,22 @@ public class JmsComponent extends 
HeaderFilterStrategyComponent implements Appli
         
getConfiguration().setStreamMessageTypeEnabled(streamMessageTypeEnabled);
     }
 
+    /**
+     * Gets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    public boolean isFormatDateHeadersToIso8601() {
+        return getConfiguration().isFormatDateHeadersToIso8601();
+    }
+
+    /**
+     * Sets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    @Metadata(label = "producer", description = "Sets whether date headers 
should be formatted according to the ISO 8601 standard.")
+    public void setFormatDateHeadersToIso8601(boolean 
formatDateHeadersToIso8601) {
+        
getConfiguration().setFormatDateHeadersToIso8601(formatDateHeadersToIso8601);
+    }
 
     // Implementation methods
     // 
-------------------------------------------------------------------------
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
index f67a7b8..8a471b9 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
@@ -491,6 +491,9 @@ public class JmsConfiguration implements Cloneable {
         + " By enabling this option the message payload is read into memory in 
chunks and each chunk is then written to the StreamMessage until no more data.")
     private boolean streamMessageTypeEnabled;
 
+    @UriParam(label = "producer", description = "Sets whether JMS date 
properties should be formatted according to the ISO 8601 standard.")
+    private boolean formatDateHeadersToIso8601;
+
     public JmsConfiguration() {
     }
 
@@ -2213,4 +2216,21 @@ public class JmsConfiguration implements Cloneable {
     public void setStreamMessageTypeEnabled(boolean streamMessageTypeEnabled) {
         this.streamMessageTypeEnabled = streamMessageTypeEnabled;
     }
+
+    /**
+     * Gets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    public boolean isFormatDateHeadersToIso8601() {
+        return formatDateHeadersToIso8601;
+    }
+
+    /**
+     * Sets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    public void setFormatDateHeadersToIso8601(boolean 
formatDateHeadersToIso8601) {
+        this.formatDateHeadersToIso8601 = formatDateHeadersToIso8601;
+    }
+
 }
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
index 3f87f97..4d0e147 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
@@ -1332,6 +1332,16 @@ public class JmsEndpoint extends DefaultEndpoint 
implements AsyncEndpoint, Heade
         
configuration.setWaitForProvisionCorrelationToBeUpdatedThreadSleepingTime(sleepingTime);
     }
 
+    @ManagedAttribute
+    public boolean isFormatDateHeadersToIso8601() {
+        return configuration.isFormatDateHeadersToIso8601();
+    }
+
+    @ManagedAttribute
+    public void setFormatDateHeadersToIso8601(boolean 
formatDateHeadersToIso8601) {
+        
configuration.setFormatDateHeadersToIso8601(formatDateHeadersToIso8601);
+    }
+
     // Implementation methods
     //-------------------------------------------------------------------------
 
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
index 9beb20a..4efeb3f 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
@@ -18,32 +18,69 @@ package org.apache.camel.component.jms;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
 
 import org.apache.activemq.command.ActiveMQBlobMessage;
+import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class JmsBindingTest {
 
+    private final Instant instant = Instant.ofEpochMilli(1519672338000L);
+
+    @Mock
+    private JmsConfiguration mockJmsConfiguration;
+    @Mock
+    private JmsEndpoint mockJmsEndpoint;
+
+    private JmsBinding jmsBindingUnderTest;
+
+    @Before
+    public void setup() {
+        
when(mockJmsConfiguration.isFormatDateHeadersToIso8601()).thenReturn(false);
+        when(mockJmsConfiguration.isMapJmsMessage()).thenReturn(true);
+        
when(mockJmsEndpoint.getConfiguration()).thenReturn(mockJmsConfiguration);
+        jmsBindingUnderTest = new JmsBinding(mockJmsEndpoint);
+    }
+
     @Test
-    public void testJmsBindingNoArgs() throws Exception {
-        JmsBinding underTest = new JmsBinding();
-        assertNull(underTest.extractBodyFromJms(null, new 
ActiveMQBlobMessage()));
+    public void testExtractNullBodyFromJmsShouldReturnNull() throws Exception {
+        assertNull(jmsBindingUnderTest.extractBodyFromJms(null, new 
ActiveMQBlobMessage()));
     }
 
     @Test
-    public void testGetValidJmsHeaderValueWithBigInteger() {
-        JmsBinding binding = new JmsBinding();
-        Object value = binding.getValidJMSHeaderValue("foo", new 
BigInteger("12345"));
+    public void testGetValidJmsHeaderValueWithBigIntegerShouldSucceed() {
+        Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo", new 
BigInteger("12345"));
         assertEquals("12345", value);
     }
 
     @Test
-    public void testGetValidJmsHeaderValueWithBigDecimal() {
-        JmsBinding binding = new JmsBinding();
-        Object value = binding.getValidJMSHeaderValue("foo", new 
BigDecimal("123.45"));
+    public void testGetValidJmsHeaderValueWithBigDecimalShouldSucceed() {
+        Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo", new 
BigDecimal("123.45"));
         assertEquals("123.45", value);
     }
+
+    @Test
+    public void testGetValidJmsHeaderValueWithDateShouldSucceed() {
+        Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo", 
Date.from(instant));
+        assertNotNull(value);
+        // We can't assert further as the returned value is bound to the 
machine time zone and locale
+    }
+
+    @Test
+    public void testGetValidJmsHeaderValueWithIso8601DateShouldSucceed() {
+        
when(mockJmsConfiguration.isFormatDateHeadersToIso8601()).thenReturn(true);
+        Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo", 
Date.from(instant));
+        assertEquals("2018-02-26T19:12:18Z", value);
+    }
 }
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
index cded429..8f7524d 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
@@ -48,7 +48,7 @@ public class JmsComponentTest extends CamelTestSupport {
         assertEquals(true, endpoint.isDeliveryPersistent());
         assertEquals(true, endpoint.isExplicitQosEnabled());
         assertEquals(20, endpoint.getIdleTaskExecutionLimit());
-        assertEquals(21, endpoint.getIdleConsumerLimit());        
+        assertEquals(21, endpoint.getIdleConsumerLimit());
         assertEquals(5, endpoint.getMaxConcurrentConsumers());
         assertEquals(90, endpoint.getMaxMessagesPerTask());
         assertEquals(3, endpoint.getPriority());
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
index 8274d45..4d61cb8 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
@@ -354,6 +354,7 @@ public class JmsEndpointConfigurationTest extends 
CamelTestSupport {
         assertFalse(endpoint.isTransferException());
         assertFalse(endpoint.isTransactedInOut());
         assertFalse(endpoint.isTransferException());
+        assertFalse(endpoint.isFormatDateHeadersToIso8601());
     }
 
     @SuppressWarnings("deprecation")
@@ -491,6 +492,9 @@ public class JmsEndpointConfigurationTest extends 
CamelTestSupport {
 
         endpoint.setJmsMessageType(JmsMessageType.Text);
         assertEquals(JmsMessageType.Text, endpoint.getJmsMessageType());
+
+        endpoint.setFormatDateHeadersToIso8601(true);
+        assertTrue(endpoint.isFormatDateHeadersToIso8601());
     }
 
     protected void assertCacheLevel(JmsEndpoint endpoint, int expected) throws 
Exception {
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsFormatDateHeadersToIso8601Test.java
similarity index 52%
copy from 
components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
copy to 
components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsFormatDateHeadersToIso8601Test.java
index 3ebffc0..f67ae41 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsFormatDateHeadersToIso8601Test.java
@@ -16,67 +16,53 @@
  */
 package org.apache.camel.component.jms;
 
-import java.io.File;
-import java.io.InputStream;
+import java.time.Instant;
+import java.util.Date;
+
 import javax.jms.ConnectionFactory;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.util.FileUtil;
 import org.junit.Test;
 
 import static 
org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
 
-public class JmsStreamMessageTypeTest extends CamelTestSupport {
+public class JmsFormatDateHeadersToIso8601Test extends CamelTestSupport {
 
-    @Override
-    public void setUp() throws Exception {
-        deleteDirectory("target/stream");
-        super.setUp();
+    private static final Date DATE = 
Date.from(Instant.ofEpochMilli(1519672338000L));
+
+    @Test
+    public void testComponentFormatDateHeaderToIso8601() throws Exception {
+        String outDate = 
template.requestBodyAndHeader("direct:start-isoformat", "body", "date", DATE, 
String.class);
+        assertEquals(outDate, "2018-02-26T19:12:18Z");
+    }
+
+    @Test
+    public void testBindingFormatDateHeaderToIso8601() throws Exception {
+        String outDate = 
template.requestBodyAndHeader("direct:start-nonisoformat", "body", "date", 
DATE, String.class);
+        assertNotEquals(outDate, "2018-02-26T19:12:18Z");
     }
 
+    @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
-
         ConnectionFactory connectionFactory = 
CamelJmsTestHelper.createConnectionFactory();
         JmsComponent jms = jmsComponentAutoAcknowledge(connectionFactory);
-        jms.setStreamMessageTypeEnabled(true); // turn on streaming
-        camelContext.addComponent("jms", jms);
+        jms.setFormatDateHeadersToIso8601(true);
+        camelContext.addComponent("activemq", jms);
         return camelContext;
     }
 
-    @Test
-    public void testStreamType() throws Exception {
-        getMockEndpoint("mock:result").expectedMessageCount(1);
-
-        // copy the file
-        FileUtil.copyFile(new File("src/test/data/message1.xml"), new 
File("target/stream/in/message1.xml"));
-
-        assertMockEndpointsSatisfied();
-
-        StreamMessageInputStream is = 
getMockEndpoint("mock:result").getReceivedExchanges().get(0).getIn().getBody(StreamMessageInputStream.class);
-        assertNotNull(is);
-
-        // no more bytes should be available on the inputstream
-        assertEquals(0, is.available());
-
-        // assert on the content of input versus output file
-        String srcContent = 
context.getTypeConverter().mandatoryConvertTo(String.class, new 
File("src/test/data/message1.xml"));
-        String dstContent = 
context.getTypeConverter().mandatoryConvertTo(String.class, new 
File("target/stream/out/message1.xml"));
-        assertEquals("both the source and destination files should have the 
same content", srcContent, dstContent);
-    }
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file:target/stream/in").to("jms:queue:foo");
-
-                
from("jms:queue:foo").to("file:target/stream/out").to("mock:result");
+                from("direct:start-isoformat").to("activemq:queue:foo");
+                
from("direct:start-nonisoformat").to("activemq:queue:foo?formatDateHeadersToIso8601=false");
+                
from("activemq:queue:foo").setBody(simple("${in.header.date}"));
             }
         };
     }
-
 }
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
index 3ebffc0..263ea2e 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
@@ -36,6 +36,7 @@ public class JmsStreamMessageTypeTest extends 
CamelTestSupport {
         super.setUp();
     }
 
+    @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
 
diff --git 
a/platforms/spring-boot/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
index 1881a30..26c8a43 100644
--- 
a/platforms/spring-boot/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
+++ 
b/platforms/spring-boot/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
@@ -608,6 +608,11 @@ public class AMQPComponentConfiguration
      */
     private Boolean streamMessageTypeEnabled = false;
     /**
+     * Sets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    private Boolean formatDateHeadersToIso8601 = false;
+    /**
      * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter
      * header to and from Camel message.
      */
@@ -1249,6 +1254,14 @@ public class AMQPComponentConfiguration
         this.streamMessageTypeEnabled = streamMessageTypeEnabled;
     }
 
+    public Boolean getFormatDateHeadersToIso8601() {
+        return formatDateHeadersToIso8601;
+    }
+
+    public void setFormatDateHeadersToIso8601(Boolean 
formatDateHeadersToIso8601) {
+        this.formatDateHeadersToIso8601 = formatDateHeadersToIso8601;
+    }
+
     public HeaderFilterStrategy getHeaderFilterStrategy() {
         return headerFilterStrategy;
     }
diff --git 
a/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
index b14cba7..1418504 100644
--- 
a/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
+++ 
b/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
@@ -611,6 +611,11 @@ public class JmsComponentConfiguration
      */
     private Boolean streamMessageTypeEnabled = false;
     /**
+     * Sets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    private Boolean formatDateHeadersToIso8601 = false;
+    /**
      * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter
      * header to and from Camel message.
      */
@@ -1253,6 +1258,14 @@ public class JmsComponentConfiguration
         this.streamMessageTypeEnabled = streamMessageTypeEnabled;
     }
 
+    public Boolean getFormatDateHeadersToIso8601() {
+        return formatDateHeadersToIso8601;
+    }
+
+    public void setFormatDateHeadersToIso8601(Boolean 
formatDateHeadersToIso8601) {
+        this.formatDateHeadersToIso8601 = formatDateHeadersToIso8601;
+    }
+
     public HeaderFilterStrategy getHeaderFilterStrategy() {
         return headerFilterStrategy;
     }
@@ -1948,6 +1961,11 @@ public class JmsComponentConfiguration
          * chunk is then written to the StreamMessage until no more data.
          */
         private Boolean streamMessageTypeEnabled = false;
+        /**
+         * Sets whether date headers should be formatted according to the ISO
+         * 8601 standard.
+         */
+        private Boolean formatDateHeadersToIso8601 = false;
 
         public ConsumerType getConsumerType() {
             return consumerType;
@@ -2702,5 +2720,14 @@ public class JmsComponentConfiguration
         public void setStreamMessageTypeEnabled(Boolean 
streamMessageTypeEnabled) {
             this.streamMessageTypeEnabled = streamMessageTypeEnabled;
         }
+
+        public Boolean getFormatDateHeadersToIso8601() {
+            return formatDateHeadersToIso8601;
+        }
+
+        public void setFormatDateHeadersToIso8601(
+                Boolean formatDateHeadersToIso8601) {
+            this.formatDateHeadersToIso8601 = formatDateHeadersToIso8601;
+        }
     }
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
aldettin...@apache.org.

Reply via email to