public void testJavaBeanArray() { try { MyBean lTest1 = new MyBean(); lTest1.setId(100); lTest1.setName("SISE Rules!"); MyBean lTest2 = new MyBean(); lTest2.setId(200); lTest2.setName("S.D.I.-Consulting"); MarshallValue lResult = marshall.unmarshall(marshall.marshall(new MyBean[] {lTest1, lTest2})); Assert.assertTrue(MarshallValue.REFERENCE == lResult.getType()); MyBean[] lArr = (MyBean[]) lResult.getReference(); Assert.assertNotNull(lArr); Assert.assertTrue(lArr.length == 2); Assert.assertEquals(lArr[0].getName(), "SISE Rules!"); Assert.assertEquals(lArr[0].getId(), 100); Assert.assertEquals(lArr[1].getName(), "S.D.I.-Consulting"); Assert.assertEquals(lArr[1].getId(), 200); } catch (Exception e) { e.printStackTrace(System.out); Assert.fail(); } }
public void testJavaBean() { try { MyBean lTest1 = new MyBean(); lTest1.setId(100); lTest1.setName("SISE Rules!"); lTest1.setInt1(new Integer(0)); lTest1.setInt2(new Integer(0)); System.out.println(marshall.marshall(lTest1).render(true)); MarshallValue lResult = marshall.unmarshall(marshall.marshall(lTest1)); Assert.assertTrue(MarshallValue.REFERENCE == lResult.getType()); MyBean lTest2 = (MyBean) lResult.getReference(); // Test if the contents are intact. Assert.assertNotNull(lTest2); Assert.assertEquals(lTest2.getName(), "SISE Rules!"); Assert.assertEquals(lTest2.getId(), 100); // Different physical objects should remain different, even if they // are equal. Assert.assertTrue(!(lTest2.getInt1() == lTest2.getInt2())); } catch (Exception e) { e.printStackTrace(System.out); Assert.fail(); } }
public void testSelfReference() { try { MyBean lTest1 = new MyBean(); lTest1.setId(113); lTest1.setName("SELF-POINTING"); lTest1.setPtr(lTest1); MarshallValue lResult = marshall.unmarshall(marshall.marshall(lTest1)); Assert.assertTrue(MarshallValue.REFERENCE == lResult.getType()); MyBean lTest2 = (MyBean) lResult.getReference(); Assert.assertNotNull(lTest2); Assert.assertEquals(lTest2.getName(), "SELF-POINTING"); Assert.assertEquals(lTest2.getId(), 113); Assert.assertTrue(lTest2 == lTest2.getPtr()); } catch (Exception e) { Assert.fail(); } }