Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and Test

on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
container:
image: eclipse-temurin:17-jdk

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Ant
run: |
apt-get update
apt-get install -y ant

- name: Show versions
run: |
java -version
ant -version

- name: Build and test
run: ant all

- name: Upload jars
uses: actions/upload-artifact@v4
with:
name: opendis7-jars
path: dist/*.jar
retention-days: 30

- name: Upload javadoc
uses: actions/upload-artifact@v4
with:
name: opendis7-javadoc
path: dist/javadoc/
retention-days: 30

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: build/test/results/
retention-days: 14
55 changes: 55 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
build-and-release:
runs-on: ubuntu-latest
container:
image: eclipse-temurin:17-jdk

permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Ant and tools
run: |
apt-get update
apt-get install -y ant zip

- name: Build
run: ant all

- name: Create release bundle
run: |
mkdir -p release
cp dist/opendis7-*.jar release/
cp dist/license.txt release/
cp dist/license.html release/
cd release && zip -r ../opendis7-release.zip .

- name: Upload release assets
if: github.event_name == 'release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
apt-get install -y gh
for jar in dist/opendis7-*.jar; do
gh release upload "${{ github.event.release.tag_name }}" "$jar" --clobber
done
gh release upload "${{ github.event.release.tag_name }}" opendis7-release.zip --clobber

- name: Upload artifacts
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: opendis7-release
path: |
dist/opendis7-*.jar
opendis7-release.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/pduLog/Pdusave.dislog
.DS_Store
/nbproject/genfiles.properties
PDU_TESTING.md
18 changes: 6 additions & 12 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,22 +179,16 @@ POSSIBILITY OF SUCH DAMAGE.
</delete>
</target>

<target name="view.issues.online" description="view online issues in web browser (NetBeans only)">
<target name="view.issues.online" description="view online issues in web browser">
<echo message="https://github.com/open-dis/opendis7-java/issues" />
<nbbrowse url="https://github.com/open-dis/opendis7-java/issues" />
<!-- TODO implementation-independent approach if possible, but note that other Ant approaches usually have to be customized for each OS. -->
</target>
<target name="view.javadoc.local" description="view local package javadoc in web browser (NetBeans only)">

<target name="view.javadoc.local" description="view local javadoc">
<echo message="view local javadoc in ${dist.javadoc.dir} subdirectory"/>
<nbbrowse file="${dist.javadoc.dir}/index.html" />
<!-- TODO implementation-independent approach if possible, but note that other Ant approaches usually have to be customized for each OS. -->
</target>

<target name="view.javadoc.online" description="view online package javadoc in web browser (NetBeans only)">
<echo message="view online javadoc in dist/javadoc subdirectory"/>
<nbbrowse url="https://savage.nps.edu/opendis7-java/javadoc" />
<!-- TODO implementation-independent approach if possible, but note that other Ant approaches usually have to be customized for each OS. -->

<target name="view.javadoc.online" description="view online javadoc">
<echo message="view online javadoc: https://savage.nps.edu/opendis7-java/javadoc"/>
</target>

<target name="deploy.guidance" description="instructions">
Expand Down
114 changes: 114 additions & 0 deletions test/edu/nps/moves/dis7/test/AcknowledgePduTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
Copyright (c) 1995-2026 held by the author(s). All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the names of the Naval Postgraduate School (NPS)
Modeling Virtual Environments and Simulation (MOVES) Institute
https://www.nps.edu and https://www.nps.edu/web/moves
nor the names of its contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package edu.nps.moves.dis7.test;

import edu.nps.moves.dis7.enumerations.AcknowledgeAcknowledgeFlag;
import edu.nps.moves.dis7.enumerations.AcknowledgeResponseFlag;
import edu.nps.moves.dis7.pdus.AcknowledgePdu;
import edu.nps.moves.dis7.pdus.Pdu;
import edu.nps.moves.dis7.pdus.SimulationIdentifier;
import edu.nps.moves.dis7.pdus.SimulationAddress;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;

/**
* Unit tests for satisfactory handling of Acknowledge PDU fields and values.
*/
@DisplayName("AcknowledgePduTest")
public class AcknowledgePduTest extends PduTest
{
/** default constructor */
public AcknowledgePduTest()
{
// initialization code here, but beware order dependencies with JUnit tests
}

/** preparation **/
@BeforeAll
public static void setUpClass()
{
if (isVerbose())
System.out.println("*** AcknowledgePduTest setUpClass()");
}

/** Test PDU sending, receiving, marshalling (serialization) and unmarshalling (deserialization) */
@Test
@Override
public void testMultiplePdus()
{
if (isVerbose())
System.out.println("*** AcknowledgePduTest testMultiplePdus()");

AcknowledgePdu acknowledgePdu = pduFactory.makeAcknowledgePdu();

acknowledgePdu.setOriginatingID(new SimulationIdentifier().setSimulationAddress(new SimulationAddress().setSite(1).setApplication(2)));
acknowledgePdu.setReceivingID(new SimulationIdentifier().setSimulationAddress(new SimulationAddress().setSite(3).setApplication(4)));
acknowledgePdu.setAcknowledgeFlag(AcknowledgeAcknowledgeFlag.CREATE_ENTITY);
acknowledgePdu.setResponseFlag(AcknowledgeResponseFlag.ABLE_TO_COMPLY);
acknowledgePdu.setRequestID(5001);
testOnePdu(acknowledgePdu);

acknowledgePdu.setRequestID(5002);
acknowledgePdu.setAcknowledgeFlag(AcknowledgeAcknowledgeFlag.REMOVE_ENTITY);
testOnePdu(acknowledgePdu);
}

@Override
protected void testOnePdu(Pdu createdPdu)
{
testPduSendReceiveHeaderMatch(createdPdu);

AcknowledgePdu createdCast = (AcknowledgePdu) createdPdu;
AcknowledgePdu receivedCast = (AcknowledgePdu) receivedPdus.get(0);

assertEquals(createdCast.getOriginatingID(), receivedCast.getOriginatingID(), "mismatched OriginatingID");
assertEquals(createdCast.getReceivingID(), receivedCast.getReceivingID(), "mismatched ReceivingID");
assertEquals(createdCast.getAcknowledgeFlag(), receivedCast.getAcknowledgeFlag(), "mismatched AcknowledgeFlag");
assertEquals(createdCast.getResponseFlag(), receivedCast.getResponseFlag(), "mismatched ResponseFlag");
assertEquals(createdCast.getRequestID(), receivedCast.getRequestID(), "mismatched RequestID");

testPduCommonFields(createdPdu);
}

/** Command-line invocation (CLI) of program, execution starts here
* @param args command-line arguments
*/
public static void main(String[] args)
{
PduTest test = new AcknowledgePduTest();
test.setUp();
test.testMultiplePdus();
test.tearDown();
}
}
115 changes: 115 additions & 0 deletions test/edu/nps/moves/dis7/test/AcknowledgeReliablePduTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
Copyright (c) 1995-2026 held by the author(s). All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the names of the Naval Postgraduate School (NPS)
Modeling Virtual Environments and Simulation (MOVES) Institute
https://www.nps.edu and https://www.nps.edu/web/moves
nor the names of its contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package edu.nps.moves.dis7.test;

import edu.nps.moves.dis7.enumerations.AcknowledgeAcknowledgeFlag;
import edu.nps.moves.dis7.enumerations.AcknowledgeResponseFlag;
import edu.nps.moves.dis7.pdus.AcknowledgeReliablePdu;
import edu.nps.moves.dis7.pdus.Pdu;
import edu.nps.moves.dis7.pdus.SimulationIdentifier;
import edu.nps.moves.dis7.pdus.SimulationAddress;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;

/**
* Unit tests for satisfactory handling of Acknowledge Reliable PDU fields and values.
*/
@DisplayName("AcknowledgeReliablePduTest")
public class AcknowledgeReliablePduTest extends PduTest
{
/** default constructor */
public AcknowledgeReliablePduTest()
{
// initialization code here, but beware order dependencies with JUnit tests
}

/** preparation **/
@BeforeAll
public static void setUpClass()
{
if (isVerbose())
System.out.println("*** AcknowledgeReliablePduTest setUpClass()");
}

/** Test PDU sending, receiving, marshalling (serialization) and unmarshalling (deserialization) */
@Test
@Override
public void testMultiplePdus()
{
if (isVerbose())
System.out.println("*** AcknowledgeReliablePduTest testMultiplePdus()");

AcknowledgeReliablePdu arPdu = pduFactory.makeAcknowledgeReliablePdu();

arPdu.setOriginatingID(new SimulationIdentifier().setSimulationAddress(new SimulationAddress().setSite(1).setApplication(2)));
arPdu.setReceivingID(new SimulationIdentifier().setSimulationAddress(new SimulationAddress().setSite(3).setApplication(4)));
arPdu.setAcknowledgeFlag(AcknowledgeAcknowledgeFlag.CREATE_ENTITY);
arPdu.setResponseFlag(AcknowledgeResponseFlag.ABLE_TO_COMPLY);
arPdu.setRequestID(501);
testOnePdu(arPdu);

arPdu.setAcknowledgeFlag(AcknowledgeAcknowledgeFlag.REMOVE_ENTITY);
arPdu.setResponseFlag(AcknowledgeResponseFlag.UNABLE_TO_COMPLY);
arPdu.setRequestID(502);
testOnePdu(arPdu);
}

@Override
protected void testOnePdu(Pdu createdPdu)
{
testPduSendReceiveHeaderMatch(createdPdu);

AcknowledgeReliablePdu createdCast = (AcknowledgeReliablePdu) createdPdu;
AcknowledgeReliablePdu receivedCast = (AcknowledgeReliablePdu) receivedPdus.get(0);

assertEquals(createdCast.getOriginatingID(), receivedCast.getOriginatingID(), "mismatched OriginatingID");
assertEquals(createdCast.getReceivingID(), receivedCast.getReceivingID(), "mismatched ReceivingID");
assertEquals(createdCast.getAcknowledgeFlag(), receivedCast.getAcknowledgeFlag(), "mismatched AcknowledgeFlag");
assertEquals(createdCast.getResponseFlag(), receivedCast.getResponseFlag(), "mismatched ResponseFlag");
assertEquals(createdCast.getRequestID(), receivedCast.getRequestID(), "mismatched RequestID");

testPduCommonFields(createdPdu);
}

/** Command-line invocation (CLI) of program, execution starts here
* @param args command-line arguments
*/
public static void main(String[] args)
{
PduTest test = new AcknowledgeReliablePduTest();
test.setUp();
test.testMultiplePdus();
test.tearDown();
}
}
Loading