Package org.apache.qpid.test.utils

Examples of org.apache.qpid.test.utils.QpidClientConnection


    protected void setUp() throws Exception
    {
        super.setUp();

        conn = new QpidClientConnection(BROKER);

        conn.connect();
        // clear queue
        conn.consume(queue, consumeTimeout);
        // load test data
View Full Code Here


    protected void tearDown() throws Exception
    {

        if (!passed) // clean up
        {
            QpidClientConnection conn = new QpidClientConnection(BROKER);

            conn.connect();
            // clear queue
            conn.consume(queue, consumeTimeout);

            conn.disconnect();
        }

        super.tearDown();
    }
View Full Code Here

     * @throws javax.jms.JMSException if a JMS problem occurs
     * @throws InterruptedException   on timeout
     */
    public void testDrain() throws Exception
    {
        QpidClientConnection conn = new QpidClientConnection(BROKER);

        conn.connect();

        _logger.info("consuming queue " + queue);
        Queue q = conn.getSession().createQueue(queue);

        final MessageConsumer consumer = conn.getSession().createConsumer(q);
        int messagesReceived = 0;

        long[] messageLog = new long[numTestMessages + 1];

        _logger.info("consuming...");
        Message msg = consumer.receive(1000);
        while (msg != null)
        {
            messagesReceived++;

            long dt = ((AbstractJMSMessage) msg).getDeliveryTag();

            int msgindex = msg.getIntProperty("index");
            if (messageLog[msgindex] != 0)
            {
                _logger.error("Received Message(" + msgindex + ":" + ((AbstractJMSMessage) msg).getDeliveryTag()
                              + ") more than once.");
            }

            if (_logger.isInfoEnabled())
            {
                _logger.info("Received Message(" + System.identityHashCode(msgindex) + ") " + "DT:" + dt + "IN:" + msgindex);
            }

            if (dt == 0)
            {
                _logger.error("DT is zero for msg:" + msgindex);
            }

            messageLog[msgindex] = dt;

            // get Next message
            msg = consumer.receive(1000);
        }

        _logger.info("consuming done.");
        conn.getSession().commit();
        consumer.close();

        int index = 0;
        StringBuilder list = new StringBuilder();
        list.append("Failed to receive:");
        int failed = 0;

        _logger.info("consumed: " + messagesReceived);

        assertEquals("number of consumed messages does not match initial data", (int) numTestMessages, messagesReceived);
        // wit 0_10 we can have a delivery tag of 0
        if (conn.isBroker08())
        {
            for (long b : messageLog)
            {
                if ((b == 0) && (index != 0)) // delivery tag of zero shouldn't exist
                {
                    _logger.error("Index: " + index + " was not received.");
                    list.append(" ");
                    list.append(index);
                    list.append(":");
                    list.append(b);
                    failed++;
                }

                index++;
            }

            assertEquals(list.toString(), 0, failed);
        }

        conn.disconnect();
        passed = true;
    }
View Full Code Here

            }

            String virtualHost = "/test";
            String brokerlist = BROKER;
            String brokerUrl = "amqp://guest:guest@" + virtualHost + "?brokerlist='" + brokerlist + "'";
            QpidClientConnection qpc =      new QpidClientConnection(BROKER);
            qpc.connect();
            Connection conn = qpc. getConnection();

            Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
            Queue q = session.createQueue(queue);

            _logger.debug("Create Consumer");
View Full Code Here

        public void run()
        {
            try
            {
                _logger.info("consumer-" + id + ": starting");
                QpidClientConnection conn = new QpidClientConnection(BROKER);

                conn.connect();

                _logger.info("consumer-" + id + ": connected, consuming...");
                Message result;
                do
                {
                    result = conn.getNextMessage(queue, consumeTimeout);
                    if (result != null)
                    {

                        long dt = ((AbstractJMSMessage) result).getDeliveryTag();

                        if (testReception)
                        {
                            int msgindex = result.getIntProperty("index");
                            if (receieved[msgindex] != 0)
                            {
                                _logger.error("Received Message(" + msgindex + ":"
                                    + ((AbstractJMSMessage) result).getDeliveryTag() + ") more than once.");
                            }

                            if (_logger.isInfoEnabled())
                            {
                                _logger.info("Received Message(" + System.identityHashCode(msgindex) + ") " + "DT:" + dt
                                    + "IN:" + msgindex);
                            }

                            if (dt == 0)
                            {
                                _logger.error("DT is zero for msg:" + msgindex);
                            }

                            receieved[msgindex] = dt;
                        }

                        count++;
                        if ((count % 100) == 0)
                        {
                            _logger.info("consumer-" + id + ": got " + result + ", new count is " + count);
                        }
                    }
                }
                while (result != null);

                _logger.info("consumer-" + id + ": complete");
                conn.disconnect();

            }
            catch (Exception e)
            {
                e.printStackTrace();
View Full Code Here

    protected void setUp() throws Exception
    {
        super.setUp();

        conn = new QpidClientConnection(BROKER);

        conn.connect();
        // clear queue
        conn.consume(queue, consumeTimeout);
        // load test data
View Full Code Here

    protected void tearDown() throws Exception
    {

        if (!passed) // clean up
        {
            QpidClientConnection conn = new QpidClientConnection(BROKER);

            conn.connect();
            // clear queue
            conn.consume(queue, consumeTimeout);

            conn.disconnect();
        }

        super.tearDown();
    }
View Full Code Here

     * @throws javax.jms.JMSException if a JMS problem occurs
     * @throws InterruptedException   on timeout
     */
    public void testDrain() throws Exception
    {
        QpidClientConnection conn = new QpidClientConnection(BROKER);

        conn.connect();

        _logger.info("consuming queue " + queue);
        Queue q = conn.getSession().createQueue(queue);

        final MessageConsumer consumer = conn.getSession().createConsumer(q);
        int messagesReceived = 0;

        long[] messageLog = new long[numTestMessages + 1];

        _logger.info("consuming...");
        Message msg = consumer.receive(1000);
        while (msg != null)
        {
            messagesReceived++;

            long dt = ((AbstractJMSMessage) msg).getDeliveryTag();

            int msgindex = msg.getIntProperty("index");
            if (messageLog[msgindex] != 0)
            {
                _logger.error("Received Message(" + msgindex + ":" + ((AbstractJMSMessage) msg).getDeliveryTag()
                              + ") more than once.");
            }

            if (_logger.isInfoEnabled())
            {
                _logger.info("Received Message(" + System.identityHashCode(msgindex) + ") " + "DT:" + dt + "IN:" + msgindex);
            }

            if (dt == 0)
            {
                _logger.error("DT is zero for msg:" + msgindex);
            }

            messageLog[msgindex] = dt;

            // get Next message
            msg = consumer.receive(1000);
        }

        _logger.info("consuming done.");
        conn.getSession().commit();
        consumer.close();

        int index = 0;
        StringBuilder list = new StringBuilder();
        list.append("Failed to receive:");
        int failed = 0;

        _logger.info("consumed: " + messagesReceived);

        assertEquals("number of consumed messages does not match initial data", (int) numTestMessages, messagesReceived);
        // with 0_10 we can have a delivery tag of 0
        if (!conn.isBroker010())
        {
            for (long b : messageLog)
            {
                if ((b == 0) && (index != 0)) // delivery tag of zero shouldn't exist
                {
                    _logger.error("Index: " + index + " was not received.");
                    list.append(" ");
                    list.append(index);
                    list.append(":");
                    list.append(b);
                    failed++;
                }

                index++;
            }

            assertEquals(list.toString(), 0, failed);
        }

        conn.disconnect();
        passed = true;
    }
View Full Code Here

            }

            String virtualHost = "/test";
            String brokerlist = BROKER;
            String brokerUrl = "amqp://guest:guest@" + virtualHost + "?brokerlist='" + brokerlist + "'";
            QpidClientConnection qpc =      new QpidClientConnection(BROKER);
            qpc.connect();
            Connection conn = qpc. getConnection();

            Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
            Queue q = session.createQueue(queue);

            _logger.debug("Create Consumer");
View Full Code Here

        public void run()
        {
            try
            {
                _logger.info("consumer-" + id + ": starting");
                QpidClientConnection conn = new QpidClientConnection(BROKER);

                conn.connect();

                _logger.info("consumer-" + id + ": connected, consuming...");
                Message result;
                do
                {
                    result = conn.getNextMessage(queue, consumeTimeout);
                    if (result != null)
                    {

                        long dt = ((AbstractJMSMessage) result).getDeliveryTag();

                        if (testReception)
                        {
                            int msgindex = result.getIntProperty("index");
                            if (receieved[msgindex] != 0)
                            {
                                _logger.error("Received Message(" + msgindex + ":"
                                    + ((AbstractJMSMessage) result).getDeliveryTag() + ") more than once.");
                            }

                            if (_logger.isInfoEnabled())
                            {
                                _logger.info("Received Message(" + System.identityHashCode(msgindex) + ") " + "DT:" + dt
                                    + "IN:" + msgindex);
                            }

                            if (dt == 0)
                            {
                                _logger.error("DT is zero for msg:" + msgindex);
                            }

                            receieved[msgindex] = dt;
                        }

                        count++;
                        if ((count % 100) == 0)
                        {
                            _logger.info("consumer-" + id + ": got " + result + ", new count is " + count);
                        }
                    }
                }
                while (result != null);

                _logger.info("consumer-" + id + ": complete");
                conn.disconnect();

            }
            catch (Exception e)
            {
                e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.apache.qpid.test.utils.QpidClientConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.