Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public void testAssociate()
        {
            Console.WriteLine("--> associate");

            DatagramTransport[]     trans         = mkMockTransports();
            MockAssociationListener listenLeft    = new MockAssociationListener();
            MockAssociationListener listenRight   = new MockAssociationListener();
            ThreadedAssociation     instanceLeft  = new ThreadedAssociation(trans[0], listenLeft);
            ThreadedAssociation     instanceRight = new ThreadedAssociation(trans[1], listenRight);

            instanceLeft.associate();
            lock (listenLeft) {
                Monitor.Wait(listenLeft, 1000);
                Assert.IsTrue(listenLeft.associated);
                Assert.IsTrue(listenRight.associated);
            }
        }
Ejemplo n.º 3
0
        public void testMkStream()
        {
            Console.WriteLine("--> mkStream");

            DatagramTransport[]     trans         = mkMockTransports();
            MockAssociationListener listenLeft    = new MockAssociationListener();
            MockAssociationListener listenRight   = new MockAssociationListener();
            ThreadedAssociation     instanceLeft  = new ThreadedAssociation(trans[0], listenLeft);
            ThreadedAssociation     instanceRight = new ThreadedAssociation(trans[1], listenRight);

            instanceLeft.associate();
            lock (listenLeft) {
                Monitor.Wait(listenLeft, 1000);
                Assert.IsTrue(listenLeft.associated);
                Assert.IsTrue(listenRight.associated);
            }
            int        id     = 10;
            SCTPStream result = instanceLeft.mkStream(id);

            Assert.IsTrue(typeof(BlockingSCTPStream).IsAssignableFrom(result.GetType()));
        }
Ejemplo n.º 4
0
        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);
            }
        }