Skip to content

Commit

Permalink
Fix Terracotta-OSS#122 - Add teardown and setup to harness
Browse files Browse the repository at this point in the history
  • Loading branch information
myronkscott committed Nov 30, 2016
1 parent e1890b1 commit d20efda
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.terracotta.testing.api.ITestMaster;
import org.terracotta.testing.api.BasicTestClusterConfiguration;
import org.terracotta.testing.logging.VerboseManager;
import org.terracotta.testing.support.AbstractHarnessTest;


public class BasicHarnessMain {
Expand All @@ -43,7 +44,24 @@ public static void main(String[] args) throws InterruptedException, IOException
}
try {
BasicHarnessEntry harness = new BasicHarnessEntry();
harness.runTestHarness(environmentOptions, master, debugOptions, verboseManager);
if (master instanceof AbstractHarnessTest) {
try {
((AbstractHarnessTest)master).setup();
} catch (Exception e) {
throw new GalvanFailureException("", e);
}
}
try {
harness.runTestHarness(environmentOptions, master, debugOptions, verboseManager);
} finally {
if (master instanceof AbstractHarnessTest) {
try {
((AbstractHarnessTest)master).teardown();
} catch (Exception e) {
throw new GalvanFailureException("", e);
}
}
}
System.out.println("TEST RUN SUCCESSFUL!");
} catch (GalvanFailureException e) {
System.out.println("TEST FAILED! " + e.getLocalizedMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ public BasicHarnessRunner(Class<?> testClass) throws InstantiationException, Ill
@Override
protected void runTest(EnvironmentOptions environmentOptions, ITestMaster<BasicTestClusterConfiguration> masterClass, DebugOptions debugOptions, VerboseManager verboseManager) throws IOException, GalvanFailureException {
BasicHarnessEntry harness = new BasicHarnessEntry();
harness.runTestHarness(environmentOptions, masterClass, debugOptions, verboseManager);
if (masterClass instanceof AbstractHarnessTest) {
try {
((AbstractHarnessTest)masterClass).setup();
} catch (Exception e) {
throw new GalvanFailureException("", e);
}
}
try {
harness.runTestHarness(environmentOptions, masterClass, debugOptions, verboseManager);
} finally {
if (masterClass instanceof AbstractHarnessTest) {
try {
((AbstractHarnessTest)masterClass).teardown();
} catch (Exception e) {
throw new GalvanFailureException("", e);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ public void interpretResult(Throwable error) throws Throwable {
throw error;
}
}

public void setup() throws Exception {
setUp();
}

public void teardown() throws Exception {
tearDown();
}
}

0 comments on commit d20efda

Please sign in to comment.