diff --git a/test/java/foundation/pEp/jniadapter/test/jni111/TestAlice.java b/test/java/foundation/pEp/jniadapter/test/jni111/TestAlice.java index 52f0f04..550c2c3 100644 --- a/test/java/foundation/pEp/jniadapter/test/jni111/TestAlice.java +++ b/test/java/foundation/pEp/jniadapter/test/jni111/TestAlice.java @@ -16,7 +16,7 @@ import java.util.Vector; class JNI111TestContext extends AdapterBaseTestContext { @Override - public void init() throws Throwable { + public void init() throws RuntimeException { super.init(); alice = null; bob = null; diff --git a/test/java/foundation/pEp/jniadapter/test/jni115/TestAlice.java b/test/java/foundation/pEp/jniadapter/test/jni115/TestAlice.java index fb82385..2aba549 100644 --- a/test/java/foundation/pEp/jniadapter/test/jni115/TestAlice.java +++ b/test/java/foundation/pEp/jniadapter/test/jni115/TestAlice.java @@ -19,7 +19,7 @@ class Jni115TestContext extends AdapterBaseTestContext { public List messagesToBob; @Override - public void init() throws Throwable { + public void init() throws RuntimeException { super.init(); messagesToBobSmall = new ArrayList<>(); messagesToBobBig = new ArrayList<>(); diff --git a/test/java/foundation/pEp/jniadapter/test/utils/AdapterBaseTestContext.java b/test/java/foundation/pEp/jniadapter/test/utils/AdapterBaseTestContext.java index 5c3fa10..311c2e5 100644 --- a/test/java/foundation/pEp/jniadapter/test/utils/AdapterBaseTestContext.java +++ b/test/java/foundation/pEp/jniadapter/test/utils/AdapterBaseTestContext.java @@ -63,7 +63,7 @@ public class AdapterBaseTestContext extends AbstractTestContext { public Vector vID; public Vector vStr; - public void init() throws Throwable { + public void init() throws RuntimeException { vID = new Vector(); vStr = new Vector(); @@ -74,7 +74,7 @@ public class AdapterBaseTestContext extends AbstractTestContext { TestLogger.logH2("Machine directory: "); TestLogger.log(engine.getMachineDirectory()); - TestLogger.logH2("User directory:" ); + TestLogger.logH2("User directory:"); TestLogger.log(engine.getUserDirectory()); @@ -96,22 +96,27 @@ public class AdapterBaseTestContext extends AbstractTestContext { Path path; path = Paths.get(filenameBobPub); - keyBobPub = Files.readAllBytes(path); + try { + keyBobPub = Files.readAllBytes(path); - path = Paths.get(filenameBobSec); - keyBobSec = Files.readAllBytes(path); + path = Paths.get(filenameBobSec); + keyBobSec = Files.readAllBytes(path); - path = Paths.get(filenameAlicePub); - keyAlicePub = Files.readAllBytes(path); + path = Paths.get(filenameAlicePub); + keyAlicePub = Files.readAllBytes(path); - path = Paths.get(filenameAliceSec); - keyAliceSec = Files.readAllBytes(path); + path = Paths.get(filenameAliceSec); + keyAliceSec = Files.readAllBytes(path); - path = Paths.get(filenameAlicePubPassphrase); - keyAlicePubPassphrase = Files.readAllBytes(path); + path = Paths.get(filenameAlicePubPassphrase); + keyAlicePubPassphrase = Files.readAllBytes(path); + + path = Paths.get(filenameAliceSecPassphrase); + keyAliceSecPassphrase = Files.readAllBytes(path); + } catch (Throwable e) { + throw new RuntimeException(e); + } - path = Paths.get(filenameAliceSecPassphrase); - keyAliceSecPassphrase = Files.readAllBytes(path); } } \ No newline at end of file diff --git a/test/java/foundation/pEp/pitytest/TestSuite.java b/test/java/foundation/pEp/pitytest/TestSuite.java index f44d355..e5e5920 100644 --- a/test/java/foundation/pEp/pitytest/TestSuite.java +++ b/test/java/foundation/pEp/pitytest/TestSuite.java @@ -75,7 +75,7 @@ public class TestSuite { } public void add(TestUnit t) { - tests.add(t); + tests.add(t.copy()); } public void run() { diff --git a/test/java/foundation/pEp/pitytest/TestUnit.java b/test/java/foundation/pEp/pitytest/TestUnit.java index a14b4f0..1e4429d 100644 --- a/test/java/foundation/pEp/pitytest/TestUnit.java +++ b/test/java/foundation/pEp/pitytest/TestUnit.java @@ -44,20 +44,45 @@ public class TestUnit implements Runnable { add(TestSuite.getDefault()); } + //Shallow Copy + public TestUnit(TestUnit orig) { + testUnitName = orig.testUnitName; + ctx = orig.ctx; + lambda = orig.lambda; + result = orig.result; + state = orig.state; + lastException = orig.lastException; + verboseMode = orig.verboseMode; + testColor = orig.testColor; + logFmtPadding = orig.logFmtPadding; + logFmtMsgLen = orig.logFmtMsgLen; + logFmtTestDuration = orig.logFmtTestDuration; + lineWidthMin = orig.lineWidthMin; + logFmtTestNameLen = orig.logFmtTestNameLen; + logFmtCtxNameLen = orig.logFmtCtxNameLen; + } + + //Shallow Copy + public TestUnit copy() { + return new TestUnit<>(this); + } + public boolean isVerboseMode() { return verboseMode; } - public void setVerboseMode(boolean verboseMode) { + public TestUnit setVerboseMode(boolean verboseMode) { this.verboseMode = verboseMode; + return this; } public TermColor getTestColor() { return testColor; } - public void setTestColor(TermColor testColor) { + public TestUnit setTestColor(TermColor testColor) { this.testColor = testColor; + return this; } public TestState getResult() { @@ -82,6 +107,11 @@ public class TestUnit implements Runnable { return ctx; } + public TestUnit setContext(T ctx) { + this.ctx = ctx; + return this; + } + public void run() { TestUtils.standardOutErrEnabled(verboseMode); if (ctx.isUninitializable()) { @@ -154,7 +184,7 @@ public class TestUnit implements Runnable { } private void setTestResult(TestState r) { - assert (r == TestState.SKIPPED || r == TestState.FAILED || r == TestState.SUCCESS || r == TestState.UNEVALUATED ): "PityTest Internal: illegal result value '" + r +"'"; + assert (r == TestState.SKIPPED || r == TestState.FAILED || r == TestState.SUCCESS || r == TestState.UNEVALUATED) : "PityTest Internal: illegal result value '" + r + "'"; result = r; TestUtils.standardOutErrEnabled(true); logH1(makeLogString()); @@ -193,7 +223,7 @@ public class TestUnit implements Runnable { DecimalFormat f = new DecimalFormat("0.000"); String durationFmtd = f.format(testDuration.toMillis() / 1000.0); strTestDuration = TestUtils.padOrClipString(" [" + durationFmtd + " sec] ", "=", logFmtTestDuration, TestUtils.Alignment.Right, ".. "); - } else { + } else { strTestDuration = TestUtils.padOrClipString("", "=", logFmtTestDuration, TestUtils.Alignment.Right, ".. "); }