protected void testParser(Class parserClass, String[] headers) {
try {
for (int i = 0; i < headers.length; i++) {
System.out.print(headers[i]);
HeaderParser hp = createParser(parserClass, headers[i]);
SIPHeader hdr = (SIPHeader) hp.parse();
if ( hdr instanceof SIPHeaderList<?> ) {
SIPHeaderList<?> list = (SIPHeaderList<?>) hdr;
assertNotNull( "Header should be added to list", list.getFirst() );
// JvB: Should be consistent, some parser classes override getFirst but leave list empty
assertTrue( "List should contain at least 1 header", list.size() > 0 );
}
hp = createParser(parserClass, ((SIPHeader) hdr.clone()).encode().trim() + "\n");
System.out.println("Encoded header = " + hdr.encode());
assertEquals(hdr, hp.parse());
}
} catch (java.text.ParseException ex) {
ex.printStackTrace();
fail(getClass().getName());