Skip to content

Commit

Permalink
chore: Update Java version to 21 and fix test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
LitschiW committed Nov 26, 2023
1 parent 1cb4b22 commit 1b17416
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 54 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/awesomebot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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"
4 changes: 2 additions & 2 deletions .github/workflows/build_artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: true

env:
java_version: 8
java_version: '21'
java_distribution: 'temurin'

jobs:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/checkstyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ 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

steps:
- 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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'

Expand Down
94 changes: 65 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>cambio.simulator</groupId>
Expand All @@ -11,29 +12,29 @@
<url>https://github.com/Cambio-Project/MiSim</url>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.release>21</maven.compiler.release>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gson.version>2.9.1</gson.version>
<javatuples.version>1.2</javatuples.version>
<reflections.version>0.10.2</reflections.version>
<commons-io.version>2.11.0</commons-io.version>
<commons-cli.version>1.5.0</commons-cli.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-io.version>2.15.0</commons-io.version>
<commons-cli.version>1.6.0</commons-cli.version>
<commons-lang3.version>3.14.0</commons-lang3.version>
<commons-math3.version>3.6.1</commons-math3.version>
<commons-text.version>1.10.0</commons-text.version>
<commons-text.version>1.11.0</commons-text.version>
<desmoj.version>2.5.1e</desmoj.version>
<annotations.version>23.0.0</annotations.version>
<annotations.version>24.1.0</annotations.version>

<junit.version>5.9.1</junit.version>
<mockito.version>4.8.0</mockito.version>
<junit.version>5.10.1</junit.version>
<mockito.version>5.7.0</mockito.version>
</properties>

<scm>
<developerConnection>scm:git:https://github.com/Cambio-Project/MiSim</developerConnection>
<tag>HEAD</tag>
</scm>

<distributionManagement>
<repository>
<id>github</id>
Expand All @@ -50,6 +51,19 @@
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-bom</artifactId>
<version>5.7.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>


<dependencies>

<!-- util -->
Expand Down Expand Up @@ -107,37 +121,24 @@
<scope>provided</scope>
</dependency>

<!-- checkstyle plugin requires an outdated version of junit-vintage, this dependency overwrites that -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

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

<dependency> <!-- this may needs to be moved to default scope if needed elsewhere than the tests -->
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
Expand All @@ -150,6 +151,31 @@
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>${maven.compiler.release}</version>
</requireJavaVersion>
<requireMavenVersion>
<version>3.9.0</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand All @@ -158,7 +184,16 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>9.3</version> <!-- TODO: update to >10 when moving to java >8 -->
<version>10.12.5</version> <!-- TODO: update to >10 when moving to java >8 -->
<scope>compile</scope>
</dependency>

<!-- checkstyle plugin requires an outdated version of junit-vintage, this dependency overwrites that -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<configuration>
Expand Down Expand Up @@ -223,7 +258,8 @@
<version>3.3.0</version>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>cambio.simulator.Main</mainClass>
</transformer>
</transformers>
Expand Down Expand Up @@ -252,13 +288,13 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.12.0</version>
<version>2.16.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M6</version>
<version>3.0.1</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 1b17416

Please sign in to comment.