Cancel rcancel1 = new Cancel();
long deliveryId = dis.readLong(); int deliveryCount = dis.readInt(); DefaultCancel rcancel1 = new DefaultCancel(deliveryId, deliveryCount);
      public void testCancelDeliveries() throws Exception      {                                     long methodHash = 62365354;                  int objectId = 54321;                  List cancels = new ArrayList();                  Cancel cancel1 = new Cancel(65654, 43);         Cancel cancel2 = new Cancel(65765, 2);         cancels.add(cancel1);         cancels.add(cancel2);                  MethodInvocation mi = new MethodInvocation(null, methodHash, cancelDeliveriesMethod, cancelDeliveriesMethod, null);                  mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));                     mi.setArguments(new Object[] {cancels});                  MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);                  InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);                  ByteArrayOutputStream bos = new ByteArrayOutputStream();                  OutputStream oos = new DataOutputStream(bos);                           wf.write(ir, oos);                 oos.flush();                        byte[] bytes = bos.toByteArray();                       ByteArrayInputStream bis = new ByteArrayInputStream(bytes);                           DataInputStream dis = new DataInputStream(bis);                         //Check the bytes                      //First byte should be version         assertEquals(77, dis.readByte());                  //Next byte should be CANCEL_MESSAGES         assertEquals(JMSWireFormat.CANCEL_DELIVERIES, dis.readByte());                  //Next int should be objectId         assertEquals(objectId, dis.readInt());                  //Next long should be methodHash         assertEquals(methodHash, dis.readLong());                           //Next should the size of the list                  int size = dis.readInt();                  assertEquals(2, size);                  //then the AckInfos         Cancel rcancel1 = new Cancel();                  Cancel rcancel2 = new Cancel();                  rcancel1.read(dis);                  rcancel2.read(dis);                  assertEquals(cancel1.getDeliveryCount(), rcancel1.getDeliveryCount());                  assertEquals(cancel1.getDeliveryId(), cancel1.getDeliveryId());                  assertEquals(cancel2.getDeliveryCount(), rcancel2.getDeliveryCount());                  assertEquals(cancel2.getDeliveryId(), cancel2.getDeliveryId());                            //should be eos                         try         {            dis.readByte();            fail("End of stream expected");         }         catch (EOFException e)         {            //Ok         }                           bis.reset();                  InputStream ois = new DataInputStream(bis);                  InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);                  mm = (MessagingMarshallable)ir2.getParameter();                  assertEquals(77, mm.getVersion());                  MethodInvocation mi2 = (MethodInvocation)mm.getLoad();                  assertEquals(methodHash, mi2.getMethodHash());                  assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());                  List list = (List)mi2.getArguments()[0];                 assertEquals(2, list.size());                  Cancel xack1 = (Cancel)list.get(0);         Cancel xack2 = (Cancel)list.get(1);                  assertEquals(cancel1.getDeliveryId(), xack1.getDeliveryId());                  assertEquals(cancel1.getDeliveryCount(), xack1.getDeliveryCount());                  assertEquals(cancel2.getDeliveryId(), xack2.getDeliveryId());                  assertEquals(cancel2.getDeliveryCount(), xack2.getDeliveryCount());               }  