Author: cmueller
Date: Sat Sep 22 17:10:32 2012
New Revision: 1388846
URL: http://svn.apache.org/viewvc?rev=1388846&view=rev
Log:
CAMEL-5641: JmsBinding Does Not Handle BigInteger and BigDecimal Properly
Thanks James Carman for the patch
Modified:
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
Modified:
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?rev=1388846&r1=1388845&r2=1388846&view=diff
==============================================================================
---
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
(original)
+++
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
Sat Sep 22 17:10:32 2012
@@ -20,6 +20,8 @@ import java.io.File;
import java.io.InputStream;
import java.io.Reader;
import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Date;
import java.util.Enumeration;
@@ -402,6 +404,10 @@ public class JmsBinding {
protected Object getValidJMSHeaderValue(String headerName, Object
headerValue) {
if (headerValue instanceof String) {
return headerValue;
+ } else if (headerValue instanceof BigInteger) {
+ return headerValue.toString();
+ } else if (headerValue instanceof BigDecimal) {
+ return headerValue.toString();
} else if (headerValue instanceof Number) {
return headerValue;
} else if (headerValue instanceof Character) {
Modified:
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java?rev=1388846&r1=1388845&r2=1388846&view=diff
==============================================================================
---
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
(original)
+++
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
Sat Sep 22 17:10:32 2012
@@ -16,14 +16,15 @@
*/
package org.apache.camel.component.jms;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
import org.apache.activemq.command.ActiveMQBlobMessage;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-/**
- * @version
- */
public class JmsBindingTest {
@Test
@@ -31,4 +32,18 @@ public class JmsBindingTest {
JmsBinding underTest = new JmsBinding();
assertNull(underTest.extractBodyFromJms(null, new
ActiveMQBlobMessage()));
}
+
+ @Test
+ public void testGetValidJmsHeaderValueWithBigInteger() {
+ JmsBinding binding = new JmsBinding();
+ Object value = binding.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"));
+ assertEquals("123.45", value);
+ }
}