Browse Source

TestContext rename

JNI-96
heck 5 years ago
parent
commit
733ca522c7
  1. 33
      test/java/foundation/pEp/jniadapter/test/utils/transport/fsmqmanager/test/regression/TestMain.java

33
test/java/foundation/pEp/jniadapter/test/utils/transport/fsmqmanager/test/regression/TestMain.java

@ -1,19 +1,16 @@
package foundation.pEp.jniadapter.test.utils.transport.fsmqmanager.test.regression; package foundation.pEp.jniadapter.test.utils.transport.fsmqmanager.test.regression;
import static foundation.pEp.jniadapter.test.framework.TestLogger.*; import static foundation.pEp.jniadapter.test.framework.TestLogger.*;
import static foundation.pEp.jniadapter.test.framework.TestUtils.deleteRecursively;
import foundation.pEp.jniadapter.test.utils.transport.fsmqmanager.*; import foundation.pEp.jniadapter.test.utils.transport.fsmqmanager.*;
import foundation.pEp.jniadapter.test.framework.*; import foundation.pEp.jniadapter.test.framework.*;
import foundation.pEp.jniadapter.test.utils.transport.fsmsgqueue.FsMsgQueue;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
class FsMsgQueueTestContext extends AbstractTestContext { class FsMQManagerTestContext extends AbstractTestContext {
String ownAddress = "Alice"; String ownAddress = "Alice";
String ownQDir = "../resources/fsmsgqueue-test/alice"; String ownQDir = "../resources/fsmsgqueue-test/alice";
String bobAddress = "Bob"; String bobAddress = "Bob";
@ -47,21 +44,21 @@ class FsMsgQueueTestContext extends AbstractTestContext {
class TestMain { class TestMain {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
TestSuite.setVerbose(true); TestSuite.setVerbose(true);
FsMsgQueueTestContext testCtx = new FsMsgQueueTestContext(); FsMQManagerTestContext testCtx = new FsMQManagerTestContext();
new TestUnit<FsMsgQueueTestContext>("Create own ident: " + testCtx.ownAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("Create own ident: " + testCtx.ownAddress, testCtx, ctx -> {
ctx.self = new FsMQIdentity(ctx.ownAddress, ctx.ownQDir); ctx.self = new FsMQIdentity(ctx.ownAddress, ctx.ownQDir);
assert ctx.self != null : "null"; assert ctx.self != null : "null";
assert ctx.self.getAddress().equals(ctx.ownAddress): "Address mismatch"; assert ctx.self.getAddress().equals(ctx.ownAddress): "Address mismatch";
assert ctx.self.getqDir().equals(ctx.ownQDir): "qDir mismatch"; assert ctx.self.getqDir().equals(ctx.ownQDir): "qDir mismatch";
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("Constructor with: " + testCtx.ownAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("Constructor with: " + testCtx.ownAddress, testCtx, ctx -> {
ctx.qm = new FsMQManager(ctx.self); ctx.qm = new FsMQManager(ctx.self);
assert ctx.qm != null : "null"; assert ctx.qm != null : "null";
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("Ident known: " + testCtx.ownAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("Ident known: " + testCtx.ownAddress, testCtx, ctx -> {
FsMQIdentity self = ctx.qm.getIdentityForAddress(ctx.ownAddress); FsMQIdentity self = ctx.qm.getIdentityForAddress(ctx.ownAddress);
assert self != null : "null"; assert self != null : "null";
assert self.equals(ctx.self) : "Obj mismatch"; assert self.equals(ctx.self) : "Obj mismatch";
@ -69,14 +66,14 @@ class TestMain {
log("qDir: " + self.getqDir()); log("qDir: " + self.getqDir());
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("Create ident " + testCtx.bobAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("Create ident " + testCtx.bobAddress, testCtx, ctx -> {
ctx.bob = new FsMQIdentity(ctx.bobAddress, ctx.bobQDir); ctx.bob = new FsMQIdentity(ctx.bobAddress, ctx.bobQDir);
assert ctx.bob != null : "null"; assert ctx.bob != null : "null";
assert ctx.bob.getAddress().equals(ctx.bobAddress) : "Address mismatch"; assert ctx.bob.getAddress().equals(ctx.bobAddress) : "Address mismatch";
assert ctx.bob.getqDir().equals(ctx.bobQDir) : "qDir mismatch"; assert ctx.bob.getqDir().equals(ctx.bobQDir) : "qDir mismatch";
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("Ident unknown: " + testCtx.bobAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("Ident unknown: " + testCtx.bobAddress, testCtx, ctx -> {
try { try {
FsMQIdentity self = ctx.qm.getIdentityForAddress(ctx.bobAddress); FsMQIdentity self = ctx.qm.getIdentityForAddress(ctx.bobAddress);
} catch (UnknownIdentityException e) { } catch (UnknownIdentityException e) {
@ -85,24 +82,24 @@ class TestMain {
assert false : "Ident is known but shouldnt"; assert false : "Ident is known but shouldnt";
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("Add ident " + testCtx.bobAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("Add ident " + testCtx.bobAddress, testCtx, ctx -> {
assert ctx.qm.addOrUpdateIdentity(ctx.bob) : "Identity updated but should have been added"; assert ctx.qm.addOrUpdateIdentity(ctx.bob) : "Identity updated but should have been added";
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("Ident known: " + testCtx.bobAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("Ident known: " + testCtx.bobAddress, testCtx, ctx -> {
FsMQIdentity bob = ctx.qm.getIdentityForAddress(ctx.bobAddress); FsMQIdentity bob = ctx.qm.getIdentityForAddress(ctx.bobAddress);
assert bob.equals(ctx.bob) : "Obj mismatch"; assert bob.equals(ctx.bob) : "Obj mismatch";
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("Update ident " + testCtx.bobAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("Update ident " + testCtx.bobAddress, testCtx, ctx -> {
assert !ctx.qm.addOrUpdateIdentity(ctx.bob) : "Ident got added but should have been updated"; assert !ctx.qm.addOrUpdateIdentity(ctx.bob) : "Ident got added but should have been updated";
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("ClearOwnQueue: " + testCtx.bobAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("ClearOwnQueue: " + testCtx.bobAddress, testCtx, ctx -> {
ctx.qm.clearOwnQueue(); ctx.qm.clearOwnQueue();
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("waitForMsg timeout", testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("waitForMsg timeout", testCtx, ctx -> {
log("waitForMessage with timeout..."); log("waitForMessage with timeout...");
try { try {
ctx.qm.waitForMsg(3); ctx.qm.waitForMsg(3);
@ -115,7 +112,7 @@ class TestMain {
} }
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("sendMsgTo self " + testCtx.ownAddress, testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("sendMsgTo self " + testCtx.ownAddress, testCtx, ctx -> {
String msg = ctx.messages.get(0); String msg = ctx.messages.get(0);
log("TX MSG: " + msg); log("TX MSG: " + msg);
try { try {
@ -125,7 +122,7 @@ class TestMain {
} }
}).add(); }).add();
new TestUnit<FsMsgQueueTestContext>("waitForMsg", testCtx, ctx -> { new TestUnit<FsMQManagerTestContext>("waitForMsg", testCtx, ctx -> {
String msg = null; String msg = null;
try { try {
msg = ctx.qm.waitForMsg(10); msg = ctx.qm.waitForMsg(10);
@ -133,7 +130,7 @@ class TestMain {
throw new RuntimeException(e.toString()); throw new RuntimeException(e.toString());
} }
log("RX MSG: " + msg); log("RX MSG: " + msg);
assert msg.equals(ctx.messages.get(0)); assert msg.equals(ctx.messages.get(0)) : "message content mismatch";
}).add(); }).add();

Loading…
Cancel
Save