Package org.apache.qpid.client

Examples of org.apache.qpid.client.AMQConnectionURL


    public void testCheckVirtualhostFormat() throws URLSyntaxException
    {
        String url = "amqp://guest:guest@/t.-_+!=:?brokerlist='tcp://localhost:5672'";

        AMQConnectionURL connection = new AMQConnectionURL(url);
        assertTrue(connection.getVirtualHost().equals("/t.-_+!=:"));
    }
View Full Code Here


    public void testCheckDefaultPort() throws URLSyntaxException
    {
        String url = "amqp://guest:guest@/test=:?brokerlist='tcp://localhost'";

        AMQConnectionURL connection = new AMQConnectionURL(url);

        BrokerDetails broker = connection.getBrokerDetails(0);
        assertTrue(broker.getPort() == AMQBrokerDetails.DEFAULT_PORT);

    }
View Full Code Here

    {
        String url = "amqp://guest:guest@id/test" + "?brokerlist='tcp://localhost:5672";

        try
        {
            new AMQConnectionURL(url);
        }
        catch (URLSyntaxException e)
        {
            assertEquals(e.getMessage(), "Unterminated option at index 32: brokerlist='tcp://localhost:5672");
        }
View Full Code Here

    public void testDefaultExchanges() throws URLSyntaxException
    {
        String url = "amqp://guest:guest@id/test" + "?defaultQueueExchange='test.direct'&defaultTopicExchange='test.topic'&temporaryQueueExchange='tmp.direct'&temporaryTopicExchange='tmp.topic'";

        AMQConnectionURL conn = new AMQConnectionURL(url);

        assertEquals(conn.getDefaultQueueExchangeName().asString(),"test.direct");

        assertEquals(conn.getDefaultTopicExchangeName().asString(),"test.topic");

        assertEquals(conn.getTemporaryQueueExchangeName().asString(),"tmp.direct");

        assertEquals(conn.getTemporaryTopicExchangeName().asString(),"tmp.topic");

    }
View Full Code Here

    public void testSingleTransportMultiOptionOnBrokerURL() throws URLSyntaxException
    {
        String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672?foo='jim'&bar='bob'&fred='jimmy'',routingkey='jim',timeout='200',immediatedelivery='true'";

        ConnectionURL connectionurl = new AMQConnectionURL(url);

        assertTrue(connectionurl.getFailoverMethod() == null);
        assertTrue(connectionurl.getUsername().equals("guest"));
        assertTrue(connectionurl.getPassword().equals("guest"));
        assertTrue(connectionurl.getVirtualHost().equals("/test"));

        assertTrue(connectionurl.getBrokerCount() == 1);

        BrokerDetails service = connectionurl.getBrokerDetails(0);

        assertTrue(service.getTransport().equals("tcp"));

        assertTrue(service.getHost().equals("localhost"));
        assertTrue(service.getPort() == 5672);
        assertEquals("jim",service.getProperty("foo"));
        assertEquals("bob",service.getProperty("bar"));
        assertEquals("jimmy",service.getProperty("fred"));

        assertTrue(connectionurl.getOption("routingkey").equals("jim"));
        assertTrue(connectionurl.getOption("timeout").equals("200"));
        assertTrue(connectionurl.getOption("immediatedelivery").equals("true"));
    }
View Full Code Here

        AMQConnection conn = null;
        try
        {
            BrokerDetails broker = getBroker();
            broker.setProperty(BrokerDetails.OPTIONS_RETRY, "1");
            ConnectionURL url = new AMQConnectionURL("amqp://guest:guest@clientid/test?brokerlist='"
                                     + broker
                                     + "'&defaultQueueExchange='test.direct'"
                                     + "&defaultTopicExchange='test.topic'"
                                     + "&temporaryQueueExchange='tmp.direct'"
                                     + "&temporaryTopicExchange='tmp.topic'");

            System.err.println(url.toString());
            conn = new AMQConnection(url);


            AMQSession sess = (AMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
View Full Code Here

    }

    public Connection getConnectionWithOptions(Map<String, String> options)
                throws URLSyntaxException, NamingException, JMSException
    {
        ConnectionURL curl = new AMQConnectionURL(getConnectionFactory().getConnectionURLString());
        for(Map.Entry<String,String> entry : options.entrySet())
        {
            curl.setOption(entry.getKey(), entry.getValue());
        }
        curl = new AMQConnectionURL(curl.toString());

        curl.setUsername(GUEST_USERNAME);
        curl.setPassword(GUEST_PASSWORD);
        return getConnection(curl);
    }
View Full Code Here

     * <p>
     * QPID-2697
     */
    public void testOptionToString() throws Exception
    {
        ConnectionURL url = new AMQConnectionURL("amqp://user:pass@temp/test?maxprefetch='12345'&brokerlist='tcp://localhost:5672'");

        assertTrue("String representation should contain options and values", url.toString().contains("maxprefetch='12345'"));
    }
View Full Code Here

    public void testHostNamesWithUnderScore() throws URLSyntaxException
    {
        String url = "amqp://guest:guest@clientid/test?brokerlist='tcp://under_score:6672'";

        ConnectionURL connectionurl = new AMQConnectionURL(url);

        assertTrue(connectionurl.getUsername().equals("guest"));
        assertTrue(connectionurl.getPassword().equals("guest"));
        assertTrue(connectionurl.getVirtualHost().equals("/test"));

        assertTrue(connectionurl.getBrokerCount() == 1);
        BrokerDetails service = connectionurl.getBrokerDetails(0);
        assertTrue(service.getTransport().equals("tcp"));
        assertTrue(service.getHost().equals("under_score"));
        assertTrue(service.getPort() == 6672);

        url = "amqp://guest:guest@clientid/test?brokerlist='tcp://under_score'";

        connectionurl = new AMQConnectionURL(url);

        assertTrue(connectionurl.getUsername().equals("guest"));
        assertTrue(connectionurl.getPassword().equals("guest"));
        assertTrue(connectionurl.getVirtualHost().equals("/test"));

        assertTrue(connectionurl.getBrokerCount() == 1);
        service = connectionurl.getBrokerDetails(0);
        assertTrue(service.getTransport().equals("tcp"));
        assertTrue(service.getHost().equals("under_score"));
        assertTrue(service.getPort() == 5672);
    }
View Full Code Here

    public void testRejectBehaviourPresent() throws Exception
    {
        String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'&rejectbehaviour='server'";

        ConnectionURL connectionURL = new AMQConnectionURL(url);

        assertTrue(connectionURL.getFailoverMethod() == null);
        assertTrue(connectionURL.getUsername().equals("guest"));
        assertTrue(connectionURL.getPassword().equals("guest"));
        assertTrue(connectionURL.getVirtualHost().equals("/test"));

        //check that the reject behaviour option is returned as expected
        assertEquals("Reject behaviour option was not as expected", "server",
                connectionURL.getOption(ConnectionURL.OPTIONS_REJECT_BEHAVIOUR));
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.client.AMQConnectionURL

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.