Examples of XMLEncoder


Examples of java.beans.XMLEncoder

        d.close();
    }

    @Override
    public void writeData() throws IOException {
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(getFile())));
        e.writeObject(dictionary);
        customWriteData(e);
        e.close();
    }
View Full Code Here

Examples of java.beans.XMLEncoder

        ClassLoader ccl = Thread.currentThread().getContextClassLoader();
        try
        {
            Thread.currentThread().setContextClassLoader( Utils.class.getClassLoader() );
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XMLEncoder encoder = new XMLEncoder( baos );
            encoder.writeObject( o );
            encoder.close();
            String s = LdifUtils.utf8decode( baos.toByteArray() );
            return s;
        }
        finally
        {
View Full Code Here

Examples of java.beans.XMLEncoder

        str += "=" + string((Statement) exp);
        return str;
    }

    public void testWriteExpression_Scenario1() {
        XMLEncoder xmlEncoder = new XMLEncoder((OutputStream) null);
        try {
            xmlEncoder.writeExpression((Expression) null);
            fail("should throw NullPointerException");
        } catch (NullPointerException e) {
            // Expected
        }
    }
View Full Code Here

Examples of java.beans.XMLEncoder

            // Expected
        }
    }

    public void testWriteExpression_Scenario2() {
        XMLEncoder xmlEncoder = new XMLEncoder(new ByteArrayOutputStream());
        try {
            xmlEncoder.writeExpression((Expression) null);
            fail("should throw NullPointerException");
        } catch (NullPointerException e) {
            // Expected
        }
    }
View Full Code Here

Examples of java.beans.XMLEncoder

    public void testWriteStatement() {
        // covered by testWriteStatement

         //Regression for HARMONY-1521
         //no exception expected
         new XMLEncoder(new ByteArrayOutputStream()).writeStatement(null);
    }
View Full Code Here

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

Examples of java.beans.XMLEncoder

    }

    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

Examples of java.beans.XMLEncoder

        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

Examples of java.beans.XMLEncoder

                }
                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

Examples of java.beans.XMLEncoder

        }
    }

    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
TOP
Copyright © 2018 www.massapi.com. 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.