Browse Source

JNI-134 - Tests for class Message getter/setter

JNI-134
heck 4 years ago
parent
commit
784a49ce70
  1. 37
      test/java/foundation/pEp/jniadapter/test/jni129/Makefile
  2. 109
      test/java/foundation/pEp/jniadapter/test/jni129/TestAlice.java
  3. 37
      test/java/foundation/pEp/jniadapter/test/jni134/Makefile
  4. 109
      test/java/foundation/pEp/jniadapter/test/jni134/TestAlice.java

37
test/java/foundation/pEp/jniadapter/test/jni129/Makefile

@ -0,0 +1,37 @@
include ../../../../../../../Makefile.conf
include ../Makefile.conf
TEST_UNIT_NAME=jni129
JAVA_CLASSES = \
TestAlice.class \
../utils/AdapterBaseTestContext.class \
../utils/AdapterTestUtils.class \
../utils/TestCallbacks.class
.PHONY: pitytest compile alice test clean
all: alice compile
pitytest:
$(MAKE) -C $(PITYTEST_DIR)
alice: compile clean-pep-home-alice
cd $(JAVA_CWD);pwd;HOME=$(JAVA_PEP_HOME_DIR_ALICE) $(JAVA) $(JAVA_PKG_BASENAME).$(TEST_UNIT_NAME).TestAlice
compile: $(JAVA_CLASSES) pitytest
%.class: %.java
cd $(JAVA_CWD);javac -cp $(CLASSPATH) $(JAVA_PKG_BASEPATH)/$(TEST_UNIT_NAME)/$<
clean:
rm -f $(JAVA_CLASSES)
rm -f *.class
rm -f *.log
rm -Rf .gnupg
rm -Rf .lldb
clean-pep-home: clean-pep-home-alice
clean-pep-home-alice:
rm -rf $(PEP_HOME_DIR_ALICE)/.pEp

109
test/java/foundation/pEp/jniadapter/test/jni129/TestAlice.java

@ -0,0 +1,109 @@
package foundation.pEp.jniadapter.test.jni129;
import foundation.pEp.jniadapter.Blob;
import foundation.pEp.jniadapter.Identity;
import foundation.pEp.jniadapter.Message;
import foundation.pEp.jniadapter.test.utils.AdapterBaseTestContext;
import foundation.pEp.pitytest.TestSuite;
import foundation.pEp.pitytest.TestUnit;
import foundation.pEp.pitytest.utils.TestUtils;
import java.util.Date;
import java.util.Vector;
class Jni129TestContext extends AdapterBaseTestContext {
@Override
public AdapterBaseTestContext init() throws Throwable {
super.init();
return this;
}
}
class TestAlice {
public static void main(String[] args) throws Exception {
TestSuite.getDefault().setVerbose(true);
TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN);
AdapterBaseTestContext jni129Ctx = new Jni129TestContext();
new TestUnit<AdapterBaseTestContext>("setDir() == getDir() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
Message.Direction inVal = ctx.msgDirOutgoing;
msg.setDir(inVal);
Message.Direction outVal = msg.getDir();
assert outVal == inVal : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setId() == getId() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
String inVal = "23";
msg.setId(inVal);
String outVal = msg.getId();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setShortmsg() == getShortmsg() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
String inVal = "23";
msg.setShortmsg(inVal);
String outVal = msg.getShortmsg();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setLongmsg() == getLongmsg() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
String inVal = "23";
msg.setLongmsg(inVal);
String outVal = msg.getLongmsg();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setLongmsgFormatted() == getLongmsgFormatted() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
String inVal = "23";
msg.setLongmsgFormatted(inVal);
String outVal = msg.getLongmsgFormatted();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setAttachments() == getAttachments() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
Vector<Blob> inVal = ctx.attachments;
msg.setAttachments(inVal);
Vector<Blob> outVal = msg.getAttachments();
for (int i = 0; i < 3; i++) {
Blob inElem = inVal.get(i);
Blob outElem = outVal.get(i);
assert inElem == inElem : "\nreturned '" + outElem + "' instead of '" + inElem + "'";
}
});
new TestUnit<AdapterBaseTestContext>("setSent() == getSent() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
Date inVal = new Date();
msg.setSent(inVal);
Date outVal = msg.getSent();
assert outVal == inVal : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setRecv() == getRecv() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
Date inVal = new Date();
msg.setRecv(inVal);
Date outVal = msg.getRecv();
assert outVal == inVal : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setFrom() == getFrom() ", new Jni129TestContext(), ctx -> {
Message msg = new Message();
Identity inVal = ctx.alice;
msg.setFrom(inVal);
Identity outVal = msg.getFrom();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "'\nexpected '" + inVal + "'";
});
TestSuite.getDefault().run();
}
}

37
test/java/foundation/pEp/jniadapter/test/jni134/Makefile

@ -0,0 +1,37 @@
include ../../../../../../../Makefile.conf
include ../Makefile.conf
TEST_UNIT_NAME=jni134
JAVA_CLASSES = \
TestAlice.class \
../utils/AdapterBaseTestContext.class \
../utils/AdapterTestUtils.class \
../utils/TestCallbacks.class
.PHONY: pitytest compile alice test clean
all: alice compile
pitytest:
$(MAKE) -C $(PITYTEST_DIR)
alice: compile clean-pep-home-alice
cd $(JAVA_CWD);pwd;HOME=$(JAVA_PEP_HOME_DIR_ALICE) $(JAVA) $(JAVA_PKG_BASENAME).$(TEST_UNIT_NAME).TestAlice
compile: $(JAVA_CLASSES) pitytest
%.class: %.java
cd $(JAVA_CWD);javac -cp $(CLASSPATH) $(JAVA_PKG_BASEPATH)/$(TEST_UNIT_NAME)/$<
clean:
rm -f $(JAVA_CLASSES)
rm -f *.class
rm -f *.log
rm -Rf .gnupg
rm -Rf .lldb
clean-pep-home: clean-pep-home-alice
clean-pep-home-alice:
rm -rf $(PEP_HOME_DIR_ALICE)/.pEp

109
test/java/foundation/pEp/jniadapter/test/jni134/TestAlice.java

@ -0,0 +1,109 @@
package foundation.pEp.jniadapter.test.jni134;
import foundation.pEp.jniadapter.Blob;
import foundation.pEp.jniadapter.Identity;
import foundation.pEp.jniadapter.Message;
import foundation.pEp.jniadapter.test.utils.AdapterBaseTestContext;
import foundation.pEp.pitytest.TestSuite;
import foundation.pEp.pitytest.TestUnit;
import foundation.pEp.pitytest.utils.TestUtils;
import java.util.Date;
import java.util.Vector;
class Jni134TestContext extends AdapterBaseTestContext {
@Override
public AdapterBaseTestContext init() throws Throwable {
super.init();
return this;
}
}
class TestAlice {
public static void main(String[] args) throws Exception {
TestSuite.getDefault().setVerbose(true);
TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN);
AdapterBaseTestContext jni134Ctx = new Jni134TestContext();
new TestUnit<AdapterBaseTestContext>("setDir() == getDir() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
Message.Direction inVal = ctx.msgDirOutgoing;
msg.setDir(inVal);
Message.Direction outVal = msg.getDir();
assert outVal == inVal : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setId() == getId() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
String inVal = "23";
msg.setId(inVal);
String outVal = msg.getId();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setShortmsg() == getShortmsg() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
String inVal = "23";
msg.setShortmsg(inVal);
String outVal = msg.getShortmsg();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setLongmsg() == getLongmsg() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
String inVal = "23";
msg.setLongmsg(inVal);
String outVal = msg.getLongmsg();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setLongmsgFormatted() == getLongmsgFormatted() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
String inVal = "23";
msg.setLongmsgFormatted(inVal);
String outVal = msg.getLongmsgFormatted();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setAttachments() == getAttachments() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
Vector<Blob> inVal = ctx.attachments;
msg.setAttachments(inVal);
Vector<Blob> outVal = msg.getAttachments();
for (int i = 0; i < 3; i++) {
Blob inElem = inVal.get(i);
Blob outElem = outVal.get(i);
assert inElem == inElem : "\nreturned '" + outElem + "' instead of '" + inElem + "'";
}
});
new TestUnit<AdapterBaseTestContext>("setSent() == getSent() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
Date inVal = new Date();
msg.setSent(inVal);
Date outVal = msg.getSent();
assert outVal == inVal : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setRecv() == getRecv() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
Date inVal = new Date();
msg.setRecv(inVal);
Date outVal = msg.getRecv();
assert outVal == inVal : "\nreturned '" + outVal + "' instead of '" + inVal + "'";
});
new TestUnit<AdapterBaseTestContext>("setFrom() == getFrom() ", new Jni134TestContext(), ctx -> {
Message msg = new Message();
Identity inVal = ctx.alice;
msg.setFrom(inVal);
Identity outVal = msg.getFrom();
assert outVal.equals(inVal) : "\nreturned '" + outVal + "'\nexpected '" + inVal + "'";
});
TestSuite.getDefault().run();
}
}
Loading…
Cancel
Save