public void testToByteFromNumber() throws Exception { argTag.setType("byte"); argTag.setValue(new Double(17.3d)); argTag.doTag(getXMLOutput()); assertEquals(Byte.TYPE,parentTag.getType(0)); assertEquals(new Byte((byte)17),parentTag.getValue(0)); }
public void testToShortFromNumber() throws Exception { argTag.setType("short"); argTag.setValue(new Double(17.3d)); argTag.doTag(getXMLOutput()); assertEquals(Short.TYPE,parentTag.getType(0)); assertEquals(new Short((short)17),parentTag.getValue(0)); }
public void testToLongFromNumber() throws Exception { argTag.setType("long"); argTag.setValue(new Double(17.3d)); argTag.doTag(getXMLOutput()); assertEquals(Long.TYPE,parentTag.getType(0)); assertEquals(new Long((long)17),parentTag.getValue(0)); }
public void testToDoubleFromNumber() throws Exception { argTag.setType("double"); argTag.setValue(new Long(17L)); argTag.doTag(getXMLOutput()); assertEquals(Double.TYPE,parentTag.getType(0)); assertEquals(new Double((double)17),parentTag.getValue(0)); }
public void testToIntFromNumber() throws Exception { argTag.setType("int"); argTag.setValue(new Double(17.3d)); argTag.doTag(getXMLOutput()); assertEquals(Integer.TYPE,parentTag.getType(0)); assertEquals(new Integer((int)17),parentTag.getValue(0)); }
public void testToFloatFromNumber() throws Exception { argTag.setType("float"); argTag.setValue(new Double(17.3d)); argTag.doTag(getXMLOutput()); assertEquals(Float.TYPE,parentTag.getType(0)); assertEquals(new Float((float)17.3),parentTag.getValue(0)); }
public void testToShortFromString() throws Exception { argTag.setType("short"); argTag.setValue("17"); argTag.doTag(getXMLOutput()); assertEquals(Short.TYPE,parentTag.getType(0)); assertEquals(new Short((short)17),parentTag.getValue(0)); }
public void testToIntFromString() throws Exception { argTag.setType("int"); argTag.setValue("17"); argTag.doTag(getXMLOutput()); assertEquals(Integer.TYPE,parentTag.getType(0)); assertEquals(new Integer((int)17),parentTag.getValue(0)); }
public void testToFloatFromString() throws Exception { argTag.setType("float"); argTag.setValue("17.3"); argTag.doTag(getXMLOutput()); assertEquals(Float.TYPE,parentTag.getType(0)); assertEquals(new Float((float)17.3),parentTag.getValue(0)); }
public void testToLongFromString() throws Exception { argTag.setType("long"); argTag.setValue("17"); argTag.doTag(getXMLOutput()); assertEquals(Long.TYPE,parentTag.getType(0)); assertEquals(new Long((int)17),parentTag.getValue(0)); }
public void testFromNull() throws Exception { Class[] types = { Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Float.class, Long.class, Double.class, String.class, Object.class }; for(int i=0;i<types.length;i++) { argTag.setType(types[i].getName()); argTag.setValue(null); argTag.doTag(getXMLOutput()); assertEquals(types[i],parentTag.getType(i)); assertNull(parentTag.getValue(i)); } }
public void testToCharFromString() throws Exception { argTag.setType("char"); argTag.setValue("X"); argTag.doTag(getXMLOutput()); assertEquals(Character.TYPE,parentTag.getType(0)); assertEquals(new Character('X'),parentTag.getValue(0)); }
public void testToByteFromString() throws Exception { argTag.setType("byte"); argTag.setValue("17"); argTag.doTag(getXMLOutput()); assertEquals(Byte.TYPE,parentTag.getType(0)); assertEquals(new Byte((byte)17),parentTag.getValue(0)); }
public void testToDoubleFromString() throws Exception { argTag.setType("double"); argTag.setValue("17.3"); argTag.doTag(getXMLOutput()); assertEquals(Double.TYPE,parentTag.getType(0)); assertEquals(new Double((double)17.3),parentTag.getValue(0)); }
public void testToPrimitiveFromNull() throws Exception { String[] types = { "boolean", "char", "byte", "short", "int", "float", "long", "double" }; for(int i=0;i<types.length;i++) { argTag.setType(types[i]); argTag.setValue(null); try { argTag.doTag(getXMLOutput()); fail("Expected JellyException"); } catch (JellyException e) { // expected } } }
public void testToBooleanFromString() throws Exception { argTag.setType("boolean"); argTag.setValue("true"); argTag.doTag(getXMLOutput()); assertEquals(Boolean.TYPE,parentTag.getType(0)); assertEquals(Boolean.TRUE,parentTag.getValue(0)); }