@Test
public void testLinkheader() throws Exception
{
LinkHeaderDelegate delegate = new LinkHeaderDelegate();
LinkHeader header = delegate.fromString("<http://example.com/TheBook/chapter2>; rel=\"previous\";\n" +
" title=\"previous chapter\"");
Assert.assertTrue(header.getLinksByTitle().containsKey("previous chapter"));
Assert.assertTrue(header.getLinksByRelationship().containsKey("previous"));
Assert.assertEquals(header.getLinksByTitle().get("previous chapter").getHref(), "http://example.com/TheBook/chapter2");
System.out.println(delegate.toString(header));
String str = delegate.toString(header);
header = delegate.fromString(str);
Assert.assertTrue(header.getLinksByTitle().containsKey("previous chapter"));
Assert.assertTrue(header.getLinksByRelationship().containsKey("previous"));
Assert.assertEquals(header.getLinksByTitle().get("previous chapter").getHref(), "http://example.com/TheBook/chapter2");
ClientRequest request = new ClientRequest(generateURL("/linkheader/str"));
request.addLink("previous chapter", "previous", "http://example.com/TheBook/chapter2", null);
ClientResponse response = request.post();
header = response.getLinkHeader();
Assert.assertNotNull(header);
Assert.assertTrue(header.getLinksByTitle().containsKey("previous chapter"));
Assert.assertTrue(header.getLinksByRelationship().containsKey("previous"));
Assert.assertEquals(header.getLinksByTitle().get("previous chapter").getHref(), "http://example.com/TheBook/chapter2");
}