Example usage for org.springframework.http HttpHeaders size

List of usage examples for org.springframework.http HttpHeaders size

Introduction

In this page you can find the example usage for org.springframework.http HttpHeaders size.

Prototype

@Override
    public int size() 

Source Link

Usage

From source file:net.paslavsky.springrest.HttpHeadersHelperTest.java

@Test(dataProvider = "data")
public void testGetHttpHeaders(String header, Object value, String converted) throws Exception {
    Map<String, Integer> map = new HashMap<String, Integer>();
    map.put(header, 0);//from w  w w  .ja v  a  2 s .c o m
    HttpHeaders headers = helper.getHttpHeaders(map, new Object[] { value });
    Assert.assertNotNull(headers);
    Assert.assertEquals(headers.size(), 1);
    Assert.assertEquals(headers.get(header).get(0), converted);
}

From source file:io.neba.core.mvc.MultipartSlingHttpServletRequestTest.java

@Test
public void testGetMultipartHeaders() {
    String fileName = "test1";
    String contentType = "image/png";

    mockFileFieldWithContentType(fileName, contentType);

    HttpHeaders headers = this.testee.getMultipartHeaders(fileName);
    assertThat(headers.size()).isEqualTo(1);
    assertThat(headers.containsKey(MultipartSlingHttpServletRequest.CONTENT_TYPE)).isTrue();
    assertThat(headers.getFirst(MultipartSlingHttpServletRequest.CONTENT_TYPE)).isEqualTo(contentType);
}

From source file:com.monarchapis.driver.spring.rest.ApiErrorResponseEntityExceptionHandlerTest.java

@Test
public void testHttpMediaTypeNotSupportedException() {
    List<MediaType> supportedMediaTypes = Lists.newArrayList(MediaType.APPLICATION_XML,
            MediaType.APPLICATION_JSON);
    ResponseEntity<Object> response = //
            performTest(new HttpMediaTypeNotSupportedException(MediaType.TEXT_PLAIN, supportedMediaTypes), //
                    400, "mediaTypeNotSupported");
    HttpHeaders headers = response.getHeaders();
    assertEquals(1, headers.size());
    assertEquals(supportedMediaTypes, headers.getAccept());

    supportedMediaTypes = Collections.emptyList();
    response = //
            performTest(new HttpMediaTypeNotSupportedException(MediaType.TEXT_PLAIN, supportedMediaTypes), //
                    400, "mediaTypeNotSupported");
    headers = response.getHeaders();// w  ww  .ja va 2s . c o m
    assertEquals(0, headers.size());
}

From source file:com.monarchapis.driver.spring.rest.ApiErrorResponseEntityExceptionHandlerTest.java

@Test
public void testHttpRequestMethodNotSupported() {
    Set<String> allowedMethods = Sets.newLinkedHashSet(Lists.newArrayList("GET", "POST"));
    ResponseEntity<Object> response = //
            performTest(new HttpRequestMethodNotSupportedException("PUT", allowedMethods), //
                    400, "methodNotAllowed");
    HttpHeaders headers = response.getHeaders();
    assertEquals(1, headers.size());
    Set<String> actualAllow = new HashSet<String>();

    for (HttpMethod method : headers.getAllow()) {
        actualAllow.add(method.name());/*from w w  w . j  a  va2s .  co  m*/
    }
    assertEquals(allowedMethods, actualAllow);

    allowedMethods = Collections.emptySet();
    response = //
            performTest(new HttpRequestMethodNotSupportedException("PUT", allowedMethods), //
                    400, "methodNotAllowed");
    headers = response.getHeaders();
    assertEquals(0, headers.size());
}