Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Java 21 #89

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions .github/workflows/awesomebot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '20'
java-version: '21'
distribution: 'temurin'
cache: 'maven'

Expand All @@ -39,4 +39,3 @@ jobs:
awesome_bot_exit_code="$?"
echo "awesome_bot_exit_code=$awesome_bot_exit_code" >> $GITHUB_OUTPUT
exit "$awesome_bot_exit_code"

2 changes: 1 addition & 1 deletion .github/workflows/build_artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: true

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

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/checkstyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,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
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '20'
java-version: '21'
distribution: 'temurin'
cache: 'maven'

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ABCDE Experiment_*.html
.idea/modules
*.iml
*.ipr
*.versionsBackup

# CMake
cmake-build-*/
Expand Down
106 changes: 71 additions & 35 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,15 +151,48 @@
<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.8.0</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<dependencies>
<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>
<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 All @@ -184,13 +218,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.2.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.6.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -209,9 +243,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration> <!-- Prevent NoSuchFileException during verify when having a dummy package-info.java -->
<version>3.11.0</version>
<configuration>
<compilerArgs>
<!-- Prevent NoSuchFileException during verify when having a dummy package-info.java -->
<arg>-Xpkginfo:always</arg>
</compilerArgs>
</configuration>
Expand All @@ -220,10 +255,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.5.1</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 @@ -26,16 +26,14 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

class CPUProcessSchedulerTest<T extends CPUProcessScheduler> {
abstract class CPUProcessSchedulerTest<T extends CPUProcessScheduler> {

private CPUProcessScheduler scheduler;

@BeforeEach
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, () -> {
}, () -> {
Expand Down Expand Up @@ -186,4 +184,4 @@ protected void testProcessOrder(ArrayList<Pair<CPUProcess, Integer>> arrivalList
assertEquals(arrivalList.get(expectedResult[i] - 1).getValue0(), current.getValue0());
}
}
}
}
Loading
Loading