Skip to content

Upgrades to java17 #4

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

Open
wants to merge 2 commits into
base: main
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
Binary file added .gradle/8.8/checksums/checksums.lock
Binary file not shown.
Empty file.
Binary file added .gradle/8.8/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/8.8/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added .gradle/8.8/fileHashes/fileHashes.lock
Binary file not shown.
Empty file added .gradle/8.8/gc.properties
Empty file.
Binary file added .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Wed Feb 26 12:57:42 IST 2025
gradle.version=8.8
Empty file added .gradle/vcs-1/gc.properties
Empty file.
41 changes: 19 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?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>org.springframework</groupId>
Expand All @@ -10,14 +9,19 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<version>3.3.9</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.14.27</version>
<version>2.28.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -38,7 +42,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
<version>20240303</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -49,38 +53,33 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.13.3</version>
<version>2.24.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
<version>2.24.3</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>

</dependencies>

<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<build>
Expand All @@ -92,10 +91,8 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import software.amazon.awssdk.services.appconfig.model.GetConfigurationResponse;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.validation.Valid;
import jakarta.validation.Valid;

import static org.springframework.web.bind.annotation.RequestMethod.POST;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// depreciation example - sun.misc.BASE64Encoder;
package com.amazonaws.samples.appconfig.utils;
import sun.misc.BASE64Encoder;

import java.util.Date;
import java.util.Base64;
import java.util.Calendar;
import java.util.GregorianCalendar;


public class Encoder {

Date defaultDate = new Date(1999, 0, 1);
Calendar defaultDate = new GregorianCalendar(1999, Calendar.JANUARY, 1);

byte[] bytes = new byte[57];
String enc1 = new sun.misc.BASE64Encoder().encode(bytes);
String enc1 = Base64.getEncoder().encodeToString(bytes);


}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ public String getMoviesHtml(Movie[] movies) {
private static String getMovieItemsHtml(Movie[] movies) {
StringBuilder movieItemsHtml = new StringBuilder();
for (Movie movie : movies) {
movieItemsHtml.append("<div class='movie-item'>"
+ "<p>ID: ").append(movie.getId()).append("</p>"
+ "<h3>").append(movie.getMovieName()).append("</h3>"
+ "<hr width=\"100%\" size=\"2\" color=\"blue\" noshade>"
+ "</div>");
movieItemsHtml.append("""
<div class='movie-item'>\
<p>ID: \
""").append(movie.getId()).append("""
</p>\
<h3>\
""").append(movie.getMovieName()).append("""
</h3>\
<hr width="100%" size="2" color="blue" noshade>\
</div>\
""");
}
return movieItemsHtml.toString();
}
Expand Down
29 changes: 15 additions & 14 deletions src/main/java/com/amazonaws/samples/appconfig/utils/Math.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
//example from https://docs.openrewrite.org/running-recipes/popular-recipe-guides/migrate-to-java-17
package com.amazonaws.samples.appconfig.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Math {
Boolean bool = new Boolean(true);
Byte b = new Byte("1");
Character c = new Character('c');
Double d = new Double(1.0);
Float f = new Float(1.1f);
Long l = new Long(1);
Short sh = new Short("12");
Boolean bool = Boolean.valueOf(true);
Byte b = Byte.valueOf("1");
Character c = Character.valueOf('c');
Double d = Double.valueOf(1.0);
Float f = Float.valueOf(1.1f);
Long l = Long.valueOf(1);
Short sh = Short.valueOf("12");
short s3 = 3;
Short sh3 = new Short(s3);
Integer i = new Integer(1);
Short sh3 = Short.valueOf(s3);
Integer i = Integer.valueOf(1);

public void divide() {
BigDecimal bd = BigDecimal.valueOf(10);
BigDecimal bd2 = BigDecimal.valueOf(2);
bd.divide(bd2, BigDecimal.ROUND_DOWN);
bd.divide(bd2, 1);
bd.divide(bd2, 1, BigDecimal.ROUND_CEILING);
bd.divide(bd2, 1, 1);
bd.setScale(2, 1);
bd.divide(bd2, RoundingMode.DOWN);
bd.divide(bd2, RoundingMode.DOWN);
bd.divide(bd2, 1, RoundingMode.CEILING);
bd.divide(bd2, 1, RoundingMode.DOWN);
bd.setScale(2, RoundingMode.DOWN);
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
//javax.security.cert to java.security.cert classes migration
package com.amazonaws.samples.appconfig.utils;

import javax.security.cert.*;
import java.security.cert.*;
import java.security.cert.CertificateFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;

public class Security {
public Certificate getCertificate(File certFile) throws CertificateExpiredException, CertificateNotYetValidException {
X509Certificate cert = null;
try {
InputStream inStream = new FileInputStream(certFile);
cert = X509Certificate.getInstance(inStream);
} catch (CertificateException e) {
throw new RuntimeException(e);
} catch (FileNotFoundException e) {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
try (InputStream inStream = new FileInputStream(certFile)) {
cert = (X509Certificate) cf.generateCertificate(inStream);
}
} catch (CertificateException | IOException e) {
throw new RuntimeException(e);
}
cert.checkValidity(new Date());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.amazonaws.samples.appconfig.movies;

import org.junit.Test;

import java.math.BigDecimal;
import com.amazonaws.samples.appconfig.utils.Math;
import java.math.RoundingMode;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.amazonaws.samples.appconfig.utils.Math;

public class MathTest {

Expand All @@ -18,21 +18,21 @@ public void testDivide() {
BigDecimal bd = BigDecimal.valueOf(10);
BigDecimal bd2 = BigDecimal.valueOf(2);
BigDecimal expectedResult1 = BigDecimal.valueOf(5);
assertEquals(expectedResult1, bd.divide(bd2, BigDecimal.ROUND_DOWN));
assertEquals(expectedResult1, bd.divide(bd2, RoundingMode.DOWN));

// Test divide(BigDecimal, int)
BigDecimal expectedResult2 = BigDecimal.valueOf(5.0);

// Test divide(BigDecimal, int, int)
BigDecimal expectedResult3 = BigDecimal.valueOf(5.0);
assertEquals(expectedResult3, bd.divide(bd2, 1, BigDecimal.ROUND_CEILING));
assertEquals(expectedResult3, bd.divide(bd2, 1, RoundingMode.CEILING));

BigDecimal expectedResult4 = BigDecimal.valueOf(5.0);
assertEquals(expectedResult4, bd.divide(bd2, 1, 1));
assertEquals(expectedResult4, bd.divide(bd2, 1, RoundingMode.DOWN));

// Test setScale(int, int)
BigDecimal expectedResult5 = BigDecimal.valueOf(10);
bd.setScale(2, 1);
bd.setScale(2, RoundingMode.DOWN);
assertEquals(expectedResult5, bd);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.amazonaws.samples.appconfig.movies;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.anyInt;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.amazonaws.samples.appconfig.movies;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.amazonaws.samples.appconfig.movies.MoviesController;

@RunWith(SpringRunner.class)
@SpringBootTest
public class MovieTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.amazonaws.samples.appconfig.utils.AppConfigUtility;
import com.amazonaws.samples.appconfig.cache.ConfigurationCache;
import com.amazonaws.samples.appconfig.model.ConfigurationKey;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.core.env.Environment;
Expand All @@ -14,9 +14,10 @@
import java.time.Duration;
import java.util.UUID;


import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class MoviesControllerTest {

Expand All @@ -31,7 +32,7 @@ public class MoviesControllerTest {

private MoviesController moviesController;

@Before
@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
moviesController = new MoviesController();
Expand All @@ -51,7 +52,7 @@ public void testMovieWithFeatureEnabled() {
GetConfigurationResponse getConfigurationResponse = GetConfigurationResponse.builder().build();

AppConfigUtility appConfigUtility = mock(AppConfigUtility.class);
when(appConfigUtility.getConfiguration(any(ConfigurationKey.class))).thenReturn(getConfigurationResponse);
when(appConfigUtility.getConfiguration(nullable(ConfigurationKey.class))).thenReturn(getConfigurationResponse);

moviesController.cacheItemTtl = Duration.ofSeconds(60);
moviesController.client = appConfigClient;
Expand Down
33 changes: 33 additions & 0 deletions summary/buildCommandOutput.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< org.springframework:movie-service >------------------
[INFO] Building movie-service 0.1.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.3.2:clean (default-clean) @ movie-service ---
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ movie-service ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ movie-service ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 11 source files with javac [debug deprecation parameters release 17] to target/classes
[WARNING] /ramdisk/code/src/main/java/com/amazonaws/samples/appconfig/utils/AppConfigUtility.java:[92,59] getConfiguration(software.amazon.awssdk.services.appconfig.model.GetConfigurationRequest) in software.amazon.awssdk.services.appconfig.AppConfigClient has been deprecated
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ movie-service ---
[INFO] skip non existing resourceDirectory /ramdisk/code/src/test/resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ movie-service ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 4 source files with javac [debug deprecation parameters release 17] to target/test-classes
[WARNING] /ramdisk/code/src/test/java/com/amazonaws/samples/appconfig/movies/MoviesControllerTest.java:[37,27] initMocks(java.lang.Object) in org.mockito.MockitoAnnotations has been deprecated
[INFO] /ramdisk/code/src/test/java/com/amazonaws/samples/appconfig/movies/MockTest.java: /ramdisk/code/src/test/java/com/amazonaws/samples/appconfig/movies/MockTest.java uses unchecked or unsafe operations.
[INFO] /ramdisk/code/src/test/java/com/amazonaws/samples/appconfig/movies/MockTest.java: Recompile with -Xlint:unchecked for details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.084 s
[INFO] Finished at: 2025-02-26T07:42:00Z
[INFO] ------------------------------------------------------------------------
5 changes: 5 additions & 0 deletions summary/qct-icons/transform-build-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions summary/qct-icons/transform-clock-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading