public void testMakeMessage_string_BlockingSCTPStream() { Console.WriteLine("---->makeMessage string"); StringBuilder rightout = new StringBuilder(); SCTPStreamListener rsl = new ASCTPStreamListenerImpl(rightout); DatagramTransport[] trans = mkMockTransports(); MockAssociationListener listenLeft = new MockAssociationListener(); MockAssociationListener listenRight = new MockAssociationListenerImpl(rsl); ThreadedAssociation instanceLeft = new ThreadedAssociation(trans[0], listenLeft); ThreadedAssociation instanceRight = new ThreadedAssociation(trans[1], listenRight); instanceLeft.associate(); lock (listenLeft) { Monitor.Wait(listenLeft, 2000); Assert.IsTrue(listenLeft.associated); Assert.IsTrue(listenRight.associated); } int id = 10; SCTPStream s = instanceLeft.mkStream(id); Assert.IsTrue(typeof(BlockingSCTPStream).IsAssignableFrom(s.GetType())); string test = "Test message"; SCTPMessage m = instanceLeft.makeMessage(test, (BlockingSCTPStream)s); instanceLeft.sendAndBlock(m); lock (rightout) { Monitor.Wait(rightout, 2000); Assert.AreEqual(rightout.ToString(), test); } }
public void testMakeMessage_byteArr_BlockingSCTPStream() { Console.WriteLine("---->makeMessage bytes"); ByteBuffer rightout = new ByteBuffer(new byte[10000]); StringBuilder empty = new StringBuilder(); SCTPByteStreamListener rsl = new SCTPByteStreamListenerImpl(empty, rightout); DatagramTransport[] trans = mkMockTransports(); MockAssociationListener listenLeft = new MockAssociationListener(); MockAssociationListener listenRight = new MockAssociationListenerImpl(rsl); ThreadedAssociation instanceLeft = new ThreadedAssociation(trans[0], listenLeft); ThreadedAssociation instanceRight = new ThreadedAssociation(trans[1], listenRight); instanceLeft.associate(); lock (listenLeft) { Monitor.Wait(listenLeft, 2000); Assert.IsTrue(listenLeft.associated); Assert.IsTrue(listenRight.associated); } int id = 10; SCTPStream s = instanceLeft.mkStream(id); Assert.IsTrue(typeof(BlockingSCTPStream).IsAssignableFrom(s.GetType())); string test = "Test message"; SCTPMessage m = instanceLeft.makeMessage(test.getBytes(), (BlockingSCTPStream)s); instanceLeft.sendAndBlock(m); lock (rightout) { Monitor.Wait(rightout, 2000); int l = rightout.Position; string res = rightout.Data.getString(0, l); Assert.AreEqual(res, test); Assert.AreEqual(empty.Length, 0); } }