Package java.beans

Examples of java.beans.XMLDecoder


        assertNotNull(xmlDecoder.readObject());
        assertTrue(mockListener.isCalled());
    }

    public void testSetExceptionListener() {
        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
        Object defaultL = dec.getExceptionListener();

        dec.setExceptionListener(null);
        assertSame(defaultL, dec.getExceptionListener());

        ExceptionListener newL = new MockExceptionListener();
        dec.setExceptionListener(newL);
        assertSame(newL, dec.getExceptionListener());
    }
View Full Code Here


        assertSame(newL, dec.getExceptionListener());
    }

    public void testSetExceptionListener_CatchException() {
        MockExceptionListener l = new MockExceptionListener();
        new XMLDecoder(XMLDecoderTest.class
                .getResourceAsStream("/xml/bad_int.xml"), null, l);
        assertTrue(l.size() > 0);
    }
View Full Code Here

                .getResourceAsStream("/xml/bad_int.xml"), null, l);
        assertTrue(l.size() > 0);
    }

    public void testSetOwner() {
        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
        assertNull(dec.getOwner());

        String owner = "owner";
        dec.setOwner(owner);
        assertSame(owner, dec.getOwner());

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

    /*
     * Class under test for void XMLDecoder(java.io.InputStream)
     */
    public void testXMLDecoderInputStream() {
        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
        assertNull(dec.getOwner());
        assertNotNull(dec.getExceptionListener());
    }
View Full Code Here

     * Class under test for void XMLDecoder(java.io.InputStream,
     * java.lang.Object)
     */
    public void testXMLDecoderInputStreamObject() {
        String owner = "owner";
        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
                owner);
        assertSame(owner, dec.getOwner());
        assertNotNull(dec.getExceptionListener());
    }
View Full Code Here

     * java.lang.Object, java.beans.ExceptionListener)
     */
    public void testXMLDecoderInputStreamObjectExceptionListener() {
        String owner = "owner";
        MockExceptionListener l = new MockExceptionListener();
        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
                owner, l);
        assertSame(owner, dec.getOwner());
        assertSame(l, dec.getExceptionListener());
    }
View Full Code Here

     * Regression test for HARMONY-1890
     */
    public void testDecodeEmptyStringArray1890() {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        XMLEncoder encoder = new XMLEncoder(out);
        XMLDecoder decoder;
        Object obj;

        encoder.writeObject(new String[10]);
        encoder.close();

        decoder = new XMLDecoder(new ByteArrayInputStream(out.toByteArray()));
        obj = decoder.readObject();
        decoder.close();
       
        assertTrue("Returned object is not array", obj.getClass().isArray());
        assertSame("String type expected", String.class,
                obj.getClass().getComponentType());
        assertEquals("Size mismatch", 10, Array.getLength(obj));
View Full Code Here

    /**
     *
     */
    private void decode(String resourceName) throws Exception {
        XMLDecoder d = null;
        try {
            Introspector.setBeanInfoSearchPath(new String[] {});
            d = new XMLDecoder(new BufferedInputStream(ClassLoader
                    .getSystemClassLoader().getResourceAsStream(resourceName)));
            while (true) {
                d.readObject();
            }
        } catch (ArrayIndexOutOfBoundsException aibe) {
            assertTrue(true);
        } finally {
            if (d != null) {
                d.close();
            }
        }
    }
View Full Code Here

      throw new RuntimeException("UTF-8 support required", ex);
    }

    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);

    XMLDecoder decoder = new XMLDecoder(bais, null, null);
    try {
      ExprNodeDesc expr = (ExprNodeDesc) decoder.readObject();
      return expr;
    } finally {
      decoder.close();
    }
  }
View Full Code Here

   * De-serialize an object. This helper function mainly makes sure that enums,
   * counters, etc are handled properly.
   */
  @SuppressWarnings("unchecked")
  public static <T> T deserializeObject(InputStream in) {
    XMLDecoder d = null;
    try {
      d = new XMLDecoder(in, null, null);
      return (T) d.readObject();
    } finally {
      if (null != d) {
        d.close();
      }
    }
  }
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.