// is = new InputSource(new FileInputStream(xmlFileName));
is = new FileInputStream(xmlFileName);
}
String charSet = System.getProperty("charSet", null);
SqlInfo record = parser.parse(is, charSet);
SqlDescription description = record.getDescription();
assertNotNull("the description shall not be null", description);
assertNotNull("the identity shall not be null", description.getIdentity());
assertNotNull("the command shall not be null", description.getCommand());
assertEquals("the identity content is wrong", "EDDI", description.getIdentity());
assertEquals("the command content is wrong", "INSERT", description.getCommand());
// test the column descriptions
SqlColumn[] colDescriptions = description.getColumns();
assertEquals("the number of column descriptions is wrong", 4, colDescriptions.length);
String[] names = new String[] { "DATUM", "CPU", "COL1", "ICAO_ID"};
for (int i=0; i < colDescriptions.length; i++) {
log.info("test column description #" + i + " names: '" + names[i] + "' and '" + colDescriptions[i].getColName() + "'");
assertEquals("the name of the column description #" + i + " is wrong", names[i], colDescriptions[i].getColName());
}
List rows = record.getRows();
assertEquals("the number of rows is wrong", 3, rows.size());
int[] attr = new int[] { 2, 0, 1 };
for (int i=0; i < 3; i++) {
SqlRow row = (SqlRow)rows.get(i);
assertEquals("wrong number of columns for row '" + i+ "'", 4, row.getColumnNames().length);
assertEquals("wrong number of attributes for row '" + i+ "'", attr[i], row.getAttributeNames().length);
}
System.out.println("\n\nshould be:\n" + xml);
System.out.println("\nis:\n" + record.toXml(""));
assertXMLEqual("output xml is not the same as input xml", xml, record.toXml(""));
//assertXpathNotExists("/myRootTag/row[@num='0']", xml);
//assertXpathEvaluatesTo("CREATE", "/myRootTag/desc/command/text()", xml);
log.info("SUCCESS");
}