Package java.beans

Examples of java.beans.XMLDecoder.readObject()


    public void testReadObject_ArrayOutOfBounds() {
        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
        assertEquals(Integer.valueOf("1"), dec.readObject());
        assertEquals(Integer.valueOf("2"), dec.readObject());
        assertEquals(Integer.valueOf("3"), dec.readObject());

        try {
            dec.readObject();
            fail();
        } catch (ArrayIndexOutOfBoundsException e) {
View Full Code Here


        assertEquals(Integer.valueOf("1"), dec.readObject());
        assertEquals(Integer.valueOf("2"), dec.readObject());
        assertEquals(Integer.valueOf("3"), dec.readObject());

        try {
            dec.readObject();
            fail();
        } catch (ArrayIndexOutOfBoundsException e) {
            // expected
        }
    }
View Full Code Here

    }

    public void testReadObject_Null() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/null.xml"));
        Object obj = dec.readObject();
        assertNull(obj);
    }

    public void testReadObject_Integer() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
View Full Code Here

    }

    public void testReadObject_Integer() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/int.xml"));
        Object obj = dec.readObject();
        assertEquals(Integer.valueOf("3"), obj);
    }

    public void testReadObject_StringCodec() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
View Full Code Here

    }

    public void testReadObject_StringCodec() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/SampleBean_StringCodec.xml"));
        SampleBean obj = (SampleBean) dec.readObject();
        assertEquals("<Li Yang> & \"liyang'", obj.getMyid());
        assertEquals("a child", obj.getRef().getMyid());
    }

    public void testReadObject_IntArray() {
View Full Code Here

    }

    public void testReadObject_IntArray() {
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/IntArray.xml"));
        int ints[] = (int[]) dec.readObject();
        assertEquals(1, ints[0]);
        assertEquals(2, ints[1]);
        assertEquals(3, ints[2]);
    }
   
View Full Code Here

   
    public void testReadObject_Array_WithoutLength() {
        // Read array of primitive types without length attribute
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/Array_Primitive.xml"));
        Object[] arrays = (Object[]) dec.readObject();

        boolean[] booleanArray = (boolean[]) arrays[0];
        assertTrue(booleanArray[0]);
        assertFalse(booleanArray[1]);
View Full Code Here

        assertEquals(7d, doubleArray[1]);

        // Read array of Object types without length attribute
        dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/Array_Object.xml"));
        Object[] array = (Object[]) dec.readObject();

        assertTrue((Boolean) array[0]);
        assertEquals(new Short((short) 1), (Short) array[1]);
        assertEquals(new Byte((byte) 2), (Byte) array[2]);
        assertEquals(new Character('c'), (Character) array[3]);
View Full Code Here

        assertEquals("string", (String) array[8]);

        // Read wrapper element in array of primitive types
        dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/Array_Wrapper.xml"));
        int[] integers = (int[]) dec.readObject();
        assertEquals(11, integers[0]);
        assertEquals(22, integers[1]);
    }

    public void testReadObject_Array_Special() {
View Full Code Here

    public void testReadObject_Array_Special() {
        // Read array of Object types in special case without length attribute
        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
                "/xml/Array_Null.xml"));
        Object[] array = (Object[]) dec.readObject();
        assertNull(array[0]);
        assertNull(array[1]);
        assertEquals("", (String) array[2]);

        // Read array with wrong type, it should return null,
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.