[
https://issues.apache.org/jira/browse/CAMEL-12295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16377682#comment-16377682
]
ASF GitHub Bot commented on CAMEL-12295:
----------------------------------------
aldettinger commented on a change in pull request #2238: CAMEL-12295: Added an
option to Jms Endpoints so that they format JMS…
URL: https://github.com/apache/camel/pull/2238#discussion_r170753559
##########
File path:
components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
##########
@@ -18,32 +18,69 @@
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.isFormatDatePropertiesToIso8601()).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.isFormatDatePropertiesToIso8601()).thenReturn(true);
+ Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo",
Date.from(instant));
+ assertEquals("2018-02-26T19:12:18Z", value);
Review comment:
Expressing date at GMT+0 is not necessarily easy to read for end users
deploying in a single country. But, I find them easier to work with when your
deployments is spread across data centers located in different time zones.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Add an option to Jms Endpoints so that they format JMS date properties
> according to the ISO 8601 standard
> ---------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-12295
> URL: https://issues.apache.org/jira/browse/CAMEL-12295
> Project: Camel
> Issue Type: New Feature
> Components: camel-jms
> Reporter: Alex Dettinger
> Assignee: Alex Dettinger
> Priority: Minor
> Fix For: 2.22.0
>
>
> Find the inception context in [this
> discussion|http://camel.465427.n5.nabble.com/JMS-override-Camel-header-type-conversions-td5817516.html].
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)