Skip to content

Commit

Permalink
Merge pull request #50 from CDOT-CV/update/java-lts-version
Browse files Browse the repository at this point in the history
Update ODE Java Version to Java 21
  • Loading branch information
drewjj authored Jan 15, 2024
2 parents 4d5d670 + 6de4f3d commit f14a82d
Show file tree
Hide file tree
Showing 22 changed files with 165 additions and 252 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
43 changes: 23 additions & 20 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
28 changes: 14 additions & 14 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: "11"
java-version: "21"
distribution: "temurin"
- name: Run Sonar
env:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
5 changes: 3 additions & 2 deletions jpo-ode-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InetAddress>() {
@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<InetAddress> 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[]
Expand All @@ -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 };

Expand All @@ -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 };

Expand All @@ -157,4 +143,4 @@ public void parseBundleCrcCccittReturnsTrue() {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -148,7 +149,7 @@ public void subscribe(String... topics) {
boolean gotMessages = false;
while (isRunning) {
try {
ConsumerRecords<K, V> records = consumer.poll(CONSUMER_POLL_TIMEOUT_MS);
ConsumerRecords<K, V> records = consumer.poll(Duration.ofMillis(CONSUMER_POLL_TIMEOUT_MS));
if (records != null && !records.isEmpty()) {
gotMessages = true;
logger.debug("{} consuming {} message(s)", name, records.count());
Expand Down
1 change: 1 addition & 0 deletions jpo-ode-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.4.14</version>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit f14a82d

Please sign in to comment.