Ejemplo n.º 1
0
  @Test
  public void testGetFirstHeader() {
    Map<String, List<String>> headers = new HashMap<>();
    List<String> list = new ArrayList<>();
    list.add("value0");
    list.add("value1");
    list.add("value2");
    headers.put("header0", list);

    RequestContext ctx = new RequestContext("\basepath", "\requesturi", null, headers);

    assertNull(ctx.getFirstHeader(null));
    assertEquals("value0", ctx.getFirstHeader("header0"));
    assertNull(ctx.getFirstHeader("HEADER0"));
    assertNull(ctx.getFirstHeader("Header0"));
  }
Ejemplo n.º 2
0
  @Test
  public void testInexistentHeader() {
    Map<String, List<String>> headers = new HashMap<>();
    List<String> singleElementList = new ArrayList<>();
    singleElementList.add("value0");
    headers.put("header0", singleElementList);

    RequestContext ctx = new RequestContext("\basepath", "\requesturi", null, headers);

    assertTrue(ctx.getHeaders("header1").isEmpty());
    assertNull(ctx.getFirstHeader("header1"));
  }
Ejemplo n.º 3
0
  @Test
  public void testSingleValueHeader() {
    Map<String, List<String>> headers = new HashMap<>();
    List<String> singleElementList = new ArrayList<>();
    singleElementList.add("value0");
    headers.put("header0", singleElementList);

    RequestContext ctx = new RequestContext("\basepath", "\requesturi", null, headers);

    assertEquals(1, ctx.getHeaders("header0").size());
    assertEquals("value0", ctx.getHeaders("header0").get(0));
    assertEquals("value0", ctx.getFirstHeader("header0"));
  }
Ejemplo n.º 4
0
  @Test
  public void testMultiValueHeader() {
    Map<String, List<String>> headers = new HashMap<>();
    List<String> list = new ArrayList<>();
    list.add("value0");
    list.add("value1");
    list.add("value2");
    headers.put("header0", list);

    RequestContext ctx = new RequestContext("\basepath", "\requesturi", null, headers);

    assertEquals(3, ctx.getHeaders("header0").size());
    assertEquals("value0", ctx.getHeaders("header0").get(0));
    assertEquals("value1", ctx.getHeaders("header0").get(1));
    assertEquals("value2", ctx.getHeaders("header0").get(2));
    assertEquals("value0", ctx.getFirstHeader("header0"));
  }