Skip to content

Commit

Permalink
FORGE-1677: AssumptionViolatedException is now correctly propagated back
Browse files Browse the repository at this point in the history
to client
  • Loading branch information
gastaldi committed Mar 18, 2014
1 parent cafbab0 commit d1d6db5
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
*/
package org.jboss.forge.arquillian;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -151,7 +155,16 @@ public TestResult invoke(final TestMethodExecutor testMethodExecutor)
&& "org.junit.internal.AssumptionViolatedException".equals(rootCause.getClass()
.getName()))
{
result = new TestResult(Status.SKIPPED);
try
{
// Due to classloader restrictions, we need to serialize and deserialize back
result = new TestResult(Status.SKIPPED, reserialize(rootCause));
}
catch (Exception ex)
{
// ignore
result = new TestResult(Status.SKIPPED);
}
}
else
{
Expand Down Expand Up @@ -259,6 +272,16 @@ private Throwable getRootCause(Throwable t)
return result;
}

private Throwable reserialize(Throwable obj) throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
oos.close();
ByteArrayInputStream in = new ByteArrayInputStream(baos.toByteArray());
return (Throwable) new ObjectInputStream(in).readObject();
}

private void waitUntilStable(Furnace furnace) throws InterruptedException
{
while (furnace.getStatus().isStarting())
Expand Down

0 comments on commit d1d6db5

Please sign in to comment.