Package org.eclipse.jetty.client

Examples of org.eclipse.jetty.client.ContentExchange


    public void testDisconnect() throws Exception {

        producer.send(session.createTextMessage("test"));
        HttpClient httpClient = new HttpClient();
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL("http://localhost:8080/message/test?readTimeout=1000&type=queue&clientId=test");
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        LOG.info("Received: [" + contentExchange.getResponseStatus() + "] " + contentExchange.getResponseContent());

        contentExchange = new ContentExchange();
        contentExchange.setMethod("POST");
        contentExchange.setURL("http://localhost:8080/message/test?clientId=test&action=unsubscribe");
        httpClient.send(contentExchange);
        contentExchange.waitForDone();

        httpClient.stop();


View Full Code Here


        getMessage(httpClient, urlGET, selector1, message1)//should receive message1
    }

    private void postMessage(HttpClient httpClient, String url, String properties, String message) throws Exception
    {
        ContentExchange contentExchange = new ContentExchange();
        contentExchange.setMethod("POST");
        contentExchange.setURL(url+"&"+properties);
        //contentExchange.setRequestHeader("accept", "text/xml");
        contentExchange.setRequestHeader("Content-Type","text/xml");
        contentExchange.setRequestContentSource(new ByteArrayInputStream(message.getBytes("UTF-8")));

        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        assertTrue("success status", HttpStatus.isSuccess(contentExchange.getResponseStatus()));
     }
View Full Code Here

        assertTrue("success status", HttpStatus.isSuccess(contentExchange.getResponseStatus()));
     }

    private void getMessage(HttpClient httpClient, String url, String selector, String expectedMessage) throws Exception
    {
        ContentExchange contentExchange = new ContentExchange(true);
        contentExchange.setURL(url);
        contentExchange.setRequestHeader("accept", "text/xml");
        contentExchange.setRequestHeader("Content-Type","text/xml");
        if(selector!=null)
        {
            contentExchange.setRequestHeader("selector", selector);
        }
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        assertTrue("success status", HttpStatus.isSuccess(contentExchange.getResponseStatus()));

        if(expectedMessage!=null)
        {
            assertNotNull(contentExchange.getResponseContent());
            assertEquals(expectedMessage, contentExchange.getResponseContent().trim());
        }
     }
View Full Code Here

        producer.send(session.createTextMessage("test"));
        LOG.info("message sent");

        HttpClient httpClient = new HttpClient();
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL("http://localhost:8080/message/test?readTimeout=1000&type=queue");
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        assertEquals("test", contentExchange.getResponseContent());
    }
View Full Code Here

    @Test(timeout = 60 * 1000)
    public void testSubscribeFirst() throws Exception {
        HttpClient httpClient = new HttpClient();
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL("http://localhost:8080/message/test?readTimeout=5000&type=queue");
        httpClient.send(contentExchange);

        Thread.sleep(1000);

        producer.send(session.createTextMessage("test"));
        LOG.info("message sent");

        contentExchange.waitForDone();
        assertEquals("test", contentExchange.getResponseContent());
    }
View Full Code Here

        producer.send(msg2);
        LOG.info("message 2 sent");

        HttpClient httpClient = new HttpClient();
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL("http://localhost:8080/message/test?readTimeout=1000&type=queue");
        contentExchange.setRequestHeader("selector", "test=2");
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        assertEquals("test2", contentExchange.getResponseContent());
    }
View Full Code Here

            message.setJMSCorrelationID(correlId);

            LOG.info("Sending: " + correlId);
            producer.send(message);

            ContentExchange contentExchange = new ContentExchange();
            contentExchange.setURL("http://localhost:8080/message/test?readTimeout=1000&type=queue&clientId=test");
            httpClient.send(contentExchange);
            contentExchange.waitForDone();
            LOG.info("Received: [" + contentExchange.getResponseStatus() + "] " + contentExchange.getResponseContent());
            assertEquals(200, contentExchange.getResponseStatus());
            assertEquals(correlId, contentExchange.getResponseContent());
        }
      httpClient.stop();
    }
View Full Code Here

    public void testDisconnect() throws Exception {

        producer.send(session.createTextMessage("test"));
        HttpClient httpClient = new HttpClient();
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL("http://localhost:8080/message/test?readTimeout=1000&type=queue&clientId=test");
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        LOG.info("Received: [" + contentExchange.getResponseStatus() + "] " + contentExchange.getResponseContent());

        contentExchange = new ContentExchange();
        contentExchange.setMethod("POST");
        contentExchange.setURL("http://localhost:8080/message/test?clientId=test&action=unsubscribe");
        httpClient.send(contentExchange);
        contentExchange.waitForDone();

        httpClient.stop();

        ObjectName query = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Subscription,destinationType=Queue,destinationName=test,*");
        Set<ObjectName> subs = broker.getManagementContext().queryNames(query, null);
View Full Code Here

    @Test(timeout = 15 * 1000)
    public void testPost() throws Exception {
        HttpClient httpClient = new HttpClient();
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setMethod("POST");
        contentExchange.setURL("http://localhost:8080/message/testPost?type=queue");
        httpClient.send(contentExchange);

        contentExchange.waitForDone();
        assertTrue("success status", HttpStatus.isSuccess(contentExchange.getResponseStatus()));

        ContentExchange contentExchange2 = new ContentExchange();
        contentExchange2.setURL("http://localhost:8080/message/testPost?readTimeout=1000&type=Queue");
        httpClient.send(contentExchange2);
        contentExchange2.waitForDone();
        assertTrue("success status", HttpStatus.isSuccess(contentExchange2.getResponseStatus()));
    }
View Full Code Here

    // test for https://issues.apache.org/activemq/browse/AMQ-3857
    @Test(timeout = 15 * 1000)
    public void testProperties() throws Exception {
        HttpClient httpClient = new HttpClient();
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setMethod("POST");
        contentExchange.setURL("http://localhost:8080/message/testPost?type=queue&property=value");
        httpClient.send(contentExchange);

        contentExchange.waitForDone();
        assertTrue("success status", HttpStatus.isSuccess(contentExchange.getResponseStatus()));

        ContentExchange contentExchange2 = new ContentExchange(true);
        contentExchange2.setURL("http://localhost:8080/message/testPost?readTimeout=1000&type=Queue");
        httpClient.send(contentExchange2);
        contentExchange2.waitForDone();
        assertTrue("success status", HttpStatus.isSuccess(contentExchange2.getResponseStatus()));

        HttpFields fields = contentExchange2.getResponseFields();
        assertNotNull("Headers Exist", fields);
        assertEquals("header value", "value", fields.getStringField("property"));
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.client.ContentExchange

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.