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