From 59c9f5cb2ff302f4f764e4249131140afb74a107 Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 28 May 2020 15:40:01 +0200 Subject: [PATCH] Testframework add example "ctxinitfail" --- .../framework/examples/ctxinitfail/Makefile | 25 +++++++++ .../examples/ctxinitfail/TestMain.java | 56 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/Makefile create mode 100644 test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/TestMain.java diff --git a/test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/Makefile b/test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/Makefile new file mode 100644 index 0000000..2faca28 --- /dev/null +++ b/test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/Makefile @@ -0,0 +1,25 @@ +include ../Makefile.conf + +TEST_UNIT_NAME=ctxinitfail + +JAVA_CLASSES = \ + TestMain.class \ + +# Use the test framework +JAVA_CLASSES += $(JAVA_CLASSES_FRAMEWORK) + +.PHONY: compile run test clean + +all: compile + $(MAKE) run + +run: compile + cd $(JAVA_CWD);$(JAVA) $(JAVA_PKG_BASENAME).$(TEST_UNIT_NAME).TestMain + +compile: $(JAVA_CLASSES) + +%.class: %.java + cd $(JAVA_CWD);pwd;javac $(JAVA_PKG_BASEPATH)/$(TEST_UNIT_NAME)/$< + +clean: + rm -f $(JAVA_CLASSES) diff --git a/test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/TestMain.java b/test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/TestMain.java new file mode 100644 index 0000000..6c2b49c --- /dev/null +++ b/test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/TestMain.java @@ -0,0 +1,56 @@ +package foundation.pEp.jniadapter.test.framework.examples.ctxinitfail; +import static foundation.pEp.jniadapter.test.framework.TestLogger.*; +import foundation.pEp.jniadapter.test.framework.*; + + +class CtxInitFailContext extends AbstractTestContext { + String name; + int result; + @Override + public void init() throws Throwable { + name = "UnitTestFrameWorkWithoutAName"; + result = 50 / 0; + } +} + +class TestMain { + public static void main(String[] args) throws Exception { +// TestSuite.setVerbose(true); + + new TestUnit("ctxinitfail1",new CtxInitFailContext() , ctx -> { + // do stuff using the context + // Test FAILS on unhandled exception, otherwise SUCCESS + log("Hello World from: " + ctx.name); + }).add(); + + new TestUnit("ctxinitfail1",new CtxInitFailContext() , ctx -> { + // do stuff using the context + // Test FAILS on unhandled exception, otherwise SUCCESS + log("Hello World from: " + ctx.name); + }).add(); + + CtxInitFailContext failingContext = new CtxInitFailContext(); + + new TestUnit("ctxinitfail2",failingContext , ctx -> { + // do stuff using the context + // Test FAILS on unhandled exception, otherwise SUCCESS + log("Hello World from: " + ctx.name); + }).add(); + + new TestUnit("ctxinitfail3",failingContext , ctx -> { + // do stuff using the context + // Test FAILS on unhandled exception, otherwise SUCCESS + log("Hello World from: " + ctx.name); + }).add(); + + new TestUnit("ctxinitfail4",failingContext , ctx -> { + // do stuff using the context + // Test FAILS on unhandled exception, otherwise SUCCESS + log("Hello World from: " + ctx.name); + }).add(); + + TestSuite.run(); + } +} + +