diff --git a/.github/pr_template.yml b/.github/pr_template.md similarity index 100% rename from .github/pr_template.yml rename to .github/pr_template.md diff --git a/.gitignore b/.gitignore index e362a12..1e1b23c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,45 @@ # Ignoring root .vscode folder. .vscode/ # Ignoring ~/build inside LMSourceCode -/Software/LMSourceCode/ImageProcessing/build \ No newline at end of file +/Software/LMSourceCode/ImageProcessing/build + +HELP.md +out/ +**/target/ +!.mvn/wrapper/maven-wrapper.jar +*.war +!**/src/main/**/target/ +!**/src/test/**/target/ +.DS_Store +**/.DS_Store +# Package Files # +/Software/ImageProcessing/golfsim_tomee_webapp/target +/Software/ImageProcessing/golfsim_tomee_webapp/.codesight +**/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/target +**/.war + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +**/.idea +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ \ No newline at end of file diff --git a/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/pom.xml b/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/pom.xml index 1c2f1aa..4c609fb 100644 --- a/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/pom.xml +++ b/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/pom.xml @@ -16,19 +16,57 @@ 17 17 false + + + 8.0.9 + 10.0.0 + + + 3.1.0 + 3.0.2 + 3.8.0 + 3.0.0-M7 + 3.0.2 + 3.3.2 + 2.5.2 + 2.8.2 + 3.7.1 + 3.0.0 + + + 9.0.0 + 6.1.0-M1 + + + 6.0.1 + + 5.16.7 + 6.0.1 + 6.0.1 + + + 0.9.6 + 2.9.0 + + + 2.24.3 + + + 5.11.4 + 5.15.2 jakarta.platform jakarta.jakartaee-web-api - 9.0.0 + ${jakartaee-web-api.version} provided jakarta.servlet jakarta.servlet-api - 6.1.0-M1 + ${jakarta-servlet-api.version} provided @@ -36,39 +74,61 @@ org.apache.activemq activemq-client - 6.0.1 + ${activemq-client.version} org.apache.activemq activemq-camel - 5.16.7 + ${activemq-camel.version} org.apache.activemq activemq-pool - 6.0.1 + ${activemq-pool.version} org.apache.activemq activemq-broker - 6.0.1 + ${activemq-broker.version} + + + + org.msgpack + msgpack-core + ${msgpack-core.version} - - org.msgpack - msgpack-core - 0.9.6 - + + com.google.code.gson + gson + ${gson.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter-api.version} + test + + + org.mockito + mockito-junit-jupiter + ${mockito-junit-jupiter.version} + test + - - com.google.code.gson - gson - 2.9.0 - + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + - @@ -79,57 +139,56 @@ ly --> org.apache.tomee.maven tomee-maven-plugin - 8.0.9 + ${tommee-maven-plugin.version} - 10.0.0 + ${tommee.version} plus maven-clean-plugin - 3.1.0 + ${maven-clean-plugin.version} maven-resources-plugin - 3.0.2 + ${maven-resources-plugin.version} maven-compiler-plugin - 3.8.0 + ${maven-compiler-plugin.version} maven-surefire-plugin - 2.22.1 + ${maven-sunfire-plugin.version} maven-jar-plugin - 3.0.2 + ${maven-jar-plugin.version} maven-war-plugin - 3.3.2 + ${maven-war-plugin.version} false maven-install-plugin - 2.5.2 + ${maven-install-plugin.version} maven-deploy-plugin - 2.8.2 + ${maven-deploy-plugin.version} - maven-site-plugin - 3.7.1 + ${maven-site-plugin.version} maven-project-info-reports-plugin - 3.0.0 + ${maven-project-info-reports-plugin.version} diff --git a/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/main/java/com/verdanttechs/jakarta/ee9/MonitorServlet.java b/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/main/java/com/verdanttechs/jakarta/ee9/MonitorServlet.java index 0b7942f..1ff53c0 100644 --- a/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/main/java/com/verdanttechs/jakarta/ee9/MonitorServlet.java +++ b/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/main/java/com/verdanttechs/jakarta/ee9/MonitorServlet.java @@ -1,37 +1,22 @@ package com.verdanttechs.jakarta.ee9; import java.util.Vector; -import java.lang.Math; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.msgpack.core.MessagePack; -import org.msgpack.core.MessagePack.PackerConfig; -import org.msgpack.core.MessagePack.UnpackerConfig; import org.msgpack.core.MessageBufferPacker; -import org.msgpack.core.MessageFormat; -import org.msgpack.core.MessagePacker; import org.msgpack.core.MessageUnpacker; import org.msgpack.value.ArrayValue; -import org.msgpack.value.ExtensionValue; -import org.msgpack.value.FloatValue; -import org.msgpack.value.IntegerValue; -import org.msgpack.value.TimestampValue; import org.msgpack.value.Value; -import org.msgpack.core.annotations.Nullable; -import org.msgpack.core.annotations.VisibleForTesting; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; -import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import jakarta.servlet.ServletContextListener; -import jakarta.servlet.ServletContext; -import jakarta.servlet.ServletContextEvent; -import jakarta.servlet.ServletContextListener; -import jakarta.servlet.annotation.WebListener; import jakarta.jms.Connection; import jakarta.jms.Session; @@ -42,9 +27,6 @@ import jakarta.jms.DeliveryMode; import jakarta.jms.TextMessage; import jakarta.jms.BytesMessage; -import jakarta.jms.Topic; -import jakarta.jms.Queue; -import jakarta.jms.ConnectionFactory; import jakarta.jms.JMSException; import jakarta.jms.ExceptionListener; @@ -62,7 +44,7 @@ @WebServlet("/monitor") public class MonitorServlet extends HttpServlet { - // NOTE - these should reflect types in gs_ipc_result + private static Logger logger = LogManager.getLogger(MonitorServlet.class); public enum GsIPCResultType { kUnknown, kInitializing, @@ -109,8 +91,9 @@ public static class GsControlMessage { public static Session producer_session; public static Destination producer_destination; - public static void SetCurrentClubType(GsClubType club) { - System.out.println("SetClubType called with club type = " + String.valueOf(club)); + public static void SetCurrentClubType(GsClubType club) { + logger.info("SetClubType called with club type = " + String.valueOf(club)); + System.out.println("SetClubType called with club type = " + String.valueOf(club)); try { if (!producer_created) { diff --git a/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/main/resources/log4j2.yml b/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/main/resources/log4j2.yml new file mode 100644 index 0000000..ca50807 --- /dev/null +++ b/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/main/resources/log4j2.yml @@ -0,0 +1,40 @@ +Configuration: + status: warn + + appenders: + Console: + name: LogToConsole + PatternLayout: + Pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" + + #File: + # name: File + # fileName: logs/app.log + # PatternLayout: + # Pattern: "%d %p %C{1.} [%t] %m%n" + + RollingFile: + - name: LogToRollingFile + fileName: logs/app.log + filePattern: "logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz" + PatternLayout: + pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" + Policies: + SizeBasedTriggeringPolicy: + size: 10MB + DefaultRollOverStrategy: + max: 10 + + Loggers: + logger: + - name: com.mkyong + level: debug + additivity: false + AppenderRef: + - ref: LogToConsole + - ref: LogToRollingFile + + Root: + level: error + AppenderRef: + ref: LogToConsole \ No newline at end of file diff --git a/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/test/java/com/verdanttechs/jakarta/ee9/HelloServletTest.java b/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/test/java/com/verdanttechs/jakarta/ee9/HelloServletTest.java new file mode 100644 index 0000000..203c2ab --- /dev/null +++ b/Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/src/test/java/com/verdanttechs/jakarta/ee9/HelloServletTest.java @@ -0,0 +1,41 @@ +package com.verdanttechs.jakarta.ee9; + +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.PrintWriter; + +import static org.mockito.Mockito.*; + +class HelloServletTest { + private HelloServlet helloServlet; + private HttpServletRequest request; + private HttpServletResponse response; + private PrintWriter writer; + private ServletOutputStream outputStream; + + @BeforeEach + void setUp() throws IOException { + response = mock(HttpServletResponse.class); + outputStream = mock(ServletOutputStream.class); + writer = mock(PrintWriter.class); + when(response.getOutputStream()).thenReturn(outputStream); + when(response.getWriter()).thenReturn(writer); + helloServlet = new HelloServlet(); + request = mock(HttpServletRequest.class); + } + + + + @Test + void doGet_returnsTestMonitorCompleted() throws ServletException, IOException { + helloServlet.doGet(request, response); + verify(outputStream).println("Test Monitor Completed."); + } + +} \ No newline at end of file