diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0fd4e4f59..534998eb8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. #------------------------------------------------------------------------------------------------------------- -FROM openjdk:11-jdk +FROM eclipse-temurin:21-jdk # This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" # property in devcontainer.json to use it. On Linux, the container user's GID/UIDs @@ -45,7 +45,7 @@ RUN apt-get -y install snmp #-------------------Install Kafka---------------------------------- RUN mkdir ~/Downloads -RUN curl "https://archive.apache.org/dist/kafka/2.1.1/kafka_2.11-2.1.1.tgz" -o ~/Downloads/kafka.tgz +RUN curl "https://archive.apache.org/dist/kafka/3.6.0/kafka_2.12-3.6.0.tgz" -o ~/Downloads/kafka.tgz RUN mkdir ~/kafka \ && cd ~/kafka \ && tar -xvzf ~/Downloads/kafka.tgz --strip 1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 40fdc16c2..078e5fb88 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,30 +1,33 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.154.0/containers/java-8 { - "name": "Java 11 and C++", + "name": "Java 21 and C++", "dockerFile": "Dockerfile", "overrideCommand": false, "shutdownAction": "stopContainer", - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "extensions": [ + "vscjava.vscode-java-pack", + "vscjava.vscode-java-debug", + "vscjava.vscode-maven", + "vscjava.vscode-java-dependency", + "vscjava.vscode-java-test", + "hbenl.vscode-test-explorer", + "ms-vscode.test-adapter-converter", + "esbenp.prettier-vscode", + "mhutchie.git-graph", + "tabnine.tabnine-vscode", + "redhat.java", + "redhat.vscode-commons", + "ms-vscode.cpptools", + "ms-vscode.cmake-tools" + ] + } }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "vscjava.vscode-java-pack", - "vscjava.vscode-java-debug", - "vscjava.vscode-maven", - "vscjava.vscode-java-dependency", - "vscjava.vscode-java-test", - "hbenl.vscode-test-explorer", - "ms-vscode.test-adapter-converter", - "esbenp.prettier-vscode", - "mhutchie.git-graph", - "tabnine.tabnine-vscode", - "redhat.java", - "redhat.vscode-commons", - "ms-vscode.cpptools", - "ms-vscode.cmake-tools" - ], // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [8080, 9090, 46753, 46800, 5555, 6666, 8090, 2181, 9092], // Use 'postCreateCommand' to run commands after the container is created. diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index 4939670a0..2df28ef9b 100644 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -6,17 +6,17 @@ bin/kafka-server-start.sh -daemon config/server.properties # wait 2 seconds for the server to start and be able to add partitions sleep 2s # add topics -bin/kafka-topics.sh --create --topic "topic.OdeBsmPojo" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.OdeBsmJson" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.FilteredOdeBsmJson" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.OdeTimJson" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.OdeTimBroadcastJson" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.J2735TimBroadcastJson" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.OdeDriverAlertJson" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.Asn1DecoderInput" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.Asn1DecoderOutput" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.Asn1EncoderInput" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.Asn1EncoderOutput" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.SDWDepositorInput" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.OdeTIMCertExpirationTimeJson" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 -bin/kafka-topics.sh --create --topic "topic.OdeRawEncodedMessageJson" --zookeeper localhost:2181 --replication-factor 1 --partitions 1 \ No newline at end of file +bin/kafka-topics.sh --create --topic "topic.OdeBsmPojo" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.OdeBsmJson" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.FilteredOdeBsmJson" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.OdeTimJson" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.OdeTimBroadcastJson" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.J2735TimBroadcastJson" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.OdeDriverAlertJson" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.Asn1DecoderInput" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.Asn1DecoderOutput" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.Asn1EncoderInput" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.Asn1EncoderOutput" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.SDWDepositorInput" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.OdeTIMCertExpirationTimeJson" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 +bin/kafka-topics.sh --create --topic "topic.OdeRawEncodedMessageJson" --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 89a5dbd01..85fd68b60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM maven:3.8.1-openjdk-11 as builder +FROM maven:3.8-eclipse-temurin-21-alpine as builder MAINTAINER 583114@bah.com WORKDIR /home @@ -16,7 +16,7 @@ COPY ./jpo-ode-svcs/src ./jpo-ode-svcs/src RUN mvn clean package -DskipTests -FROM eclipse-temurin:11-jre-alpine +FROM eclipse-temurin:21-jre-alpine WORKDIR /home diff --git a/jpo-ode-common/pom.xml b/jpo-ode-common/pom.xml index 17352e1b4..1c37150dd 100644 --- a/jpo-ode-common/pom.xml +++ b/jpo-ode-common/pom.xml @@ -37,8 +37,9 @@ jackson-dataformat-xml - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api + 4.0.0 javax.websocket diff --git a/jpo-ode-common/src/main/java/us/dot/its/jpo/ode/util/CodecUtils.java b/jpo-ode-common/src/main/java/us/dot/its/jpo/ode/util/CodecUtils.java index a93135061..98c640508 100644 --- a/jpo-ode-common/src/main/java/us/dot/its/jpo/ode/util/CodecUtils.java +++ b/jpo-ode-common/src/main/java/us/dot/its/jpo/ode/util/CodecUtils.java @@ -21,7 +21,7 @@ import java.nio.ByteOrder; import java.util.Arrays; -import javax.xml.bind.DatatypeConverter; +import jakarta.xml.bind.DatatypeConverter; public class CodecUtils { diff --git a/jpo-ode-common/src/test/java/us/dot/its/jpo/ode/inet/InetPacketTest.java b/jpo-ode-common/src/test/java/us/dot/its/jpo/ode/inet/InetPacketTest.java index 273647928..68cb18db0 100644 --- a/jpo-ode-common/src/test/java/us/dot/its/jpo/ode/inet/InetPacketTest.java +++ b/jpo-ode-common/src/test/java/us/dot/its/jpo/ode/inet/InetPacketTest.java @@ -17,62 +17,49 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; import java.net.DatagramPacket; import java.net.InetAddress; import java.net.UnknownHostException; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; import mockit.Expectations; -import mockit.Mock; -import mockit.MockUp; import mockit.Mocked; import us.dot.its.jpo.ode.util.CrcCccitt; +import static org.junit.Assert.assertArrayEquals; public class InetPacketTest { - @Mocked DatagramPacket mockDatagramPacket; - byte[] mockPayload; - - @Mocked InetAddress mockAddress; - - @BeforeEach - public void setup() { - new MockUp() { - @Mock InetAddress getByName(String host) { - return mockAddress; - } - }; - } - @Test public void testStringConstructorCallsPointConstructor() { try { - new InetPacket("testHost", 5, new byte[] { 1, 2, 3 }); + new InetPacket("localhost", 5, new byte[] { 1, 2, 3 }); } catch (UnknownHostException e) { fail("Unexpected exception: " + e); } } @Test - public void testDatagramPacketConstructor() { - new InetPacket(mockDatagramPacket); - } - - @Test - public void testByteConstructor() { - InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); - testPacket.getPoint(); - testPacket.getPayload(); - testPacket.getBundle(); - testPacket.toHexString(); - + void testDatagramPacketConstructor() { + try (MockedStatic mockedInetAddress = Mockito.mockStatic(InetAddress.class)) { + mockedInetAddress.when(() -> InetAddress.getByName(Mockito.anyString())).thenReturn(mock(InetAddress.class)); + mockDatagramPacket = new DatagramPacket(new byte[] { 1, 2, 3 }, 3); + new InetPacket(mockDatagramPacket); + } } + +@Test +public void testByteConstructor() { + InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); + assertArrayEquals(new byte[] { 1, 2, 3 }, testPacket.getPayload()); +} /* * @Test public void testEvenNum() { boolean ans = false; boolean val; byte[] @@ -82,59 +69,58 @@ public void testByteConstructor() { * val = InetPacket.parseBundle(bundle); assertEquals(ans,val); } */ - @Test - public void parseBundleNull() { - InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); - byte[] bundle = null; +@Test +public void testParseBundleNull() { + InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); + byte[] bundle = null; - assertFalse(testPacket.parseBundle(bundle)); - } + assertFalse(testPacket.parseBundle(bundle)); +} - @Test - public void parseBundleNotMagic() { - InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); - byte[] bundle = new byte[] { 1, 2, 3, 4, 5, 6 }; - assertFalse(testPacket.parseBundle(bundle)); - } +@Test +public void testParseBundleNotMagic() { + InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); + byte[] bundle = new byte[] { 1, 2, 3, 4, 5, 6 }; + assertFalse(testPacket.parseBundle(bundle)); +} - @Test - public void parseBundleMagic() { - InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); - byte[] bundle = new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }; - assertFalse(testPacket.parseBundle(bundle)); - } +@Test +public void testParseBundleMagic() { + InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); + byte[] bundle = new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }; + assertFalse(testPacket.parseBundle(bundle)); +} - @Test - public void parseBundleMagicother() { - InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); - byte[] bundle = new byte[] { 1, 1, 1, 1, 1 }; - assertFalse(testPacket.parseBundle(bundle)); - } +@Test +public void testParseBundleMagicOther() { + InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); + byte[] bundle = new byte[] { 1, 1, 1, 1, 1 }; + assertFalse(testPacket.parseBundle(bundle)); +} @Test - public void parseBundleMaxLength() { + public void testParseBundleMaxLength() { InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); byte[] bundle = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1 }; assertFalse(testPacket.parseBundle(bundle)); } @Test - public void parseBundleMaxMaxLength() { + public void testParseBundleMaxMaxLength() { InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); byte[] bundle = new byte[] { 9, 8, 2, 4, 5, 1, 6, 5, 3 }; assertFalse(testPacket.parseBundle(bundle)); } - @Test - public void setByteBuffer() { + @Test + public void testSetByteBuffer() { InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); byte[] bundle = new byte[] { 58, (byte) 143, 5, (byte) 197, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; assertFalse(testPacket.parseBundle(bundle)); - } @Test - public void parseBundleAddressLengthLessThanRemaining() { + public void testParseBundleAddressLengthLessThanRemaining() { InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); byte[] bundle = new byte[] { 58, (byte) 143, 5, (byte) 197, 1, 2, 3, 4, 9, 1, 1, 1, 1, 1, 1, 1, 1 }; @@ -143,7 +129,7 @@ public void parseBundleAddressLengthLessThanRemaining() { } @Test - public void parseBundleCrcCccittReturnsTrue() { + public void testParseBundleCrcCccittReturnsTrue() { InetPacket testPacket = new InetPacket(new byte[] { 1, 2, 3 }); byte[] bundle = new byte[] { 58, (byte) 143, 5, (byte) 197, 1, 2, 3, 4, 9, 1, 1, 1, 1, 1, 1, 1, 1 }; @@ -157,4 +143,4 @@ public void parseBundleCrcCccittReturnsTrue() { } -} +} \ No newline at end of file diff --git a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/dds/CASClient.java b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/dds/CASClient.java index 80d07bc70..2e5789647 100644 --- a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/dds/CASClient.java +++ b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/dds/CASClient.java @@ -15,7 +15,7 @@ ******************************************************************************/ package us.dot.its.jpo.ode.dds; -import java.net.URL; +import java.net.URI; import java.util.Collections; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -90,7 +90,7 @@ public String login(String websocketURL) throws CASException { String httpWebsocketURL = "https" + websocketURL.substring(websocketURL.indexOf(':')); String ddsHttpWebSocketUrl = - new URL(httpWebsocketURL).toExternalForm(); + new URI(httpWebsocketURL).toString(); String serviceTicket = getServiceTicket( ddsCasUrl, ticketGrantingTicket, diff --git a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/wrapper/MessageConsumer.java b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/wrapper/MessageConsumer.java index ae9e5baf9..2e952a269 100644 --- a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/wrapper/MessageConsumer.java +++ b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/wrapper/MessageConsumer.java @@ -15,6 +15,7 @@ ******************************************************************************/ package us.dot.its.jpo.ode.wrapper; +import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.Properties; @@ -148,7 +149,7 @@ public void subscribe(String... topics) { boolean gotMessages = false; while (isRunning) { try { - ConsumerRecords records = consumer.poll(CONSUMER_POLL_TIMEOUT_MS); + ConsumerRecords records = consumer.poll(Duration.ofMillis(CONSUMER_POLL_TIMEOUT_MS)); if (records != null && !records.isEmpty()) { gotMessages = true; logger.debug("{} consuming {} message(s)", name, records.count()); diff --git a/jpo-ode-plugins/pom.xml b/jpo-ode-plugins/pom.xml index 2b9639b5f..2fe5c23f8 100644 --- a/jpo-ode-plugins/pom.xml +++ b/jpo-ode-plugins/pom.xml @@ -43,6 +43,7 @@ ch.qos.logback logback-core + 1.4.14 diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/PluginFactory.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/PluginFactory.java index d4962cc24..eb75b0553 100644 --- a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/PluginFactory.java +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/PluginFactory.java @@ -15,6 +15,7 @@ ******************************************************************************/ package us.dot.its.jpo.ode.plugin; +import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.net.URLClassLoader; @@ -57,9 +58,13 @@ public static void init() { * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException + * @throws SecurityException + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalArgumentException */ public static OdePlugin getPluginByName(String coderClassName) - throws ClassNotFoundException, InstantiationException, IllegalAccessException { + throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { logger.info("Getting Plugin: {}", coderClassName); OdePlugin result = (OdePlugin) buildObject(coderClassName); @@ -74,7 +79,7 @@ public static OdePlugin getPluginByName(String coderClassName) } private static Object buildObject(String aClassName) - throws ClassNotFoundException, InstantiationException, IllegalAccessException { + throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { Object result = null; try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); @@ -93,7 +98,7 @@ private static Object buildObject(String aClassName) } private static Object buildObject(ClassLoader cl, String aClassName) - throws ClassNotFoundException, InstantiationException, IllegalAccessException { + throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { Object result; logger.info("Getting class: {}", aClassName); @@ -102,7 +107,7 @@ private static Object buildObject(ClassLoader cl, String aClassName) Class implClass = cl.loadClass(aClassName); logger.info("creating an instance of: {}", implClass); - result = implClass.newInstance(); + result = implClass.getDeclaredConstructor().newInstance(); return result; } diff --git a/jpo-ode-svcs/pom.xml b/jpo-ode-svcs/pom.xml index 65c2df698..7eae2f55d 100644 --- a/jpo-ode-svcs/pom.xml +++ b/jpo-ode-svcs/pom.xml @@ -51,8 +51,9 @@ spring-boot-starter-data-rest - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api + 4.0.0 org.springframework.boot @@ -117,6 +118,17 @@ snmp4j 3.7.7 + + jakarta.annotation + jakarta.annotation-api + 2.1.1 + + + javax.annotation + javax.annotation-api + 1.3.2 + + diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeProperties.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeProperties.java index bf21c071a..98c57adf7 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeProperties.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeProperties.java @@ -26,7 +26,7 @@ import java.util.Set; import java.util.UUID; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeSvcsApplication.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeSvcsApplication.java index 5cd188327..a6c45ad5f 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeSvcsApplication.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeSvcsApplication.java @@ -17,7 +17,7 @@ import java.lang.management.ManagementFactory; -import javax.annotation.PreDestroy; +import jakarta.annotation.PreDestroy; import javax.management.InstanceAlreadyExistsException; import javax.management.MBeanRegistrationException; import javax.management.MBeanServer; diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/snmp/SnmpFourDot1Protocol.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/snmp/SnmpFourDot1Protocol.java index 01a5b4c84..f192c909b 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/snmp/SnmpFourDot1Protocol.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/snmp/SnmpFourDot1Protocol.java @@ -2,7 +2,7 @@ import java.text.ParseException; -import javax.xml.bind.DatatypeConverter; +import jakarta.xml.bind.DatatypeConverter; import org.snmp4j.smi.Integer32; import org.snmp4j.smi.OID; diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/snmp/SnmpNTCIP1218Protocol.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/snmp/SnmpNTCIP1218Protocol.java index c8f0f486a..b99b292f2 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/snmp/SnmpNTCIP1218Protocol.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/snmp/SnmpNTCIP1218Protocol.java @@ -2,7 +2,7 @@ import java.text.ParseException; -import javax.xml.bind.DatatypeConverter; +import jakarta.xml.bind.DatatypeConverter; import org.snmp4j.smi.Integer32; import org.snmp4j.smi.OID; diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/stomp/WebSocketConfig.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/stomp/WebSocketConfig.java index 37d4c7d4a..e5dcf1628 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/stomp/WebSocketConfig.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/stomp/WebSocketConfig.java @@ -17,13 +17,13 @@ import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; -import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer; import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; @Configuration @EnableWebSocketMessageBroker -public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { +public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(MessageBrokerRegistry config) { diff --git a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/OdePropertiesTest.java b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/OdePropertiesTest.java index f39ea0a68..430a71a32 100644 --- a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/OdePropertiesTest.java +++ b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/OdePropertiesTest.java @@ -22,7 +22,6 @@ import java.util.HashSet; import java.util.Set; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.boot.info.BuildProperties; import org.springframework.core.env.Environment; @@ -45,16 +44,6 @@ public class OdePropertiesTest { @Capturing CommonUtils capturingCommonUtils; - @BeforeEach - public void setup() { - new Expectations() { - { - CommonUtils.getEnvironmentVariable("DOCKER_HOST_IP"); - result = "testKafkaBrokers"; - } - }; - } - @Test public void testInit() { new Expectations() { diff --git a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/stomp/WebSocketConfigTest.java b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/stomp/WebSocketConfigTest.java index ff6183eb0..13528c1d8 100644 --- a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/stomp/WebSocketConfigTest.java +++ b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/stomp/WebSocketConfigTest.java @@ -16,47 +16,42 @@ package us.dot.its.jpo.ode.stomp; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; import mockit.Mocked; -import mockit.Tested; import mockit.Verifications; -//import mockit.integration.junit4.JMockit; -import us.dot.its.jpo.ode.stomp.WebSocketConfig; -//@RunWith(JMockit.class) -public class WebSocketConfigTest { +import static org.mockito.Mockito.*; -// @Mocked -// WebSocketConfig testWebSocketConfig; +class WebSocketConfigTest { + + // mock the webSocketConfig class + @Mocked + WebSocketConfig webSocketConfig; @Test - public void test(@Mocked MessageBrokerRegistry mockMessageBrokerRegistry) { - WebSocketConfig testWebSocketConfig = new WebSocketConfig(); - testWebSocketConfig.configureMessageBroker(mockMessageBrokerRegistry); - - new Verifications() { - { - mockMessageBrokerRegistry.enableSimpleBroker(anyString); - times = 1; - mockMessageBrokerRegistry.setApplicationDestinationPrefixes(anyString); - times = 1; - } - }; + void configureMessageBroker_shouldConfigureMessageBrokerRegistry() { + webSocketConfig = new WebSocketConfig(); + MessageBrokerRegistry config = mock(MessageBrokerRegistry.class); + webSocketConfig.configureMessageBroker(config); + + new Verifications() {{ + config.enableSimpleBroker(anyString); + times = 1; + config.setApplicationDestinationPrefixes(anyString); + times = 1; + }}; } @Test - public void testRegisterStompEndpoints(@Mocked StompEndpointRegistry mockStompEndpointRegistry) { - WebSocketConfig testWebSocketConfig = new WebSocketConfig(); - testWebSocketConfig.registerStompEndpoints(mockStompEndpointRegistry); - - new Verifications() { - { - mockStompEndpointRegistry.addEndpoint(anyString); - } - }; + void registerStompEndpoints_shouldRegisterStompEndpointRegistry() { + webSocketConfig = new WebSocketConfig(); + StompEndpointRegistry registry = mock(StompEndpointRegistry.class); + webSocketConfig.registerStompEndpoints(registry); + + new Verifications() {{ + registry.addEndpoint(anyString); + }}; } - } diff --git a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/upload/FileUploadIntegrationTests.java b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/upload/FileUploadIntegrationTests.java index e9fcdfe5c..d6fd7ad2d 100644 --- a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/upload/FileUploadIntegrationTests.java +++ b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/upload/FileUploadIntegrationTests.java @@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -27,7 +27,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -61,7 +61,7 @@ public void shouldUploadFile() throws Exception { map.add("file", resource); ResponseEntity response = this.restTemplate.postForEntity("/", map, String.class); - assertThat(response.getStatusCode()).isEqualByComparingTo(HttpStatus.FOUND); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.FOUND); assertThat(response.getHeaders().getLocation().toString()).startsWith("http://localhost:" + this.port + "/"); then(storageService).should().store(any(MultipartFile.class), "obulog"); } @@ -75,7 +75,7 @@ public void shouldDownloadFile() throws Exception { ResponseEntity response = this.restTemplate .getForEntity("/files/{filename}", String.class, "testupload.txt"); - assertThat(response.getStatusCodeValue()).isEqualTo(200); + assertThat(response.getStatusCode()).isEqualTo(200); assertThat(response.getHeaders().getFirst(HttpHeaders.CONTENT_DISPOSITION)) .isEqualTo("attachment; filename=\"testupload.txt\""); assertThat(response.getBody()).isEqualTo("Spring Framework"); diff --git a/pom.xml b/pom.xml index 9577783d9..3a589b7c1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.5.0 + 3.1.3 @@ -33,13 +33,13 @@ UTF-8 UTF-8 - 11 + 21 ${project.build.directory}/${project.artifactId}-${project.version} ${maven.build.timestamp} yyyy-MM-dd'T'HH:mm:ss.SSSZ - 11 + 21 usdot-jpo-ode https://sonarcloud.io @@ -105,7 +105,7 @@ ch.qos.logback logback-core - 1.2.9 + 1.4.14 @@ -126,8 +126,12 @@ org.apache.maven.plugins maven-compiler-plugin - 11 - 11 + 21 + 21 + true + + -Xlint:deprecation +