Methods Summary |
---|
protected SipHeader | createSipHeader(java.lang.String headerName, java.lang.String headerParam)Creates SipHeader with the specified name and parameter.
SipHeader sh;
try {
sh = new SipHeader(headerName, headerParam);
} catch (java.lang.IllegalArgumentException e) {
sh = null;
fail("IllegalArgumentException: " + e);
} catch (Exception e) {
sh = null;
fail(e + " was caught");
}
return sh;
|
protected boolean | equalsIgnoreSpaces(java.lang.String str1, java.lang.String str2)Compares two strings ignoring the spaces and tabs around delimeters.
Comparision is case-insensitive.
String s1 = removeSpaces(str1);
String s2 = removeSpaces(str2);
// DEBUG: System.out.println(">>> s1 = '" + s1 + "'");
// DEBUG: System.out.println(">>> s2 = '" + s2 + "'");
return s1.equalsIgnoreCase(s2);
|
protected java.lang.String | removeNewLine(java.lang.String str)Cuts ending CRLF's if any.
int len = Separators.NEWLINE.length();
// Remove CRLF
while (str.endsWith(Separators.NEWLINE)) {
str = str.substring(0, str.length() - len);
}
return str;
|
protected java.lang.String | removeSpaces(java.lang.String str)Remove spaces/tabs surrounding delimeters in the string.
String strResult = "";
boolean delimeterOn = false;
char ch;
for (int i = 0; i < str.length(); i++) {
ch = str.charAt(i);
if (delimeterOn) {
if ((ch == ' ") || (ch == '\t")) {
continue; // skip the space/tab
}
delimeterOn = false;
}
if (ch == ';" || ch == '/") {
strResult = strResult.trim();
delimeterOn = true;
}
strResult += ch;
} // end for
return strResult;
|
protected boolean | testConstructorNegative(java.lang.String headerName, java.lang.String invalidParam)Checks if an exception is thrown when attempting to create
a header with invalid value.
SipHeader sh;
boolean result;
try {
sh = new SipHeader(headerName, invalidParam);
result = false;
fail("Constructor: IAE was not thrown!");
} catch (java.lang.IllegalArgumentException e) {
result = true;
} catch (Exception e) {
result = false;
fail(e + " was thrown instead of IAE.");
}
return result;
|
protected void | testSetValue(java.lang.String headerName, java.lang.String headerParam)Test for setValue() method of Header's subclasses.
SipHeader sh = createSipHeader(headerName, headerParam);
if (sh == null) {
return;
}
// Here the one common case is tested:
// if setValue() argument does include header's parameters,
// IllegalArgumentException must be generated.
try {
sh.setValue("test;param1=val1");
fail("setValue(): IAE was not thrown!");
} catch (IllegalArgumentException iae) {
// ok: IAE was thrown
} catch (Exception e) {
fail("setValue(): " + e + " was thrown instead of IAE!");
}
assertTrue(true);
|
protected void | testToString(java.lang.String headerName, java.lang.String headerParam)Test for toString() method of Header's subclasses.
SipHeader sh = createSipHeader(headerName, headerParam);
if (sh == null) {
return;
}
String strHeader = sh.toString();
// Skip CRLF
strHeader = removeNewLine(strHeader);
assertTrue("Invalid string representation: '" + strHeader + "'",
equalsIgnoreSpaces(strHeader, headerName + ": " + headerParam));
|