List of usage examples for org.apache.http.message BasicHeader getValue
public String getValue()
From source file:io.cloudslang.content.httpclient.build.HeadersBuilderTest.java
@Test public void build() { ContentType contentType = ContentType.parse(CONTENT_TYPE); List<Header> headers = new HeadersBuilder().setHeaders("header1:value1\nheader2:value2") .setContentType(contentType).buildHeaders(); assertEquals(3, headers.size());/* ww w. j av a2 s . co m*/ assertThat(headers.get(0), instanceOf(BufferedHeader.class)); BufferedHeader basicHeader = (BufferedHeader) headers.get(1); assertEquals("header2", basicHeader.getName()); assertEquals("value2", basicHeader.getValue()); BasicHeader contentTypeHeader = (BasicHeader) headers.get(2); assertEquals("Content-Type", contentTypeHeader.getName()); assertEquals(CONTENT_TYPE, contentTypeHeader.getValue()); }
From source file:io.github.jonestimd.neo4j.client.http.ApacheHttpDriverTest.java
@Test public void delete() throws Exception { BasicHeader header = new BasicHeader("", "header-value"); StringEntity responseEntity = new StringEntity("response entity"); when(client.execute(any(HttpUriRequest.class))).thenReturn(httpResponse); when(httpResponse.getFirstHeader(anyString())).thenReturn(null, header); when(httpResponse.getEntity()).thenReturn(responseEntity); HttpResponse response = driver.delete(uri); verify(client).execute(deleteCaptor.capture()); HttpDelete delete = deleteCaptor.getValue(); assertThat(delete.getURI().toString()).isEqualTo(uri); assertThat(response.getHeader("header1")).isNull(); assertThat(response.getHeader("header2")).isEqualTo(header.getValue()); verify(httpResponse).getFirstHeader("header1"); verify(httpResponse).getFirstHeader("header2"); assertThat(getContent(response.getEntityContent())).isEqualTo("response entity"); response.close();//from ww w. ja v a 2 s . c om verify(httpResponse).close(); }
From source file:io.github.jonestimd.neo4j.client.http.ApacheHttpDriverTest.java
@Test public void post() throws Exception { BasicHeader header = new BasicHeader("", "header-value"); StringEntity responseEntity = new StringEntity("response entity"); when(client.execute(any(HttpUriRequest.class), any(HttpClientContext.class))).thenReturn(httpResponse); when(httpResponse.getFirstHeader(anyString())).thenReturn(null, header); when(httpResponse.getEntity()).thenReturn(responseEntity); HttpResponse response = driver.post(uri, "json entity"); verify(client).execute(postCaptor.capture(), same(context)); HttpPost post = postCaptor.getValue(); assertThat(post.getURI().toString()).isEqualTo(uri); assertThat(post.getEntity().getContentType().getValue()).isEqualTo(ContentType.APPLICATION_JSON.toString()); assertThat(getContent(post.getEntity().getContent())).isEqualTo("json entity"); assertThat(response.getHeader("header1")).isNull(); assertThat(response.getHeader("header2")).isEqualTo(header.getValue()); verify(httpResponse).getFirstHeader("header1"); verify(httpResponse).getFirstHeader("header2"); assertThat(getContent(response.getEntityContent())).isEqualTo("response entity"); response.close();//from www .j ava 2s.c o m verify(httpResponse).close(); }