Browse Source

Testframework add example "ctxinitfail"

JNI-96
heck 5 years ago
parent
commit
59c9f5cb2f
  1. 25
      test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/Makefile
  2. 56
      test/java/foundation/pEp/jniadapter/test/framework/examples/ctxinitfail/TestMain.java

25
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)

56
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<CtxInitFailContext>("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<CtxInitFailContext>("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<CtxInitFailContext>("ctxinitfail2",failingContext , ctx -> {
// do stuff using the context
// Test FAILS on unhandled exception, otherwise SUCCESS
log("Hello World from: " + ctx.name);
}).add();
new TestUnit<CtxInitFailContext>("ctxinitfail3",failingContext , ctx -> {
// do stuff using the context
// Test FAILS on unhandled exception, otherwise SUCCESS
log("Hello World from: " + ctx.name);
}).add();
new TestUnit<CtxInitFailContext>("ctxinitfail4",failingContext , ctx -> {
// do stuff using the context
// Test FAILS on unhandled exception, otherwise SUCCESS
log("Hello World from: " + ctx.name);
}).add();
TestSuite.run();
}
}
Loading…
Cancel
Save