
3 changed files with 118 additions and 0 deletions
@ -0,0 +1,37 @@ |
|||
include ../../../../../../../Makefile.conf |
|||
include ../Makefile.conf |
|||
|
|||
TEST_UNIT_NAME=jni115 |
|||
|
|||
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 |
@ -0,0 +1,66 @@ |
|||
package foundation.pEp.jniadapter.test.jni115; |
|||
|
|||
import static foundation.pEp.pitytest.TestLogger.*; |
|||
|
|||
import foundation.pEp.jniadapter.Message; |
|||
import foundation.pEp.pitytest.*; |
|||
import foundation.pEp.pitytest.utils.TestUtils; |
|||
import foundation.pEp.jniadapter.test.utils.*; |
|||
|
|||
import java.time.Duration; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
class Jni115TestContext extends AdapterBaseTestContext { |
|||
public int messagesToBobCount = 1000; |
|||
public List<Message> messagesToBob = new ArrayList<>(); |
|||
|
|||
@Override |
|||
public void init() throws Throwable { |
|||
super.init(); |
|||
|
|||
for (int i = 0; i < messagesToBobCount; i++) { |
|||
Message tmp = AdapterTestUtils.makeNewTestMessage(alice, bob, Message.Direction.Outgoing); |
|||
tmp.setLongmsg(tmp.getLongmsg() + " nr: " + String.valueOf(i)); |
|||
messagesToBob.add(tmp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
class TestAlice { |
|||
public static void main(String[] args) throws Exception { |
|||
TestSuite.getDefault().setVerbose(true); |
|||
TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN); |
|||
|
|||
Jni115TestContext ctx1 = new Jni115TestContext(); |
|||
|
|||
new TestUnit<Jni115TestContext>("myself()", ctx1, ctx -> { |
|||
ctx.alice = ctx.engine.myself(ctx.alice); |
|||
if (ctx.alice.fpr == null) { |
|||
throw new RuntimeException(); |
|||
} |
|||
}); |
|||
new TestUnit<Jni115TestContext>("importKey()", ctx1, ctx -> { |
|||
ctx.engine.importKey(ctx.keyBobPub); |
|||
}); |
|||
|
|||
new TestUnit<Jni115TestContext>("#MassEncryption", ctx1, ctx -> { |
|||
TestUtils.readKey(); |
|||
log("Encrypting " + ctx.messagesToBobCount + " messages"); |
|||
Duration total = new StopWatch(() -> { |
|||
for (Message msg : ctx.messagesToBob) { |
|||
Message encrypted = ctx.engine.encrypt_message(msg, null, Message.EncFormat.PEP); |
|||
logRaw("."); |
|||
} |
|||
}).getDuration(); |
|||
logRaw("\n"); |
|||
log("Total time [ms]: " + total.toMillis()); |
|||
}); |
|||
|
|||
TestSuite.getDefault().run(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
Loading…
Reference in new issue