Arquillian Test SPI 1.0.0.CR1

org.jboss.arquillian.test.spi
Class ExceptionProxy

java.lang.Object
  extended by org.jboss.arquillian.test.spi.ExceptionProxy
All Implemented Interfaces:
Serializable

public class ExceptionProxy
extends Object
implements Serializable

Takes an exception class and creates a proxy that can be used to rebuild the exception. The problem stems from problems serializing exceptions and deserializing them in another application where the exception classes might not exist, or they might exist in different version. This proxy also propagates the stacktrace and the cause exception to create totally portable exceptions.

This class creates a serializable proxy of the exception and when unserialized can be used to re-create the exception based on the following rules :

Author:
Andy Gibson
See Also:
Serialized Form

Constructor Summary
ExceptionProxy(Throwable throwable)
           
 
Method Summary
 Throwable createException()
          Constructs an instance of the proxied exception based on the class name, message, stack trace and if applicable, the cause.
static ExceptionProxy createForException(Throwable throwable)
          Static method to create an exception proxy for the passed in Throwable class.
 ArquillianProxyException createProxyException(String reason)
           
 Throwable getCause()
          Returns the cause of the exception represented by this proxy
 boolean hasException()
          Indicates whether this proxy wraps an exception
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExceptionProxy

public ExceptionProxy(Throwable throwable)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

hasException

public boolean hasException()
Indicates whether this proxy wraps an exception

Returns:
Flag indicating an exception is wrapped.

createException

public Throwable createException()
Constructs an instance of the proxied exception based on the class name, message, stack trace and if applicable, the cause.

Returns:
The constructed Throwable instance

createProxyException

public ArquillianProxyException createProxyException(String reason)

createForException

public static ExceptionProxy createForException(Throwable throwable)
Static method to create an exception proxy for the passed in Throwable class. If null is passed in, null is returned as the exception proxy

Parameters:
throwable - Exception to proxy
Returns:
An ExceptionProxy representing the exception passed in

getCause

public Throwable getCause()
Returns the cause of the exception represented by this proxy

Returns:
The cause of this exception

Arquillian Test SPI 1.0.0.CR1

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.