Author: sletellier Date: 2010-08-13 10:27:13 +0200 (Fri, 13 Aug 2010) New Revision: 256 Url: http://nuiton.org/repositories/revision/wikitty/256 Log: Add test for Hessian BigDecimal serialization Added: trunk/wikitty-hessian-server/src/test/java/HessianTest.java Modified: trunk/wikitty-hessian-server/pom.xml Modified: trunk/wikitty-hessian-server/pom.xml =================================================================== --- trunk/wikitty-hessian-server/pom.xml 2010-08-12 17:28:30 UTC (rev 255) +++ trunk/wikitty-hessian-server/pom.xml 2010-08-13 08:27:13 UTC (rev 256) @@ -54,6 +54,16 @@ <artifactId>postgresql</artifactId> <scope>runtime</scope> </dependency> + <dependency> + <groupId>postgresql</groupId> + <artifactId>postgresql</artifactId> + <scope>runtime</scope> + </dependency> + <!-- TEST --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> </dependencies> <!-- ************************************************************* --> Added: trunk/wikitty-hessian-server/src/test/java/HessianTest.java =================================================================== --- trunk/wikitty-hessian-server/src/test/java/HessianTest.java (rev 0) +++ trunk/wikitty-hessian-server/src/test/java/HessianTest.java 2010-08-13 08:27:13 UTC (rev 256) @@ -0,0 +1,34 @@ +import com.caucho.hessian.io.Hessian2Input; +import com.caucho.hessian.io.Hessian2Output; +import com.caucho.hessian.io.SerializerFactory; +import org.junit.Assert; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.math.BigDecimal; + +/** + * @author sletellier <letellier@codelutin.com> + */ +public class HessianTest { + + @Test + public void testHessianBigDecimal() throws Exception { + BigDecimal object = new BigDecimal("12474639.945458954"); + Hessian2Output os = new Hessian2Output(null); + SerializerFactory factory = new SerializerFactory(); + os.setSerializerFactory(factory); + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + os.init(buffer); + os.writeObject(object); + os.close(); + byte[] bytes = buffer.toByteArray(); + + Hessian2Input is = new Hessian2Input(new ByteArrayInputStream(bytes)); + BigDecimal newObject = (BigDecimal) is.readObject(); + is.close(); + + Assert.assertEquals(object, newObject); + } +}