Browse Source

PityTest Framework improvements:

- copy constructor for TestUnit, so you can add the same TestUnit multiple times, with e.g. different context
- TestUnit.setContext() so you can add the same TestUnit multiple times, with e.g. different context
- TestUnit throws RuntimeException instead of Throwable
JNI-118
heck 5 years ago
parent
commit
7f2391ad60
  1. 2
      test/java/foundation/pEp/jniadapter/test/jni111/TestAlice.java
  2. 2
      test/java/foundation/pEp/jniadapter/test/jni115/TestAlice.java
  3. 7
      test/java/foundation/pEp/jniadapter/test/utils/AdapterBaseTestContext.java
  4. 2
      test/java/foundation/pEp/pitytest/TestSuite.java
  5. 34
      test/java/foundation/pEp/pitytest/TestUnit.java

2
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;

2
test/java/foundation/pEp/jniadapter/test/jni115/TestAlice.java

@ -19,7 +19,7 @@ class Jni115TestContext extends AdapterBaseTestContext {
public List<Message> messagesToBob;
@Override
public void init() throws Throwable {
public void init() throws RuntimeException {
super.init();
messagesToBobSmall = new ArrayList<>();
messagesToBobBig = new ArrayList<>();

7
test/java/foundation/pEp/jniadapter/test/utils/AdapterBaseTestContext.java

@ -63,7 +63,7 @@ public class AdapterBaseTestContext extends AbstractTestContext {
public Vector<Identity> vID;
public Vector<String> vStr;
public void init() throws Throwable {
public void init() throws RuntimeException {
vID = new Vector<Identity>();
vStr = new Vector<String>();
@ -96,6 +96,7 @@ public class AdapterBaseTestContext extends AbstractTestContext {
Path path;
path = Paths.get(filenameBobPub);
try {
keyBobPub = Files.readAllBytes(path);
path = Paths.get(filenameBobSec);
@ -112,6 +113,10 @@ public class AdapterBaseTestContext extends AbstractTestContext {
path = Paths.get(filenameAliceSecPassphrase);
keyAliceSecPassphrase = Files.readAllBytes(path);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
}

2
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() {

34
test/java/foundation/pEp/pitytest/TestUnit.java

@ -44,20 +44,45 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
add(TestSuite.getDefault());
}
//Shallow Copy
public TestUnit(TestUnit<T> 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<T> copy() {
return new TestUnit<>(this);
}
public boolean isVerboseMode() {
return verboseMode;
}
public void setVerboseMode(boolean verboseMode) {
public TestUnit<T> setVerboseMode(boolean verboseMode) {
this.verboseMode = verboseMode;
return this;
}
public TermColor getTestColor() {
return testColor;
}
public void setTestColor(TermColor testColor) {
public TestUnit<T> setTestColor(TermColor testColor) {
this.testColor = testColor;
return this;
}
public TestState getResult() {
@ -82,6 +107,11 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
return ctx;
}
public TestUnit<T> setContext(T ctx) {
this.ctx = ctx;
return this;
}
public void run() {
TestUtils.standardOutErrEnabled(verboseMode);
if (ctx.isUninitializable()) {

Loading…
Cancel
Save