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

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

Introduction

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

Prototype

public void setMethod(HttpMethod httpMethod) 

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);
    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();//ww w  .j  av  a  2 s.  c o m

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