Package org.eclipse.jetty.client

Examples of org.eclipse.jetty.client.ContentExchange


    }

    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
    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

    }

    public void testAuth() 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");
        contentExchange.setRequestHeader("Authorization", "Basic YWRtaW46YWRtaW4=");
        httpClient.send(contentExchange);

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

    @Override
    public void createJob(JobInfo request, final JobInfoResponseCallback callback) {
        // clear system fields if set
        sanitizeJobRequest(request);

        final ContentExchange post = getContentExchange(HttpMethods.POST, jobUrl(null));
        try {
            marshalRequest(objectFactory.createJobInfo(request), post, APPLICATION_XML_UTF8);
        } catch (SalesforceException e) {
            callback.onResponse(null, e);
            return;
View Full Code Here

        request.setSystemModstamp(null);
    }

    @Override
    public void getJob(String jobId, final JobInfoResponseCallback callback) {
        final ContentExchange get = getContentExchange(HttpMethods.GET, jobUrl(jobId));

        // make the call and parse the result
        doHttpRequest(get, new ClientResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException ex) {
View Full Code Here

    @Override
    public void closeJob(String jobId, final JobInfoResponseCallback callback) {
        final JobInfo request = new JobInfo();
        request.setState(JobStateEnum.CLOSED);

        final ContentExchange post = getContentExchange(HttpMethods.POST, jobUrl(jobId));
        try {
            marshalRequest(objectFactory.createJobInfo(request), post, APPLICATION_XML_UTF8);
        } catch (SalesforceException e) {
            callback.onResponse(null, e);
            return;
View Full Code Here

    @Override
    public void abortJob(String jobId, final JobInfoResponseCallback callback) {
        final JobInfo request = new JobInfo();
        request.setState(JobStateEnum.ABORTED);

        final ContentExchange post = getContentExchange(HttpMethods.POST, jobUrl(jobId));
        try {
            marshalRequest(objectFactory.createJobInfo(request), post, APPLICATION_XML_UTF8);
        } catch (SalesforceException e) {
            callback.onResponse(null, e);
            return;
View Full Code Here

    }

    @Override
    public void createBatch(InputStream batchStream, String jobId, ContentType contentTypeEnum,
        final BatchInfoResponseCallback callback) {
        final ContentExchange post = getContentExchange(HttpMethods.POST, batchUrl(jobId, null));
        post.setRequestContentSource(batchStream);
        post.setRequestContentType(getContentType(contentTypeEnum) + ";charset=" + StringUtil.__UTF8);

        // make the call and parse the result
        doHttpRequest(post, new ClientResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException ex) {
View Full Code Here

        });
    }

    @Override
    public void getBatch(String jobId, String batchId, final BatchInfoResponseCallback callback) {
        final ContentExchange get = getContentExchange(HttpMethods.GET, batchUrl(jobId, batchId));

        // make the call and parse the result
        doHttpRequest(get, new ClientResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException ex) {
View Full Code Here

        });
    }

    @Override
    public void getAllBatches(String jobId, final BatchInfoListResponseCallback callback) {
        final ContentExchange get = getContentExchange(HttpMethods.GET, batchUrl(jobId, null));

        // make the call and parse the result
        doHttpRequest(get, new ClientResponseCallback() {
            @Override
            public void onResponse(InputStream response, SalesforceException ex) {
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.