Skip to content

Commit

Permalink
Minor refactoring and updated some deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Aug 4, 2014
1 parent c8f06d8 commit c497922
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
Expand Up @@ -13,7 +13,6 @@
import org.jboss.arquillian.container.test.spi.ContainerMethodExecutor;
import org.jboss.arquillian.test.spi.TestMethodExecutor;
import org.jboss.arquillian.test.spi.TestResult;
import org.jboss.arquillian.test.spi.TestResult.Status;
import org.jboss.forge.arquillian.protocol.ForgeProtocolConfiguration;
import org.jboss.forge.arquillian.protocol.FurnaceHolder;
import org.jboss.forge.furnace.Furnace;
Expand All @@ -23,6 +22,7 @@
import org.jboss.forge.furnace.spi.ExportedInstance;
import org.jboss.forge.furnace.spi.ServiceRegistry;
import org.jboss.forge.furnace.util.Annotations;
import org.jboss.forge.furnace.util.Assert;
import org.jboss.forge.furnace.util.ClassLoaders;

/**
Expand All @@ -35,14 +35,8 @@ public class ForgeTestMethodExecutor implements ContainerMethodExecutor

public ForgeTestMethodExecutor(ForgeProtocolConfiguration config, final FurnaceHolder holder)
{
if (config == null)
{
throw new IllegalArgumentException("ForgeProtocolConfiguration must be specified");
}
if (holder == null)
{
throw new IllegalArgumentException("Furnace runtime must be provided");
}
Assert.notNull(config, "ForgeProtocolConfiguration must be specified");
Assert.notNull(holder, "Furnace runtime must be provided");
this.furnace = holder.getFurnace();
}

Expand All @@ -51,11 +45,7 @@ public TestResult invoke(final TestMethodExecutor testMethodExecutor)
{
try
{
if (testMethodExecutor == null)
{
throw new IllegalArgumentException("TestMethodExecutor must be specified");
}

Assert.notNull(testMethodExecutor, "TestMethodExecutor must be specified");
final String testClassName = testMethodExecutor.getInstance().getClass().getName();

Object testInstance = null;
Expand Down Expand Up @@ -125,7 +115,7 @@ public TestResult invoke(final TestMethodExecutor testMethodExecutor)
{
if ("org.junit.Ignore".equals(annotation.getClass().getName()))
{
result = new TestResult(Status.SKIPPED);
result = TestResult.skipped(null);
}
}

Expand All @@ -141,7 +131,7 @@ public TestResult invoke(final TestMethodExecutor testMethodExecutor)
{
invokeBefore(testInstance.getClass(), testInstance);
method.invoke(testInstance);
result = new TestResult(Status.PASSED);
result = TestResult.passed();
}
catch (Exception e)
{
Expand All @@ -159,12 +149,12 @@ public TestResult invoke(final TestMethodExecutor testMethodExecutor)
.forName("org.junit.internal.AssumptionViolatedException")
.getConstructor(String.class).newInstance(rootCause.getMessage());
thisClassloaderException.setStackTrace(rootCause.getStackTrace());
result = new TestResult(Status.SKIPPED, thisClassloaderException);
result = TestResult.skipped(thisClassloaderException);
}
catch (Exception ex)
{
// ignore
result = new TestResult(Status.SKIPPED);
result = TestResult.skipped(ex);
}
}
else
Expand All @@ -189,18 +179,18 @@ public TestResult invoke(final TestMethodExecutor testMethodExecutor)
}
catch (AssertionError e)
{
result = new TestResult(Status.FAILED, e);
result = TestResult.failed(e);
}
catch (Exception e)
{
result = new TestResult(Status.FAILED, e);
result = TestResult.failed(e);

Throwable cause = e.getCause();
while (cause != null)
{
if (cause instanceof AssertionError)
{
result = new TestResult(Status.FAILED, cause);
result = TestResult.failed(cause);
break;
}
cause = cause.getCause();
Expand Down
Expand Up @@ -16,7 +16,6 @@
import org.jboss.arquillian.container.test.spi.command.CommandCallback;
import org.jboss.arquillian.test.spi.TestMethodExecutor;
import org.jboss.arquillian.test.spi.TestResult;
import org.jboss.arquillian.test.spi.TestResult.Status;
import org.jboss.forge.arquillian.ForgeDeploymentPackager;
import org.jboss.forge.arquillian.ForgeTestMethodExecutor;
import org.jboss.forge.furnace.Furnace;
Expand Down Expand Up @@ -56,7 +55,7 @@ public ContainerMethodExecutor getExecutor(ForgeProtocolConfiguration protocolCo
@Override
public TestResult invoke(TestMethodExecutor arg0)
{
return new TestResult(Status.SKIPPED);
return TestResult.skipped(null);
}
};
}
Expand Down

0 comments on commit c497922

Please sign in to comment.