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"));
}
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());
}
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"));
}
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"));
}
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));
}