Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/java cleanup add unit test #45

Closed
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
Binary file added .DS_Store
Binary file not shown.
File renamed without changes.
43 changes: 42 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,45 @@
# Ignoring root .vscode folder.
.vscode/
# Ignoring ~/build inside LMSourceCode
/Software/LMSourceCode/ImageProcessing/build
/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/
Binary file added Software/.DS_Store
Binary file not shown.
121 changes: 88 additions & 33 deletions Software/LMSourceCode/ImageProcessing/golfsim_tomee_webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,126 @@
<artifactId>golfsim</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>golfsim</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>

<!-- tommee -->
<tommee-maven-plugin.version>8.0.9</tommee-maven-plugin.version>
<tommee.version>10.0.0</tommee.version>

<!-- maven -->
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
<maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<maven-sunfire-plugin.version>3.0.0-M7</maven-sunfire-plugin.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
<maven-install-plugin.version>2.5.2</maven-install-plugin.version>
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
<maven-project-info-reports-plugin.version>3.0.0</maven-project-info-reports-plugin.version>

<!-- jakarta -->
<jakartaee-web-api.version>9.0.0</jakartaee-web-api.version>
<jakarta-servlet-api.version>6.1.0-M1</jakarta-servlet-api.version>

<!-- Apache ActiveMQ -->
<activemq-client.version>6.0.1</activemq-client.version>
<!-- activemq-camel, vulnerability found, upgrade on future PR -->
<activemq-camel.version>5.16.7</activemq-camel.version>
<activemq-pool.version>6.0.1</activemq-pool.version>
<activemq-broker.version>6.0.1</activemq-broker.version>

<!-- misc -->
<msgpack-core.version>0.9.6</msgpack-core.version>
<gson.version>2.9.0</gson.version>

<!-- logging -->
<log4j.version>2.24.3</log4j.version>

<!-- test -->
<junit-jupiter-api.version>5.11.4</junit-jupiter-api.version>
<mockito-junit-jupiter.version>5.15.2</mockito-junit-jupiter.version>
</properties>

<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>9.0.0</version>
<version>${jakartaee-web-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0-M1</version>
<version>${jakarta-servlet-api.version}</version>
<scope>provided</scope>
</dependency>

<!-- the ActiveMQ client with connection pooling -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>6.0.1</version>
<version>${activemq-client.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
<version>5.16.7</version>
<version>${activemq-camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>6.0.1</version>
<version>${activemq-pool.version}</version>
</dependency>
<!-- the ActiveMQ broker is optional and can be removed if connecting to a remote broker on
ly -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>6.0.1</version>
<version>${activemq-broker.version}</version>
</dependency>

<dependency>
<groupId>org.msgpack</groupId>
<artifactId>msgpack-core</artifactId>
<version>0.9.6</version>
</dependency>
<dependency>
<groupId>org.msgpack</groupId>
<artifactId>msgpack-core</artifactId>
<version>${msgpack-core.version}</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>


<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -79,57 +137,54 @@ ly -->
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>8.0.9</version>
<version>${tommee-maven-plugin.version}</version>
<configuration>
<tomeeVersion>10.0.0</tomeeVersion>
<tomeeVersion>${tommee.version}</tomeeVersion>
<tomeeClassifier>plus</tomeeClassifier>
</configuration>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<version>${maven-clean-plugin.version}</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>${maven-resources-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>${maven-compiler-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<version>${maven-sunfire-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<version>${maven-install-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<version>${maven-deploy-plugin.version}</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
<version>${maven-site-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<version>${maven-project-info-reports-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
package com.verdanttechs.jakarta.ee9;

import java.util.Vector;
import java.lang.Math;

import com.verdanttechs.jakarta.ee9.type.GsIPCResultType;
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;
Expand All @@ -42,9 +26,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;

Expand All @@ -57,35 +38,13 @@
import org.apache.activemq.ActiveMQConnectionFactory;

import java.io.IOException;
import java.util.logging.Logger;


@WebServlet("/monitor")
public class MonitorServlet extends HttpServlet {

// NOTE - these should reflect types in gs_ipc_result
public enum GsIPCResultType {
kUnknown,
kInitializing,
kWaitingForBallToAppear,
kWaitingForSimulatorArmed,
kPausingForBallStabilization,
kMultipleBallsPresent,
kBallPlacedAndReadyForHit,
kHit,
kError,
kCalibrationResults;
}

public enum IPCMessageType {
kUnknown,
kRequestForCamera2Image,
kCamera2Image,
kRequestForCamera2TestStillImage,
kResults,
kShutdown,
kCamera2ReturnPreImage,
kControlMessage;
}
private static Logger LOGGER = Logger.getLogger(MonitorServlet.class.getName());

public enum GsClubType {
kNotSelected,
Expand All @@ -109,7 +68,8 @@ public static class GsControlMessage {
public static Session producer_session;
public static Destination producer_destination;

public static void SetCurrentClubType(GsClubType 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 {
Expand Down Expand Up @@ -683,6 +643,8 @@ public boolean initializeMonitor(String config_filename) {
System.out.println("Failed to parse JSON config file: " + e.getMessage());
return false;
}


System.out.println("Golf Sim Configuration Settings: ");
System.out.println(" kWebActiveMQHostAddress: " + kWebActiveMQHostAddress);
System.out.println(" kWebServerTomcatShareDirectory (NOTE - Must be setup in Tomcat's conf/server.xml): " + kWebServerTomcatShareDirectory);
Expand Down Expand Up @@ -800,7 +762,7 @@ public void run() {
HttpSession httpSession = request.getSession();
Long times = (Long) httpSession.getAttribute("times");
if (times == null) {
httpSession.setAttribute("times", new Long(0));
httpSession.setAttribute("times", Long.valueOf(0));
}

long value = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.verdanttechs.jakarta.ee9.type;

public enum GsIPCResultType {
// NOTE - these should reflect types in gs_ipc_result
kUnknown,
kInitializing,
kWaitingForBallToAppear,
kWaitingForSimulatorArmed,
kPausingForBallStabilization,
kMultipleBallsPresent,
kBallPlacedAndReadyForHit,
kHit,
kError,
kCalibrationResults;
}
Loading
Loading