Apache.NMS.ActiveMQ.Test.FailoverTransportTest.OpenWireCommandsTest C# (CSharp) Method

OpenWireCommandsTest() private method

private OpenWireCommandsTest ( ) : void
return void
        public void OpenWireCommandsTest()
        {
            Uri uri = new Uri("failover:(mock://localhost:61616)?transport.randomize=false");
            FailoverTransportFactory factory = new FailoverTransportFactory();

            using(ITransport transport = factory.CreateTransport(uri))
            {
                Assert.IsNotNull(transport);
                transport.Command = OnCommand;
                transport.Exception = OnException;

                FailoverTransport failover =  transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
                Assert.IsNotNull(failover);
                Assert.IsFalse(failover.Randomize);

                transport.Start();
                Thread.Sleep(1000);
                Assert.IsTrue(failover.IsConnected);

                ConnectionInfo connection = createConnection();
                transport.Request(connection);
                SessionInfo session1 = createSession(connection);
                transport.Request(session1);
                SessionInfo session2 = createSession(connection);
                transport.Request(session2);
                ConsumerInfo consumer1 = createConsumer(session1);
                transport.Request(consumer1);
                ConsumerInfo consumer2 = createConsumer(session1);
                transport.Request(consumer2);
                ConsumerInfo consumer3 = createConsumer(session2);
                transport.Request(consumer3);

                ProducerInfo producer1 = createProducer(session2);
                transport.Request(producer1);

                // Remove the Producers
                disposeOf(transport, producer1);

                // Remove the Consumers
                disposeOf(transport, consumer1);
                disposeOf(transport, consumer2);
                disposeOf(transport, consumer3);

                // Remove the Session instances.
                disposeOf(transport, session1);
                disposeOf(transport, session2);

                // Indicate that we are done.
                ShutdownInfo shutdown = new ShutdownInfo();
                transport.Oneway(shutdown);
            }
        }