Esempio n. 1
0
        public void testSendRecvServerTransport()
        {
            const String     connectionString = "bnmq://localhost:3333";
            TransportFactory conFactory       = new TransportFactory();

            try {
                conFactory.TransportMessageCoderFactory = new ASN1TransportMessageCoderFactory();
                ITransport server = conFactory.getServerTransport(new Uri(connectionString));
                Assert.NotNull(server);
                server.start();
                ITransport client = conFactory.getClientTransport(new Uri(connectionString));
                Assert.NotNull(client);
                client.start();

                byte[] buffer = new byte[] { 0x01, 0x02, 0x03, 0x04 };
                for (int i = 0; i < 255; i++)
                {
                    client.sendAsync(buffer);
                }
                Thread.Sleep(500);
                server.close();
                client.close();
            }
            finally {
                conFactory.close();
            }
            Console.WriteLine("Finished: testSendRecvServerTransport");
        }
        public void testTakeMessage()
        {
            const String     connectionString = "bnmq://localhost:3333";
            TransportFactory conFactory       = new TransportFactory();

            try {
                conFactory.TransportMessageCoderFactory = new ASN1TransportMessageCoderFactory();

                ITransport server = conFactory.getServerTransport(new Uri(connectionString));
                Assert.NotNull(server);
                MessageListener ml = new MessageListener(this);
                server.addConnectionListener(ml);
                server.addReader(ml);
                server.start();

                ITransport client = conFactory.getClientTransport(new Uri(connectionString));
                ml = new MessageListener(this);
                client.addConnectionListener(ml);
                client.addReader(ml);
                Assert.NotNull(client);
                client.start();

                client.send(createMessage("AAAaasasasasassas"));
                client.sendAsync(createMessage("Two"));
                Thread.Sleep(1500);
                client.close();
                server.close();
            }
            finally {
                conFactory.close();
            }
            Console.WriteLine("Finished: testTakeMessage");
        }
        public void testCall()
        {
            const String     connectionString = "bnmq://localhost:3333";
            TransportFactory conFactory       = new TransportFactory();

            try {
                conFactory.TransportMessageCoderFactory = (new ASN1TransportMessageCoderFactory());

                ITransport server = conFactory.getServerTransport(new Uri(connectionString));
                Assert.NotNull(server);
                CallMessageListener cl = new CallMessageListener(this);
                server.addConnectionListener(cl);
                server.addReader(cl);
                Thread.Sleep(500);
                server.start();

                ITransport client = conFactory.getClientTransport(new Uri(connectionString));
                Assert.NotNull(client);
                client.start();
                MessageEnvelope result = client.call(createMessage("Call"), 10);
                Console.WriteLine("Result call received with Id:" + result.Id + " has been received successfully");
                client.close();
                server.close();
            }
            finally {
                conFactory.close();
            }
            Console.WriteLine("Finished: testCall");
        }
        public void testAsyncCall()
        {
            const String     connectionString = "bnmq://localhost:3333";
            TransportFactory conFactory       = new TransportFactory();

            try {
                conFactory.TransportMessageCoderFactory = (new ASN1TransportMessageCoderFactory());

                ITransport server = conFactory.getServerTransport(new Uri(connectionString));
                Assert.NotNull(server);
                CallMessageListener cl = new CallMessageListener(this);
                server.addConnectionListener(cl);
                server.addReader(cl);
                server.start();

                ITransport client = conFactory.getClientTransport(new Uri(connectionString));
                Assert.NotNull(client);
                client.start();
                client.callAsync(createMessage("CallAsync"), new AsyncCallMessageListener());
                Thread.Sleep(500);

                client.close();
                server.close();
            }
            finally {
                conFactory.close();
            }
            Console.WriteLine("Finished: testCall");
        }
Esempio n. 5
0
        public void testGetServerTransport()
        {
            const string connectionString = "bnmq://localhost:3333";

            TransportFactory conFactory = new TransportFactory();

            try {
                conFactory.TransportMessageCoderFactory = new ASN1TransportMessageCoderFactory();
                ITransport transport = conFactory.getServerTransport(new Uri(connectionString));
                Assert.NotNull(transport);
                transport.start();
                Thread.Sleep(500);
                transport.close();
            }
            finally {
                conFactory.close();
            }
            Console.WriteLine("Finished: testGetServerTransport");
        }