Example usage for org.springframework.http HttpMethod HEAD

List of usage examples for org.springframework.http HttpMethod HEAD

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod HEAD.

Prototype

HttpMethod HEAD

To view the source code for org.springframework.http HttpMethod HEAD.

Click Source Link

Usage

From source file:net.eusashead.hateoas.response.argumentresolver.EntityController.java

@RequestMapping(method = RequestMethod.OPTIONS)
public ResponseEntity<Entity> options(OptionsResponseBuilder<Entity> builder) {
    return builder.allow(HttpMethod.GET, HttpMethod.HEAD).entity(new Entity("foo")).build();
}

From source file:net.eusashead.hateoas.springhalbuilder.controller.CustomerController.java

@RequestMapping(method = RequestMethod.OPTIONS)
public ResponseEntity<Void> options(OptionsResponseBuilder<Void> builder) {
    return builder.allow(HttpMethod.GET, HttpMethod.HEAD).build();
}

From source file:org.androidannotations.test15.rest.HttpMethodServiceTest.java

@Test
@SuppressWarnings("unchecked")
public void useHeadHttpMethod() {
    HttpMethodsService_ service = new HttpMethodsService_(null);

    RestTemplate restTemplate = mock(RestTemplate.class);
    ResponseEntity<Object> response = mock(ResponseEntity.class);
    when(restTemplate.exchange(Matchers.anyString(), Matchers.<HttpMethod>eq(HttpMethod.HEAD),
            Matchers.<HttpEntity<?>>any(), Matchers.<Class<Object>>any())).thenReturn(response);

    service.setRestTemplate(restTemplate);

    service.head();//from   w w w .  ja  v a 2 s. com

    verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod>eq(HttpMethod.HEAD),
            Matchers.<HttpEntity<?>>any(), Matchers.<Class<Object>>any());
}

From source file:net.eusashead.hateoas.response.argumentresolver.AsyncEntityController.java

@RequestMapping(method = RequestMethod.OPTIONS)
public Callable<ResponseEntity<Entity>> options(final OptionsResponseBuilder<Entity> builder) {

    return new Callable<ResponseEntity<Entity>>() {

        @Override//from  w  w  w. java 2 s.  c  o m
        public ResponseEntity<Entity> call() throws Exception {
            return builder.allow(HttpMethod.GET, HttpMethod.HEAD).entity(new Entity("foo")).build();
        }
    };
}

From source file:net.eusashead.hateoas.springhalbuilder.controller.CustomerListController.java

@RequestMapping(method = RequestMethod.OPTIONS)
public ResponseEntity<Void> options(OptionsResponseBuilder<Void> builder) {
    return builder.allow(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.POST).build();
}

From source file:net.eusashead.hateoas.response.argumentresolver.ResponseBuilderMethodArgumentResolverITCase.java

@Test
public void testHead() throws Exception {
    this.mockMvc/* w w  w  . j a v  a 2 s .com*/
            .perform(request(HttpMethod.HEAD, "http://localhost/entity").contentType(MediaType.APPLICATION_JSON)
                    .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isNoContent())
            .andExpect(header().string("ETag", "W/\"b0c689597eb9dd62c0a1fb90a7c5c5a5\"")).andReturn();

}

From source file:net.eusashead.hateoas.conditional.interceptor.SyncTestControllerITCase.java

@Test
public void testConditionalHead() throws Exception {

    this.mockMvc// www.j av  a 2  s  .  c  om
            .perform(request(HttpMethod.HEAD, "http://localhost/sync/123")
                    .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk()).andExpect(header().string("ETag", "\"123456\""))
            .andExpect(content().string("")).andReturn();

    this.mockMvc
            .perform(request(HttpMethod.HEAD, "http://localhost/sync/123")
                    .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)
                    .header("If-None-Match", "\"123456\""))
            .andExpect(status().isNotModified()).andExpect(content().string("")).andReturn();
}

From source file:net.eusashead.hateoas.springhalbuilder.controller.CustomerControllerITCase.java

@Test
public void testHead() throws Exception {
    this.mockMvc/*from w  w w.  j a  v a 2 s  .  c o m*/
            .perform(request(HttpMethod.HEAD, "http://localhost/customer/1")
                    .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isNoContent()).andExpect(header().string("ETag", "\"3\""))
            .andExpect(header().string("Last-Modified", "Mon, 29 Jul 2013 23:00:00 GMT")).andReturn();
}

From source file:net.eusashead.hateoas.springhalbuilder.controller.OrderControllerITCase.java

@Test
public void testHead() throws Exception {
    this.mockMvc/*from   w w  w  . j a  v a  2s  . co m*/
            .perform(request(HttpMethod.HEAD, "http://localhost/order/1")
                    .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isNoContent()).andExpect(header().string("ETag", "\"1\""))
            .andExpect(header().string("Last-Modified", "Wed, 02 Jan 2013 00:00:00 GMT")).andReturn();
}

From source file:net.eusashead.hateoas.hal.response.impl.HalResponseBuilderITCase.java

@Test
public void testHead() throws Exception {
    // Execute controller method
    this.mockMvc/*from w  w w  . j a  va 2s .c om*/
            .perform(request(HttpMethod.HEAD, "http://localhost/order/123")
                    .contentType(HalHttpMessageConverter.HAL_JSON).accept(HalHttpMessageConverter.HAL_JSON))
            .andExpect(status().isNoContent()).andExpect(header().string("ETag", "W/\"123456789\""))
            .andReturn();
}