@Test
public void ToBytesMultiple() throws MalformedDataException
{
UUID testID = UUID.Random();
DirPlacesReplyPacket bigPacket = new DirPlacesReplyPacket();
bigPacket.header.Zerocoded = false;
bigPacket.header.Sequence = 42;
bigPacket.header.AppendedAcks = true;
//Unsigned int
bigPacket.header.AckList = new long[50];
for (int i = 0; i < bigPacket.header.AckList.length; i++) { bigPacket.header.AckList[i] = (long)i; }
bigPacket.AgentData.AgentID = testID;
bigPacket.QueryData = new DirPlacesReplyPacket.QueryDataBlock[100];
for (int i = 0; i < bigPacket.QueryData.length; i++)
{
bigPacket.QueryData[i] = new DirPlacesReplyPacket.QueryDataBlock();
bigPacket.QueryData[i].QueryID = testID;
}
bigPacket.QueryReplies = new DirPlacesReplyPacket.QueryRepliesBlock[100];
for (int i = 0; i < bigPacket.QueryReplies.length; i++)
{
bigPacket.QueryReplies[i] = new DirPlacesReplyPacket.QueryRepliesBlock();
bigPacket.QueryReplies[i].Auction = (i & 1) == 0;
bigPacket.QueryReplies[i].Dwell = (float)i;
bigPacket.QueryReplies[i].ForSale = (i & 1) == 0;
bigPacket.QueryReplies[i].Name = Utils.stringToBytes("DirPlacesReply Test String");
bigPacket.QueryReplies[i].ParcelID = testID;
}
bigPacket.StatusData = new DirPlacesReplyPacket.StatusDataBlock[100];
for (int i = 0; i < bigPacket.StatusData.length; i++)
{
bigPacket.StatusData[i] = new DirPlacesReplyPacket.StatusDataBlock();
bigPacket.StatusData[i].Status = (long)i;
}
byte[][] splitPackets = bigPacket.ToBytesMultiple();
int queryDataCount = 0;
int queryRepliesCount = 0;
int statusDataCount = 0;
for (int i = 0; i < splitPackets.length; i++)
{
byte[] packetData = splitPackets[i];
int[] len = new int[]{packetData.length - 1};
DirPlacesReplyPacket packet = (DirPlacesReplyPacket)Packet.BuildPacket(packetData, len, packetData);
Assert.assertTrue(packet.AgentData.AgentID.equals(bigPacket.AgentData.AgentID));
for (int j = 0; j < packet.QueryReplies.length; j++)
{