当前位置: 首页>>代码示例>>Java>>正文


Java ContentExchange.waitForDone方法代码示例

本文整理汇总了Java中org.eclipse.jetty.client.ContentExchange.waitForDone方法的典型用法代码示例。如果您正苦于以下问题:Java ContentExchange.waitForDone方法的具体用法?Java ContentExchange.waitForDone怎么用?Java ContentExchange.waitForDone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.client.ContentExchange的用法示例。


在下文中一共展示了ContentExchange.waitForDone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sentRequest

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
public static int sentRequest(final String url, final String method, final String content) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        contentExchange.setMethod(method);
        contentExchange.setRequestContentType(MediaType.APPLICATION_JSON);
        contentExchange.setRequestContent(new ByteArrayBuffer(content.getBytes("UTF-8")));
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL(url);
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        return contentExchange.getResponseStatus();
    } finally {
        httpClient.stop();
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:18,代码来源:RestfulTestsUtil.java

示例2: sentGetRequest

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
public static String sentGetRequest(final String url) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        contentExchange.setMethod("GET");
        contentExchange.setRequestContentType(MediaType.APPLICATION_JSON);
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL(url);
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        return contentExchange.getResponseContent();
    } finally {
        httpClient.stop();
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:17,代码来源:RestfulTestsUtil.java

示例3: sentRequest

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
private static ContentExchange sentRequest(final String content) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange result = new ContentExchange();
        result.setMethod("POST");
        result.setRequestContentType(MediaType.APPLICATION_JSON);
        result.setRequestContent(new ByteArrayBuffer(content.getBytes("UTF-8")));
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        result.setURL(URL);
        httpClient.send(result);
        result.waitForDone();
        return result;
    } finally {
        httpClient.stop();
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:18,代码来源:RestfulServerTest.java

示例4: sendRequestWithHeaders

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
private ContentExchange sendRequestWithHeaders(String url, Map<String, List<String>> headers, String method, String payload) throws IOException, InterruptedException {
  ContentExchange exchange = new ContentExchange(true);
  exchange.setURL(url);
  if (null != method) {
    exchange.setMethod(method);
  }
  if (null != payload) {
    exchange.setRequestContentSource(new ByteArrayInputStream(payload.getBytes()));
  }

  for (Entry<String, List<String>> e : headers.entrySet()) {
    for (String val : e.getValue()) {
      exchange.addRequestHeader(e.getKey(), val);
    }
  }

  client.send(exchange);
  exchange.waitForDone();
  return exchange;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:21,代码来源:ContextTest.java

示例5: getAllBooks

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Override
public Book[] getAllBooks() {
    try {
        ContentExchange contentExchange = new ContentExchange(true);
        contentExchange.setMethod("GET");
        contentExchange.setURL("http://" + host + ":" + port + "/get_books");
        httpClient.send(contentExchange);

        if (contentExchange.waitForDone() == HttpExchange.STATUS_COMPLETED) {
            return objectMapper.readValue(contentExchange.getResponseContent(), Book[].class);
        } else {
            throw new RuntimeException("Exception making request to retrieve all books");
        }
    } catch (Exception e) {
        throw new RuntimeException("Exception making request to retrieve all books", e);
    }
}
 
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:18,代码来源:BookServiceJettyHttpClient.java

示例6: getBook

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Override
public Book getBook(String id) {
    try {
        ContentExchange contentExchange = new ContentExchange(true);
        contentExchange.setMethod("GET");
        contentExchange.setURL("http://" + host + ":" + port + "/get_book" + "?id=" + id);
        httpClient.send(contentExchange);

        if (contentExchange.waitForDone() == HttpExchange.STATUS_COMPLETED) {
            return objectMapper.readValue(contentExchange.getResponseContent(), Book.class);
        } else {
            throw new RuntimeException("Exception making request to retrieve all books");
        }

    } catch (Exception e) {
        throw new RuntimeException("Exception making request to retrieve a book with id [" + id + "]", e);
    }
}
 
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:19,代码来源:BookServiceJettyHttpClient.java

示例7: notFoundXml

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Test
public void notFoundXml() throws Exception {
  ContentExchange exchange = sendRequest(FEED_URL + "('Z')");
  exchange.waitForDone();
  assertThat(exchange.getStatus(), is(HttpExchange.STATUS_COMPLETED));
  assertThat(exchange.getResponseStatus(), is(HttpStatus.NOT_FOUND_404));
  assertThat(exchange.getResponseFields().getStringField(HttpHeaders.CONTENT_TYPE), containsString(MediaType.APPLICATION_XML));
  assertThat(exchange.getResponseContent().length(), greaterThan(0));
  assertRegexMatches(exchange.getResponseContent(), ".*<code>NotFoundException</code>.*");
  assertRegexNotMatches(exchange.getResponseContent(), ".*<innererror>.+</innererror>.*");
}
 
开发者ID:teiid,项目名称:oreva,代码行数:12,代码来源:ErrorTest.java

示例8: notFoundJson

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Test
public void notFoundJson() throws Exception {
  ContentExchange exchange = sendRequest(FEED_URL + "('Z')?$format=jsonverbose");
  exchange.waitForDone();
  assertThat(exchange.getStatus(), is(HttpExchange.STATUS_COMPLETED));
  assertThat(exchange.getResponseStatus(), is(HttpStatus.NOT_FOUND_404));
  assertThat(exchange.getResponseFields().getStringField(HttpHeaders.CONTENT_TYPE), containsString(MediaType.APPLICATION_JSON));
  assertThat(exchange.getResponseContent().length(), greaterThan(0));
  assertRegexMatches(exchange.getResponseContent(), ".*\"code\"\\s*:\\s*\"NotFoundException\".*");
  assertRegexNotMatches(exchange.getResponseContent(), ".*\"innererror\"\\s*:\\s*\".+\".*");
}
 
开发者ID:teiid,项目名称:oreva,代码行数:12,代码来源:ErrorTest.java

示例9: badRequestXmlWithInnerError

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Test
public void badRequestXmlWithInnerError() throws Exception {
  simulateErrorResponseExtension();
  ContentExchange exchange = sendRequest(FEED_URL + "(1.2)");
  exchange.waitForDone();
  assertThat(exchange.getStatus(), is(HttpExchange.STATUS_COMPLETED));
  assertThat(exchange.getResponseStatus(), is(HttpStatus.NOT_FOUND_404));
  assertThat(exchange.getResponseFields().getStringField(HttpHeaders.CONTENT_TYPE), containsString(MediaType.APPLICATION_XML));
  assertThat(exchange.getResponseContent().length(), greaterThan(0));
  assertRegexMatches(exchange.getResponseContent(), ".*<code>NotFoundException</code>.*<innererror>.+</innererror>.*");
}
 
开发者ID:teiid,项目名称:oreva,代码行数:12,代码来源:ErrorTest.java

示例10: badRequestJsonWithInnerError

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Test
public void badRequestJsonWithInnerError() throws Exception {
  simulateErrorResponseExtension();
  ContentExchange exchange = sendRequest(FEED_URL + "(1.2)?$format=jsonverbose");
  exchange.waitForDone();
  assertThat(exchange.getStatus(), is(HttpExchange.STATUS_COMPLETED));
  assertThat(exchange.getResponseStatus(), is(HttpStatus.NOT_FOUND_404));
  assertThat(exchange.getResponseFields().getStringField(HttpHeaders.CONTENT_TYPE), containsString(MediaType.APPLICATION_JSON));
  assertThat(exchange.getResponseContent().length(), greaterThan(0));
  assertRegexMatches(exchange.getResponseContent(), ".*\"code\"\\s*:\\s*\"NotFoundException\".*\"innererror\"\\s*:\\s*\".+\".*");
}
 
开发者ID:teiid,项目名称:oreva,代码行数:12,代码来源:ErrorTest.java

示例11: sendRequest

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
/**
 * Helper method to send an HTTP request.
 */
protected ContentExchange sendRequest(String url) throws Exception {
  ContentExchange exchange = new ContentExchange(true);
  exchange.setURL(url);
  client.send(exchange);
  exchange.waitForDone();
  return exchange;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:11,代码来源:AbstractJettyHttpClientTest.java

示例12: readExchangeCallLog

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
static CallLog[] readExchangeCallLog(ObjectMapper mapper, ContentExchange exchange) {
  try {
    exchange.waitForDone();
    String responseJson = exchange.getResponseContent();
    return mapper.readValue(responseJson, CallLog[].class);
  } catch (Exception e) {
    return new CallLog[0];
  }
}
 
开发者ID:holdenk,项目名称:learning-spark-examples,代码行数:10,代码来源:ChapterSixExample.java

示例13: serviceUrlReturnsOkStatus

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Test
public void serviceUrlReturnsOkStatus() throws Exception {
  ContentExchange exchange = sendRequest(BASE_URI);
  exchange.waitForDone();
  verifyOkStatusIsReturned(exchange);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:7,代码来源:SmokeTest.java

示例14: metaDataUrlReturnsOkStatus

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Test
public void metaDataUrlReturnsOkStatus() throws Exception {
  ContentExchange exchange = sendRequest(META_DATA_URL);
  exchange.waitForDone();
  verifyOkStatusIsReturned(exchange);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:7,代码来源:SmokeTest.java

示例15: feedUrlReturnsOkStatus

import org.eclipse.jetty.client.ContentExchange; //导入方法依赖的package包/类
@Test
public void feedUrlReturnsOkStatus() throws Exception {
  ContentExchange exchange = sendRequest(FEED_URL);
  exchange.waitForDone();
  verifyOkStatusIsReturned(exchange);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:7,代码来源:SmokeTest.java


注:本文中的org.eclipse.jetty.client.ContentExchange.waitForDone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。