Examples of postForEntity()


Examples of org.springframework.web.client.RestTemplate.postForEntity()

    RestTemplate template = new RestTemplate();

    ByteArrayOutputStream fileBytes = new ByteArrayOutputStream();
    IOUtils.copy(new FileInputStream(fileToUpload), fileBytes);

    ResponseEntity<String> entity = template.postForEntity(uploadURL,
        fileBytes.toByteArray(), String.class);

    assertEquals("Returned response: " + entity.getBody(), HttpStatus.OK,
        entity.getStatusCode());
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    person.setEmail("bot@gmail.com");
    person.setPassword("secret");
    person.setName("SuperBot");
    person.setDob(new Date());
   
    ResponseEntity<Person> responseEntity = rt.postForEntity(url , person, Person.class);
    person = responseEntity.getBody();
    Assert.assertNotNull(person);
    System.out.println(person.getId());
  }
 
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    String text = "how much wood would a woodchuck chuck if a woodchuck could chuck wood";
    int postAttempts = 0;
    while (postAttempts++ < 50) {
      Thread.sleep(100);
      try {
        ResponseEntity<?> entity = restTemplate.postForEntity("http://localhost:" + httpPort, text,
            String.class);
        assertEquals(HttpStatus.OK, entity.getStatusCode());
        break;
      }
      catch (Exception e) {
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    adapter.setOutputChannel(channel);
    adapter.start();
    RestTemplate template = new RestTemplate();
    URI uri1 = new URI("http://localhost:" + port + "/test1");
    URI uri2 = new URI("http://localhost:" + port + "/test2");
    ResponseEntity<?> response1 = template.postForEntity(uri1, "foo", Object.class);
    ResponseEntity<?> response2 = template.postForEntity(uri2, "bar", Object.class);
    assertEquals(HttpStatus.OK, response1.getStatusCode());
    assertEquals(HttpStatus.OK, response2.getStatusCode());
    assertTrue(latch.await(1, TimeUnit.SECONDS));
    assertEquals(2, messages.size());
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    adapter.start();
    RestTemplate template = new RestTemplate();
    URI uri1 = new URI("http://localhost:" + port + "/test1");
    URI uri2 = new URI("http://localhost:" + port + "/test2");
    ResponseEntity<?> response1 = template.postForEntity(uri1, "foo", Object.class);
    ResponseEntity<?> response2 = template.postForEntity(uri2, "bar", Object.class);
    assertEquals(HttpStatus.OK, response1.getStatusCode());
    assertEquals(HttpStatus.OK, response2.getStatusCode());
    assertTrue(latch.await(1, TimeUnit.SECONDS));
    assertEquals(2, messages.size());
    Message<?> message1 = messages.get(0);
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);

    HttpEntity<String> entity = new HttpEntity<String>("foo", headers);

    ResponseEntity<?> response = template.postForEntity(uri1, entity, HttpEntity.class);
    assertEquals(HttpStatus.OK, response.getStatusCode());

    assertTrue(latch.await(1, TimeUnit.SECONDS));
    assertEquals(1, messages.size());
    Message<?> message = messages.get(0);
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);

    HttpEntity<byte[]> entity = new HttpEntity<byte[]>("foo".getBytes(), headers);

    ResponseEntity<?> response = template.postForEntity(uri1, entity, HttpEntity.class);
    assertEquals(HttpStatus.OK, response.getStatusCode());

    assertTrue(latch.await(10, TimeUnit.SECONDS));
    assertEquals(1, messages.size());
    Message<?> message = messages.get(0);
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    NettyHttpInboundChannelAdapter adapter = new NettyHttpInboundChannelAdapter(port);
    adapter.setOutputChannel(channel);
    adapter.start();
    RestTemplate template = new RestTemplate();
    URI uri1 = new URI("http://localhost:" + port + "/test1");
    template.postForEntity(uri1, "foo", Object.class);

    adapter.stop();
  }

  @Test
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    }));
    adapter.start();
    RestTemplate template = new RestTemplate();
    URI uri1 = new URI("http://localhost:" + port + "/test1");
    URI uri2 = new URI("http://localhost:" + port + "/test2");
    ResponseEntity<?> response1 = template.postForEntity(uri1, "foo", Object.class);
    ResponseEntity<?> response2 = template.postForEntity(uri2, "bar", Object.class);
    assertEquals(HttpStatus.OK, response1.getStatusCode());
    assertEquals(HttpStatus.OK, response2.getStatusCode());
    assertTrue(latch.await(1, TimeUnit.SECONDS));
    // Ensure messages were received on the single thread with custom name
View Full Code Here

Examples of org.springframework.web.client.RestTemplate.postForEntity()

    adapter.start();
    RestTemplate template = new RestTemplate();
    URI uri1 = new URI("http://localhost:" + port + "/test1");
    URI uri2 = new URI("http://localhost:" + port + "/test2");
    ResponseEntity<?> response1 = template.postForEntity(uri1, "foo", Object.class);
    ResponseEntity<?> response2 = template.postForEntity(uri2, "bar", Object.class);
    assertEquals(HttpStatus.OK, response1.getStatusCode());
    assertEquals(HttpStatus.OK, response2.getStatusCode());
    assertTrue(latch.await(1, TimeUnit.SECONDS));
    // Ensure messages were received on the single thread with custom name
    assertEquals(Collections.singleton("executor-test"), threadNames);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.