Package java.beans

Examples of java.beans.XMLEncoder


                "/xml/MockBean4Codec_ManyChanges_2.xml");
    }

    public void testWriteObject_SetOwner() throws Exception {
        ByteArrayOutputStream temp = new ByteArrayOutputStream();
        XMLEncoder enc = new XMLEncoder(temp);

        MockBean4Owner_Target t = new MockBean4Owner_Target();
        MockBean4Owner_Owner o = new MockBean4Owner_Owner();
        t.setV(o);
        enc.setOwner(o);

        assertCodedXML(t, "/xml/MockBean4Owner_SetOwner.xml", temp, enc);

    }
View Full Code Here


    }

    public void testWriteObject_SetOwnerWithWriteStatement() throws Exception {
        ByteArrayOutputStream temp = new ByteArrayOutputStream();
        XMLEncoder enc = new XMLEncoder(temp);

        MockBean4Owner_Target t = new MockBean4Owner_Target();
        MockBean4Owner_Owner o = new MockBean4Owner_Owner();
        t.setV(o);
        enc.setOwner(o);

        enc.writeStatement(new Statement(o, "loading", new Object[] {}));

        assertCodedXML(t, "/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml",
                temp, enc);

    }
View Full Code Here

    }

    public void testWriteObject_StaticField() throws Exception {
        ByteArrayOutputStream temp = new ByteArrayOutputStream();
        XMLEncoder enc = new XMLEncoder(temp);

        enc.setPersistenceDelegate(MockBean4StaticField.class,
                new MockBean4StaticField_PD());

        assertCodedXML(MockBean4StaticField.inst,
                "/xml/MockBean4StaticField.xml", temp, enc);
View Full Code Here

        Map<String, TreeMap<String, String>> innerTreeMap = new MockTreeMapClass();
        TreeMap resultTreeMap = innerTreeMap.get("outKey");
        resultTreeMap.put("innerKey", "innerValue");

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLEncoder xmlEncoder = new XMLEncoder(baos);

        assertCodedXML(innerTreeMap, "/xml/MockTreeMap.xml", baos, xmlEncoder);
        assertEquals(1, innerTreeMap.size());
    }
View Full Code Here

                }
                closeCalled = true;
                super.close();
            }
        };
        XMLEncoder enc = new XMLEncoder(out);
        enc.writeObject(new Integer(3));
        assertEquals(0, out.size());

        enc.close();

        assertTrue(out.size() > 0);
        try {
            out.close();
            fail();
View Full Code Here

        }
    }

    public void testFlush() {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        XMLEncoder enc = new XMLEncoder(out);
        Integer i = new Integer(3);
        enc.writeObject(i);
        assertEquals(0, out.size());
        assertNotNull(enc.get(i));

        enc.flush();

        assertTrue(out.size() > 0);
        assertNull(enc.get(i));
    }
View Full Code Here

        assertTrue(out.size() > 0);
        assertNull(enc.get(i));
    }

    public void testXMLEncoder_Null() throws NullPointerException {
        new XMLEncoder(null);
    }
View Full Code Here

    public void testXMLEncoder_Null() throws NullPointerException {
        new XMLEncoder(null);
    }

    public void testGetOwner() {
        XMLEncoder enc = new XMLEncoder(System.out);
        assertNull(enc.getOwner());
    }
View Full Code Here

        XMLEncoder enc = new XMLEncoder(System.out);
        assertNull(enc.getOwner());
    }

    public void testSetOwner() {
        XMLEncoder enc = new XMLEncoder(System.out);
        Object owner = Boolean.FALSE;

        enc.setOwner(owner);
        assertSame(owner, enc.getOwner());

        enc.setOwner(null);
        assertNull(enc.getOwner());
    }
View Full Code Here

        assertNull(enc.getOwner());
    }

    private void assertCodedXML(Object obj, String xmlFile) throws Exception {
        ByteArrayOutputStream temp = new ByteArrayOutputStream();
        XMLEncoder enc = new XMLEncoder(temp);

        assertCodedXML(obj, xmlFile, temp, enc);
    }
View Full Code Here

TOP

Related Classes of java.beans.XMLEncoder

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.