Permalink
Browse files

Bugfix. More testing.

  • Loading branch information...
1 parent 730c6ff commit 7e87897f64b4e4b0501bd623e02c21cd890b51eb @kayahr committed Jan 25, 2007
@@ -163,6 +163,7 @@ else if (object instanceof Mixed)
else if (object instanceof Object[])
{
serializeArray((Object[]) object, buffer);
+ return;
}
else if (object instanceof Collection)
{
@@ -31,6 +31,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import de.ailis.pherialize.test.CustomClass;
/**
@@ -378,4 +379,25 @@ public void testSerializeArray()
s2 = Pherialize.serialize(strings);
assertEquals(s1, s2);
}
+
+
+ /**
+ * Test serializing array
+ */
+
+ public void testSerializeCustomArray()
+ {
+ CustomClass[] array;
+ String s1, s2;
+
+ array = new CustomClass[3];
+
+ array[0] = new CustomClass("String 1");
+ array[1] = new CustomClass("String 2");
+ array[2] = new CustomClass("String 3");
+
+ s1 = "a:3:{i:0;O:11:\"customclass\":1:{s:5:\"value\";s:8:\"String 1\";}i:1;O:11:\"customclass\":1:{s:5:\"value\";s:8:\"String 2\";}i:2;O:11:\"customclass\":1:{s:5:\"value\";s:8:\"String 3\";}}";
+ s2 = Pherialize.serialize(array);
+ assertEquals(s1, s2);
+ }
}
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ * Copyright (C) 2006 Klaus Reimer <k@ailis.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package de.ailis.pherialize.test;
+
+import java.io.Serializable;
+
+
+/**
+ * CustomClass
+ *
+ * @author Klaus Reimer (k@ailis.de)
+ * @version $Revision$
+ */
+
+public class CustomClass implements Serializable
+{
+ /** Serial version UID */
+ private static final long serialVersionUID = -7396948063312053556L;
+
+ /** A test value */
+ private String value;
+
+
+ /**
+ * Constructor
+ *
+ * @param value
+ * A test value
+ */
+
+ public CustomClass(String value)
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * Returns the test value
+ *
+ * @return The test value
+ */
+
+ public String getValue()
+ {
+ return this.value;
+ }
+}

0 comments on commit 7e87897

Please sign in to comment.