public void testAss() { DatagramTransportImpl mock = new DatagramTransportImpl(null); AssociationListenerImpl al = new AssociationListenerImpl(null); MockAssociation ass = new MockAssociation(mock, al); ass.setMyVerTag(335297160); ByteBuffer b = ByteBuffer.wrap(sampleDataOpen); Packet p = new Packet(b); ass.deal(p); Packet ack = new Packet(mock.sent); List <Chunk> chunks = ack.getChunkList(); Assert.AreEqual(1, chunks.Count, "Expecting 1 chunk "); DataChunk dat = chunks[0] as DataChunk; Assert.AreEqual(dat.getType(), DataChunk.CType.DATA, "Expecting a Data chunk"); Console.WriteLine("got " + dat.GetType().Name + " chunk" + dat.ToString()); Assert.AreEqual(dat.getSSeqNo(), 0, "Expecting seqno of zero"); Assert.AreEqual(dat.getStreamId(), 0, "Expecting stream of zero"); Assert.AreEqual(dat.getPpid(), 50, "Expecting an DCEP"); Assert.AreEqual(dat.getData(), null, "Data should be zero"); Assert.AreEqual(dat.getDCEP() != null, true, "Expected to parse a DCEP packet"); Assert.AreEqual(dat.getDCEP().isAck(), true, "Expected an ack DCEP packet "); Assert.AreEqual((al.stream == null), false, "expecting a stream"); al.stream.send("hello"); // ugh - uses a side effect on the sent buffer, which we capture. Packet pack = new Packet(mock.sent); chunks = pack.getChunkList(); Assert.AreEqual(1, chunks.Count, "Expecting 1 chunk "); dat = chunks[0] as DataChunk; Assert.AreEqual(dat.getType(), Chunk.CType.DATA, "Expecting a Data chunk"); Console.WriteLine("got " + dat.GetType().Name + " chunk" + dat.ToString()); Assert.AreEqual(dat.getSSeqNo(), 1, "Expecting seqno of one"); // we've done a DCEP ack by now. Assert.AreEqual(dat.getStreamId(), 0, "Expecting stream of zero"); Assert.AreEqual(dat.getDataAsString(), "hello", "Expecting hello in the data"); }
public void testOpenDataChunk() { ByteBuffer b = ByteBuffer.wrap(sampleData); Packet p = new Packet(b); List <Chunk> chunks = p.getChunkList(); Assert.AreEqual(1, chunks.Count, "Expecting 1 chunk "); DataChunk dat = chunks[0] as DataChunk; Assert.AreEqual(dat.getType(), Chunk.CType.DATA, "Expecting a Data chunk"); Console.WriteLine("got " + dat.GetType().Name + " chunk" + dat.ToString()); Assert.AreEqual(dat.getSSeqNo(), 0, "Expecting seqno of zero"); Assert.AreEqual(dat.getStreamId(), 0, "Expecting stream of zero"); Assert.AreEqual(dat.getPpid(), 50, "Expecting an DCEP"); Assert.AreEqual(dat.getData(), null, "Data should be zero"); Assert.AreEqual(dat.getDCEP() != null, true, "Expected to parse a DCEP packet"); Assert.AreEqual(dat.getDCEP().isAck(), false, "Expected an open DCEP packet "); }