Example usage for org.apache.http.client.methods HttpUriRequest getLastHeader

List of usage examples for org.apache.http.client.methods HttpUriRequest getLastHeader

Introduction

In this page you can find the example usage for org.apache.http.client.methods HttpUriRequest getLastHeader.

Prototype

Header getLastHeader(String str);

Source Link

Usage

From source file:com.klarna.checkout.ConnectorGETTest.java

/**
 * Test to ensure the resource parses the payload as expected.
 *
 * @throws Exception but not really/* w ww .j  a  va  2s  . c o m*/
 */
@Test
public void testApplyGet200() throws Exception {

    transport.addResponse(new HTTPResponseStub(200, new HashMap<String, String>(), payloadJson));

    HttpResponse result = conn.apply("GET", this.resource, null);

    assertEquals("HTTP Response Code", 200, result.getStatusLine().getStatusCode());

    assertEquals("GET", this.transport.getHttpUriRequest().getMethod());

    HttpUriRequest req = transport.getHttpUriRequest();
    assertNotNull("UserAgent", req.getLastHeader("UserAgent"));

    verify(this.resource).parse(this.payloadMap);
}

From source file:com.klarna.checkout.ConnectorGETTest.java

/**
 * Test to ensure headers are set./*  w  w  w .ja v a2s  .  c o m*/
 *
 * @throws Exception should never occur.
 */
@Test
public void testHeadersSet() throws Exception {
    String authorization = "Klarna ".concat(digestString);

    String contentType = "klarna/json";

    when(resource.getContentType()).thenReturn(contentType);

    transport.addResponse(new HTTPResponseStub(200, new HashMap<String, String>(), payloadJson));

    conn.apply("GET", resource, null);
    HttpUriRequest req = transport.getHttpUriRequest();
    assertNotNull("Authorization header set", req.getLastHeader("Authorization"));
    assertEquals("Authorization", authorization, req.getLastHeader("Authorization").getValue());

    assertEquals("Accept header", contentType, req.getLastHeader("Accept").getValue());

    assertNotNull("UserAgent", req.getLastHeader("UserAgent"));

    verify(digest, times(1)).create("");
}

From source file:com.klinker.android.spotify.loader.OAuthTokenRefresherTest.java

@Test
public void test_addAuthHeader() {
    HttpUriRequest post = new HttpPost("http://www.google.com");
    post = refresher.addAuthHeader(post);

    assertNotNull(post.getFirstHeader("Authorization"));
    assertEquals("application/x-www-form-urlencoded", post.getLastHeader("Content-Type").getValue());
}