From a92d37a32b1b155e9f7372c1d56785bfc86fbe57 Mon Sep 17 00:00:00 2001 From: rcollier Date: Fri, 27 Jan 2012 21:30:09 +0000 Subject: [PATCH] SMACK-349 Couple of fixes to test cases based on changes in base64 encoding buffer sizes. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_2_0@12957 b35dd754-fafc-0310-a699-88a17e54d16e --- build/build.xml | 2 +- build/resources/releasedocs/changelog.html | 23 +++++++++ .../smack/SmackConfiguration.java | 4 +- .../InBandBytestreamSessionMessageTest.java | 41 +++++++-------- .../ibb/InBandBytestreamSessionTest.java | 51 ++++++++++--------- .../smackx/pubsub/ConfigureFormTest.java | 13 ++--- 6 files changed, 76 insertions(+), 58 deletions(-) diff --git a/build/build.xml b/build/build.xml index a4f2736da..74e1774de 100644 --- a/build/build.xml +++ b/build/build.xml @@ -27,7 +27,7 @@ - + diff --git a/build/resources/releasedocs/changelog.html b/build/resources/releasedocs/changelog.html index 8e7c67621..9d75fd6a1 100644 --- a/build/resources/releasedocs/changelog.html +++ b/build/resources/releasedocs/changelog.html @@ -141,6 +141,29 @@ hr {
+

3.2.2 -- Dec. 23, 2011

+ +

Bug

+
    +
  • [SMACK-263] - Set file info in all send* methods
  • +
  • [SMACK-322] - NPE in XMPPConnection
  • +
  • [SMACK-324] - Investigate SASL issue with jabberd2 servers
  • +
  • [SMACK-338] - IBB filetransfer doesn't work as expected
  • +
  • [SMACK-346] - Bug in return code for rejection handling in FileTransferManager
  • +
  • [SMACK-348] - Documentation error - broken link
  • +
  • [SMACK-349] - Smack's IBB sends too much data in a packet
  • +
  • [SMACK-350] - Bytestream is not working in Spark 2.6.3 from XP to W7
  • +
  • [SMACK-353] - Thread leak in the FaultTolerantNegotiator
  • +
  • [SMACK-362] - smack throw NoSuchElementException if the muc#roominfo_subject has no values
  • +
+ +

Improvement

+
    +
  • [SMACK-343] - Make Smack jar an OSGi bundle.
  • +
  • [SMACK-354] - Provide milliseconds in timestamp colum debugwindow
  • +
+ +

3.2.1 -- July 4, 2011

Bug

    diff --git a/source/org/jivesoftware/smack/SmackConfiguration.java b/source/org/jivesoftware/smack/SmackConfiguration.java index 5c4c931a3..0cb23abe4 100644 --- a/source/org/jivesoftware/smack/SmackConfiguration.java +++ b/source/org/jivesoftware/smack/SmackConfiguration.java @@ -44,14 +44,14 @@ import java.util.*; */ public final class SmackConfiguration { - private static final String SMACK_VERSION = "3.2.1"; + private static final String SMACK_VERSION = "3.2.2"; private static int packetReplyTimeout = 5000; private static int keepAliveInterval = 30000; private static Vector defaultMechs = new Vector(); private static boolean localSocks5ProxyEnabled = true; - private static int localSocks5ProxyPort = 7778; + private static int localSocks5ProxyPort = 7777; private static int packetCollectorSize = 5000; private SmackConfiguration() { diff --git a/test-unit/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionMessageTest.java b/test-unit/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionMessageTest.java index a420fdff4..632d4410a 100644 --- a/test-unit/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionMessageTest.java +++ b/test-unit/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionMessageTest.java @@ -40,6 +40,7 @@ public class InBandBytestreamSessionMessageTest { String sessionID = "session_id"; int blockSize = 10; + int dataSize = blockSize/4 * 3; // protocol verifier Protocol protocol; @@ -102,7 +103,7 @@ public class InBandBytestreamSessionMessageTest { protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); - byte[] controlData = new byte[blockSize * 3]; + byte[] controlData = new byte[dataSize * 3]; OutputStream outputStream = session.getOutputStream(); outputStream.write(controlData); @@ -127,7 +128,7 @@ public class InBandBytestreamSessionMessageTest { protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); - byte[] controlData = new byte[blockSize * 3]; + byte[] controlData = new byte[dataSize * 3]; OutputStream outputStream = session.getOutputStream(); for (byte b : controlData) { @@ -154,11 +155,11 @@ public class InBandBytestreamSessionMessageTest { protocol.addResponse(null, incrementingSequence); protocol.addResponse(null, incrementingSequence); - byte[] controlData = new byte[(blockSize * 3) - 2]; + byte[] controlData = new byte[(dataSize * 3) - 2]; OutputStream outputStream = session.getOutputStream(); int off = 0; - for (int i = 1; i <= 7; i++) { + for (int i = 1; off+i <= controlData.length; i++) { outputStream.write(controlData, off, i); off += i; } @@ -175,7 +176,7 @@ public class InBandBytestreamSessionMessageTest { */ @Test public void shouldSendThirtyDataPackets() throws Exception { - byte[] controlData = new byte[blockSize * 3]; + byte[] controlData = new byte[dataSize * 3]; InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); @@ -202,7 +203,7 @@ public class InBandBytestreamSessionMessageTest { */ @Test public void shouldSendNothingOnSuccessiveCallsToFlush() throws Exception { - byte[] controlData = new byte[blockSize * 3]; + byte[] controlData = new byte[dataSize * 3]; InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); @@ -273,7 +274,7 @@ public class InBandBytestreamSessionMessageTest { public void shouldReadAllReceivedData1() throws Exception { // create random data Random rand = new Random(); - byte[] controlData = new byte[3 * blockSize]; + byte[] controlData = new byte[3 * dataSize]; rand.nextBytes(controlData); // get IBB sessions data packet listener @@ -283,8 +284,8 @@ public class InBandBytestreamSessionMessageTest { PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); // verify data packet and notify listener - for (int i = 0; i < controlData.length / blockSize; i++) { - String base64Data = StringUtils.encodeBase64(controlData, i * blockSize, blockSize, + for (int i = 0; i < controlData.length / dataSize; i++) { + String base64Data = StringUtils.encodeBase64(controlData, i * dataSize, dataSize, false); DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data); Message dataMessage = new Message(); @@ -292,14 +293,14 @@ public class InBandBytestreamSessionMessageTest { listener.processPacket(dataMessage); } - byte[] bytes = new byte[3 * blockSize]; + byte[] bytes = new byte[3 * dataSize]; int read = 0; - read = inputStream.read(bytes, 0, blockSize); - assertEquals(blockSize, read); - read = inputStream.read(bytes, 10, blockSize); - assertEquals(blockSize, read); - read = inputStream.read(bytes, 20, blockSize); - assertEquals(blockSize, read); + read = inputStream.read(bytes, 0, dataSize); + assertEquals(dataSize, read); + read = inputStream.read(bytes, dataSize, dataSize); + assertEquals(dataSize, read); + read = inputStream.read(bytes, dataSize*2, dataSize); + assertEquals(dataSize, read); // verify data for (int i = 0; i < bytes.length; i++) { @@ -319,7 +320,7 @@ public class InBandBytestreamSessionMessageTest { public void shouldReadAllReceivedData2() throws Exception { // create random data Random rand = new Random(); - byte[] controlData = new byte[3 * blockSize]; + byte[] controlData = new byte[3 * dataSize]; rand.nextBytes(controlData); // get IBB sessions data packet listener @@ -329,8 +330,8 @@ public class InBandBytestreamSessionMessageTest { PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); // verify data packet and notify listener - for (int i = 0; i < controlData.length / blockSize; i++) { - String base64Data = StringUtils.encodeBase64(controlData, i * blockSize, blockSize, + for (int i = 0; i < controlData.length / dataSize; i++) { + String base64Data = StringUtils.encodeBase64(controlData, i * dataSize, dataSize, false); DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data); Message dataMessage = new Message(); @@ -339,7 +340,7 @@ public class InBandBytestreamSessionMessageTest { } // read data - byte[] bytes = new byte[3 * blockSize]; + byte[] bytes = new byte[3 * dataSize]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) inputStream.read(); } diff --git a/test-unit/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionTest.java b/test-unit/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionTest.java index d2f20e5e9..723572747 100644 --- a/test-unit/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionTest.java +++ b/test-unit/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSessionTest.java @@ -40,7 +40,8 @@ public class InBandBytestreamSessionTest { String xmppServer = "xmpp-server"; String sessionID = "session_id"; - int blockSize = 10; + int blockSize = 20; + int dataSize = blockSize/4 * 3; // protocol verifier Protocol protocol; @@ -102,7 +103,7 @@ public class InBandBytestreamSessionTest { protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); - byte[] controlData = new byte[blockSize * 3]; + byte[] controlData = new byte[dataSize * 3]; OutputStream outputStream = session.getOutputStream(); outputStream.write(controlData); @@ -128,7 +129,7 @@ public class InBandBytestreamSessionTest { protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); - byte[] controlData = new byte[blockSize * 3]; + byte[] controlData = new byte[dataSize * 3]; OutputStream outputStream = session.getOutputStream(); for (byte b : controlData) { @@ -156,11 +157,11 @@ public class InBandBytestreamSessionTest { protocol.addResponse(resultIQ, incrementingSequence); protocol.addResponse(resultIQ, incrementingSequence); - byte[] controlData = new byte[(blockSize * 3) - 2]; + byte[] controlData = new byte[(dataSize * 3) - 2]; OutputStream outputStream = session.getOutputStream(); int off = 0; - for (int i = 1; i <= 7; i++) { + for (int i = 1; i+off <= controlData.length; i++) { outputStream.write(controlData, off, i); off += i; } @@ -177,7 +178,7 @@ public class InBandBytestreamSessionTest { */ @Test public void shouldSendThirtyDataPackets() throws Exception { - byte[] controlData = new byte[blockSize * 3]; + byte[] controlData = new byte[dataSize * 3]; InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); @@ -205,7 +206,7 @@ public class InBandBytestreamSessionTest { */ @Test public void shouldSendNothingOnSuccessiveCallsToFlush() throws Exception { - byte[] controlData = new byte[blockSize * 3]; + byte[] controlData = new byte[dataSize * 3]; InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, initiatorJID); @@ -236,7 +237,7 @@ public class InBandBytestreamSessionTest { public void shouldSendDataCorrectly() throws Exception { // create random data Random rand = new Random(); - final byte[] controlData = new byte[256 * blockSize]; + final byte[] controlData = new byte[256 * dataSize]; rand.nextBytes(controlData); // compares the data of each packet with the control data @@ -246,7 +247,7 @@ public class InBandBytestreamSessionTest { byte[] decodedData = request.getDataPacketExtension().getDecodedData(); int seq = (int) request.getDataPacketExtension().getSeq(); for (int i = 0; i < decodedData.length; i++) { - assertEquals(controlData[(seq * blockSize) + i], decodedData[i]); + assertEquals(controlData[(seq * dataSize) + i], decodedData[i]); } } @@ -254,7 +255,7 @@ public class InBandBytestreamSessionTest { // set acknowledgments for the data packets IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID); - for (int i = 0; i < controlData.length / blockSize; i++) { + for (int i = 0; i < controlData.length / dataSize; i++) { protocol.addResponse(resultIQ, incrementingSequence, dataVerification); } @@ -462,7 +463,7 @@ public class InBandBytestreamSessionTest { public void shouldReadAllReceivedData1() throws Exception { // create random data Random rand = new Random(); - byte[] controlData = new byte[3 * blockSize]; + byte[] controlData = new byte[3 * dataSize]; rand.nextBytes(controlData); IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID); @@ -473,24 +474,24 @@ public class InBandBytestreamSessionTest { InputStream inputStream = session.getInputStream(); PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); - // set data packet acknowledgment and notify listener - for (int i = 0; i < controlData.length / blockSize; i++) { + // set data packet acknowledgement and notify listener + for (int i = 0; i < controlData.length / dataSize; i++) { protocol.addResponse(resultIQ); - String base64Data = StringUtils.encodeBase64(controlData, i * blockSize, blockSize, + String base64Data = StringUtils.encodeBase64(controlData, i * dataSize, dataSize, false); DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data); Data data = new Data(dpe); listener.processPacket(data); } - byte[] bytes = new byte[3 * blockSize]; + byte[] bytes = new byte[3 * dataSize]; int read = 0; - read = inputStream.read(bytes, 0, blockSize); - assertEquals(blockSize, read); - read = inputStream.read(bytes, 10, blockSize); - assertEquals(blockSize, read); - read = inputStream.read(bytes, 20, blockSize); - assertEquals(blockSize, read); + read = inputStream.read(bytes, 0, dataSize); + assertEquals(dataSize, read); + read = inputStream.read(bytes, dataSize, dataSize); + assertEquals(dataSize, read); + read = inputStream.read(bytes, dataSize*2, dataSize); + assertEquals(dataSize, read); // verify data for (int i = 0; i < bytes.length; i++) { @@ -510,7 +511,7 @@ public class InBandBytestreamSessionTest { public void shouldReadAllReceivedData2() throws Exception { // create random data Random rand = new Random(); - byte[] controlData = new byte[3 * blockSize]; + byte[] controlData = new byte[3 * dataSize]; rand.nextBytes(controlData); IQ resultIQ = IBBPacketUtils.createResultIQ(initiatorJID, targetJID); @@ -522,9 +523,9 @@ public class InBandBytestreamSessionTest { PacketListener listener = Whitebox.getInternalState(inputStream, PacketListener.class); // set data packet acknowledgment and notify listener - for (int i = 0; i < controlData.length / blockSize; i++) { + for (int i = 0; i < controlData.length / dataSize; i++) { protocol.addResponse(resultIQ); - String base64Data = StringUtils.encodeBase64(controlData, i * blockSize, blockSize, + String base64Data = StringUtils.encodeBase64(controlData, i * dataSize, dataSize, false); DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data); Data data = new Data(dpe); @@ -532,7 +533,7 @@ public class InBandBytestreamSessionTest { } // read data - byte[] bytes = new byte[3 * blockSize]; + byte[] bytes = new byte[3 * dataSize]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) inputStream.read(); } diff --git a/test-unit/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java b/test-unit/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java index 949bb3725..78364a3da 100644 --- a/test-unit/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java +++ b/test-unit/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java @@ -53,7 +53,7 @@ public class ConfigureFormTest } } - @Test + @Test (expected=XMPPException.class) public void getConfigFormWithTimeout() throws XMPPException { ThreadedDummyConnection con = new ThreadedDummyConnection(); @@ -66,14 +66,7 @@ public class ConfigureFormTest Node node = mgr.getNode("princely_musings"); -// try -// { - SmackConfiguration.setPacketReplyTimeout(100); - node.getNodeConfiguration(); -// } -// catch (XMPPException e) -// { -// Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType()); -// } + SmackConfiguration.setPacketReplyTimeout(100); + node.getNodeConfiguration(); } }