/** * If the test failed, the exception that was thrown. It does not need to be * the root cause. */ public Throwable getThrowable() { if (throwable == null) { if (exceptionProxy != null) { throwable = exceptionProxy.createException(); } } return throwable; }
public TestResult setThrowable(Throwable throwable) { this.throwable = throwable; this.exceptionProxy = ExceptionProxy.createForException(throwable); return this; }
/** * Static method to create an exception proxy for the passed in * {@link Throwable} class. If null is passed in, null is returned as the * exception proxy * * @param throwable * Exception to proxy * * @return An ExceptionProxy representing the exception passed in */ public static ExceptionProxy createForException(Throwable throwable) { if (throwable == null) { return null; } return new ExceptionProxy(throwable); }
/** * Constructs an instance of the proxied exception based on the class name, * message, stack trace and if applicable, the cause. * * @return The constructed {@link Throwable} instance */ public Throwable createException() { if (!hasException()) { return null; } if (original != null) { return original; } Throwable throwable = createProxyException( "Original exception caused: " + (serializationProcessException != null ? serializationProcessException.getClass() + ": " + serializationProcessException.getMessage() : "Unknown serialization issue")); return throwable; }
private void proxy(Throwable throwable) throws Throwable { //printConstructors(throwable); throw ExceptionProxy.createForException(throwable).createException(); }
public ArquillianProxyException createProxyException(String reason) { ArquillianProxyException exception = new ArquillianProxyException(message, className, reason, getCause()); exception.setStackTrace(trace); return exception; }
@Test public void shouldRecreateInvocationTargetExceptions() throws Exception { ExceptionProxy proxy = serialize(ExceptionProxy.createForException( new InvocationTargetException(new RuntimeException(new ClassNotFoundException())))); Throwable t = proxy.createException(); Assert.assertEquals(InvocationTargetException.class, t.getClass()); Assert.assertEquals(RuntimeException.class, t.getCause().getClass()); Assert.assertEquals(ClassNotFoundException.class, t.getCause().getCause().getClass()); }
/** * Constructs an instance of the proxied exception based on the class name, * message, stack trace and if applicable, the cause. * * @return The constructed {@link Throwable} instance */ public Throwable createException() { if (!hasException()) { return null; } if (original != null) { return original; } Throwable throwable = createProxyException( "Original exception caused: " + (serializationProcessException != null ? serializationProcessException.getClass() + ": " + serializationProcessException.getMessage() : "Unknown serialization issue")); return throwable; }
public ArquillianProxyException createProxyException(String reason) { ArquillianProxyException exception = new ArquillianProxyException(message, className, reason, getCause()); exception.setStackTrace(trace); return exception; }
@Test public void shouldSerializeNonDeSerializableExceptions() throws Exception { ExceptionProxy proxy = serialize(ExceptionProxy.createForException(new NonDeserializableExtension("Test"))); Throwable t = proxy.createException(); Assert.assertEquals(ArquillianProxyException.class, t.getClass()); Assert.assertTrue( "Verify Proxy message contain root exception of deserialization problem", t.getMessage().contains("NonDeserializableExtension")); Assert.assertTrue( "Verify Proxy message contain root cause of deserialization problem", t.getMessage().contains("Could not de-serialize")); Assert.assertEquals(UnsupportedOperationException.class, t.getCause().getClass()); }
/** * If the test failed, the exception that was thrown. It does not need to be * the root cause. */ public Throwable getThrowable() { if (throwable == null) { if (exceptionProxy != null) { throwable = exceptionProxy.createException(); } } return throwable; }
public TestResult setThrowable(Throwable throwable) { this.throwable = throwable; this.exceptionProxy = ExceptionProxy.createForException(throwable); return this; }
/** * Static method to create an exception proxy for the passed in * {@link Throwable} class. If null is passed in, null is returned as the * exception proxy * * @param throwable * Exception to proxy * * @return An ExceptionProxy representing the exception passed in */ public static ExceptionProxy createForException(Throwable throwable) { if (throwable == null) { return null; } return new ExceptionProxy(throwable); }
@Test public void shouldSerializeNonSerializableExceptions() throws Exception { ExceptionProxy proxy = serialize(ExceptionProxy.createForException(new NonSerializableException())); Throwable t = proxy.createException(); Assert.assertEquals(ArquillianProxyException.class, t.getClass()); Assert.assertTrue( "Verify Proxy message contain root exception of serialization problem", t.getMessage().contains("java.io.NotSerializableException")); Assert.assertTrue( "Verify Proxy message contain root cause of serialization problem", t.getMessage().contains("BufferedInputStream")); Assert.assertEquals(UnsupportedOperationException.class, t.getCause().getClass()); }
/** * Returns the cause of the exception represented by this proxy * * @return The cause of this exception */ public Throwable getCause() { // lazy create cause if (cause == null) { if (causeProxy != null) { cause = causeProxy.createException(); } } return cause; }
public ExceptionProxy(Throwable throwable) { this.className = throwable.getClass().getName(); this.message = throwable.getMessage(); this.trace = throwable.getStackTrace(); this.causeProxy = ExceptionProxy.createForException(throwable.getCause()); this.original = throwable; }
throw new RuntimeException("Test", new UnknownException(null)); } catch (Exception e) { proxy = ExceptionProxy.createForException(e); readProxy.createException().printStackTrace();
/** * Returns the cause of the exception represented by this proxy * * @return The cause of this exception */ public Throwable getCause() { // lazy create cause if (cause == null) { if (causeProxy != null) { cause = causeProxy.createException(); } } return cause; }
public ExceptionProxy(Throwable throwable) { this.className = throwable.getClass().getName(); this.message = throwable.getMessage(); this.trace = throwable.getStackTrace(); this.causeProxy = ExceptionProxy.createForException(throwable.getCause()); this.original = throwable; }
Throwable cause = causeProxy.createException(); if (original instanceof InvocationTargetException) { SecurityActions.setFieldValue(InvocationTargetException.class, original, "target", cause);