diff --git a/build.gradle b/build.gradle index 65ee461..8734f2c 100755 --- a/build.gradle +++ b/build.gradle @@ -106,6 +106,9 @@ dependencies { //------------------------------------------------------------------------------------------------------------------- testImplementation 'junit:junit:4.12' testImplementation 'com.carrotsearch:junit-benchmarks:0.7.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.8.2' } @@ -220,6 +223,8 @@ artifacts { // Adjust test to run concurrently test { + useJUnitPlatform() + // Exclude performance related test // exclude "**/perf/*.java" // exclude "**/*_perf*" diff --git a/src/test/java/picoded/lang/inheritance/StaticExtendedClass_test.java b/src/test/java/picoded/lang/inheritance/StaticExtendedClass_test.java index c858ad4..d59056d 100755 --- a/src/test/java/picoded/lang/inheritance/StaticExtendedClass_test.java +++ b/src/test/java/picoded/lang/inheritance/StaticExtendedClass_test.java @@ -1,22 +1,25 @@ package picoded.lang.inheritance; // Junit includes -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; // Base class to build on public class StaticExtendedClass_test { @Test + @DisplayName("Static base class hello method inheritance") public void hello() { assertEquals("world", StaticExtendedClass.hello()); } @Test + @DisplayName("Static base class toExtend method extension inheritance") public void extended() { assertEquals("base plus", StaticExtendedClass.toExtend()); } diff --git a/src/test/java/picoded/lang/reflection/Class_isAssignableFrom_test.java b/src/test/java/picoded/lang/reflection/Class_isAssignableFrom_test.java index 218f908..a007c7b 100755 --- a/src/test/java/picoded/lang/reflection/Class_isAssignableFrom_test.java +++ b/src/test/java/picoded/lang/reflection/Class_isAssignableFrom_test.java @@ -1,17 +1,18 @@ package picoded.lang.reflection; // Junit includes -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.core.struct.GenericConvertHashMap; import picoded.core.struct.GenericConvertMap; @@ -20,6 +21,7 @@ public class Class_isAssignableFrom_test { @Test + @DisplayName("Reflection check for Map interface assignment capabilities on subclass conversion classes") public void assignableTest() { Class mapClass = Map.class; Class genericMapClass = GenericConvertMap.class; diff --git a/src/test/java/picoded/servlet/AxiosApiBuilder_test.java b/src/test/java/picoded/servlet/AxiosApiBuilder_test.java index aec6c61..4617036 100755 --- a/src/test/java/picoded/servlet/AxiosApiBuilder_test.java +++ b/src/test/java/picoded/servlet/AxiosApiBuilder_test.java @@ -1,8 +1,8 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.*; import java.net.URI; @@ -16,9 +16,10 @@ import javax.servlet.ServletRequest; import java.lang.reflect.Method; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.core.conv.ConvertJSON; import picoded.core.conv.GenericConvert; @@ -40,13 +41,13 @@ public class AxiosApiBuilder_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -101,6 +102,10 @@ public void middle() { @RequestPath("to/*") public static SmallWorld rerouteToSmallWorld; + @Override + public void contextInitialized(ServletContextEvent sce) { + super.contextInitialized(sce); + } } public static class RerouteWorld extends BasePage { @@ -130,6 +135,7 @@ public Map assortedPath() { } @Test + @DisplayName("Checks dynamic resolution of static hello path") public void testHelloPath() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/hello"; @@ -148,6 +154,7 @@ public void testHelloPath() throws Exception { smallWorld -> smallWorld */ @Test + @DisplayName("Checks dynamic resolution of static endpoints behind nested page rerouting variables") public void testRerouteWorld() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new RerouteWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/reroute/hello"; @@ -156,6 +163,7 @@ public void testRerouteWorld() throws Exception { } @Test + @DisplayName("Checks compilation and verification of complete scanned path endpoint configurations") public void rerouteScannedApiPaths() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new RerouteWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/paths/hello"; @@ -209,6 +217,7 @@ protected void doSharedSetup() throws Exception { } @Test + @DisplayName("Checks serialization structure of endpoint configuration objects") public void test_endpointMapGeneration() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new EndpointMapGenerator())); String testUrl = "http://127.0.0.1:" + testPort + "/endpoint"; @@ -217,6 +226,7 @@ public void test_endpointMapGeneration() { } @Test + @DisplayName("Checks dynamic compilation of endpoints metadata maps as flat strings") public void test_endpointMapInString() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new EndpointMapGenerator())); String testUrl = "http://127.0.0.1:" + testPort + "/endpoint/string"; @@ -250,6 +260,7 @@ protected void doSharedSetup() throws Exception { } @Test + @DisplayName("Checks compilation and verification of generated Axios JS client templates") public void test_loadingTemplate() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new EndpointLoad())); String testUrl = "http://127.0.0.1:" + testPort + "/template/load"; diff --git a/src/test/java/picoded/servlet/BasePage_advanced_test.java b/src/test/java/picoded/servlet/BasePage_advanced_test.java index a08266f..8883964 100755 --- a/src/test/java/picoded/servlet/BasePage_advanced_test.java +++ b/src/test/java/picoded/servlet/BasePage_advanced_test.java @@ -1,8 +1,8 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.FileOutputStream; import java.io.PrintWriter; @@ -11,14 +11,14 @@ import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.core.conv.ConvertJSON; import picoded.core.struct.GenericConvertMap; import picoded.core.struct.GenericConvertHashMap; -import picoded.core.struct.GenericConvertMap; import picoded.servlet.util.EmbeddedServlet; import picoded.servlet.ServletRequestMap; import picoded.servlet.internal.*; @@ -37,13 +37,13 @@ public class BasePage_advanced_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -119,9 +119,11 @@ public StringBuilder sb_new_after() { return new StringBuilder("sb_new_after "); } + } @Test + @DisplayName("Checks dynamic resolution of Map configurations in complex interceptor chain executions") public void test_complexInterceptors_map() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withComplexInterceptors())); @@ -146,6 +148,7 @@ public void test_complexInterceptors_map() { } @Test + @DisplayName("Checks dynamic resolution of StringBuilder buffers in complex interceptor chain executions") public void test_complexInterceptors_sb() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withComplexInterceptors())); diff --git a/src/test/java/picoded/servlet/BasePage_basic_test.java b/src/test/java/picoded/servlet/BasePage_basic_test.java index 83cad76..dd46b3f 100755 --- a/src/test/java/picoded/servlet/BasePage_basic_test.java +++ b/src/test/java/picoded/servlet/BasePage_basic_test.java @@ -1,22 +1,22 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.core.conv.ConvertJSON; import picoded.core.conv.GenericConvert; import picoded.core.struct.GenericConvertMap; import picoded.core.struct.GenericConvertHashMap; -import picoded.core.struct.GenericConvertMap; import picoded.servlet.util.EmbeddedServlet; import picoded.servlet.ServletRequestMap; import picoded.servlet.internal.*; @@ -35,13 +35,13 @@ public class BasePage_basic_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -61,6 +61,7 @@ public void helloWorld() { } @Test + @DisplayName("Basic page static hello route rendering") public void testHelloPath() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/hello"; @@ -89,6 +90,7 @@ public void after() { } @Test + @DisplayName("Basic page standard before, path, and after interceptor chain rendering") public void test_withSimpleInterceptors() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withSimpleInterceptors())); @@ -138,6 +140,7 @@ public void helloRequest(String sentence, int age) { } @Test + @DisplayName("Injects standard Printwriter as target method argument") public void test_parameter() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withMethodParameters())); @@ -147,6 +150,7 @@ public void test_parameter() { } @Test + @DisplayName("Injects empty request Map representation as target method argument") public void test_multipleParams() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withMethodParameters())); @@ -156,6 +160,7 @@ public void test_multipleParams() { } @Test + @DisplayName("Injects populated GenericConvertMap argument mapping") public void test_subClass() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withMethodParameters())); @@ -172,6 +177,7 @@ public void test_subClass() { } @Test + @DisplayName("Fails cleanly when method injects unsupported argument types") public void test_unknownDefaultParameters() { try { assertNotNull(testServlet = new EmbeddedServlet(testPort, @@ -184,6 +190,7 @@ public void test_unknownDefaultParameters() { } @Test + @DisplayName("Fails cleanly when method injects unsupported argument types alongside standard types") public void test_parametersWithUnknownDefaultParameters() { try { assertNotNull(testServlet = new EmbeddedServlet(testPort, @@ -232,6 +239,7 @@ public Map sameResponseMap(Map responseMap) { } @Test + @DisplayName("Resolves response when custom method returns alternative StringBuilder container") public void test_differentResponseStringBuilder() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withStringBuilderAndApiMap())); @@ -241,6 +249,7 @@ public void test_differentResponseStringBuilder() { } @Test + @DisplayName("Resolves response when custom method returns alternative HashMap mapping") public void test_differentResponseMap() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withStringBuilderAndApiMap())); @@ -250,6 +259,7 @@ public void test_differentResponseMap() { } @Test + @DisplayName("Resolves response when custom method appends to context StringBuilder container") public void test_sameResponseStringBuilder() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld_withStringBuilderAndApiMap())); @@ -284,6 +294,7 @@ public Map simpleNameParamAfter(ServletRequestMap map) { } @Test + @DisplayName("Dynamic URL path parameter matching and routing resolution") public void test_nameParameter() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new NameParametersServlet())); String testUrl = "http://127.0.0.1:" + testPort + "/name/testingUser"; @@ -292,6 +303,7 @@ public void test_nameParameter() { } @Test + @DisplayName("Dynamic URL path parameter matching across interceptors and target method") public void test_nameParametersWithBeforeAndAfter() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new NameParametersServlet())); String testUrl = "http://127.0.0.1:" + testPort + "/name/testingUser/beforeValue/afterValue"; @@ -313,6 +325,7 @@ public void simpleNameParam(Integer wrongParam) { } @Test + @DisplayName("Returns descriptive API JSON error response on unsupported argument signature exceptions") public void test_apiException() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new ApiExceptionServlet())); String testUrl = "http://127.0.0.1:" + testPort + "/name/testing"; diff --git a/src/test/java/picoded/servlet/BasePage_multipleEndpoint_test.java b/src/test/java/picoded/servlet/BasePage_multipleEndpoint_test.java index c02119d..faabfea 100755 --- a/src/test/java/picoded/servlet/BasePage_multipleEndpoint_test.java +++ b/src/test/java/picoded/servlet/BasePage_multipleEndpoint_test.java @@ -1,21 +1,21 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.core.conv.ConvertJSON; import picoded.core.struct.GenericConvertMap; import picoded.core.struct.GenericConvertHashMap; -import picoded.core.struct.GenericConvertMap; import picoded.servlet.util.EmbeddedServlet; import picoded.servlet.ServletRequestMap; import picoded.servlet.internal.*; @@ -38,13 +38,13 @@ public class BasePage_multipleEndpoint_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -68,6 +68,7 @@ public void fallback() { } @Test + @DisplayName("Precise static path matches prioritized over general wildcard fallbacks inside single class") public void testMultipleEndpoint_inOneClas() throws Exception { // Setup servlet assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); @@ -124,6 +125,7 @@ public void hearings() { } @Test + @DisplayName("Precise child page methods prioritize over inherited parent wildcard fallbacks across class structures") public void testMultipleEndpoint_inExtendedClas() throws Exception { // Setup servlet assertNotNull(testServlet = new EmbeddedServlet(testPort, new ExtendedEndpoints())); diff --git a/src/test/java/picoded/servlet/BasePage_requestBefore_test.java b/src/test/java/picoded/servlet/BasePage_requestBefore_test.java index d1daaf2..7d6c481 100644 --- a/src/test/java/picoded/servlet/BasePage_requestBefore_test.java +++ b/src/test/java/picoded/servlet/BasePage_requestBefore_test.java @@ -1,17 +1,18 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.servlet.util.EmbeddedServlet; import picoded.core.web.RequestHttp; @@ -32,13 +33,13 @@ public class BasePage_requestBefore_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -95,6 +96,7 @@ public void handleHaltException(HaltException e) { } @Test + @DisplayName("Stops execution context when first layer interceptor throws HaltException") public void test_firstLayerHaltException() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort + "/account/verify/RANDOMID/info/get"; @@ -104,6 +106,7 @@ public void test_firstLayerHaltException() throws Exception { } @Test + @DisplayName("Stops execution context when nested second layer interceptor throws HaltException") public void test_secondLayerHaltException() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort + "/project/info/get"; @@ -113,6 +116,7 @@ public void test_secondLayerHaltException() throws Exception { } @Test + @DisplayName("Renders clean 404 response when nested route structures mismatch completely") public void test_noRouteFound() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort + "/project/info/unknown"; diff --git a/src/test/java/picoded/servlet/BasePage_requestType_test.java b/src/test/java/picoded/servlet/BasePage_requestType_test.java index 9515469..3b7779a 100755 --- a/src/test/java/picoded/servlet/BasePage_requestType_test.java +++ b/src/test/java/picoded/servlet/BasePage_requestType_test.java @@ -1,16 +1,17 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.core.conv.ConvertJSON; import picoded.core.struct.GenericConvertMap; @@ -31,13 +32,13 @@ public class BasePage_requestType_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -155,6 +156,7 @@ public void after_api_multi_verb() { } @Test + @DisplayName("Standard GET routing with restricted @RequestType(\"GET\")") public void test_singleType() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/type/single"; @@ -163,6 +165,7 @@ public void test_singleType() throws Exception { } @Test + @DisplayName("Standard multi-verb routing with restricted @RequestType({\"GET\", \"POST\"})") public void test_multipleType() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/type/multiple"; @@ -173,6 +176,7 @@ public void test_multipleType() throws Exception { } @Test + @DisplayName("Standard routing with unrestricted @RequestType (omitted defaults to all verbs)") public void test_noRequestType() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/type/multiple"; @@ -183,6 +187,7 @@ public void test_noRequestType() throws Exception { } @Test + @DisplayName("Standard routing correctly rejects non-matching verbs with 404 for multi-verb definitions") public void test_invalidRequestType_multiple() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/type/multiple"; @@ -195,6 +200,7 @@ public void test_invalidRequestType_multiple() throws Exception { } @Test + @DisplayName("Standard routing correctly rejects non-matching verbs with 404 for single-verb definitions") public void test_invalidRequestType_single() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/type/single"; @@ -207,6 +213,7 @@ public void test_invalidRequestType_single() throws Exception { } @Test + @DisplayName("API JSON routing with unrestricted @RequestType (omitted defaults to all verbs)") public void test_api_none() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/api/none"; @@ -217,6 +224,7 @@ public void test_api_none() throws Exception { } @Test + @DisplayName("API JSON routing with restricted @RequestType(\"POST\")") public void test_api_single() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/api/single"; @@ -225,6 +233,7 @@ public void test_api_single() throws Exception { } @Test + @DisplayName("API JSON routing correctly rejects non-matching verbs with 404 for single-verb definitions") public void test_api_single_invalid() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/api/single"; @@ -234,6 +243,7 @@ public void test_api_single_invalid() throws Exception { } @Test + @DisplayName("API JSON routing with restricted @RequestType({\"GET\", \"POST\"})") public void test_api_multiple() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/api/multiple"; @@ -244,6 +254,7 @@ public void test_api_multiple() throws Exception { } @Test + @DisplayName("API JSON routing correctly rejects non-matching verbs with 404 for multi-verb definitions") public void test_api_multiple_invalid() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/api/multiple"; @@ -253,6 +264,7 @@ public void test_api_multiple_invalid() throws Exception { } @Test + @DisplayName("Same-route standard page matching across GET, POST, and DELETE with universal interceptors") public void test_requestPath_multipleVerbs() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/multi/verb"; @@ -272,6 +284,7 @@ public void test_requestPath_multipleVerbs() throws Exception { } @Test + @DisplayName("Same-route API JSON matching across GET, POST, and DELETE with universal interceptors") public void test_apiPath_multipleVerbs() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); String testUrl = "http://127.0.0.1:" + testPort + "/api/multi/verb"; diff --git a/src/test/java/picoded/servlet/BasePage_reroute_parameter_test.java b/src/test/java/picoded/servlet/BasePage_reroute_parameter_test.java index 8f74da5..0a069d3 100644 --- a/src/test/java/picoded/servlet/BasePage_reroute_parameter_test.java +++ b/src/test/java/picoded/servlet/BasePage_reroute_parameter_test.java @@ -1,16 +1,17 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.servlet.util.EmbeddedServlet; import picoded.core.web.RequestHttp; @@ -30,13 +31,13 @@ public class BasePage_reroute_parameter_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -76,6 +77,7 @@ public static class LandingPage extends BasePage { } @Test + @DisplayName("Preserves name path parameters through nested rerouting redirection") public void test_withNameParams() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort + "/pass/testing/internal/nested/param"; @@ -85,6 +87,7 @@ public void test_withNameParams() throws Exception { } @Test + @DisplayName("Preserves URL query parameters through nested rerouting redirection") public void test_withGetParams() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort @@ -94,6 +97,7 @@ public void test_withGetParams() throws Exception { } @Test + @DisplayName("Preserves HTTP POST payload maps through nested rerouting redirection") public void test_withPostParams() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort + "/pass/testing/internal/nested/param"; diff --git a/src/test/java/picoded/servlet/BasePage_reroute_test.java b/src/test/java/picoded/servlet/BasePage_reroute_test.java index 935b4af..d478d25 100755 --- a/src/test/java/picoded/servlet/BasePage_reroute_test.java +++ b/src/test/java/picoded/servlet/BasePage_reroute_test.java @@ -1,14 +1,15 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.FileOutputStream; import java.io.PrintWriter; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.servlet.util.EmbeddedServlet; import picoded.core.web.RequestHttp; @@ -24,13 +25,13 @@ public class BasePage_reroute_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -58,6 +59,7 @@ public static class LandingPage extends BasePage { } @Test + @DisplayName("Static nested page redirection matches target route cleanly") public void test_withSimpleInterceptors() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort + "/say/hello"; @@ -66,6 +68,7 @@ public void test_withSimpleInterceptors() throws Exception { } @Test + @DisplayName("Renders clean 404 response when nested static page redirects to mismatched path") public void test_existRedirectButInvalidPath() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort + "/say/invalid"; @@ -75,6 +78,7 @@ public void test_existRedirectButInvalidPath() throws Exception { } @Test + @DisplayName("Renders clean 404 response when requested base path has no registered page mapping") public void test_nonExistenceRedirect() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new LandingPage())); String testUrl = "http://127.0.0.1:" + testPort + "/gone/invalid"; @@ -101,6 +105,7 @@ public TestInternalWorld rerouting() { } @Test + @DisplayName("Dispatches requests dynamically to class instances instantiated via routing methods") public void test_methodReroute() throws Exception { assertNotNull(testServlet = new EmbeddedServlet(testPort, new RerouteWithMethod())); String testUrl = "http://127.0.0.1:" + testPort + "/anything/last/moments"; diff --git a/src/test/java/picoded/servlet/BaseUtilPage_config_test.java b/src/test/java/picoded/servlet/BaseUtilPage_config_test.java index d0534be..adc09a5 100755 --- a/src/test/java/picoded/servlet/BaseUtilPage_config_test.java +++ b/src/test/java/picoded/servlet/BaseUtilPage_config_test.java @@ -1,6 +1,7 @@ package picoded.servlet; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.*; import java.io.*; import java.net.*; @@ -9,8 +10,6 @@ import javax.servlet.*; import javax.servlet.http.*; -import org.junit.*; - import picoded.servlet.util.EmbeddedServlet; import picoded.core.conv.*; import picoded.core.web.RequestHttp; @@ -31,13 +30,13 @@ public class BaseUtilPage_config_test { // // Standard setup and teardown // - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void tearDown() throws Exception { if (testServlet != null) { testServlet.close(); @@ -65,6 +64,7 @@ protected void doRequest(PrintWriter writer) throws Exception { } @Test + @DisplayName("Checks dynamic resolution of system settings from configuration directories") public void simpleHelloWorldTest() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new BaseUtilPageConfig())); diff --git a/src/test/java/picoded/servlet/CorePage_test.java b/src/test/java/picoded/servlet/CorePage_test.java index b5122cb..9b4109c 100755 --- a/src/test/java/picoded/servlet/CorePage_test.java +++ b/src/test/java/picoded/servlet/CorePage_test.java @@ -1,6 +1,7 @@ package picoded.servlet; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.*; import java.io.*; import java.net.*; @@ -9,8 +10,6 @@ import javax.servlet.*; import javax.servlet.http.*; -import org.junit.*; - import picoded.servlet.util.EmbeddedServlet; import picoded.core.conv.*; import picoded.core.web.RequestHttp; @@ -28,13 +27,13 @@ public class CorePage_test { // // Standard setup and teardown // - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void tearDown() throws Exception { if (testServlet != null) { testServlet.close(); @@ -68,6 +67,7 @@ public void helloWorldAssert(String testUrl, String testString) { } @Test + @DisplayName("Sanity verification of low level CorePage servlet responses") public void simpleHelloWorldTest() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new SimpleHelloWorld())); helloWorldAssert("http://localhost:" + testPort + "/test/", null); @@ -85,6 +85,7 @@ protected void doRequest(PrintWriter writer) throws Exception { } @Test + @DisplayName("Verifies stream print methods handle special symbols without truncation") public void outputPrintBugFixing() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new SpecialSymbolsTesting())); helloWorldAssert("http://localhost:" + testPort + "/test/", "Test *>> This"); @@ -105,6 +106,7 @@ protected void doRequest(PrintWriter writer) { } @Test + @DisplayName("Verifies core page extracts accurate request verbs from client calls") public void test_requestTypes() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new TestCorePage())); String testUrl = "http://127.0.0.1:" + testPort + "/type/single"; diff --git a/src/test/java/picoded/servlet/DStackPage_basic_test.java b/src/test/java/picoded/servlet/DStackPage_basic_test.java index 7f05b7e..3a36c73 100755 --- a/src/test/java/picoded/servlet/DStackPage_basic_test.java +++ b/src/test/java/picoded/servlet/DStackPage_basic_test.java @@ -1,11 +1,12 @@ package picoded.servlet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import java.io.File; import java.nio.file.Files; @@ -32,13 +33,13 @@ public class DStackPage_basic_test { int testPort = 0; EmbeddedServlet testServlet = null; - @Before + @BeforeEach public void setUp() { testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void teardown() { if (testServlet != null) { testServlet.close(); @@ -72,6 +73,7 @@ public String getConfigPath() { } @Test + @DisplayName("Validates basic context database initialization and transactional saves") public void DStack_simple() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new SimplePage())); String testUrl = "http://127.0.0.1:" + testPort + "/dstack"; diff --git a/src/test/java/picoded/servlet/annotation/RequestPathDetection_test.java b/src/test/java/picoded/servlet/annotation/RequestPathDetection_test.java index 12c8efe..3fa1f32 100755 --- a/src/test/java/picoded/servlet/annotation/RequestPathDetection_test.java +++ b/src/test/java/picoded/servlet/annotation/RequestPathDetection_test.java @@ -1,12 +1,13 @@ package picoded.servlet.annotation; // Junit includes -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; // Base class to build on public class RequestPathDetection_test { @@ -26,6 +27,7 @@ public void hello() { } @Test + @DisplayName("Reflective inspection of @RequestPath runtime method annotation") public void hello() throws Exception { //assertEquals("world", StaticExtendedClass.hello()); // Get the example class diff --git a/src/test/java/picoded/servlet/internal/EndpointMap_test.java b/src/test/java/picoded/servlet/internal/EndpointMap_test.java index d889440..dc82f9b 100755 --- a/src/test/java/picoded/servlet/internal/EndpointMap_test.java +++ b/src/test/java/picoded/servlet/internal/EndpointMap_test.java @@ -2,18 +2,19 @@ // Junit includes -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; import picoded.servlet.annotation.*; @@ -22,12 +23,13 @@ public class EndpointMap_test { EndpointMap endpoints = null; - @Before + @BeforeEach public void setUp() { endpoints = new EndpointMap<>(); } @Test + @DisplayName("Precise full valid static path route matching") public void fullValidPathMatch() { assertEquals(0, endpoints.findValidKeys("hello/good/world").size()); endpoints.registerEndpointPath("hello/good/world", "Awesome world"); @@ -35,6 +37,7 @@ public void fullValidPathMatch() { } @Test + @DisplayName("Rejects nested sub-paths exceeding registered static full path length") public void invalidRegisteredFullPathMatch() { assertEquals(0, endpoints.findValidKeys("hello/good/world/others").size()); endpoints.registerEndpointPath("hello/good/world", "Awesome world"); @@ -42,6 +45,7 @@ public void invalidRegisteredFullPathMatch() { } @Test + @DisplayName("Rejects parent path calls lacking complete registered child path elements") public void invalidRequestFullPathMatch() { assertEquals(0, endpoints.findValidKeys("hello/good/world").size()); endpoints.registerEndpointPath("hello/good/world/others", "Awesome world"); @@ -49,6 +53,7 @@ public void invalidRequestFullPathMatch() { } @Test + @DisplayName("Matches trailing wildcard routes and orders multiple matching keys") public void wildCardPathMatch() { assertEquals(0, endpoints.findValidKeys("hello/good/world").size()); endpoints.registerEndpointPath("hello/good/*", "Awesome world"); @@ -59,6 +64,7 @@ public void wildCardPathMatch() { } @Test + @DisplayName("Rejects requests failing to match wildcard segments") public void badRequestPath() { assertEquals(0, endpoints.findValidKeys("hello/bad/world").size()); endpoints.registerEndpointPath("hello/good/*", "Awesome world"); @@ -66,6 +72,7 @@ public void badRequestPath() { } @Test + @DisplayName("Resolves root empty path routes and global wildcard matching") public void emptyRequestPath() { assertEquals(0, endpoints.findValidKeys("").size()); endpoints.registerEndpointPath("hello/good/*", "Awesome world"); @@ -75,6 +82,7 @@ public void emptyRequestPath() { } @Test + @DisplayName("Resolves dynamic path variables inside registered routes") public void endpointPathVariableMatch() { assertEquals(0, endpoints.findValidKeys("hello/test/world").size()); endpoints.registerEndpointPath("hello/:variable/world", "Awesome world"); @@ -83,6 +91,7 @@ public void endpointPathVariableMatch() { } @Test + @DisplayName("Rejects dynamic path variables when adjacent static structures mismatch") public void endpointPathVariableFailMatch() { assertEquals(0, endpoints.findValidKeys("hello/test/notworld").size()); endpoints.registerEndpointPath("hello/:variable/world", "Awesome world"); @@ -91,6 +100,7 @@ public void endpointPathVariableFailMatch() { } @Test + @DisplayName("Orders endpoints prioritising concrete configurations over wildcards") public void sortEndpointListing() { String[] sample = new String[] { "*", "session", "a/b" }; List sampleList = new ArrayList<>(Arrays.asList(sample)); diff --git a/src/test/java/picoded/servlet/util/EmbeddedServlet_test.java b/src/test/java/picoded/servlet/util/EmbeddedServlet_test.java index c4b0029..6ebb770 100755 --- a/src/test/java/picoded/servlet/util/EmbeddedServlet_test.java +++ b/src/test/java/picoded/servlet/util/EmbeddedServlet_test.java @@ -1,7 +1,7 @@ package picoded.servlet.util; -import static org.junit.Assert.*; -import org.junit.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.*; import java.io.*; import java.net.*; @@ -39,14 +39,14 @@ public class EmbeddedServlet_test { // // Standard setup and teardown // - @Before + @BeforeEach public void setUp() { // Issue a possible port to use testPort = ServletTestConfig.issuePortNumber(); testServlet = null; } - @After + @AfterEach public void tearDown() throws Exception { if (testServlet != null) { testServlet.close(); @@ -56,6 +56,7 @@ public void tearDown() throws Exception { // Sanity check @Test + @DisplayName("Sanity verification of required mock workspace testing resources") public void fileChecks() { assertTrue(testCollection.isDirectory()); assertTrue(helloWorldHtml.isDirectory()); @@ -67,6 +68,7 @@ public void fileChecks() { // Testing various servlet packages deployment // @Test + @DisplayName("Deploys directory with static index.html and checks raw stream response") public void helloWorldHtml() { assertNotNull(testServlet = new EmbeddedServlet(testPort, helloWorldHtml)); RequestHttpClient client = new RequestHttpClient(); @@ -81,6 +83,7 @@ public void helloWorldHtml() { // } @Test + @DisplayName("Deploys nested directory with custom servlets, JSPs, and assets") public void helloWorldJava() { assertNotNull(testServlet = new EmbeddedServlet(testPort, helloWorldJava)); assertEquals("

Hello World

", @@ -92,6 +95,7 @@ public void helloWorldJava() { } @Test + @DisplayName("Deploys compiled WAR archive with direct endpoint resolution") public void helloWorldJWar() { assertNotNull(testServlet = new EmbeddedServlet(testPort, helloWorldJWar)); assertEquals("

Hello World

", @@ -103,6 +107,7 @@ public void helloWorldJWar() { } @Test + @DisplayName("Deploys compiled WAR archive under non-root context names") public void helloWorldJWar_contextName() { assertNotNull(testServlet = new EmbeddedServlet(testPort, "ctest", helloWorldJWar)); assertEquals("

Hello World

", @@ -140,6 +145,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) } @Test + @DisplayName("Deploys dynamically instantiated HttpServlet class") public void helloWorldServlet() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld())); assertEquals("

Hello World

", RequestHttp @@ -147,6 +153,7 @@ public void helloWorldServlet() { } @Test + @DisplayName("Deploys dynamically instantiated HttpServlet on fixed routes") public void helloWorldServlet_fixedPath() { assertNotNull(testServlet = new EmbeddedServlet(testPort, new HelloWorld(), "/fixed")); assertEquals("

Hello World

", @@ -156,6 +163,7 @@ public void helloWorldServlet_fixedPath() { } @Test + @DisplayName("Deploys dynamically instantiated HttpServlet on fixed routes with custom contexts") public void helloWorldServlet_contextName() { assertNotNull(testServlet = new EmbeddedServlet(testPort, "ctest", new HelloWorld(), null)); assertEquals("

Hello World

",