Search in sources :

Example 11 with ParameterizedHeader

use of org.glassfish.jersey.message.internal.ParameterizedHeader in project jersey by jersey.

the class ParameterizedHeadersMapTest method testGet.

/**
     * Test of get method, of class ParametrizedHeadersMap.
     */
@Test
public void testGet() throws Exception {
    map.add("foo", new ParameterizedHeader("bar"));
    assertNotNull(map.get("foo"));
    assertNotNull(map.get("FOO"));
    assertNotNull(map.get("Foo"));
    assertNotNull(map.get("fOo"));
    assertNotNull(map.get("foO"));
    assertNull(map.get("bar"));
    List<ParameterizedHeader> values = map.get("foo");
    assertNotNull(values);
    assertEquals(1, values.size());
    assertEquals("bar", values.get(0).getValue());
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) Test(org.junit.Test)

Example 12 with ParameterizedHeader

use of org.glassfish.jersey.message.internal.ParameterizedHeader in project jersey by jersey.

the class ParameterizedHeadersMapTest method testPut.

/**
     * Test of put method, of class ParametrizedHeadersMap.
     */
@Test
public void testPut() throws Exception {
    List<ParameterizedHeader> fooValues1 = new ArrayList<>();
    fooValues1.add(new ParameterizedHeader("foo1"));
    fooValues1.add(new ParameterizedHeader("foo2"));
    assertNull(map.get("foo"));
    map.put("foo", fooValues1);
    assertTrue(map.containsKey("foo"));
    assertTrue(map.containsValue(fooValues1));
    assertTrue(map.get("foo") == fooValues1);
    List<ParameterizedHeader> fooValues2 = new ArrayList<>();
    fooValues2.add(new ParameterizedHeader("foo3"));
    fooValues2.add(new ParameterizedHeader("foo4"));
    map.put("foo", fooValues2);
    assertEquals(1, map.size());
    assertTrue(map.containsKey("foo"));
    assertTrue(!map.containsValue(fooValues1));
    assertTrue(map.containsValue(fooValues2));
    assertTrue(map.get("foo") == fooValues2);
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 13 with ParameterizedHeader

use of org.glassfish.jersey.message.internal.ParameterizedHeader in project jersey by jersey.

the class ParameterizedHeadersMapTest method testEqualsAndHashCode.

@Test
public void testEqualsAndHashCode() throws Exception {
    ParameterizedHeadersMap map2 = new ParameterizedHeadersMap();
    List<ParameterizedHeader> valuesFoo = new ArrayList<>();
    valuesFoo.add(new ParameterizedHeader("foo1"));
    valuesFoo.add(new ParameterizedHeader("foo2"));
    map.put("foo", valuesFoo);
    map2.put("foo", valuesFoo);
    List<ParameterizedHeader> valuesBar = new ArrayList<>();
    valuesBar.add(new ParameterizedHeader("bar1"));
    valuesBar.add(new ParameterizedHeader("bar2"));
    map.put("bar", valuesBar);
    map2.put("bar", valuesBar);
    assertTrue(map.equals(map2));
    assertTrue(map2.equals(map));
    assertEquals(map.hashCode(), map2.hashCode());
    map2.remove("bar");
    assertTrue(!map.equals(map2));
    assertTrue(!map2.equals(map));
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 14 with ParameterizedHeader

use of org.glassfish.jersey.message.internal.ParameterizedHeader in project jersey by jersey.

the class ParameterizedHeadersMapTest method testAdd.

/**
     * Test of add method, of class ParametrizedHeadersMap.
     */
@Test
public void testAdd() throws Exception {
    map.add("foo", new ParameterizedHeader("bar"));
    List<ParameterizedHeader> values = map.get("foo");
    assertNotNull(values);
    assertEquals(1, values.size());
    assertEquals("bar", values.get(0).getValue());
    map.add("foo", new ParameterizedHeader("baz"));
    assertEquals(1, map.size());
    values = map.get("foo");
    assertEquals(2, values.size());
    assertEquals("bar", values.get(0).getValue());
    assertEquals("baz", values.get(1).getValue());
    map.add("bop", new ParameterizedHeader("boo"));
    assertEquals(2, map.size());
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) Test(org.junit.Test)

Example 15 with ParameterizedHeader

use of org.glassfish.jersey.message.internal.ParameterizedHeader in project jersey by jersey.

the class ParameterizedHeadersMapTest method testParameters.

@Test
public void testParameters() throws Exception {
    ParameterizedHeader header;
    header = new ParameterizedHeader("foo");
    assertEquals("foo", header.getValue());
    assertEquals(0, header.getParameters().size());
    header = new ParameterizedHeader("foo;bar=baz;bop=abc");
    assertEquals("foo", header.getValue());
    assertEquals(2, header.getParameters().size());
    assertEquals("baz", header.getParameters().get("bar"));
    assertEquals("abc", header.getParameters().get("bop"));
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) Test(org.junit.Test)

Aggregations

ParameterizedHeader (org.glassfish.jersey.message.internal.ParameterizedHeader)18 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)2 List (java.util.List)2 Entry (java.util.Map.Entry)1