1 package com.thoughtworks.acceptance; 2 3 import java.util.Date; 4 5 public class BasicTypesTest extends AbstractAcceptanceTest { 6 7 public void testPrimitiveNumbers() { 8 assertBothWays(new Integer(99), "<int>99</int>"); 9 assertBothWays(new Integer(-99), "<int>-99</int>"); 10 assertBothWays(new Integer(0), "<int>0</int>"); 11 assertBothWays(new Float(-123.45f), "<float>-123.45</float>"); 12 assertBothWays(new Double(-1234567890.12345), "<double>-1.23456789012345E9</double>"); 13 assertBothWays(new Long(123456789123456L), "<long>123456789123456</long>"); 14 assertBothWays(new Short((short) 123), "<short>123</short>"); 15 } 16 17 public void testOtherPrimitives() { 18 assertBothWays(new Character('z'), "<char>z</char>"); 19 assertBothWays(Boolean.TRUE, "<boolean>true</boolean>"); 20 assertBothWays(Boolean.FALSE, "<boolean>false</boolean>"); 21 assertBothWays(new Byte((byte) 44), "<byte>44</byte>"); 22 } 23 24 public void testStrings() { 25 assertBothWays("hello world", "<string>hello world</string>"); 26 } 27 28 public void testStringBuffer() { 29 StringBuffer buffer = new StringBuffer(); 30 buffer.append("woo"); 31 String xml = xstream.toXML(buffer); 32 assertEquals(xml, "<string-buffer>woo</string-buffer>"); 33 StringBuffer out = (StringBuffer) xstream.fromXML(xml); 34 assertEquals("woo", out.toString()); 35 } 36 37 public void testDate() { 38 Date date = new Date(103, 02, 15, 8, 22, 7); 39 assertBothWays(date, "<date>2003-03-15 08:22:07AM</date>"); 40 } 41 42 }

This page was automatically generated by Maven