You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dk...@apache.org on 2011/07/08 22:28:03 UTC
svn commit: r1144493 - in /camel/branches/camel-2.7.x: ./
components/camel-smpp/src/main/java/org/apache/camel/component/smpp/
components/camel-smpp/src/test/java/org/apache/camel/component/smpp/
components/camel-smpp/src/test/java/org/apache/camel/com...
Author: dkulp
Date: Fri Jul 8 20:28:02 2011
New Revision: 1144493
URL: http://svn.apache.org/viewvc?rev=1144493&view=rev
Log:
Merged revisions 1142500,1142721,1143332 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r1142500 | cmueller | 2011-07-03 17:06:25 -0400 (Sun, 03 Jul 2011) | 1 line
CAMEL-4170: camel-smpp component doesn't support sms messages longer than 254 symbols.
........
r1142721 | cmueller | 2011-07-04 12:07:46 -0400 (Mon, 04 Jul 2011) | 1 line
CAMEL-4170: camel-smpp component doesn't support sms messages longer than 254 symbols.
........
r1143332 | davsclaus | 2011-07-06 06:40:33 -0400 (Wed, 06 Jul 2011) | 1 line
CAMEL-4170: Fixed broken unit tests.
........
Modified:
camel/branches/camel-2.7.x/ (props changed)
camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java
camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppProducer.java
camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java
camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppProducerTest.java
camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentIntegrationTest.java
camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentSpringIntegrationTest.java
Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 8 20:28:02 2011
@@ -1 +1 @@
-/camel/trunk:1083696,1083723-1083724,1084150,1085277,1085543,1085549,1085905,1085909,1086165,1086231,1087005,1087276,1087612,1087620,1087856,1088583,1088916-1088917,1089275,1089348,1090166,1090204,1090564,1090960-1090969,1091082,1091518,1091771,1091799,1092034,1092068,1092577,1092667,1093978,1093980,1093999,1094123,1094147,1094156,1095405,1095469,1095471,1095475-1095476,1096346,1096736,1097761,1097909,1097912,1097978,1098032,1098628,1098630,1099228,1099417,1100711,1100975,1102162,1102177,1102181,1104076,1124497,1127744,1127988,1128315,1128970,1131411,1132961,1134252,1134260,1134404,1134501,1134626,1134681,1134714-1134911,1135223,1135364,1136065,1136290,1138285,1139163,1139749,1140096-1140102,1141783,1142654,1143925,1144248,1144324
+/camel/trunk:1083696,1083723-1083724,1084150,1085277,1085543,1085549,1085905,1085909,1086165,1086231,1087005,1087276,1087612,1087620,1087856,1088583,1088916-1088917,1089275,1089348,1090166,1090204,1090564,1090960-1090969,1091082,1091518,1091771,1091799,1092034,1092068,1092577,1092667,1093978,1093980,1093999,1094123,1094147,1094156,1095405,1095469,1095471,1095475-1095476,1096346,1096736,1097761,1097909,1097912,1097978,1098032,1098628,1098630,1099228,1099417,1100711,1100975,1102162,1102177,1102181,1104076,1124497,1127744,1127988,1128315,1128970,1131411,1132961,1134252,1134260,1134404,1134501,1134626,1134681,1134714-1134911,1135223,1135364,1136065,1136290,1138285,1139163,1139749,1140096-1140102,1141783,1142500,1142654,1142721,1143332,1143925,1144248,1144324
Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java?rev=1144493&r1=1144492&r2=1144493&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java (original)
+++ camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppBinding.java Fri Jul 8 20:28:02 2011
@@ -30,6 +30,7 @@ import org.jsmpp.bean.DeliverSm;
import org.jsmpp.bean.DeliveryReceipt;
import org.jsmpp.bean.OptionalParameter;
import org.jsmpp.bean.OptionalParameter.OctetString;
+import org.jsmpp.bean.OptionalParameters;
import org.jsmpp.bean.SubmitSm;
import org.jsmpp.util.AbsoluteTimeFormatter;
import org.jsmpp.util.TimeFormatter;
@@ -90,9 +91,22 @@ public class SmppBinding {
*/
public SubmitSm createSubmitSm(Exchange exchange) throws UnsupportedEncodingException {
Message in = exchange.getIn();
-
+ String body = exchange.getIn().getBody(String.class);
+
SubmitSm submitSm = new SubmitSm();
- submitSm.setShortMessage(exchange.getIn().getBody(String.class).getBytes(configuration.getEncoding()));
+
+ if (body != null) {
+ byte[] shortMessage = body.getBytes(configuration.getEncoding());
+
+ if (shortMessage.length < 255) {
+ submitSm.setShortMessage(shortMessage);
+ } else {
+ submitSm.setShortMessage(new byte[0]);
+ OptionalParameter messagePayloadTLV = OptionalParameters.deserialize(OptionalParameter.Tag.MESSAGE_PAYLOAD.code(), shortMessage);
+
+ submitSm.setOptionalParametes(messagePayloadTLV);
+ }
+ }
if (in.getHeaders().containsKey(DEST_ADDR)) {
submitSm.setDestAddress(in.getHeader(DEST_ADDR, String.class));
Modified: camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppProducer.java?rev=1144493&r1=1144492&r2=1144493&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppProducer.java (original)
+++ camel/branches/camel-2.7.x/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppProducer.java Fri Jul 8 20:28:02 2011
@@ -146,7 +146,8 @@ public class SmppProducer extends Defaul
MessageClass.CLASS1,
Alphabet.valueOf(submitSm.getDataCoding())),
(byte) 0,
- submitSm.getShortMessage());
+ submitSm.getShortMessage(),
+ submitSm.getOptionalParametes());
if (LOG.isDebugEnabled()) {
LOG.debug("Sent a short message for exchange id '"
Modified: camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java?rev=1144493&r1=1144492&r2=1144493&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java (original)
+++ camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppBindingTest.java Fri Jul 8 20:28:02 2011
@@ -148,6 +148,31 @@ public class SmppBindingTest {
//assertEquals(0, submitSm.getCommandStatus());
//assertEquals(0, submitSm.getSequenceNumber());
}
+
+ @Test
+ public void createSubmitSmWithLongMessageBody() throws UnsupportedEncodingException {
+ String payload = "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "
+ + "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "
+ + "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "; // 270 chars
+ Exchange exchange = new DefaultExchange(new DefaultCamelContext());
+ exchange.getIn().setBody(payload);
+ SubmitSm submitSm = binding.createSubmitSm(exchange);
+
+ assertArrayEquals(new byte[0], submitSm.getShortMessage());
+
+ OptionalParameter[] optionalParametes = submitSm.getOptionalParametes();
+ assertEquals(1, optionalParametes.length);
+
+ OptionalParameter messagePayloadTLV = optionalParametes[0];
+ assertEquals(OptionalParameter.Tag.MESSAGE_PAYLOAD.code(), messagePayloadTLV.tag);
+ byte[] expectedTLV = new byte[274];
+ expectedTLV[0] = 4;
+ expectedTLV[1] = 36;
+ expectedTLV[2] = 1;
+ expectedTLV[3] = 14;
+ System.arraycopy(payload.getBytes(), 0, expectedTLV, 4, 270);
+ assertArrayEquals(expectedTLV, messagePayloadTLV.serialize());
+ }
@Test
public void createSmppMessageFromAlertNotificationShouldReturnASmppMessage() {
Modified: camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppProducerTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppProducerTest.java?rev=1144493&r1=1144492&r2=1144493&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppProducerTest.java (original)
+++ camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppProducerTest.java Fri Jul 8 20:28:02 2011
@@ -27,6 +27,7 @@ import org.jsmpp.bean.ESMClass;
import org.jsmpp.bean.GeneralDataCoding;
import org.jsmpp.bean.MessageClass;
import org.jsmpp.bean.NumberingPlanIndicator;
+import org.jsmpp.bean.OptionalParameter;
import org.jsmpp.bean.RegisteredDelivery;
import org.jsmpp.bean.SMSCDeliveryReceipt;
import org.jsmpp.bean.SubmitSm;
@@ -110,6 +111,7 @@ public class SmppProducerTest {
expect(submitSm.getReplaceIfPresent()).andReturn((byte) 0);
expect(submitSm.getDataCoding()).andReturn((byte) 0);
expect(submitSm.getShortMessage()).andReturn("Hello SMPP world!".getBytes("ISO-8859-1"));
+ expect(submitSm.getOptionalParametes()).andReturn(new OptionalParameter[]{});
}
@Test
@@ -277,6 +279,7 @@ public class SmppProducerTest {
expect(submitSm.getReplaceIfPresent()).andReturn((byte) 0);
expect(submitSm.getDataCoding()).andReturn((byte) 4);
expect(submitSm.getShortMessage()).andReturn("Hello SMPP world!".getBytes("ISO-8859-1"));
+ expect(submitSm.getOptionalParametes()).andReturn(new OptionalParameter[]{});
expect(session.submitShortMessage(
eq("CMT"),
eq(TypeOfNumber.UNKNOWN),
Modified: camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentIntegrationTest.java?rev=1144493&r1=1144492&r2=1144493&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentIntegrationTest.java (original)
+++ camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentIntegrationTest.java Fri Jul 8 20:28:02 2011
@@ -91,6 +91,27 @@ public class SmppComponentIntegrationTes
assertNotNull(exchange.getIn().getHeader(SmppBinding.ID));
}
+
+ @Test
+ public void sendLongMessage() throws Exception {
+ MockEndpoint result = getMockEndpoint("mock:result");
+ result.expectedMessageCount(1);
+
+ Endpoint start = getMandatoryEndpoint("direct:start");
+ Exchange exchange = start.createExchange();
+ exchange.setPattern(ExchangePattern.InOnly);
+ exchange.getIn().setBody("Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "
+ + "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "
+ + "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "); // 270 chars
+
+ template.send(start, exchange);
+
+ assertMockEndpointsSatisfied();
+ Exchange resultExchange = result.getExchanges().get(0);
+ assertEquals(SmppMessageType.DeliveryReceipt.toString(), resultExchange.getIn().getHeader(SmppBinding.MESSAGE_TYPE));
+
+ assertNotNull(exchange.getIn().getHeader(SmppBinding.ID));
+ }
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
Modified: camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentSpringIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentSpringIntegrationTest.java?rev=1144493&r1=1144492&r2=1144493&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentSpringIntegrationTest.java (original)
+++ camel/branches/camel-2.7.x/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/integration/SmppComponentSpringIntegrationTest.java Fri Jul 8 20:28:02 2011
@@ -91,6 +91,27 @@ public class SmppComponentSpringIntegrat
assertNotNull(exchange.getIn().getHeader(SmppBinding.ID));
}
+
+ @Test
+ public void sendLongMessage() throws Exception {
+ MockEndpoint result = getMockEndpoint("mock:result");
+ result.expectedMessageCount(1);
+
+ Endpoint start = getMandatoryEndpoint("direct:start");
+ Exchange exchange = start.createExchange();
+ exchange.setPattern(ExchangePattern.InOnly);
+ exchange.getIn().setBody("Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "
+ + "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "
+ + "Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! Hello SMPP World! "); // 270 chars
+
+ template.send(start, exchange);
+
+ assertMockEndpointsSatisfied();
+ Exchange resultExchange = result.getExchanges().get(0);
+ assertEquals(SmppMessageType.DeliveryReceipt.toString(), resultExchange.getIn().getHeader(SmppBinding.MESSAGE_TYPE));
+
+ assertNotNull(exchange.getIn().getHeader(SmppBinding.ID));
+ }
@Override
protected ClassPathXmlApplicationContext createApplicationContext() {