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

Fix collection tests for latest guava-testlib update #2786

Conversation

Marcono1234
Copy link
Collaborator

Purpose

Fixes build failure for #2784

Important: Targets the dependabot/... branch instead of main.

Description

With the fix in the latest guava-testlib version (see google/guava#7401) null support is now properly checked. But it expects that if a collection does not permit null, then creating it with null should fail as well, see guava-testlib's:

  • MapCreationTester.testCreateWithNullValueUnsupported()
  • CollectionCreationTester.testCreateWithNull_unsupported()

However, the previous implementation for the JsonArray and JsonObject test was using methods which implicitly converted null to JsonNull.

Checklist

  • New code follows the Google Java Style Guide
    This is automatically checked by mvn verify, but can also be checked on its own using mvn spotless:check.
    Style violations can be fixed using mvn spotless:apply; this can be done in a separate commit to verify that it did not cause undesired changes.
  • If necessary, new public API validates arguments, for example rejects null
  • New public API has Javadoc
    • Javadoc uses @since $next-version$
      ($next-version$ is a special placeholder which is automatically replaced during release)
  • If necessary, new unit tests have been added
    • Assertions in unit tests use Truth, see existing tests
    • No JUnit 3 features are used (such as extending class TestCase)
    • If this pull request fixes a bug, a new test was added for a situation which failed previously and is now fixed
  • mvn clean verify javadoc:jar passes without errors

With the fix in the latest guava-testlib version null support is now properly
checked. But it expects that if a collection does not permit null, then
creating it with null should fail as well, see guava-testlib's:
- MapCreationTester.testCreateWithNullValueUnsupported()
- CollectionCreationTester.testCreateWithNull_unsupported()

However, the previous implementation for the JsonArray and JsonObject test
was using methods which implicitly converted null to JsonNull.
Comment on lines -77 to +78
TestSuite testSuite = new TestSuite("LinkedTreeMap");
// Use qualified class name to make it easier to find this test class in the IDE
TestSuite testSuite = new TestSuite(LinkedTreeMapSuiteTest.class.getName());
Copy link
Collaborator Author

@Marcono1234 Marcono1234 Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Eclipse this makes a difference: Otherwise it just shows the test suite name in the UI, and assertion stack traces are just Guava code, so there is no way to easily get to this test class.

Maven and IntelliJ automatically include the LinkedTreeMapSuiteTest class name in the console output / UI.

The other test suite classes here are affected as well, but changing their name (e.g. "JsonObject#asMap") to the qualified class name would make the names derived for nested tests by Guava quite verbose. Could alternatively wrap the test suites in an additional TestSuite with the class as name (similar to here), but not sure if worth it.

See also google/guava#7585

@eamonnmcmanus
Copy link
Member

Thanks!

@eamonnmcmanus eamonnmcmanus merged commit 3bb7685 into google:dependabot/maven/maven-5039655e73 Jan 2, 2025
9 checks passed
eamonnmcmanus pushed a commit that referenced this pull request Jan 2, 2025
* Bump the maven group with 8 updates

Bumps the maven group with 8 updates:

| Package | From | To |
| --- | --- | --- |
| [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) | `3.11.1` | `3.11.2` |
| [com.google.guava:guava-testlib](https://github.com/google/guava) | `33.3.1-jre` | `33.4.0-jre` |
| [com.google.guava:guava](https://github.com/google/guava) | `33.3.1-jre` | `33.4.0-jre` |
| [com.guardsquare:proguard-base](https://github.com/Guardsquare/proguard) | `7.6.0` | `7.6.1` |
| [com.guardsquare:proguard-core](https://github.com/Guardsquare/proguard-core) | `9.1.6` | `9.1.7` |
| [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) | `5.11.3` | `5.11.4` |
| [org.graalvm.buildtools:native-maven-plugin](https://github.com/graalvm/native-build-tools) | `0.10.3` | `0.10.4` |
| [com.google.protobuf:protobuf-java](https://github.com/protocolbuffers/protobuf) | `4.29.0` | `4.29.2` |


Updates `org.apache.maven.plugins:maven-javadoc-plugin` from 3.11.1 to 3.11.2
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](apache/maven-javadoc-plugin@maven-javadoc-plugin-3.11.1...maven-javadoc-plugin-3.11.2)

Updates `com.google.guava:guava-testlib` from 33.3.1-jre to 33.4.0-jre
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)

Updates `com.google.guava:guava` from 33.3.1-jre to 33.4.0-jre
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)

Updates `com.guardsquare:proguard-base` from 7.6.0 to 7.6.1
- [Release notes](https://github.com/Guardsquare/proguard/releases)
- [Commits](Guardsquare/proguard@v7.6...v7.6.1)

Updates `com.guardsquare:proguard-core` from 9.1.6 to 9.1.7
- [Release notes](https://github.com/Guardsquare/proguard-core/releases)
- [Commits](Guardsquare/proguard-core@v9.1.6...v9.1.7)

Updates `org.junit.jupiter:junit-jupiter` from 5.11.3 to 5.11.4
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](junit-team/junit5@r5.11.3...r5.11.4)

Updates `org.graalvm.buildtools:native-maven-plugin` from 0.10.3 to 0.10.4
- [Release notes](https://github.com/graalvm/native-build-tools/releases)
- [Commits](graalvm/native-build-tools@0.10.3...0.10.4)

Updates `com.google.protobuf:protobuf-java` from 4.29.0 to 4.29.2
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/protobuf_release.bzl)
- [Commits](https://github.com/protocolbuffers/protobuf/commits)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: maven
- dependency-name: com.google.guava:guava-testlib
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: maven
- dependency-name: com.google.guava:guava
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: maven
- dependency-name: com.guardsquare:proguard-base
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: maven
- dependency-name: com.guardsquare:proguard-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: maven
- dependency-name: org.junit.jupiter:junit-jupiter
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: maven
- dependency-name: org.graalvm.buildtools:native-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: maven
- dependency-name: com.google.protobuf:protobuf-java
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: maven
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fix collection tests for latest guava-testlib update (#2786)

With the fix in the latest guava-testlib version null support is now properly
checked. But it expects that if a collection does not permit null, then
creating it with null should fail as well, see guava-testlib's:
- MapCreationTester.testCreateWithNullValueUnsupported()
- CollectionCreationTester.testCreateWithNull_unsupported()

However, the previous implementation for the JsonArray and JsonObject test
was using methods which implicitly converted null to JsonNull.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcono1234 <[email protected]>
@Marcono1234 Marcono1234 deleted the maven-dependencies-fix branch January 2, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants