mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 09:39:39 +02:00
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
This commit is contained in:
parent
62ce8e85dd
commit
a92d37a32b
6 changed files with 76 additions and 58 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue