public void testPushRoute() throws Exception
{
SipRequest request = (SipRequest) getMessage(INVITE);
assertFalse(request.isNextHopStrictRouting());
request.pushRoute(new NameAddr("<sip:strictRouting@nexcom.fr>"));
assertEquals("sip:strictRouting@nexcom.fr", request.getRequestURI().toString());
assertEquals("<sips:ss2.biloxi.example.com>", request.getTopRoute().toString());
assertTrue(request.isNextHopStrictRouting());
request.pushRoute(new NameAddr("<sip:strictRouting-2@nexcom.fr>"));
assertEquals("sip:strictRouting-2@nexcom.fr", request.getRequestURI().toString());
ListIterator<Address> it = request.getAddressHeaders("route");
List<String> expected = new ArrayList<String>();
expected.add("<sip:strictRouting@nexcom.fr>");
expected.add("<sips:ss2.biloxi.example.com>");
assertAddress(expected, it);
assertTrue(request.isNextHopStrictRouting());
request.pushRoute(new NameAddr("<sip:looseRouting@nexcom.fr;lr>"));
assertEquals("sips:ss2.biloxi.example.com", request.getRequestURI().toString());
it = request.getAddressHeaders("route");
expected = new ArrayList<String>();
expected.add("<sip:looseRouting@nexcom.fr;lr>");
expected.add("<sip:strictRouting-2@nexcom.fr>");
expected.add("<sip:strictRouting@nexcom.fr>");
assertAddress(expected, it);
assertFalse(request.isNextHopStrictRouting());
request.pushRoute(new NameAddr("<sip:looseRouting-2@nexcom.fr;lr>"));
assertEquals("sips:ss2.biloxi.example.com", request.getRequestURI().toString());
it = request.getAddressHeaders("route");
expected = new ArrayList<String>();
expected.add("<sip:looseRouting-2@nexcom.fr;lr>");
expected.add("<sip:looseRouting@nexcom.fr;lr>");
expected.add("<sip:strictRouting-2@nexcom.fr>");
expected.add("<sip:strictRouting@nexcom.fr>");
assertAddress(expected, it);
assertFalse(request.isNextHopStrictRouting());
/*-----------*/
request = (SipRequest) getMessage(INVITE);
request.pushRoute(new NameAddr("<sip:looseRouting@nexcom.fr;lr>"));
assertEquals("sips:ss2.biloxi.example.com", request.getRequestURI().toString());
assertEquals("<sip:looseRouting@nexcom.fr;lr>", request.getTopRoute().toString());
assertFalse(request.isNextHopStrictRouting());
request.pushRoute(new NameAddr("<sip:strictRouting@nexcom.fr>"));
assertEquals("sip:strictRouting@nexcom.fr", request.getRequestURI().toString());
it = request.getAddressHeaders("route");
expected = new ArrayList<String>();
expected.add("<sip:looseRouting@nexcom.fr;lr>");
expected.add("<sips:ss2.biloxi.example.com>");
assertAddress(expected, it);
assertTrue(request.isNextHopStrictRouting());
request.pushRoute(new NameAddr("<sip:strictRouting-2@nexcom.fr>"));
assertEquals("sip:strictRouting-2@nexcom.fr", request.getRequestURI().toString());
it = request.getAddressHeaders("route");
expected = new ArrayList<String>();
expected.add("<sip:strictRouting@nexcom.fr>");
expected.add("<sip:looseRouting@nexcom.fr;lr>");