From 4e8d9aae83592587e60123b94e8934ff8907e033 Mon Sep 17 00:00:00 2001 From: Joe Lauer Date: Sun, 14 Aug 2011 20:32:32 -0700 Subject: [PATCH] Added unit tests for deliver_sm parsing issues with 2 different SMSC vendors --- .../java/com/cloudhopper/smpp/Version.java | 8 ++--- .../smpp/transcoder/PduDecoderTest.java | 34 ++++++++++++++++++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/cloudhopper/smpp/Version.java b/src/main/java/com/cloudhopper/smpp/Version.java index 1419c15f..4bbc39d1 100644 --- a/src/main/java/com/cloudhopper/smpp/Version.java +++ b/src/main/java/com/cloudhopper/smpp/Version.java @@ -1,19 +1,19 @@ /** DO NOT EDIT THIS FILE. IT IS AUTO GENERATED BY MAVEN */ package com.cloudhopper.smpp; public final class Version { - private static final String TIMESTAMP="20110726-2124"; + private static final String TIMESTAMP="20110814-2028"; private static final String VERSION="4.1.0"; private static final String NAME="ch-smpp"; private static final String VENDOR="cloudhopper"; - private static final String LONG_VERSION="4.1.0 (Build @ 20110726-2124)"; + private static final String LONG_VERSION="4.1.0 (Build @ 20110814-2028)"; /** Returns the library vendor such as "cloudhopper" */ static public String getVendor() { return VENDOR; } - /** Returns the library build timestamp such as "20110726-2124" */ + /** Returns the library build timestamp such as "20110814-2028" */ static public String getTimestamp() { return TIMESTAMP; } /** Returns the library name such as "ch-smpp" */ static public String getName() { return NAME; } /** Returns the library version such as "4.1.0" */ static public String getVersion() { return VERSION; } - /** Returns a longer library version that includes the timestamp such as "4.1.0 (Build @ 20110726-2124)" */ + /** Returns a longer library version that includes the timestamp such as "4.1.0 (Build @ 20110814-2028)" */ static public String getLongVersion() { return LONG_VERSION; } } diff --git a/src/test/java/com/cloudhopper/smpp/transcoder/PduDecoderTest.java b/src/test/java/com/cloudhopper/smpp/transcoder/PduDecoderTest.java index 534d35cd..457e9249 100644 --- a/src/test/java/com/cloudhopper/smpp/transcoder/PduDecoderTest.java +++ b/src/test/java/com/cloudhopper/smpp/transcoder/PduDecoderTest.java @@ -1205,7 +1205,6 @@ public void decodeWAUMalformedPacket() throws Exception { */ } - @Test public void decodeSubmitSmWith255ByteShortMessage() throws Exception { String text255 = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in orci magna. Etiam auctor ultrices lacus vel suscipit. Maecenas eget faucibus purus. Etiam aliquet mollis fermentum. Proin vel augue arcu. Praesent venenatis tristique ante turpis duis."; @@ -1244,4 +1243,37 @@ public void decodeSubmitSmWith255ByteShortMessage() throws Exception { // interesting -- this example has optional parameters it happened to skip... Assert.assertEquals(0, buffer.readableBytes()); } + + @Ignore @Test + public void decodeDeliverSMWithCorrectTotalByteLengthButInvalidShortMessageLength() throws Exception { + // short_message is only 8 bytes, but short_message_length claims it should be 16 + // the problem is that the pdu_length in the header IS set to the correct length + // this normally causes an IndexOutOfBoundsException on the ByteBuffer read, but + // this should probably be caught and have a specific exception thrown instead! + // MX nextel parsing exception in real world + ChannelBuffer buffer = BufferHelper.createBuffer("00000039000000050000000000000001000101393939393139393134353933000000363436340000000000000000080010c1e1e9edf3faf1fc"); + + DeliverSm pdu = (DeliverSm)transcoder.decode(buffer); + + // 999919914593 + } + + @Test + public void decodeDeliverSMWithNotPerSpecSequenceNumberButNeedsToBeValid() throws Exception { + ChannelBuffer buffer = BufferHelper.createBuffer("000000390000000500000000806A179B000101393939393139393134353933000000363436340000000000000000080008c1e1e9edf3faf1fc"); + + DeliverSm pdu = (DeliverSm)transcoder.decode(buffer); + + // confirm the sequence number was parsed ok + Assert.assertEquals(pdu.getSequenceNumber(), 0x806A179B); + + // make sure the pdu is correct on a reply + DeliverSmResp pduResponse = pdu.createResponse(); + + ChannelBuffer respbuf = transcoder.encode(pduResponse); + String actualHex = BufferHelper.createHexString(respbuf).toUpperCase(); + String expectedHex = "000000118000000500000000806A179B00"; + + Assert.assertEquals(expectedHex, actualHex); + } }