Address contact = request.getAddressHeader("Contact");
assertEquals("<sip:127.0.0.1:5060;transport=TCP>", contact.toString());
contact.setDisplayName("Bob");
contact.setParameter("isfocus", "");
assertEquals("Bob", contact.getDisplayName());
SipURI uri = (SipURI) contact.getURI();
uri.setUser("bob");
assertEquals("bob", uri.getUser());
try { uri.setHost("bad"); fail(); } catch (IllegalStateException e) {}
try { uri.setLrParam(true); fail(); } catch (IllegalStateException e) {}
try { uri.setMAddrParam("bad"); fail(); } catch (IllegalStateException e) {}
try { uri.setMethodParam("Bad"); fail(); } catch (IllegalStateException e) {}
try { uri.setTTLParam(2); fail(); } catch (IllegalStateException e) {}
try { uri.setParameter("lr", ""); fail(); } catch (IllegalStateException e) {}
try { uri.removeParameter("Maddr"); fail(); } catch (IllegalStateException e) {}
uri.setParameter("transport", "UDP");
assertEquals("UDP", uri.getParameter("transport"));
assertEquals("Bob <sip:bob@127.0.0.1:5060;transport=UDP>;isfocus", contact.toString());
// Full read-only on committed
request.setCommitted(true);
contact = request.getAddressHeader("Contact");
uri = (SipURI) contact.getURI();
try { contact.setDisplayName("bad"); fail(); } catch (IllegalStateException e) {}
try { uri.setUser("bad"); fail(); } catch (IllegalStateException e) {}
// Full writable on REGISTER
request = (SipRequest) getMessage(REGISTER);
contact = request.getAddressHeader("Contact");
uri = (SipURI) contact.getURI();
contact.setDisplayName("Bob");
uri.setHost("nexcom.fr");
uri.setPort(5062);
uri.removeParameter("transport");
uri.setUser("bob");
assertEquals("Bob <sip:bob@nexcom.fr:5062>", contact.toString());
}