Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

}

Expand Down Expand Up @@ -220,6 +223,8 @@ artifacts {

// Adjust test to run concurrently
test {
useJUnitPlatform()

// Exclude performance related test
// exclude "**/perf/*.java"
// exclude "**/*_perf*"
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Map> mapClass = Map.class;
Class<GenericConvertMap> genericMapClass = GenericConvertMap.class;
Expand Down
27 changes: 19 additions & 8 deletions src/test/java/picoded/servlet/AxiosApiBuilder_test.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -130,6 +135,7 @@ public Map<String, Method> 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";
Expand All @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
21 changes: 12 additions & 9 deletions src/test/java/picoded/servlet/BasePage_advanced_test.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.*;
Expand All @@ -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();
Expand Down Expand Up @@ -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()));
Expand All @@ -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()));
Expand Down
Loading
Loading