public class SipHeaderTest
{
@Test
public void testAddress() throws Exception
{
SipRequest request = new SipRequest();
Address address = new NameAddr("sip:foo");
try
{
request.addAddressHeader("From", address, false);
fail("system header");
}
catch (IllegalArgumentException e)
{
}
try
{
request.addAddressHeader("Expires", address, false);
fail("not address header");
}
catch (IllegalArgumentException e)
{
}
request.addAddressHeader("foo", address, false);
assertEquals("foo", ((SipURI) request.getAddressHeader("FOO").getURI()).getHost());
request.addAddressHeader("bar", new ReadOnlyAddress(address), false);
assertEquals("foo", ((SipURI) request.getAddressHeader("Bar").getURI()).getHost());
request.setAddressHeader("bar", new ReadOnlyAddress(address));
assertEquals("foo", ((SipURI) request.getAddressHeader("Bar").getURI()).getHost());
}