Skip to content

Commit

Permalink
feat: Update and adapt to GraalVM for JDK 23 (#2069)
Browse files Browse the repository at this point in the history
* build(deps): update dependency com.google.cloud:native-image-shared-config to v1.14.0

* disable testDisconnectShouldNotWaitToReadResponse for JDK >= 23

* fix assumption code

* fix assumption ii

* Revert "fix assumption ii"

This reverts commit 2fbd4cb.

* Revert "fix assumption code"

This reverts commit d355740.

* Revert "disable testDisconnectShouldNotWaitToReadResponse for JDK >= 23"

This reverts commit e2c988e.

* chore: use JUnit4 in tests

this is basically not rely on extending TestCase
and using @test annotations

* use at least 1 Junit38 test

* Revert "use at least 1 Junit38 test"

This reverts commit 84f3f4f.

* fix net http response tests

* annotate tests with @RunWith(JUnit4.class)

* initialize static members in static block

* use static blocks to initialize test classes

* format

* set up class initialization

* convert google-http-client-test to JUnit4

* use java.nio for tests

* run with JUnit 4 explicitly

* use static block

* Revert "use static block"

This reverts commit 73ebee2.

* Reapply "use static block"

This reverts commit 06acc4a.

* initialize IS_WINDOWS at build time

* prevent cryptic message when initializing FileDataStoreFactory

* fix static initialization in AbstractDatastoreFactory

* test no IS_WINDOWS

* Revert "test no IS_WINDOWS"

This reverts commit 3f6483d.

* ruling out logger initialization

* add test output

* safe initialization of ID_PATTERN

* remove provided scope depdendency

* convert appengine transport to JUnit 4

* add clirr differences

* include appengine classes in runtime

this allows native compilation

* add native config

* add reflect-config for appengine

* use JUnit4 in GSON tests

* fix clirr

* port abstract json parser test to JUnit4

* remove unused imports

* update clirr again

* add native config to gson module

* convert jackson module to JUnit4

* make jackson factory instantiation native friendly

* config test-only build-time initialization

* adapt protocol buffers module to JUnit 4

* initialize test classes at test time

* convert xml module to JUnit4

* add test time initialization entries to xml module

* format

* restore debug setup

* add junit test time initialization flags

* add junit to gson deps

* add junit test-scoped dependency to jackson2 module

* add jackson factory to class initialization

this is due to one of the test classes statically initializing
this factory.

* add app engine feature

* try setup time feature registration

* Revert "try setup time feature registration"

This reverts commit eeb9352.

* Revert "add app engine feature"

This reverts commit e75875b.

* add app engine core lib for testing

this allows these classes to be included for native testing

* add test-scoped dep in test module

* use -Pnative-deps

* add conflicting dep in native-deps profile for appengine

* include appengine in graalvm tests

* restore static blocks in google-http-client

* restore static blocks in gson module

* restore static blocks in jackson

* restore static blocks in protobuf

* format

* restore static initailization in xml module

* restore static block in jackson module

* format

* remove app engine from test

---------

Co-authored-by: Mend Renovate <bot@renovateapp.com>
  • Loading branch information
diegomarquezp and renovate-bot authored Feb 6, 2025
1 parent 2285bb1 commit 7a0fab3
Show file tree
Hide file tree
Showing 93 changed files with 1,562 additions and 411 deletions.
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native-a.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ env_vars: {
}

container_properties {
docker_image: "us-docker.pkg.dev/java-graalvm-ci-prod/graalvm-integration-testing/graalvm_a:1.13.0"
docker_image: "us-docker.pkg.dev/java-graalvm-ci-prod/graalvm-integration-testing/graalvm_a:1.14.0"
}
2 changes: 1 addition & 1 deletion .kokoro/presubmit/graalvm-native-b.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ env_vars: {
}

container_properties {
docker_image: "us-docker.pkg.dev/java-graalvm-ci-prod/graalvm-integration-testing/graalvm_b:1.13.0"
docker_image: "us-docker.pkg.dev/java-graalvm-ci-prod/graalvm-integration-testing/graalvm_b:1.14.0"
}
11 changes: 11 additions & 0 deletions google-http-client-appengine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,15 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>native-deps</id>
<dependencies>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"name": "com.google.apphosting.api.DatastorePb$DeleteRequest",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "com.google.apphosting.api.DatastorePb$GetRequest",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "com.google.apphosting.api.DatastorePb$NextRequest",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "com.google.apphosting.api.DatastorePb$PutRequest",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "com.google.apphosting.api.DatastorePb$Query",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
package com.google.api.client.extensions.appengine.http;

import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* Tests {@link UrlFetchTransport}.
*
* @author Tony Aiuto
*/
@RunWith(JUnit4.class)
public class UrlFetchTransportTest extends TestCase {

@Test
public void test() {
new UrlFetchTransport();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Args=--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation \
5 changes: 5 additions & 0 deletions google-http-client-gson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,10 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

package com.google.api.client.json.gson;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

import com.google.api.client.json.GenericJson;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
Expand All @@ -25,6 +29,7 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import org.junit.Test;

/**
* Tests {@link GsonFactory}.
Expand Down Expand Up @@ -58,21 +63,19 @@ public class GsonFactoryTest extends AbstractJsonFactoryTest {
+ GSON_LINE_SEPARATOR
+ "}";

public GsonFactoryTest(String name) {
super(name);
}

@Override
protected JsonFactory newFactory() {
return new GsonFactory();
}

@Test
public final void testToPrettyString_entry() throws Exception {
Entry entry = new Entry();
entry.title = "foo";
assertEquals(JSON_ENTRY_PRETTY, newFactory().toPrettyString(entry));
}

@Test
public final void testToPrettyString_Feed() throws Exception {
Feed feed = new Feed();
Entry entryFoo = new Entry();
Expand All @@ -85,11 +88,13 @@ public final void testToPrettyString_Feed() throws Exception {
assertEquals(JSON_FEED_PRETTY, newFactory().toPrettyString(feed));
}

@Test
public final void testParse_directValue() throws IOException {
JsonParser parser = newFactory().createJsonParser("123");
assertEquals(123, parser.parse(Integer.class, true));
}

@Test
public final void testGetByteValue() throws IOException {
JsonParser parser = newFactory().createJsonParser("123");

Expand All @@ -101,6 +106,7 @@ public final void testGetByteValue() throws IOException {
}
}

@Test
public final void testReaderLeniency_lenient() throws IOException {
JsonObjectParser parser =
new JsonObjectParser(GsonFactory.builder().setReadLeniency(true).build());
Expand All @@ -113,6 +119,7 @@ public final void testReaderLeniency_lenient() throws IOException {
assertEquals("foo", json.get("title"));
}

@Test
public final void testReaderLeniency_not_lenient_by_default() throws IOException {
JsonObjectParser parser = new JsonObjectParser(GsonFactory.getDefaultInstance());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Args=--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation
5 changes: 5 additions & 0 deletions google-http-client-jackson2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@

package com.google.api.client.json.jackson2;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonParser;
import com.google.api.client.test.json.AbstractJsonFactoryTest;
import com.google.api.client.util.StringUtils;
import java.io.IOException;
import java.util.ArrayList;
import org.junit.Test;

/**
* Tests {@link JacksonFactory}.
Expand All @@ -45,21 +50,19 @@ public class JacksonFactoryTest extends AbstractJsonFactoryTest {
+ StringUtils.LINE_SEPARATOR
+ "}";

public JacksonFactoryTest(String name) {
super(name);
}

@Override
protected JsonFactory newFactory() {
return new JacksonFactory();
}

@Test
public final void testToPrettyString_entry() throws Exception {
Entry entry = new Entry();
entry.title = "foo";
assertEquals(JSON_ENTRY_PRETTY, newFactory().toPrettyString(entry));
}

@Test
public final void testToPrettyString_Feed() throws Exception {
Feed feed = new Feed();
Entry entryFoo = new Entry();
Expand All @@ -72,11 +75,13 @@ public final void testToPrettyString_Feed() throws Exception {
assertEquals(JSON_FEED_PRETTY, newFactory().toPrettyString(feed));
}

@Test
public final void testParse_directValue() throws Exception {
JsonParser parser = newFactory().createJsonParser("123");
assertEquals(123, parser.parse(Integer.class, true));
}

@Test
public final void testGetByteValue() throws IOException {
JsonParser parser = newFactory().createJsonParser("123");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Args=--initialize-at-build-time=com.google.api.client.json.jackson2.JacksonFactoryTest \
--initialize-at-build-time=com.google.api.client.json.jackson2.JacksonGeneratorTest \
--initialize-at-build-time=com.fasterxml.jackson.core.io.SerializedString \
--initialize-at-build-time=com.fasterxml.jackson.core.io.CharTypes \
--initialize-at-build-time=com.fasterxml.jackson.core.JsonFactory \
--initialize-at-build-time=com.fasterxml.jackson.core.io.JsonStringEncoder \
--initialize-at-build-time=com.google.api.client.util.StringUtils
--initialize-at-build-time=com.google.api.client.json.jackson2.JacksonFactory \
--initialize-at-build-time=com.google.api.client.util.StringUtils \
--initialize-at-build-time=com.fasterxml.jackson.core \
--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Args=--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@

package com.google.api.client.protobuf;

import static org.junit.Assert.assertEquals;

import java.io.ByteArrayInputStream;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* Tests {@link ProtocolBuffers}.
*
* @author Yaniv Inbar
*/
public class ProtocolBuffersTest extends TestCase {
@RunWith(JUnit4.class)
public class ProtocolBuffersTest {

@Test
public void testParseAndClose() throws Exception {
SimpleProto.TestMessage mockResponse =
SimpleProto.TestMessage.newBuilder()
Expand Down
75 changes: 75 additions & 0 deletions google-http-client-test/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html -->
<!--
[ERROR] 4001: com.google.api.client.test.json.AbstractJsonFactoryTest: Removed junit.framework.Test from the set of implemented interfaces
[ERROR] 5001: com.google.api.client.test.json.AbstractJsonFactoryTest: Removed junit.framework.Assert from the list of superclasses
[ERROR] 5001: com.google.api.client.test.json.AbstractJsonFactoryTest: Removed junit.framework.TestCase from the list of superclasses
[WARNING] 6002: com.google.api.client.test.json.AbstractJsonFactoryTest: Value of field BOOLEAN_TYPE_EMPTY is no longer a compile-time constant
[WARNING] 6002: com.google.api.client.test.json.AbstractJsonFactoryTest: Value of field BOOLEAN_TYPE_EMPTY_OUTPUT is no longer a compile-time constant
[WARNING] 6002: com.google.api.client.test.json.AbstractJsonFactoryTest: Value of field BOOLEAN_TYPE_FALSE is no longer a compile-time constant
[WARNING] 6002: com.google.api.client.test.json.AbstractJsonFactoryTest: Value of field BOOLEAN_TYPE_NULL is no longer a compile-time constant
[WARNING] 6002: com.google.api.client.test.json.AbstractJsonFactoryTest: Value of field BOOLEAN_TYPE_NULL_OUTPUT is no longer a compile-time constant
[WARNING] 6002: com.google.api.client.test.json.AbstractJsonFactoryTest: Value of field BOOLEAN_TYPE_TRUE is no longer a compile-time constant
[WARNING] 6002: com.google.api.client.test.json.AbstractJsonFactoryTest: Value of field BOOLEAN_TYPE_WRONG is no longer a compile-time constant
[ERROR] 7004: com.google.api.client.test.json.AbstractJsonFactoryTest: In method 'public AbstractJsonFactoryTest(java.lang.String)' the number of arguments has changed
[ERROR] 4001: com.google.api.client.test.json.AbstractJsonGeneratorTest: Removed junit.framework.Test from the set of implemented interfaces
[ERROR] 5001: com.google.api.client.test.json.AbstractJsonGeneratorTest: Removed junit.framework.Assert from the list of superclasses
[ERROR] 5001: com.google.api.client.test.json.AbstractJsonGeneratorTest: Removed junit.framework.TestCase from the list of superclasses
[ERROR] 4001: com.google.api.client.test.json.AbstractJsonParserTest: Removed junit.framework.Test from the set of implemented interfaces [ERROR] 5001: com.google.api.client.test.json.AbstractJsonParserTest: Removed junit.framework.Assert from the list of superclasses [ERROR] 5001: com.google.api.client.test.json.AbstractJsonParserTest: Removed junit.framework.TestCase from the list of superclasses
-->
<differences>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>4001</differenceType>
<className>com/google/api/client/test/util/store/AbstractDataStoreFactoryTest</className>
<to>junit/framework/Test</to>
</difference>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>4001</differenceType>
<className>com/google/api/client/test/json/AbstractJsonFactoryTest</className>
<to>junit/framework/Test</to>
</difference>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>4001</differenceType>
<className>com/google/api/client/test/json/AbstractJsonGeneratorTest</className>
<to>junit/framework/Test</to>
</difference>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>4001</differenceType>
<className>com/google/api/client/test/json/AbstractJsonParserTest</className>
<to>junit/framework/Test</to>
</difference>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>5001</differenceType>
<className>com/google/api/client/test/util/store/AbstractDataStoreFactoryTest</className>
<to>junit/framework/*</to>
</difference>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>5001</differenceType>
<className>com/google/api/client/test/json/AbstractJsonFactoryTest</className>
<to>junit/framework/*</to>
</difference>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>5001</differenceType>
<className>com/google/api/client/test/json/AbstractJsonGeneratorTest</className>
<to>junit/framework/*</to>
</difference>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>5001</differenceType>
<className>com/google/api/client/test/json/AbstractJsonParserTest</className>
<to>junit/framework/*</to>
</difference>
<difference>
<!-- migration to JUnit 4 -->
<differenceType>7004</differenceType>
<className>com/google/api/client/test/json/AbstractJsonFactoryTest</className>
<method>*</method>
</difference>
</differences>
Loading

0 comments on commit 7a0fab3

Please sign in to comment.