Search in sources :

Example 1 with ParameterizedHeader

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

the class HttpHeaderTest method testParameterizedHeader.

@Test
public void testParameterizedHeader() throws ParseException {
    ParameterizedHeader ph = new ParameterizedHeader("a");
    assertEquals("a", ph.getValue());
    ph = new ParameterizedHeader("a/b");
    assertEquals("a/b", ph.getValue());
    ph = new ParameterizedHeader("  a  /  b  ");
    assertEquals("a/b", ph.getValue());
    ph = new ParameterizedHeader("");
    assertEquals("", ph.getValue());
    ph = new ParameterizedHeader(";");
    assertEquals("", ph.getValue());
    assertEquals(0, ph.getParameters().size());
    ph = new ParameterizedHeader(";;;");
    assertEquals("", ph.getValue());
    assertEquals(0, ph.getParameters().size());
    ph = new ParameterizedHeader("  ;  ;  ;  ");
    assertEquals("", ph.getValue());
    assertEquals(0, ph.getParameters().size());
    ph = new ParameterizedHeader("a;x=1;y=2");
    assertEquals("a", ph.getValue());
    assertEquals(2, ph.getParameters().size());
    assertEquals("1", ph.getParameters().get("x"));
    assertEquals("2", ph.getParameters().get("y"));
    ph = new ParameterizedHeader("a ;  x=1  ;  y=2  ");
    assertEquals("a", ph.getValue());
    assertEquals(2, ph.getParameters().size());
    assertEquals("1", ph.getParameters().get("x"));
    assertEquals("2", ph.getParameters().get("y"));
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) Test(org.junit.Test)

Example 2 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testPutSingle.

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

Example 3 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testRemove.

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

Example 4 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testContainsKey.

/**
     * Test of containsKey method, of class ParametrizedHeadersMap.
     */
@Test
public void testContainsKey() throws Exception {
    map.add("foo", new ParameterizedHeader("bar"));
    assertTrue(map.containsKey("foo"));
    assertTrue(map.containsKey("FOO"));
    assertTrue(map.containsKey("Foo"));
    assertTrue(map.containsKey("fOo"));
    assertTrue(map.containsKey("foO"));
    assertTrue(!map.containsKey("bar"));
}
Also used : ParameterizedHeader(org.glassfish.jersey.message.internal.ParameterizedHeader) Test(org.junit.Test)

Example 5 with ParameterizedHeader

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

the class ParameterizedHeadersMapTest method testPutAll.

/**
     * Test of putAll method, of class ParametrizedHeadersMap.
     */
@Test
public void testPutAll() 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);
    assertTrue(map.isEmpty());
    map.putAll(all);
    assertTrue(!map.isEmpty());
    assertEquals(2, map.size());
    assertTrue(map.containsKey("foo"));
    assertTrue(map.containsKey("bar"));
    assertTrue(map.containsValue(fooValues));
    assertTrue(map.containsValue(barValues));
}
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)

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