Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Added unit tests for deliver_sm parsing issues with 2 different SMSC …
Browse files Browse the repository at this point in the history
…vendors
  • Loading branch information
jjlauer committed Aug 15, 2011
1 parent dedaa6d commit 4e8d9aa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
8 changes: 4 additions & 4 deletions 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; }
}
Expand Up @@ -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.";
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 4e8d9aa

Please sign in to comment.