Search in sources :

Example 6 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testEntrySet.

/**
     * Test of entrySet method, of class ParametrizedHeadersMap.
     */
@Test
public void testEntrySet() throws Exception {
    List<ParameterizedHeader> valuesFoo = new ArrayList<>();
    valuesFoo.add(new ParameterizedHeader("foo1"));
    valuesFoo.add(new ParameterizedHeader("foo2"));
    map.put("foo", valuesFoo);
    List<ParameterizedHeader> valuesBar = new ArrayList<>();
    valuesBar.add(new ParameterizedHeader("bar1"));
    valuesBar.add(new ParameterizedHeader("bar2"));
    map.put("bar", valuesBar);
    Set<Entry<String, List<ParameterizedHeader>>> entrySet = map.entrySet();
    assertEquals(2, entrySet.size());
// TODO - detailed tests for the HeadersEntries methods
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testSize.

/**
     * Test of size method, of class ParametrizedHeadersMap.
     */
@Test
public void testSize() throws Exception {
    assertEquals(0, map.size());
    map.add("foo", new ParameterizedHeader("bar"));
    assertEquals(1, map.size());
    map.add("foo", new ParameterizedHeader("arg"));
    assertEquals(1, map.size());
    map.add("baz", new ParameterizedHeader("bop"));
    assertEquals(2, map.size());
    map.remove("baz");
    assertEquals(1, map.size());
    map.remove("foo");
    assertEquals(0, map.size());
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) Test(org.junit.Test)

Example 8 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testContainsValue.

/**
     * Test of containsValue method, of class ParametrizedHeadersMap.
     */
@Test
public void testContainsValue() throws Exception {
    List<ParameterizedHeader> values = new ArrayList<>();
    values.add(new ParameterizedHeader("bar"));
    values.add(new ParameterizedHeader("bop"));
    map.put("foo", values);
    assertTrue(map.containsValue(values));
    map.clear();
    assertTrue(!map.containsValue(values));
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testValues.

/**
     * Test of values method, of class ParametrizedHeadersMap.
     */
@Test
public void testValues() throws Exception {
    Map<String, List<ParameterizedHeader>> all = new HashMap<>();
    List<ParameterizedHeader> fooValues = new ArrayList<>();
    fooValues.add(new ParameterizedHeader("foo1"));
    fooValues.add(new ParameterizedHeader("foo2"));
    all.put("foo", fooValues);
    List<ParameterizedHeader> barValues = new ArrayList<>();
    barValues.add(new ParameterizedHeader("bar1"));
    barValues.add(new ParameterizedHeader("bar2"));
    all.put("bar", barValues);
    map.putAll(all);
    Collection<List<ParameterizedHeader>> values = map.values();
    assertNotNull(values);
    assertEquals(2, values.size());
    List[] array = new List[2];
    array = values.toArray(array);
    if (array[0] == fooValues) {
        assertTrue(array[1] == barValues);
    } else if (array[0] == barValues) {
        assertTrue(array[1] == fooValues);
    } else {
        fail("Returned values were corrupted");
    }
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 10 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testClear.

/**
     * Test of clear method, of class ParametrizedHeadersMap.
     */
@Test
public void testClear() throws Exception {
    map.add("foo", new ParameterizedHeader("bar"));
    map.add("baz", new ParameterizedHeader("bop"));
    assertTrue(!map.isEmpty());
    assertEquals(2, map.size());
    map.clear();
    assertEquals(0, map.size());
    assertTrue(map.isEmpty());
}
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