From 7b4a5b945e161e21e00c7e02ee3e914a6b9394c9 Mon Sep 17 00:00:00 2001 From: Nathan Creger Date: Thu, 30 May 2024 10:45:58 -0400 Subject: [PATCH 1/6] Update eridanus to java 21 --- build.gradle | 30 +++++++++---------- gradle/wrapper/gradle-wrapper.properties | 4 +-- .../notifications/NotificationController.java | 2 +- .../NotificationControllerTest.java | 17 ++++++----- .../PackageNotificationEventServiceTest.java | 15 +++++----- .../eridanus/notifications/PackageTest.java | 13 ++++---- .../notifications/StateChangeEventTest.java | 12 ++++---- .../kpmp/eridanus/notifications/UserTest.java | 12 ++++---- 8 files changed, 53 insertions(+), 52 deletions(-) diff --git a/build.gradle b/build.gradle index e03e8fa..14f8261 100644 --- a/build.gradle +++ b/build.gradle @@ -3,16 +3,18 @@ buildscript { mavenCentral() } dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:2.6.4") + classpath("org.springframework.boot:spring-boot-gradle-plugin:3.2.5") } } plugins { - id 'com.palantir.docker' version '0.22.1' + id 'java' + id 'com.palantir.docker' version '0.35.0' + id 'org.springframework.boot' version '3.2.5' } group = 'kingstonduo' -version = "latest" +version = "1.3" apply plugin: 'java' apply plugin: 'eclipse' @@ -25,12 +27,6 @@ eclipse { project.natures 'org.eclipse.buildship.core.gradleprojectnature' } - -jar { - baseName='eridanus-data' - version= '1.3' -} - repositories { mavenCentral() } @@ -41,16 +37,18 @@ processResources { } } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = '21' +targetCompatibility = '21' dependencies { implementation("org.springframework.boot:spring-boot-starter-data-mongodb") implementation("org.springframework.boot:spring-boot-starter-web") implementation("com.sun.mail:javax.mail:1.6.2") - testImplementation("org.mockito:mockito-core") - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation 'junit:junit:4.12' + + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.mockito:mockito-core' + testImplementation('org.mockito:mockito-junit-jupiter:3.12.4') + testImplementation 'org.springframework:spring-test:5.2.25.RELEASE' } springBoot { @@ -79,7 +77,7 @@ def getCurrentGitBranch() { } catch (e) { } if (gitBranch == "develop" || gitBranch == "master"){ - return jar.version + return project.version }else{ return gitBranch } @@ -87,7 +85,7 @@ def getCurrentGitBranch() { } docker { - name "kingstonduo/${jar.baseName}:" + getCurrentGitBranch() + name "kingstonduo/eridanus-spring" + getCurrentGitBranch() copySpec.from(tasks.unpack.outputs).into("dependency") buildArgs(['DEPENDENCY': "dependency"]) } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 669386b..2bbac7d 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/src/main/java/org/kpmp/eridanus/notifications/NotificationController.java b/src/main/java/org/kpmp/eridanus/notifications/NotificationController.java index 9a78ac8..252e577 100644 --- a/src/main/java/org/kpmp/eridanus/notifications/NotificationController.java +++ b/src/main/java/org/kpmp/eridanus/notifications/NotificationController.java @@ -1,7 +1,7 @@ package org.kpmp.eridanus.notifications; import javax.mail.MessagingException; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/test/java/org/kpmp/eridanus/notifications/NotificationControllerTest.java b/src/test/java/org/kpmp/eridanus/notifications/NotificationControllerTest.java index 88bd31a..f7f73cf 100644 --- a/src/test/java/org/kpmp/eridanus/notifications/NotificationControllerTest.java +++ b/src/test/java/org/kpmp/eridanus/notifications/NotificationControllerTest.java @@ -1,16 +1,16 @@ package org.kpmp.eridanus.notifications; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import javax.mail.MessagingException; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -20,14 +20,15 @@ public class NotificationControllerTest { private PackageNotificationEventService packageEventService; private NotificationController controller; - @Before + @BeforeEach public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); controller = new NotificationController(packageEventService); } - @After + @AfterEach public void tearDown() throws Exception { + MockitoAnnotations.openMocks(this).close(); controller = null; } diff --git a/src/test/java/org/kpmp/eridanus/notifications/PackageNotificationEventServiceTest.java b/src/test/java/org/kpmp/eridanus/notifications/PackageNotificationEventServiceTest.java index d35cc0a..f85dcdc 100644 --- a/src/test/java/org/kpmp/eridanus/notifications/PackageNotificationEventServiceTest.java +++ b/src/test/java/org/kpmp/eridanus/notifications/PackageNotificationEventServiceTest.java @@ -1,6 +1,6 @@ package org.kpmp.eridanus.notifications; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.verify; @@ -13,9 +13,9 @@ import javax.mail.MessagingException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -29,17 +29,18 @@ public class PackageNotificationEventServiceTest { @Mock private PackageRepository packageRepository; - @Before + @BeforeEach public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); service = new PackageNotificationEventService(emailer, packageRepository); ReflectionTestUtils.setField(service, "toAddresses", Arrays.asList("rlreamy@umich.edu")); ReflectionTestUtils.setField(service, "uploadSuccess", "success"); ReflectionTestUtils.setField(service, "uploadFail", "fail"); } - @After + @AfterEach public void tearDown() throws Exception { + MockitoAnnotations.openMocks(this).close(); service = null; } diff --git a/src/test/java/org/kpmp/eridanus/notifications/PackageTest.java b/src/test/java/org/kpmp/eridanus/notifications/PackageTest.java index 33082d8..1810c0e 100644 --- a/src/test/java/org/kpmp/eridanus/notifications/PackageTest.java +++ b/src/test/java/org/kpmp/eridanus/notifications/PackageTest.java @@ -1,23 +1,24 @@ package org.kpmp.eridanus.notifications; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Date; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + public class PackageTest { private Package pkg; - @Before + @BeforeEach public void setUp() throws Exception { pkg = new Package(); } - @After + @AfterEach public void tearDown() throws Exception { pkg = null; } diff --git a/src/test/java/org/kpmp/eridanus/notifications/StateChangeEventTest.java b/src/test/java/org/kpmp/eridanus/notifications/StateChangeEventTest.java index 100af51..4f562f4 100644 --- a/src/test/java/org/kpmp/eridanus/notifications/StateChangeEventTest.java +++ b/src/test/java/org/kpmp/eridanus/notifications/StateChangeEventTest.java @@ -1,21 +1,21 @@ package org.kpmp.eridanus.notifications; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class StateChangeEventTest extends StateChangeEvent { private StateChangeEvent event; - @Before + @BeforeEach public void setUp() throws Exception { event = new StateChangeEvent(); } - @After + @AfterEach public void tearDown() throws Exception { event = null; } diff --git a/src/test/java/org/kpmp/eridanus/notifications/UserTest.java b/src/test/java/org/kpmp/eridanus/notifications/UserTest.java index cc3a142..861c261 100644 --- a/src/test/java/org/kpmp/eridanus/notifications/UserTest.java +++ b/src/test/java/org/kpmp/eridanus/notifications/UserTest.java @@ -1,21 +1,21 @@ package org.kpmp.eridanus.notifications; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class UserTest { private User user; - @Before + @BeforeEach public void setUp() throws Exception { user = new User(); } - @After + @AfterEach public void tearDown() throws Exception { user = null; } From e38544edde7b16f012cef0d88feff4326a685f56 Mon Sep 17 00:00:00 2001 From: Nathan Creger Date: Thu, 30 May 2024 10:48:42 -0400 Subject: [PATCH 2/6] install java21 in docker image and fix image name tag --- Dockerfile | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 53c2635..dc65a60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM alpine +FROM alpine:3.19.1 RUN apk update && \ apk upgrade -RUN apk add openjdk8 +RUN apk add openjdk21 VOLUME /tmp ARG DEPENDENCY=target/dependency diff --git a/build.gradle b/build.gradle index 14f8261..4b79951 100644 --- a/build.gradle +++ b/build.gradle @@ -85,7 +85,7 @@ def getCurrentGitBranch() { } docker { - name "kingstonduo/eridanus-spring" + getCurrentGitBranch() + name "kingstonduo/eridanus-spring:" + getCurrentGitBranch() copySpec.from(tasks.unpack.outputs).into("dependency") buildArgs(['DEPENDENCY': "dependency"]) } \ No newline at end of file From 9218a54d1d1e4770895df520a8894771cbc67607 Mon Sep 17 00:00:00 2001 From: Nathan Creger Date: Thu, 30 May 2024 10:52:57 -0400 Subject: [PATCH 3/6] update to latest version of alpine --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dc65a60..c4a3212 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.19.1 +FROM alpine:3.20.0 RUN apk update && \ apk upgrade From 82c05a118b5e864aa81a85a64b40044becbf4d1d Mon Sep 17 00:00:00 2001 From: Nathan Creger Date: Thu, 30 May 2024 15:19:56 -0400 Subject: [PATCH 4/6] fix image name --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4b79951..c1d779e 100644 --- a/build.gradle +++ b/build.gradle @@ -85,7 +85,7 @@ def getCurrentGitBranch() { } docker { - name "kingstonduo/eridanus-spring:" + getCurrentGitBranch() + name "kingstonduo/eridanus-data:" + getCurrentGitBranch() copySpec.from(tasks.unpack.outputs).into("dependency") buildArgs(['DEPENDENCY': "dependency"]) } \ No newline at end of file From 93f9fb2ba5e4a016b5726cd626dc7bfd04c5ed83 Mon Sep 17 00:00:00 2001 From: Nathan Creger Date: Tue, 11 Jun 2024 10:09:54 -0400 Subject: [PATCH 5/6] fix build error --- .github/workflows/build-gradle-project.yml | 4 ++-- src/main/resources/application.properties | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-gradle-project.yml b/.github/workflows/build-gradle-project.yml index 37c1667..95e352a 100644 --- a/.github/workflows/build-gradle-project.yml +++ b/.github/workflows/build-gradle-project.yml @@ -21,12 +21,12 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: - java-version: '8' + java-version: '21' distribution: 'temurin' - name: Setup Gradle uses: gradle/gradle-build-action@v2 with: - gradle-version: 7.4 + gradle-version: 8.5 - name: Login to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 9d3c167..3ae6aea 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,4 @@ -libra.data.version=${jar.baseName}-${jar.version} - -server.port=3040 + server.port=3040 spring.main.banner-mode=off spring.data.mongodb.uri=mongodb://mongodb:27017/dataLake From 92403514cc8e905cd29a28eb057d6dc54ea4d1d1 Mon Sep 17 00:00:00 2001 From: Nathan Creger Date: Tue, 11 Jun 2024 11:00:56 -0400 Subject: [PATCH 6/6] fix version number --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c1d779e..ceffd7b 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ plugins { } group = 'kingstonduo' -version = "1.3" +version = "4.1" apply plugin: 'java' apply plugin: 'eclipse'