Package java.beans

Examples of java.beans.XMLDecoder


        array = (Object[]) dec.readObject();
        assertNull(array);
    }

    public void testReadObject_PropertyDependency() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/DependencyBean.xml"));
        DependencyBean b = (DependencyBean) dec.readObject();
        assertEquals(888, b.getInts()[0]);
        assertSame(b.getInts(), b.getRef());
    }
View Full Code Here


        assertEquals(888, b.getInts()[0]);
        assertSame(b.getInts(), b.getRef());
    }

    public void testReadObject_NoChange() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/MockBean4Codec_NoChange.xml"));
        dec.readObject();
    }
View Full Code Here

                "/xml/MockBean4Codec_NoChange.xml"));
        dec.readObject();
    }

    public void testReadObject_BornFriendChange() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/MockBean4Codec_BornFriendChange.xml"));
        MockBean4Codec b = (MockBean4Codec) dec.readObject();
        assertEquals(888, b.getBornFriend().getZarr()[0]);
        assertEquals(b.getBornFriend(), b.getNill());
    }
View Full Code Here

        assertEquals(888, b.getBornFriend().getZarr()[0]);
        assertEquals(b.getBornFriend(), b.getNill());
    }

    public void testReadObject_ManyChanges() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/MockBean4Codec_ManyChanges.xml"));
        MockBean4Codec b = (MockBean4Codec) dec.readObject();
        assertEquals(127, b.getB());
        assertSame(b, b.getBackRef());
        assertEquals(new Byte((byte) 127), b.getBobj());
        assertFalse(b.isBool());
        assertEquals(Boolean.TRUE, b.getBoolobj());
View Full Code Here

        assertEquals("6", b.getZarrarr()[0][1]);
        assertEquals("6", b.getZarrarr()[0][2]);
    }

    public void testReadObject_StaticField() {
        XMLDecoder dec1 = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/MockBean4StaticField_Original.xml"));
        MockBean4StaticField o1 = (MockBean4StaticField) dec1.readObject();

        XMLDecoder dec2 = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/MockBean4StaticField.xml"));
        MockBean4StaticField o2 = (MockBean4StaticField) dec2.readObject();

        if (!o1.equals(o2)) {
            System.out
                    .println("Loading object with static field, original xml: "
                            + o1.getV());
View Full Code Here

        assertEquals(o1, o2);
    }

    public void testReadObject_Owner() {
        MockBean4Owner_Owner o1 = new MockBean4Owner_Owner();
        XMLDecoder dec1 = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/MockBean4Owner_SetOwner.xml"), o1);
        MockBean4Owner_Target t1 = (MockBean4Owner_Target) dec1.readObject();

        assertEquals(1, o1.getV());
        assertEquals(o1, t1.getV());
    }
View Full Code Here

    public void testReadObject_Owner_Specific(){
        String expectedValue = "expected value";
        HashMap map = new HashMap();
        map.put("key", expectedValue);
       
        XMLDecoder decoder = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/MockOwner.xml"), map);
        String actualValue = (String) decoder.readObject();
        assertEquals(expectedValue,actualValue);
       
        MockOwnerClass mock = new MockOwnerClass();
        expectedValue = "I_Ljava.lang.String";
        decoder = new XMLDecoder(this.getClass().getResourceAsStream(
        "/xml/MockOwner_Specific.xml"), mock);
        actualValue = (String) decoder.readObject();
        assertEquals(expectedValue,actualValue);
       
        decoder = new XMLDecoder(this.getClass().getResourceAsStream(
        "/xml/MockOwner_Ambiguous.xml"), mock);
        actualValue = (String) decoder.readObject();
        assertNull(actualValue);
       
        decoder = new XMLDecoder(this.getClass().getResourceAsStream(
        "/xml/MockOwner_Null.xml"), mock);
        actualValue = (String) decoder.readObject();
        assertNull(actualValue);
    }
View Full Code Here

        assertNull(actualValue);
    }

    public void testReadObject_Owner_WithWriteStatement() {
        MockBean4Owner_Owner o2 = new MockBean4Owner_Owner();
        XMLDecoder dec2 = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml"), o2);
        MockBean4Owner_Target t2 = (MockBean4Owner_Target) dec2.readObject();

        assertEquals(999, o2.getV());
        assertEquals(o2, t2.getV());
    }
View Full Code Here

            public void exceptionThrown(Exception e) {
                exceptionList.addElement(e);
            }
        };

        XMLDecoder xmlDecoder = new XMLDecoder(new ByteArrayInputStream(
                xml123bytes));
        xmlDecoder.setExceptionListener(exceptionListener);
        assertEquals(new Integer(1), xmlDecoder.readObject());
        assertEquals(new Integer(2), xmlDecoder.readObject());
        assertEquals(new Integer(3), xmlDecoder.readObject());
        xmlDecoder.close();
        assertEquals(0, exceptionList.size());
    }
View Full Code Here

            public boolean isCalled() {
                return isCalled;
            }
        }
       
        XMLDecoder xmlDecoder = new XMLDecoder(new ByteArrayInputStream(
                "<java><string/>".getBytes("UTF-8")));
        MockExceptionListener mockListener = new MockExceptionListener();
        xmlDecoder.setExceptionListener(mockListener);
       
        assertFalse(mockListener.isCalled());       
        // Real Parsing should occur in method of ReadObject rather constructor.
        assertNotNull(xmlDecoder.readObject());
        assertTrue(mockListener.isCalled());
    }
View Full Code Here

TOP

Related Classes of java.beans.XMLDecoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.