public void testPrimatives() throws Exception {
jocl.startDocument();
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","jocl","jocl",new AttributesImpl());
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","true");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","boolean","boolean",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","boolean","boolean");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","1");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","byte","byte",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","byte","byte");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","c");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","char","char",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","char","char");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","2.0");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","double","double",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","double","double");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","3.0");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","float","float",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","float","float");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","5");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","int","int",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","int","int");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","7");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","long","long");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","11");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","short","short",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","short","short");
}
{
AttributesImpl attr = new AttributesImpl();
attr.addAttribute("http://apache.org/xml/xmlns/jakarta/commons/jocl","value","value","CDATA","All your base are belong to us.");
jocl.startElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","string","string",attr);
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","string","string");
}
jocl.endElement("http://apache.org/xml/xmlns/jakarta/commons/jocl","jocl","jocl");
jocl.endDocument();
assertEquals(Boolean.TYPE,jocl.getType(0));
assertEquals(Byte.TYPE,jocl.getType(1));
assertEquals(Character.TYPE,jocl.getType(2));
assertEquals(Double.TYPE,jocl.getType(3));
assertEquals(Float.TYPE,jocl.getType(4));
assertEquals(Integer.TYPE,jocl.getType(5));
assertEquals(Long.TYPE,jocl.getType(6));
assertEquals(Short.TYPE,jocl.getType(7));
assertEquals(String.class,jocl.getType(8));
assertEquals(Boolean.TRUE,jocl.getValue(0));
assertEquals(new Byte("1"),jocl.getValue(1));
assertEquals(new Character('c"),jocl.getValue(2));
assertEquals(new Double("2.0"),jocl.getValue(3));
assertEquals(new Float("3.0"),jocl.getValue(4));
assertEquals(new Integer("5"),jocl.getValue(5));
assertEquals(new Long("7"),jocl.getValue(6));
assertEquals(new Short("11"),jocl.getValue(7));
assertEquals("All your base are belong to us.",jocl.getValue(8));
}
|