Author: cmueller Date: Tue Nov 13 21:25:35 2012 New Revision: 1408970 URL: http://svn.apache.org/viewvc?rev=1408970&view=rev Log: CAMEL-5718: Bodies of SMs with 8-bit data_coding are mangled
Modified: camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppMessage.java camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java Modified: camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java?rev=1408970&r1=1408969&r2=1408970&view=diff ============================================================================== --- camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java (original) +++ camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java Tue Nov 13 21:25:35 2012 @@ -106,7 +106,7 @@ public class SmppBinding { smppMessage.setHeader(SmppConstants.MESSAGE_TYPE, SmppMessageType.DeliverSm.toString()); if (deliverSm.getShortMessage() != null) { if (SmppUtils.parseAlphabetFromDataCoding(deliverSm.getDataCoding()) == Alphabet.ALPHA_8_BIT) { - smppMessage.setBody(new String(deliverSm.getShortMessage())); + smppMessage.setBody(deliverSm.getShortMessage()); } else { smppMessage.setBody(String.valueOf(new String(deliverSm.getShortMessage(), configuration.getEncoding()))); Modified: camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppMessage.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppMessage.java?rev=1408970&r1=1408969&r2=1408970&view=diff ============================================================================== --- camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppMessage.java (original) +++ camel/branches/camel-2.9.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppMessage.java Tue Nov 13 21:25:35 2012 @@ -85,8 +85,9 @@ public class SmppMessage extends Default if (shortMessage == null || shortMessage.length == 0) { return null; } - if (SmppUtils.parseAlphabetFromDataCoding(msgRequest.getDataCoding()) != Alphabet.ALPHA_8_BIT - && Charset.isSupported(configuration.getEncoding())) { + if (SmppUtils.parseAlphabetFromDataCoding(msgRequest.getDataCoding()) == Alphabet.ALPHA_8_BIT) { + return shortMessage; + } else if (Charset.isSupported(configuration.getEncoding())) { try { return new String(shortMessage, configuration.getEncoding()); } catch (UnsupportedEncodingException e) { Modified: camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java?rev=1408970&r1=1408969&r2=1408970&view=diff ============================================================================== --- camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java (original) +++ camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java Tue Nov 13 21:25:35 2012 @@ -206,7 +206,6 @@ public class SmppBindingTest { } @Test - @Ignore("FIXME: cmueller is working on it") public void createSmppMessageFrom8bitDataCodingDeliverSmShouldNotModifyBody() throws Exception { final Set<String> encodings = Charset.availableCharsets().keySet(); @@ -217,7 +216,10 @@ public class SmppBindingTest { (byte)0xF4 }; - byte[] body = "\u02C7AB\u0000\u02C7\u007F\u02C7".getBytes(Charset.forName("UTF-8")); + byte[] body = { + (byte)0xFF, 'A', 'B', (byte)0x00, + (byte)0xFF, (byte)0x7F, 'C', (byte)0xFF + }; DeliverSm deliverSm = new DeliverSm(); @@ -233,7 +235,7 @@ public class SmppBindingTest { dataCoding, encoding), body, - smppMessage.getBody(String.class).getBytes()); + smppMessage.getBody(byte[].class)); } } } Modified: camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java?rev=1408970&r1=1408969&r2=1408970&view=diff ============================================================================== --- camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java (original) +++ camel/branches/camel-2.9.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppMessageTest.java Tue Nov 13 21:25:35 2012 @@ -101,7 +101,6 @@ public class SmppMessageTest { } @Test - @Ignore("FIXME: cmueller is working on it") public void createBodyShouldNotMangle8bitDataCodingShortMessage() { final Set<String> encodings = Charset.availableCharsets().keySet(); @@ -112,7 +111,10 @@ public class SmppMessageTest { (byte)0xF4 }; - byte[] body = "\u02C7AB\u0000\u02C7\u007F\u02C7".getBytes(Charset.forName("UTF-8")); + byte[] body = { + (byte)0xFF, 'A', 'B', (byte)0x00, + (byte)0xFF, (byte)0x7F, 'C', (byte)0xFF + }; DeliverSm command = new DeliverSm(); SmppConfiguration config = new SmppConfiguration(); @@ -127,7 +129,7 @@ public class SmppMessageTest { String.format("data coding=0x%02X; encoding=%s", dataCoding, encoding), - body, ((String) message.createBody()).getBytes()); + body, (byte[])message.createBody()); } } }