From 12534855e93c07331e23c77071e7a1e979003c38 Mon Sep 17 00:00:00 2001 From: LWagner Date: Sun, 26 Nov 2023 17:32:13 +0100 Subject: [PATCH 1/6] chore: Ignore CPUScheduler Test Super-Class properly --- .../cambio/simulator/resources/CPUProcessSchedulerTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/java/cambio/simulator/resources/CPUProcessSchedulerTest.java b/src/test/java/cambio/simulator/resources/CPUProcessSchedulerTest.java index ced5b738..abd95b25 100644 --- a/src/test/java/cambio/simulator/resources/CPUProcessSchedulerTest.java +++ b/src/test/java/cambio/simulator/resources/CPUProcessSchedulerTest.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; -class CPUProcessSchedulerTest { +abstract class CPUProcessSchedulerTest { private CPUProcessScheduler scheduler; @@ -34,8 +34,6 @@ class CPUProcessSchedulerTest { void setUp() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - Assumptions.assumeTrue(this.getClass() != CPUProcessSchedulerTest.class); //skips tests in this superclass - TestExperiment testExperiment = new TestExperiment(); TestModel mod = new TestModel(null, "TestModel", false, false, () -> { }, () -> { @@ -186,4 +184,4 @@ protected void testProcessOrder(ArrayList> arrivalList assertEquals(arrivalList.get(expectedResult[i] - 1).getValue0(), current.getValue0()); } } -} \ No newline at end of file +} From 1cb4b22e5bd7d8a18fd897b0c32708a63aef9277 Mon Sep 17 00:00:00 2001 From: LWagner Date: Sun, 26 Nov 2023 17:32:33 +0100 Subject: [PATCH 2/6] Add .versionsBackup to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ed10d27a..a7914e58 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,7 @@ ABCDE Experiment_*.html .idea/modules *.iml *.ipr +*.versionsBackup # CMake cmake-build-*/ From 1b174167856a95c0fb5159889f2c5cb2ab357daa Mon Sep 17 00:00:00 2001 From: LWagner Date: Sun, 26 Nov 2023 17:37:51 +0100 Subject: [PATCH 3/6] chore: Update Java version to 21 and fix test setup --- .github/workflows/awesomebot.yml | 3 +- .github/workflows/build_artifact.yml | 4 +- .github/workflows/checkstyle.yml | 6 +- .github/workflows/release.yml | 8 +- .github/workflows/update_documentation.yml | 4 +- pom.xml | 94 +++++++++++++------ .../AbstractDependencyDescriptionTest.java | 4 +- .../AlternativeDependencyDescriptionTest.java | 4 +- .../LoopDependencyDescriptionTest.java | 17 ++-- .../consistency/ReproducibilityTests.java | 2 +- 10 files changed, 92 insertions(+), 54 deletions(-) diff --git a/.github/workflows/awesomebot.yml b/.github/workflows/awesomebot.yml index 02557d4f..1d3db1bf 100644 --- a/.github/workflows/awesomebot.yml +++ b/.github/workflows/awesomebot.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Java uses: actions/setup-java@v3 with: - java-version: '20' + java-version: '21' distribution: 'temurin' cache: 'maven' @@ -38,4 +38,3 @@ jobs: awesome_bot_exit_code="$?" echo "awesome_bot_exit_code=$awesome_bot_exit_code" >> $GITHUB_OUTPUT exit "$awesome_bot_exit_code" - \ No newline at end of file diff --git a/.github/workflows/build_artifact.yml b/.github/workflows/build_artifact.yml index 719e9baa..7c085099 100644 --- a/.github/workflows/build_artifact.yml +++ b/.github/workflows/build_artifact.yml @@ -11,7 +11,7 @@ concurrency: cancel-in-progress: true env: - java_version: 8 + java_version: '21' java_distribution: 'temurin' jobs: @@ -41,7 +41,7 @@ jobs: path: ./target/*.jar run_tests: - if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" + if: !contains(github.event.head_commit.message, '[maven-release-plugin]') name: Run Tests & Report runs-on: ubuntu-latest needs: build_artifact diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml index 4e767129..218d71f0 100644 --- a/.github/workflows/checkstyle.yml +++ b/.github/workflows/checkstyle.yml @@ -7,7 +7,7 @@ on: jobs: run_checkstyle: - if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" + if: !contains(github.event.head_commit.message, '[maven-release-plugin]') name: Run Checkstyle runs-on: ubuntu-latest steps: @@ -16,8 +16,8 @@ jobs: - name: Set up Java uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' + java-version: '21' + distribution: 'temurin' cache: 'maven' - name: Run Checkstyle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62fc3215..286fdc15 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: jobs: Prepare-and-Release: - if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" + if: !contains(github.event.head_commit.message, '[maven-release-plugin]') name: Prepare and Release runs-on: ubuntu-latest @@ -14,11 +14,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Set up Java 8 + - name: Set up Java uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'adopt' + java-version: '21' + distribution: 'temurin' cache: 'maven' - name: Configure Git diff --git a/.github/workflows/update_documentation.yml b/.github/workflows/update_documentation.yml index cd353fb7..20c219b1 100644 --- a/.github/workflows/update_documentation.yml +++ b/.github/workflows/update_documentation.yml @@ -8,7 +8,7 @@ on: jobs: build_documentation: - if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" + if: !contains(github.event.head_commit.message, '[maven-release-plugin]') name: Build Documentation runs-on: ubuntu-latest steps: @@ -19,7 +19,7 @@ jobs: - name: Set up Java uses: actions/setup-java@v3 with: - java-version: '20' + java-version: '21' distribution: 'temurin' cache: 'maven' diff --git a/pom.xml b/pom.xml index 9c6d0649..f4df1ff1 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 cambio.simulator @@ -11,29 +12,29 @@ https://github.com/Cambio-Project/MiSim - 1.8 - 1.8 + 21 UTF-8 2.9.1 1.2 0.10.2 - 2.11.0 - 1.5.0 - 3.12.0 + 2.15.0 + 1.6.0 + 3.14.0 3.6.1 - 1.10.0 + 1.11.0 2.5.1e - 23.0.0 + 24.1.0 - 5.9.1 - 4.8.0 + 5.10.1 + 5.7.0 scm:git:https://github.com/Cambio-Project/MiSim HEAD + github @@ -50,6 +51,19 @@ + + + + org.mockito + mockito-bom + 5.7.0 + pom + import + + + + + @@ -107,37 +121,24 @@ provided - - - org.junit.vintage - junit-vintage-engine - ${junit.version} - test - org.junit.jupiter junit-jupiter-api ${junit.version} test + org.mockito mockito-core - ${mockito.version} test org.mockito mockito-junit-jupiter - ${mockito.version} - test - - - org.mockito - mockito-inline - ${mockito.version} test + org.apache.commons commons-text @@ -150,6 +151,31 @@ ${project.artifactId} + + org.apache.maven.plugins + maven-enforcer-plugin + 3.4.1 + + + enforce + + enforce + + + + + ${maven.compiler.release} + + + 3.9.0 + + + + + + + + org.apache.maven.plugins maven-checkstyle-plugin @@ -158,7 +184,16 @@ com.puppycrawl.tools checkstyle - 9.3 + 10.12.5 + compile + + + + + org.junit.vintage + junit-vintage-engine + ${junit.version} + compile @@ -223,7 +258,8 @@ 3.3.0 - + cambio.simulator.Main @@ -252,13 +288,13 @@ org.codehaus.mojo versions-maven-plugin - 2.12.0 + 2.16.2 org.apache.maven.plugins maven-release-plugin - 3.0.0-M6 + 3.0.1 v@{project.version} diff --git a/src/test/java/cambio/simulator/entities/networking/AbstractDependencyDescriptionTest.java b/src/test/java/cambio/simulator/entities/networking/AbstractDependencyDescriptionTest.java index 4f55b175..ca53fc7a 100644 --- a/src/test/java/cambio/simulator/entities/networking/AbstractDependencyDescriptionTest.java +++ b/src/test/java/cambio/simulator/entities/networking/AbstractDependencyDescriptionTest.java @@ -8,12 +8,12 @@ import cambio.simulator.models.MiSimModel; import cambio.simulator.test.TestBase; -import org.junit.Before; import cambio.simulator.entities.microservice.Microservice; import cambio.simulator.entities.microservice.Operation; import desmoj.core.simulator.Experiment; import desmoj.core.simulator.Model; +import org.junit.jupiter.api.BeforeEach; /** * A base class that provides basic mocks for setting up unit tests on @@ -27,7 +27,7 @@ public abstract class AbstractDependencyDescriptionTest extends TestBase { protected Operation startOperation; protected Request request; - @Before + @BeforeEach public void setup() { this.random = mock(Random.class); diff --git a/src/test/java/cambio/simulator/entities/networking/AlternativeDependencyDescriptionTest.java b/src/test/java/cambio/simulator/entities/networking/AlternativeDependencyDescriptionTest.java index 227493a9..2e5df85c 100644 --- a/src/test/java/cambio/simulator/entities/networking/AlternativeDependencyDescriptionTest.java +++ b/src/test/java/cambio/simulator/entities/networking/AlternativeDependencyDescriptionTest.java @@ -1,7 +1,7 @@ package cambio.simulator.entities.networking; -import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -10,11 +10,11 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; import cambio.simulator.entities.microservice.Microservice; import cambio.simulator.entities.microservice.Operation; import desmoj.core.dist.ContDistConstant; +import org.junit.jupiter.api.Test; /** * Runs unit tests for {@link AlternativeDependencyDescription}. diff --git a/src/test/java/cambio/simulator/entities/networking/LoopDependencyDescriptionTest.java b/src/test/java/cambio/simulator/entities/networking/LoopDependencyDescriptionTest.java index eeea44c3..50d1703a 100644 --- a/src/test/java/cambio/simulator/entities/networking/LoopDependencyDescriptionTest.java +++ b/src/test/java/cambio/simulator/entities/networking/LoopDependencyDescriptionTest.java @@ -1,7 +1,7 @@ package cambio.simulator.entities.networking; -import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -10,7 +10,8 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import cambio.simulator.entities.microservice.Microservice; import cambio.simulator.entities.microservice.Operation; @@ -55,12 +56,14 @@ public void testNoChildren() { assertEquals(0, result.size()); } - @Test(expected = IllegalArgumentException.class) + @Test public void testZeroIterations() { - final LoopDependencyDescription dependency = new LoopDependencyDescription(model, 1, 1, 0); - setupLoopDependencyWithOneChild(dependency, 1); - when(random.nextDouble()).thenReturn(0.5); - dependency.generateDependenciesForExecutions(request, random); + Assertions.assertThrowsExactly(IllegalArgumentException.class, () -> { + final LoopDependencyDescription dependency = new LoopDependencyDescription(model, 1, 1, 0); + setupLoopDependencyWithOneChild(dependency, 1); + when(random.nextDouble()).thenReturn(0.5); + dependency.generateDependenciesForExecutions(request, random); + }); } @Test diff --git a/src/test/java/cambio/simulator/test/consistency/ReproducibilityTests.java b/src/test/java/cambio/simulator/test/consistency/ReproducibilityTests.java index b8a0d867..b40a14ed 100644 --- a/src/test/java/cambio/simulator/test/consistency/ReproducibilityTests.java +++ b/src/test/java/cambio/simulator/test/consistency/ReproducibilityTests.java @@ -98,7 +98,7 @@ void testReproducibility(File scenario, File architecture, boolean keepOutput, b try { TestUtils.compareFileContentsOfDirectories(rawOutput1, rawOutput2); - } catch (AssertionFailedError | junit.framework.AssertionFailedError e) { + } catch (AssertionFailedError e) { Path trace1; Path trace2; From 3e4dbc17d94099bdc9487baa7aedfdab0f308841 Mon Sep 17 00:00:00 2001 From: LWagner Date: Sun, 26 Nov 2023 17:48:05 +0100 Subject: [PATCH 4/6] drop maven requirement to 3.8 to support setup-java --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f4df1ff1..e1b60f78 100644 --- a/pom.xml +++ b/pom.xml @@ -167,7 +167,7 @@ ${maven.compiler.release} - 3.9.0 + 3.8.0 From 16ef7368128f18fd58cf4ab5d4688a22358c1e2b Mon Sep 17 00:00:00 2001 From: LWagner Date: Sun, 26 Nov 2023 18:28:45 +0100 Subject: [PATCH 5/6] update plugin versions --- pom.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index e1b60f78..e49263f6 100644 --- a/pom.xml +++ b/pom.xml @@ -179,15 +179,14 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.3.0 + 3.3.1 com.puppycrawl.tools checkstyle - 10.12.5 + 10.12.5 compile - org.junit.vintage @@ -219,13 +218,13 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M7 + 3.2.2 org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.6.2 attach-javadocs @@ -244,9 +243,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 - + 3.11.0 + + -Xpkginfo:always @@ -255,7 +255,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.3.0 + 3.5.1 Date: Sun, 26 Nov 2023 18:31:42 +0100 Subject: [PATCH 6/6] fix workflows --- .github/workflows/build_artifact.yml | 2 +- .github/workflows/checkstyle.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/update_documentation.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_artifact.yml b/.github/workflows/build_artifact.yml index 7c085099..86e9a8da 100644 --- a/.github/workflows/build_artifact.yml +++ b/.github/workflows/build_artifact.yml @@ -41,7 +41,7 @@ jobs: path: ./target/*.jar run_tests: - if: !contains(github.event.head_commit.message, '[maven-release-plugin]') + if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" name: Run Tests & Report runs-on: ubuntu-latest needs: build_artifact diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml index 218d71f0..35769441 100644 --- a/.github/workflows/checkstyle.yml +++ b/.github/workflows/checkstyle.yml @@ -7,7 +7,7 @@ on: jobs: run_checkstyle: - if: !contains(github.event.head_commit.message, '[maven-release-plugin]') + if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" name: Run Checkstyle runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 286fdc15..f88df8c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: jobs: Prepare-and-Release: - if: !contains(github.event.head_commit.message, '[maven-release-plugin]') + if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" name: Prepare and Release runs-on: ubuntu-latest diff --git a/.github/workflows/update_documentation.yml b/.github/workflows/update_documentation.yml index 20c219b1..e5c915d4 100644 --- a/.github/workflows/update_documentation.yml +++ b/.github/workflows/update_documentation.yml @@ -8,7 +8,7 @@ on: jobs: build_documentation: - if: !contains(github.event.head_commit.message, '[maven-release-plugin]') + if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" name: Build Documentation runs-on: ubuntu-latest steps: