Skip to content

Commit

Permalink
Merge pull request #1538 from microsoft/fix/java-21-build
Browse files Browse the repository at this point in the history
Fix Java 21 Build issues
  • Loading branch information
baywet authored Aug 22, 2024
2 parents 6b5fde9 + 843db9c commit d8ba2b6
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-level-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@v3.2.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: 'temurin'
cache: gradle
- name: Detect secrets
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: 'temurin'
cache: gradle
cache: gradle
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion components/abstractions/gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dependencies {
// Use JUnit Jupiter API for testing.
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.0'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito:mockito-core:5.12.0'

// Use JUnit Jupiter Engine for testing.
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
Expand Down
2 changes: 1 addition & 1 deletion components/authentication/azure/gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dependencies {
// Use JUnit Jupiter API for testing.
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.0'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito:mockito-core:5.12.0'


// Use JUnit Jupiter Engine for testing.
Expand Down
2 changes: 1 addition & 1 deletion components/bundle/gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies {

// Use JUnit Jupiter Engine for testing.
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito:mockito-core:5.12.0'

implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1'

Expand Down
2 changes: 1 addition & 1 deletion components/http/okHttp/gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies {

// Use JUnit Jupiter Engine for testing.
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito:mockito-core:5.12.0'
testImplementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ void writesSampleObjectValueWithPrimitivesInAdditionalData() throws IOException
.getAdditionalData()
.put("aliases", aliases); // place a collection in the additional data

var jsonSerializer = new JsonSerializationWriter();
jsonSerializer.writeObjectValue("", testEntity);
var contentStream = jsonSerializer.getSerializedContent();
var serializedJsonString = new String(Compatibility.readAllBytes(contentStream), "UTF-8");
// Assert
var expectedString =
"{\"aliases\":[\"alias1\",\"alias2\"],\"nickName\":\"Peter"
+ " Pan\",\"hasDependents\":true,\"accountBalance\":330.7,\"reportsCount\":4,\"averageScore\":78.142}";
assertEquals(expectedString, serializedJsonString);
try (final var jsonSerializer = new JsonSerializationWriter()) {
jsonSerializer.writeObjectValue("", testEntity);
var contentStream = jsonSerializer.getSerializedContent();
var serializedJsonString =
new String(Compatibility.readAllBytes(contentStream), "UTF-8");
// Assert
var expectedString =
"{\"aliases\":[\"alias1\",\"alias2\"],\"nickName\":\"Peter"
+ " Pan\",\"hasDependents\":true,\"accountBalance\":330.7,\"reportsCount\":4,\"averageScore\":78.142}";
assertEquals(expectedString, serializedJsonString);
}
}

@Test
Expand All @@ -79,14 +81,16 @@ void writesSampleObjectValueWithParsableInAdditionalData() throws IOException {
.getAdditionalData()
.put("manager", managerAdditionalData); // place a parsable in the addtionaldata

var jsonSerializer = new JsonSerializationWriter();
jsonSerializer.writeObjectValue("", testEntity);
var contentStream = jsonSerializer.getSerializedContent();
var serializedJsonString = new String(Compatibility.readAllBytes(contentStream), "UTF-8");
// Assert
var expectedString =
"{\"id\":\"test_id\",\"phones\":[\"123456789\"],\"manager\":{\"id\":\"manager_id\",\"myEnum\":\"VALUE1\"}}";
assertEquals(expectedString, serializedJsonString);
try (final var jsonSerializer = new JsonSerializationWriter()) {
jsonSerializer.writeObjectValue("", testEntity);
var contentStream = jsonSerializer.getSerializedContent();
var serializedJsonString =
new String(Compatibility.readAllBytes(contentStream), "UTF-8");
// Assert
var expectedString =
"{\"id\":\"test_id\",\"phones\":[\"123456789\"],\"manager\":{\"id\":\"manager_id\",\"myEnum\":\"VALUE1\"}}";
assertEquals(expectedString, serializedJsonString);
}
}

@Test
Expand Down Expand Up @@ -182,21 +186,23 @@ void writesSampleObjectValueWithUntypedProperties() throws IOException {
}
}));

var jsonSerializer = new JsonSerializationWriter();
jsonSerializer.writeObjectValue("", untypedTestEntity);
var contentStream = jsonSerializer.getSerializedContent();
var serializedJsonString = new String(Compatibility.readAllBytes(contentStream), "UTF-8");

// Assert
var expectedString =
"{\"id\":\"1\","
+ "\"location\":{\"hasReception\":true,\"address\":{\"state\":\"Washington\",\"city\":\"Redmond\",\"street\":\"NE"
+ " 36th St\",\"postalCode\":\"98052\"},\"displayName\":\"Microsoft Building"
+ " 92\",\"floorCount\":50,\"contact\":null,\"coordinates\":{\"latitude\":47.641942,\"longitude\":-122.127222}},"
+ "\"keywords\":["
+ "{\"wssId\":345345345,\"label\":\"Keyword1\",\"termGuid\":\"10e9cc83-b5a4-4c8d-8dab-4ada1252dd70\",\"created\":\"2023-07-26T10:41:26Z\"},"
+ "{\"wssId\":345345345,\"label\":\"Keyword2\",\"termGuid\":\"2cae6c6a-9bb8-4a78-afff-81b88e735fef\",\"created\":\"2023-07-26T10:51:26Z\"}],"
+ "\"extra\":{\"createdDateTime\":\"2024-01-15T00:00:00+00:00\"}}";
assertEquals(expectedString, serializedJsonString);
try (final var jsonSerializer = new JsonSerializationWriter()) {
jsonSerializer.writeObjectValue("", untypedTestEntity);
var contentStream = jsonSerializer.getSerializedContent();
var serializedJsonString =
new String(Compatibility.readAllBytes(contentStream), "UTF-8");

// Assert
var expectedString =
"{\"id\":\"1\","
+ "\"location\":{\"hasReception\":true,\"coordinates\":{\"latitude\":47.641942,\"longitude\":-122.127222},"
+ "\"address\":{\"state\":\"Washington\",\"city\":\"Redmond\",\"street\":\"NE"
+ " 36th St\",\"postalCode\":\"98052\"},\"displayName\":\"Microsoft"
+ " Building 92\",\"floorCount\":50,\"contact\":null},\"keywords\":["
+ "{\"wssId\":345345345,\"label\":\"Keyword1\",\"termGuid\":\"10e9cc83-b5a4-4c8d-8dab-4ada1252dd70\",\"created\":\"2023-07-26T10:41:26Z\"},"
+ "{\"wssId\":345345345,\"label\":\"Keyword2\",\"termGuid\":\"2cae6c6a-9bb8-4a78-afff-81b88e735fef\",\"created\":\"2023-07-26T10:51:26Z\"}],"
+ "\"extra\":{\"createdDateTime\":\"2024-01-15T00:00:00+00:00\"}}";
assertEquals(expectedString, serializedJsonString);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies {
// Use JUnit Jupiter API for testing.
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito:mockito-core:5.12.0'

// Use JUnit Jupiter Engine for testing.
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
Expand Down

0 comments on commit d8ba2b6

Please sign in to comment.