Example usage for org.springframework.boot.test.web.client TestRestTemplate TestRestTemplate

List of usage examples for org.springframework.boot.test.web.client TestRestTemplate TestRestTemplate

Introduction

In this page you can find the example usage for org.springframework.boot.test.web.client TestRestTemplate TestRestTemplate.

Prototype

TestRestTemplate

Source Link

Usage

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.RibbonRetryIntegrationTestBase.java

@Before
public void setup() {
    RequestContext.getCurrentContext().clear();
    String uri = "/resetError";
    new TestRestTemplate().exchange("http://localhost:" + this.port + uri, HttpMethod.GET,
            new HttpEntity<>((Void) null), String.class);
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.RibbonRetryIntegrationTestBase.java

@Test
public void retryable() {
    String uri = "/retryable/everyothererror";
    ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + this.port + uri,
            HttpMethod.GET, new HttpEntity<>((Void) null), String.class);
    assertEquals(HttpStatus.OK, result.getStatusCode());
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.RibbonRetryIntegrationTestBase.java

@Test
public void retryableFourOFour() {
    String uri = "/retryable/404everyothererror";
    ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + this.port + uri,
            HttpMethod.GET, new HttpEntity<>((Void) null), String.class);
    assertEquals(HttpStatus.OK, result.getStatusCode());
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.RibbonRetryIntegrationTestBase.java

@Test
public void postRetryOK() {
    String uri = "/retryable/posteveryothererror";
    ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + this.port + uri,
            HttpMethod.POST, new HttpEntity<>((Void) null), String.class);
    assertEquals(HttpStatus.OK, result.getStatusCode());
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.RibbonRetryIntegrationTestBase.java

@Test
public void getRetryable() {
    String uri = "/getretryable/everyothererror";
    ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + this.port + uri,
            HttpMethod.GET, new HttpEntity<>((Void) null), String.class);
    assertEquals(HttpStatus.OK, result.getStatusCode());
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.RibbonRetryIntegrationTestBase.java

@Test
public void postNotRetryable() {
    String uri = "/getretryable/posteveryothererror";
    ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + this.port + uri,
            HttpMethod.POST, new HttpEntity<>((Void) null), String.class);
    assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, result.getStatusCode());
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.RibbonRetryIntegrationTestBase.java

@Test
public void disableRetry() {
    String uri = "/disableretry/everyothererror";
    ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + this.port + uri,
            HttpMethod.GET, new HttpEntity<>((Void) null), String.class);
    LOG.info("Response Body: " + result.getBody());
    assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, result.getStatusCode());
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.RibbonRetryIntegrationTestBase.java

@Test
public void globalRetryDisabled() {
    String uri = "/globalretrydisabled/everyothererror";
    ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + this.port + uri,
            HttpMethod.GET, new HttpEntity<>((Void) null), String.class);
    LOG.info("Response Body: " + result.getBody());
    assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, result.getStatusCode());
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.ZuulProxyTestBase.java

@Test
public void getOnSelfViaRibbonRoutingFilter() {
    ResponseEntity<String> result = new TestRestTemplate().exchange(
            "http://localhost:" + this.port + "/simple/local/1", HttpMethod.GET, new HttpEntity<>((Void) null),
            String.class);
    assertEquals(HttpStatus.OK, result.getStatusCode());
    assertEquals("Gotten 1!", result.getBody());
}

From source file:org.springframework.cloud.netflix.zuul.filters.route.support.ZuulProxyTestBase.java

@Test
public void deleteOnSelfViaSimpleHostRoutingFilter() {
    this.routes.addRoute("/self/**", "http://localhost:" + this.port + "/local");
    this.endpoint.reset();
    ResponseEntity<String> result = new TestRestTemplate().exchange("http://localhost:" + this.port + "/self/1",
            HttpMethod.DELETE, new HttpEntity<>((Void) null), String.class);
    assertEquals(HttpStatus.OK, result.getStatusCode());
    assertEquals("Deleted 1!", result.getBody());
}