Package org.springframework.http.client

Examples of org.springframework.http.client.SimpleClientHttpRequestFactory


   * <p>This constructor uses a {@link SimpleClientHttpRequestFactory} in combination
   * with the given {@code AsyncTaskExecutor} for asynchronous execution.
   */
  public AsyncRestTemplate(AsyncListenableTaskExecutor taskExecutor) {
    Assert.notNull(taskExecutor, "AsyncTaskExecutor must not be null");
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
    requestFactory.setTaskExecutor(taskExecutor);
    this.syncTemplate = new RestTemplate(requestFactory);
    setAsyncRequestFactory(requestFactory);
  }
View Full Code Here


  public void shutdownContainer(String containerId) throws NoSuchContainerException, ContainerShutdownException {
    Container container = this.containerRepository.findOne(containerId);
    if (container != null) {
      String containerHost = container.getAttributes().getIp();
      String containerManagementPort = container.getAttributes().getManagementPort();
      RestTemplate restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory());
      try {
        restTemplate.postForObject(CONTAINER_HOST_URI_PROTOCOL + containerHost + ":"
            + containerManagementPort + managementContextPath + SHUTDOWN_ENDPOINT, Object.class,
            Object.class);
View Full Code Here

  private RestTemplate restTemplate;

  @Before
  public void setUpRestTemplate() throws Exception {
    SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory();
    // set this value as low as possible, since we're connecting locally
    simpleClientHttpRequestFactory.setConnectTimeout(500);
    simpleClientHttpRequestFactory.setReadTimeout(2000);
    restTemplate = new RestTemplate(simpleClientHttpRequestFactory);
  }
View Full Code Here

    runtimeOperations = new RuntimeTemplate(this);
    completionOperations = new CompletionTemplate(this);
  }

  public SpringXDTemplate(URI baseURI) {
    this(new SimpleClientHttpRequestFactory(), baseURI);
  }
View Full Code Here

    doTest(this.context, "/example/spring/hello");
  }

  private void doTest(AnnotationConfigEmbeddedWebApplicationContext context,
      String resourcePath) throws Exception {
    SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
    ClientHttpRequest request = clientHttpRequestFactory.createRequest(new URI(
        "http://localhost:" + context.getEmbeddedServletContainer().getPort()
            + resourcePath), HttpMethod.GET);
    ClientHttpResponse response = request.execute();
    try {
      String actual = StreamUtils.copyToString(response.getBody(),
View Full Code Here

  public Replicon(final String company, final String username,
      final String password) {

    this.company = company.toLowerCase();
    this.clientHttpRequestFactory = new SimpleClientHttpRequestFactory() {
      @Override
      protected void prepareConnection(HttpURLConnection connection,
          String httpMethod) throws IOException {
        super.prepareConnection(connection, httpMethod);
View Full Code Here

    assertContent("/controller", ports.get().management, null);
    assertContent("/endpoint", ports.get().management, null);
  }

  public void assertContent(String url, int port, Object expected) throws Exception {
    SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
    ClientHttpRequest request = clientHttpRequestFactory.createRequest(new URI(
        "http://localhost:" + port + url), HttpMethod.GET);
    try {
      ClientHttpResponse response = request.execute();
      try {
        String actual = StreamUtils.copyToString(response.getBody(),
View Full Code Here

      throw ex;
    }
  }

  public boolean hasHeader(String url, int port, String header) throws Exception {
    SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
    ClientHttpRequest request = clientHttpRequestFactory.createRequest(new URI(
        "http://localhost:" + port + url), HttpMethod.GET);
    ClientHttpResponse response = request.execute();
    return response.getHeaders().containsKey(header);
  }
View Full Code Here

    String proxyHost = properties.getProperty("http.proxyHost");
    int proxyPort = properties.containsKey("http.proxyPort") ? Integer.valueOf(properties.getProperty("http.proxyPort")) : 80;
    if (HTTP_COMPONENTS_AVAILABLE) {
      return HttpComponentsClientRequestFactoryCreator.createRequestFactory(proxyHost, proxyPort);
    } else {
      SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
      if (proxyHost != null) {
        requestFactory.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)));
      }
      return requestFactory;
    }
  }
View Full Code Here

  public void buildAuthorizationHeaderValue_Request() throws Exception {
    SigningSupport signingUtils = new SigningSupport();
    signingUtils.setTimestampGenerator(new MockTimestampGenerator(123456789, 987654321));
    URI uri = URIBuilder.fromUri("http://example.com/request").queryParam("b5", "=%3D").queryParam("a3", "a").queryParam("c@", "")
      .queryParam("a2", "r b").build();
    HttpRequest request = new SimpleClientHttpRequestFactory().createRequest(uri, HttpMethod.POST);
    request.getHeaders().setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    String authorizationHeader = signingUtils.buildAuthorizationHeaderValue(request, "c2&a3=2+q".getBytes(), new OAuth1Credentials("9djdj82h48djs9d2", "consumer_secret", "kkk9d7dh3k39sjv7", "token_secret"));
    assertAuthorizationHeader(authorizationHeader, "qz6HT3AG1Z9J%2BP99O4HeMtClGeY%3D");
  }
View Full Code Here

TOP

Related Classes of org.springframework.http.client.SimpleClientHttpRequestFactory

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.