This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 576602789c6 Upgrade jsmpp 3.0.0 576602789c6 is described below commit 576602789c64359f9583ca3d65d81116395007c9 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Jul 17 16:20:03 2023 +0200 Upgrade jsmpp 3.0.0 --- .../component/smpp/SmppSubmitMultiCommand.java | 2 +- .../camel/component/smpp/SmppSubmitSmCommand.java | 13 +++++-- .../component/smpp/SmppSubmitMultiCommandTest.java | 33 ++++++++++-------- .../component/smpp/SmppSubmitSmCommandTest.java | 40 ++++++++++++---------- parent/pom.xml | 2 +- 5 files changed, 51 insertions(+), 39 deletions(-) diff --git a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSubmitMultiCommand.java b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSubmitMultiCommand.java index 358bb9f2d0f..22f06fedf25 100644 --- a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSubmitMultiCommand.java +++ b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSubmitMultiCommand.java @@ -38,10 +38,10 @@ import org.jsmpp.bean.RegisteredDelivery; import org.jsmpp.bean.ReplaceIfPresentFlag; import org.jsmpp.bean.SMSCDeliveryReceipt; import org.jsmpp.bean.SubmitMulti; -import org.jsmpp.bean.SubmitMultiResult; import org.jsmpp.bean.TypeOfNumber; import org.jsmpp.bean.UnsuccessDelivery; import org.jsmpp.session.SMPPSession; +import org.jsmpp.session.SubmitMultiResult; public class SmppSubmitMultiCommand extends SmppSmCommand { diff --git a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSubmitSmCommand.java b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSubmitSmCommand.java index 3f94cd41be0..d0ff5000bb0 100644 --- a/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSubmitSmCommand.java +++ b/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppSubmitSmCommand.java @@ -36,6 +36,7 @@ import org.jsmpp.bean.SMSCDeliveryReceipt; import org.jsmpp.bean.SubmitSm; import org.jsmpp.bean.TypeOfNumber; import org.jsmpp.session.SMPPSession; +import org.jsmpp.session.SubmitSmResult; public class SmppSubmitSmCommand extends SmppSmCommand { @@ -48,15 +49,16 @@ public class SmppSubmitSmCommand extends SmppSmCommand { SubmitSm[] submitSms = createSubmitSm(exchange); List<String> messageIDs = new ArrayList<>(submitSms.length); + String messageID = null; for (int i = 0; i < submitSms.length; i++) { SubmitSm submitSm = submitSms[i]; - String messageID; + messageID = null; if (log.isDebugEnabled()) { log.debug("Sending short message {} for exchange id '{}'...", i, exchange.getExchangeId()); } try { - messageID = session.submitShortMessage( + SubmitSmResult result = session.submitShortMessage( submitSm.getServiceType(), TypeOfNumber.valueOf(submitSm.getSourceAddrTon()), NumberingPlanIndicator.valueOf(submitSm.getSourceAddrNpi()), @@ -75,11 +77,16 @@ public class SmppSubmitSmCommand extends SmppSmCommand { (byte) 0, submitSm.getShortMessage(), submitSm.getOptionalParameters()); + if (result != null) { + messageID = result.getMessageId(); + } } catch (Exception e) { throw new SmppException(e); } - messageIDs.add(messageID); + if (messageID != null) { + messageIDs.add(messageID); + } } if (log.isDebugEnabled()) { diff --git a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java index a849e4d1ccd..9ce4f2b774d 100644 --- a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java +++ b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java @@ -37,10 +37,10 @@ import org.jsmpp.bean.OptionalParameter.Tag; import org.jsmpp.bean.RegisteredDelivery; import org.jsmpp.bean.ReplaceIfPresentFlag; import org.jsmpp.bean.SMSCDeliveryReceipt; -import org.jsmpp.bean.SubmitMultiResult; import org.jsmpp.bean.TypeOfNumber; import org.jsmpp.bean.UnsuccessDelivery; import org.jsmpp.session.SMPPSession; +import org.jsmpp.session.SubmitMultiResult; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -86,10 +86,14 @@ public class SmppSubmitMultiCommandTest { @Test public void executeWithConfigurationData() throws Exception { + UnsuccessDelivery ud + = new UnsuccessDelivery(new Address(TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, "1717"), 0); + Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut); exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti"); exchange.getIn().setHeader(SmppConstants.ID, "1"); exchange.getIn().setBody("short message body"); + when(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), eq(new Address[] { new Address(TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, "1717") }), eq(new ESMClass()), eq((byte) 0), eq((byte) 1), (String) isNull(), (String) isNull(), @@ -97,8 +101,7 @@ public class SmppSubmitMultiCommandTest { eq(ReplaceIfPresentFlag.DEFAULT), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq("short message body".getBytes()))) .thenReturn(new SubmitMultiResult( - "1", new UnsuccessDelivery( - new Address(TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, "1717"), 0))); + "1", new UnsuccessDelivery[] { ud }, null)); command.execute(exchange); @@ -132,7 +135,7 @@ public class SmppSubmitMultiCommandTest { eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq(ReplaceIfPresentFlag.REPLACE), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq("short message body".getBytes()))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -166,7 +169,7 @@ public class SmppSubmitMultiCommandTest { eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq(ReplaceIfPresentFlag.REPLACE), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq("short message body".getBytes()))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -207,7 +210,7 @@ public class SmppSubmitMultiCommandTest { eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), eq(bodyNarrowed))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -246,7 +249,7 @@ public class SmppSubmitMultiCommandTest { eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), eq(bodyNarrowed))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -284,7 +287,7 @@ public class SmppSubmitMultiCommandTest { eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), eq(body))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -322,7 +325,7 @@ public class SmppSubmitMultiCommandTest { eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), eq(body))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -361,7 +364,7 @@ public class SmppSubmitMultiCommandTest { eq(DataCodings.newInstance(binDataCoding)), eq((byte) 0), eq(body))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -401,7 +404,7 @@ public class SmppSubmitMultiCommandTest { eq(DataCodings.newInstance(latin1DataCoding)), eq((byte) 0), eq(bodyNarrowed))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -447,7 +450,7 @@ public class SmppSubmitMultiCommandTest { eq(new OptionalParameter.Dest_telematics_id((short) 2)), eq(new OptionalParameter.Qos_time_to_live(3600000)), eq(new OptionalParameter.Alert_on_message_delivery("O".getBytes())))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -509,7 +512,7 @@ public class SmppSubmitMultiCommandTest { eq(new OptionalParameter.Short((short) 0x2153, (short) 9)), eq(new OptionalParameter.Int((short) 0x2154, 7400000)), eq(new OptionalParameter.Null((short) 0x2155)))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); command.execute(exchange); @@ -542,7 +545,7 @@ public class SmppSubmitMultiCommandTest { (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT)), eq(ReplaceIfPresentFlag.DEFAULT), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), any(byte[].class))) - .thenReturn(new SubmitMultiResult("1")); + .thenReturn(new SubmitMultiResult("1", null, null)); when(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), @@ -551,7 +554,7 @@ public class SmppSubmitMultiCommandTest { (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), any(byte[].class))) - .thenReturn(new SubmitMultiResult("2")); + .thenReturn(new SubmitMultiResult("2", null, null)); command.execute(exchange); assertEquals(Arrays.asList("1", "2"), exchange.getMessage().getHeader(SmppConstants.ID)); diff --git a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java index 0ad55c80b86..10d94750414 100644 --- a/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java +++ b/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java @@ -38,6 +38,8 @@ import org.jsmpp.bean.ReplaceIfPresentFlag; import org.jsmpp.bean.SMSCDeliveryReceipt; import org.jsmpp.bean.TypeOfNumber; import org.jsmpp.session.SMPPSession; +import org.jsmpp.session.SubmitSmResult; +import org.jsmpp.util.MessageId; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -98,7 +100,7 @@ public class SmppSubmitSmCommandTest { eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" .getBytes()))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -130,14 +132,14 @@ public class SmppSubmitSmCommandTest { (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq(firstSM))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); when(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1717"), eq(new ESMClass()), eq((byte) 0), eq((byte) 1), (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq(secondSM))) - .thenReturn("2"); + .thenReturn(new SubmitSmResult(new MessageId("2"), null)); command.execute(exchange); @@ -169,14 +171,14 @@ public class SmppSubmitSmCommandTest { (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq(firstSM))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); when(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1717"), eq(new ESMClass()), eq((byte) 0), eq((byte) 1), (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq(secondSM))) - .thenReturn("2"); + .thenReturn(new SubmitSmResult(new MessageId("2"), null)); assertThrows(SmppException.class, () -> command.execute(exchange)); } @@ -205,7 +207,7 @@ public class SmppSubmitSmCommandTest { (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq(firstSM))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -238,7 +240,7 @@ public class SmppSubmitSmCommandTest { eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq(ReplaceIfPresentFlag.REPLACE.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq("short message body".getBytes()))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -283,7 +285,7 @@ public class SmppSubmitSmCommandTest { eq(new OptionalParameter.Dest_addr_subunit((byte) 4)), eq(new OptionalParameter.Dest_telematics_id((short) 2)), eq(new OptionalParameter.Qos_time_to_live(3600000)), eq(new OptionalParameter.Alert_on_message_delivery((byte) 0)))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -344,7 +346,7 @@ public class SmppSubmitSmCommandTest { eq(new OptionalParameter.Short((short) 0x2153, (short) 9)), eq(new OptionalParameter.Int((short) 0x2154, 7400000)), eq(new OptionalParameter.Null((short) 0x2155)))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -377,7 +379,7 @@ public class SmppSubmitSmCommandTest { eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq(ReplaceIfPresentFlag.REPLACE.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), eq("short message body".getBytes()))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -400,7 +402,7 @@ public class SmppSubmitSmCommandTest { eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), argThat(not(DataCodings.newInstance(incorrectDataCoding))), eq((byte) 0), eq(body))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -434,7 +436,7 @@ public class SmppSubmitSmCommandTest { eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), eq(bodyNarrowed))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -468,7 +470,7 @@ public class SmppSubmitSmCommandTest { eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), eq(bodyNarrowed))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -501,7 +503,7 @@ public class SmppSubmitSmCommandTest { eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), eq(body))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -534,7 +536,7 @@ public class SmppSubmitSmCommandTest { eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), eq(body))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -568,7 +570,7 @@ public class SmppSubmitSmCommandTest { eq(DataCodings.newInstance(binDataCoding)), eq((byte) 0), eq(body))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -603,7 +605,7 @@ public class SmppSubmitSmCommandTest { eq(DataCodings.newInstance(latin1DataCoding)), eq((byte) 0), eq(bodyNarrowed))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); command.execute(exchange); @@ -627,7 +629,7 @@ public class SmppSubmitSmCommandTest { (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT)), eq(ReplaceIfPresentFlag.DEFAULT.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), any(byte[].class))) - .thenReturn("1"); + .thenReturn(new SubmitSmResult(new MessageId("1"), null)); when(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), @@ -636,7 +638,7 @@ public class SmppSubmitSmCommandTest { (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), any(byte[].class))) - .thenReturn("2"); + .thenReturn(new SubmitSmResult(new MessageId("2"), null)); command.execute(exchange); assertEquals(Arrays.asList("1", "2"), exchange.getMessage().getHeader(SmppConstants.ID)); diff --git a/parent/pom.xml b/parent/pom.xml index 626bcf1c578..8d63fc4745f 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -288,7 +288,7 @@ <joor-version>0.9.14</joor-version> <johnzon-version>1.2.21</johnzon-version> <jslt-version>0.1.14</jslt-version> - <jsmpp-version>2.3.11</jsmpp-version> + <jsmpp-version>3.0.0</jsmpp-version> <jsch-version>0.2.9</jsch-version> <json-api>1.0</json-api> <jsonassert-version>1.5.1</jsonassert-version>