test.unit.gov.nist.javax.sip.address.JainSipUriTest Maven / Gradle / Ivy
package test.unit.gov.nist.javax.sip.address;
import javax.sip.address.SipURI;
/**
* Tests from RFC3261 §19.1.4 URI Comparison
*/
public class JainSipUriTest extends junit.framework.TestCase {
static String[][] equal = {
// should be escaped
{"sip:%[email protected];transport=TCP", "sip:[email protected];Transport=tcp"},
{"sip:[email protected]", "sip:[email protected];newparam=5"},
{"sip:[email protected]", "sip:[email protected];lr"},
{"sip:[email protected];security=on", "sip:[email protected];newparam=5"},
{"sip:[email protected]?subject=project%20x&priority=urgent", "sip:[email protected]?priority=urgent&subject=project%20x"},
{"sip:[email protected]", "sip:[email protected];security=on"},
{"sip:[email protected];security=on", "sip:[email protected]"},
{"sip:biloxi.com;transport=tcp;method=REGISTER?to=sip:bob%40biloxi.com","sip:biloxi.com;method=REGISTER;transport=tcp?to=sip:bob%40biloxi.com"}
};
static String[][] different = {
{"sip:[email protected]", "sip:[email protected]"},
{"sip:[email protected]", "sip:[email protected]:5060"},
{"sip:[email protected];newparam=6", "sip:[email protected];newparam=5"},
{"sip:[email protected]?Subject=next%20meeting", "sip:[email protected]?Subject=another%20meeting"},
{"sip:[email protected]", "sip:[email protected];transport=tcp"},
{"sip:[email protected]", "sip:[email protected]?Subject=next%20meeting"},
{"sip:[email protected];security=off", "sip:[email protected];security=on"}
};
private javax.sip.SipFactory sipFactory;
public void setUp() {
sipFactory = javax.sip.SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
}
private SipURI sipUri(String uri) throws Exception {
return (SipURI) sipFactory.createAddressFactory().createURI(uri);
}
public void testEqual() throws Exception {
for (int i = 0; i < equal.length; i++) {
SipURI uri1 = sipUri(equal[i][0]);
SipURI uri2 = sipUri(equal[i][1]);
assertTrue(uri1 + " is different than " + uri2, uri1.equals(uri2));
assertTrue(uri2 + " is different than " + uri1, uri2.equals(uri1));
}
}
public void testDifferent() throws Exception {
for (int i = 0; i < different.length; i++) {
SipURI uri1 = sipUri(different[i][0]);
SipURI uri2 = sipUri(different[i][1]);
assertFalse(uri1 + " is the same as " + uri2, uri1.equals(uri2));
assertFalse(uri2 + " is the same as " + uri1, uri2.equals(uri1));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy