Example usage for org.springframework.mock.http.client MockClientHttpRequest setURI

List of usage examples for org.springframework.mock.http.client MockClientHttpRequest setURI

Introduction

In this page you can find the example usage for org.springframework.mock.http.client MockClientHttpRequest setURI.

Prototype

public void setURI(URI uri) 

Source Link

Usage

From source file:com.gopivotal.cla.github.RateLimitingClientHttpRequestInterceptorTest.java

@Test
public void block() throws InterruptedException, IOException {
    CountDownLatch latch = new CountDownLatch(1);

    MockClientHttpRequest request = new MockClientHttpRequest();
    MockClientHttpResponse response = new MockClientHttpResponse(new byte[0], HttpStatus.OK);
    ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class);

    request.setMethod(HttpMethod.GET);/*from   www. ja va 2  s  . c o m*/
    request.setURI(URI.create("http://localhost"));

    when(execution.execute(request, new byte[0])).thenReturn(response);

    new Thread(new Trigger(this.interceptor, latch)).start();
    latch.await();

    this.interceptor.intercept(request, new byte[0], execution);
}