Package java.beans

Examples of java.beans.ExceptionListener


   * Serialize the object. This helper function mainly makes sure that enums,
   * counters, etc are handled properly.
   */
  private static void serializeObjectByJavaXML(Object plan, OutputStream out) {
    XMLEncoder e = new XMLEncoder(out);
    e.setExceptionListener(new ExceptionListener() {
      @Override
      public void exceptionThrown(Exception e) {
        LOG.warn(org.apache.hadoop.util.StringUtils.stringifyException(e));
        throw new RuntimeException("Cannot serialize object", e);
      }
View Full Code Here


    @Test
    public void testExceptionOfDifferentTypeIsCaughtByListener() throws Exception
    {
        final AtomicBoolean exceptionThrown = new AtomicBoolean(false);
        test.setExceptionListener(new ExceptionListener()
        {
            public void exceptionThrown(Exception e)
            {
                exceptionThrown.set(true);
                assertTrue(e instanceof UnknownHostException);
View Full Code Here

    final boolean bErrorOut = true;
    XMLEncoder e = null;
   
    try{
      e = new XMLEncoder(new BufferedOutputStream(os));
      e.setExceptionListener(new ExceptionListener(){
        public void exceptionThrown(Exception e) {
          //do nothing       
       
          if(bErrorOut){
            //e.printStackTrace();
View Full Code Here

        XMLDecoder xmlDecoder;
        xmlDecoder = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
        assertEquals(null, xmlDecoder.getOwner());
       
        final Vector<Exception> exceptions = new Vector<Exception>();
        ExceptionListener el = new ExceptionListener() {
            public void exceptionThrown(Exception e) {
                exceptions.addElement(e);
            }
        };
       
View Full Code Here

    public void testConstructor_ClassLoader() {
        XMLDecoder dec;
        final Vector<Exception> exceptions = new Vector<Exception>();

        ExceptionListener el = new ExceptionListener() {
            public void exceptionThrown(Exception e) {
                exceptions.addElement(e);
            }
        };
View Full Code Here

        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

        try
        {
            Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
            encoder = new XMLEncoder( new BufferedOutputStream( new FileOutputStream( filename ) ) );

            encoder.setExceptionListener( new ExceptionListener()
            {

                public void exceptionThrown( Exception e )
                {
                    e.printStackTrace();
View Full Code Here

  /**
   * Serialize the whole query plan.
   */
  public static void serializeQueryPlan(QueryPlan plan, OutputStream out) {
    XMLEncoder e = new XMLEncoder(out);
    e.setExceptionListener(new ExceptionListener() {
      public void exceptionThrown(Exception e) {
        LOG.warn(org.apache.hadoop.util.StringUtils.stringifyException(e));
        throw new RuntimeException("Cannot serialize the query plan", e);
      }
    });
View Full Code Here

    /**
     * The test checks that java.lang.Boolean exemplar store is correct
     */
    public void testEncodeBoolean() {
        XMLEncoder e = new XMLEncoder(System.out);
        e.setExceptionListener(new ExceptionListener() {
            public void exceptionThrown(Exception e) {
                fail("Exception " + e.getClass() + " is thrown: "
                        + e.getMessage());
            }
        });
View Full Code Here

    /**
     * The test checks that java.lang.Byte exemplar store is correct
     */
    public void testEncodeByte() {
        XMLEncoder e = new XMLEncoder(System.out);
        e.setExceptionListener(new ExceptionListener() {
            public void exceptionThrown(Exception e) {
                fail("Exception " + e.getClass() + " is thrown: "
                        + e.getMessage());
            }
        });
View Full Code Here

TOP

Related Classes of java.beans.ExceptionListener

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.