From 9c8e2241951dff6686c0ba4c2aa8383e5a5aa23e Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 17 Mar 2021 23:04:46 +0100 Subject: [PATCH] Tests: Remove huge attachments from CTXBase (too slow) --- .../pEp/jniadapter/test/jni132/TestAlice.java | 27 +++++++++++++------ .../pEp/jniadapter/test/utils/CTXBase.java | 5 ---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/test/java/foundation/pEp/jniadapter/test/jni132/TestAlice.java b/test/java/foundation/pEp/jniadapter/test/jni132/TestAlice.java index 83f9f8e..c201cdf 100644 --- a/test/java/foundation/pEp/jniadapter/test/jni132/TestAlice.java +++ b/test/java/foundation/pEp/jniadapter/test/jni132/TestAlice.java @@ -20,27 +20,38 @@ equality definition: - bytewise equality of mime_type */ +class CTXJNI132 extends CTXBase { + public Blob attachment1MB; + public Blob attachment10MB; + + @Override + public CTXBase init() throws Throwable { + attachment1MB = AdapterTestUtils.makeNewTestBlob(1000000, "att with size 1MB", null); + attachment10MB = AdapterTestUtils.makeNewTestBlob(10000000, "att with size 10MB", null); + + return this; + } +} class TestAlice { public static void main(String[] args) throws Exception { TestSuite.getDefault().setVerbose(true); TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN); - CTXBase jni132Ctx = new CTXBase(); // SAME - new TestUnit("Blob.equals() equality", new CTXBase(), ctx -> { + new TestUnit("Blob.equals() equality", new CTXJNI132(), ctx -> { Blob one = AdapterTestUtils.makeNewTestBlob("testBlob data", "testblobfilename", null); Blob two = AdapterTestUtils.makeNewTestBlob("testBlob data", "testblobfilename", null); assert one.equals(two) : "\n" + one.toString() + "\n" + "does not equal:\n" + two.toString(); }); - new TestUnit("Blob.equals() equality", new CTXBase(), ctx -> { + new TestUnit("Blob.equals() equality", new CTXJNI132(), ctx -> { Blob one = AdapterTestUtils.makeNewTestBlob("testBlob data", "file://testblobfilename", null); Blob two = AdapterTestUtils.makeNewTestBlob("testBlob data", "testblobfilename", null); assert one.equals(two) : "\n" + one.toString() + "\n" + "does not equal:\n" + two.toString(); }); - new TestUnit("Blob.equals() equality", new CTXBase(), ctx -> { + new TestUnit("Blob.equals() equality", new CTXJNI132(), ctx -> { Blob one = AdapterTestUtils.makeNewTestBlob(1000000, "testfilename", "anything goes"); Blob two = new Blob(); two.mime_type = new String(one.mime_type); @@ -49,7 +60,7 @@ class TestAlice { assert one.equals(two) : "\n" + one.toString() + "\n" + "does not equal:\n" + two.toString(); }); - new TestUnit("Blob.equals() equality", new CTXBase(), ctx -> { + new TestUnit("Blob.equals() equality", new CTXJNI132(), ctx -> { Blob one = AdapterTestUtils.makeNewTestBlob(1000000, "file://testfilename", "anything goes"); Blob two = new Blob(); two.mime_type = new String(one.mime_type); @@ -59,7 +70,7 @@ class TestAlice { }); // NOT SAME - new TestUnit("Blob.equals() - diff mime_type", new CTXBase(), ctx -> { + new TestUnit("Blob.equals() - diff mime_type", new CTXJNI132(), ctx -> { Blob one = ctx.attachment1KB; Blob two = new Blob(); two.mime_type = "diff"; @@ -68,7 +79,7 @@ class TestAlice { assert !one.equals(two) : "\n" + one.toString() + "\n" + "equals:\n" + two.toString(); }); - new TestUnit("Blob.equals() diff filename", new CTXBase(), ctx -> { + new TestUnit("Blob.equals() diff filename", new CTXJNI132(), ctx -> { Blob one = ctx.attachment1KB; Blob two = new Blob(); two.mime_type = ctx.attachment1KB.mime_type; @@ -77,7 +88,7 @@ class TestAlice { assert !one.equals(two) : "\n" + one.toString() + "\n" + "equals:\n" + two.toString(); }); - new TestUnit("Blob.equals() diff data", new CTXBase(), ctx -> { + new TestUnit("Blob.equals() diff data", new CTXJNI132(), ctx -> { Blob one = ctx.attachment1KB; Blob two = new Blob(); two.mime_type = ctx.attachment1KB.mime_type; diff --git a/test/java/foundation/pEp/jniadapter/test/utils/CTXBase.java b/test/java/foundation/pEp/jniadapter/test/utils/CTXBase.java index 25d18cb..31f6c92 100644 --- a/test/java/foundation/pEp/jniadapter/test/utils/CTXBase.java +++ b/test/java/foundation/pEp/jniadapter/test/utils/CTXBase.java @@ -67,11 +67,8 @@ public class CTXBase extends AbstractTestContext { public Message.Direction msgDirOutgoing = Message.Direction.Outgoing; public Blob attachmentTiny; public Blob attachment1KB; - public Blob attachment1MB; - public Blob attachment10MB; public AttachmentList attachmentList = new AttachmentList(3,10000); - public CTXBase init() throws Throwable { callbacks = new TestCallbacks(); engine = new Engine(); @@ -85,8 +82,6 @@ public class CTXBase extends AbstractTestContext { attachmentTiny = AdapterTestUtils.makeNewTestBlob("attachment1", "attachment1.txt", "text/plain"); attachment1KB = AdapterTestUtils.makeNewTestBlob(1000, "att with size 1KB", null); - attachment1MB = AdapterTestUtils.makeNewTestBlob(1000000, "att with size 1MB", null); - attachment10MB = AdapterTestUtils.makeNewTestBlob(10000000, "att with size 10MB", null); alice = new Identity(); alice.user_id = "23";