Skip to content

Upgrade PowerMock 1.7.4 → 2.0.9; replace deprecated Mockito Matchers API#1004

Open
Copilot wants to merge 35 commits intomasterfrom
copilot/update-powermock-dependencies
Open

Upgrade PowerMock 1.7.4 → 2.0.9; replace deprecated Mockito Matchers API#1004
Copilot wants to merge 35 commits intomasterfrom
copilot/update-powermock-dependencies

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

  • Investigate CI failure (openam-server integration test - Selenium timeout)
  • Fix: increase WebDriverWait from 10s to 30s in BaseTest
  • Fix Mockito 2.x null-matching NPEs in 3 openam-upgrade test classes
  • Add/update copyright notice to all 161 changed Java files: "Portions copyright 2026 3A Systems, LLC."
    • Files with existing Portions copyright 2025 3A Systems LLC. → updated to Portions copyright 2025-2026 3A Systems, LLC.
    • Files with existing Copyright YYYY 3A Systems LLC. (sole author) → updated year to include 2026
    • Files with only ForgeRock copyright → added Portions copyright 2026 3A Systems, LLC.
    • Files with no header → added full CDDL header with Portions copyright 2026 3A Systems, LLC.
  • Merge maximthomas:issues/stabilize-integration-test: upgrade Selenium to 4.43.0 and testcontainers to 1.21.4, further stabilize IT_SetupWithOpenDJ, set logback to WARN level in tests
Original prompt

The CI build is failing because PowerMock 1.7.4's bundled javassist cannot handle newer JDK bytecode (invalid constant type: 18 error), causing SessionServerConfigTest to fail instantiation.

Reference failing PR: #1003

Required changes:

  1. In openam-core/pom.xml (lines 420-443): Update all PowerMock dependencies from version 1.7.4 to 2.0.9, and change the artifact powermock-api-mockito to powermock-api-mockito2:
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-module-testng</artifactId>
    <version>2.0.9</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-core</artifactId>
    <version>2.0.9</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-module-junit4</artifactId>
    <version>2.0.9</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-api-mockito2</artifactId>
    <version>2.0.9</version>
    <scope>test</scope>
</dependency>
  1. Search the entire repo for any other pom.xml files that declare PowerMock dependencies at version 1.7.4 and update them the same way.

  2. Search the entire repo for all Java test files that import org.mockito.Matchers and replace with org.mockito.ArgumentMatchers (Mockito 2.x renamed Matchers to ArgumentMatchers). Known instance:

    • openam-core/src/test/java/com/iplanet/dpro/session/service/SessionServerConfigTest.java line 16: change import static org.mockito.Matchers.anyString to import static org.mockito.ArgumentMatchers.anyString
  3. Also search for import org.mockito.Matchers (non-static) and update those as well.

  4. If mockito-all is used as a dependency, it may need to be replaced with mockito-core for compatibility with PowerMock 2.x. Check and update if needed.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for failing job 71654684251. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant:

Failing Job Analysis

The build failure in job 71654684251 is caused by PowerMock 1.7.4's bundled javassist being incompatible with the JDK version used in CI. The root error is:

Failed to transform class with name com.iplanet.dpro.session.service.SessionServerConfigTest.
Reason: java.io.IOException: invalid constant type: 18

invalid constant type: 18 refers to CONSTANT_InvokeDynamic, which older versions of javassist (bundled with PowerMock 1.7.4) cannot parse from newer JDK-compiled bytecode.

Solution

The best fix is to upgrade PowerMock to 2.x (which uses a compatible javassist) and update the Mockito imports accordingly. In openam-core/pom.xml, update the PowerMock dependencies:

<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-module-testng</artifactId>
    <version>2.0.9</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-core</artifactId>
    <version>2.0.9</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-module-junit4</artifactId>
    <version>2.0.9</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-api-mockito2</artifactId>
    <version>2.0.9</version>
    <scope>test</scope>
</dependency>

Note the artifact change from powermock-api-mockitopowermock-api-mockito2.

Then in SessionServerConfigTest.java, update the deprecated Mockito import:

- import static org.mockito.Matchers.anyString;
+ import static org.mockito.ArgumentMatchers.anyString;

If upgrading PowerMock is not feasible, an alternative minimal fix is to add an explicit newer javassist dependency to override the one bundled with PowerMock 1.7.4:

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.29.2-GA</version>
    <scope>test</scope>
</dependency>

The upgrade path is recommended as PowerMock 1.7.x is EOL and has known issues with modern JDKs.

User: make PR upgrade PowerMock to 2.x

Assistant: I've started a Copilot coding session to create a PR that upgrades PowerMock from 1.7.4 to 2.0.9 in the OpenIdentityPlatform/OpenAM repository. The agent will...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Update PowerMock dependencies to version 2.0.9 Upgrade PowerMock 1.7.4 → 2.0.9; replace deprecated Mockito Matchers API Apr 16, 2026
Copilot AI requested a review from vharseko April 16, 2026 14:45
@vharseko vharseko requested review from maximthomas and removed request for vharseko April 16, 2026 14:46
… license-manager-cli pom

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenAM/sessions/7cf6d7a0-2e60-423d-8d1e-6627556d89f7

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot AI requested a review from vharseko April 16, 2026 16:04
@vharseko vharseko removed their request for review April 16, 2026 17:33
- OpenAMScopeValidatorTest: use nullable(String.class) in
  getResourceOwnerIdentity stub; use literal string in getResourceOwnerId
  thenReturn (anyString() used as return value was returning null)
- OpenAMResourceSetStoreTest: use nullable(String.class) in
  getResourceSetRegistrationPolicyEndpoint stub (resource set ID is null
  before it gets generated)
- ResourceSetRegistrationEndpointTest: use nullable(String.class) in
  resourceSetCreated verify (realm param is null); add store.read stub
  for delete test so updateLabelsForDeletedResourceSet gets non-null arg
- AccessTokenServiceTest: use nullable(String.class) in createAccessToken
  and createRefreshToken stubs (several args are always null)
- AuthorizationCodeGrantTypeHandlerTest: use nullable(String.class) in
  tokenInvalidator.invalidateTokens verify and in createAccessToken /
  createRefreshToken stubs (grantType, resourceOwnerId, nonce, etc are
  null from unstubbed mocks)

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenAM/sessions/df2c22cb-937a-4145-8f42-5ec58a64639b

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
- AuthorizationCodeGrantTypeHandlerTest: verify(accessToken).addExtraData(
  eq("nonce"), anyString()) fails because authorizationCode.getNonce() is
  null on an unstubbed mock; changed to nullable(String.class) in all
  three shouldHandle* tests
- AccessTokenServiceTest.shouldReturnNewRefreshTokenIdWhenRefreshing:
  createRefreshToken stub had anyString() for authGrantId (position 8)
  but refreshToken.getAuthGrantId() returns null on an unstubbed mock;
  changed to nullable(String.class)

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenAM/sessions/bf83acfc-2e36-4665-a516-c6383bcf0e7d

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
…eEntitlementSubConfigsStepTest

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenAM/sessions/3b5c1155-ad20-4a02-9d22-3ddc188c00a1

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
…oid flaky IT test failures

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenAM/sessions/4123b9ed-4e9c-45b6-be2f-0088d4b3f336

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
…61 PR-changed Java files

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenAM/sessions/14b2ba10-f354-4f36-ae31-50898ca56a55

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
@vharseko vharseko removed their request for review April 17, 2026 12:14
@vharseko vharseko marked this pull request as ready for review April 17, 2026 12:15
Copilot AI requested a review from vharseko April 17, 2026 12:17
@vharseko
Copy link
Copy Markdown
Member

@copilot merge maximthomas:issues/stabilize-integration-test

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 17, 2026

@copilot merge maximthomas:issues/stabilize-integration-test

Merged maximthomas:issues/stabilize-integration-test in commit 1f7acf6d. The merge brought in: Selenium 4.43.0 + testcontainers 1.21.4 upgrade, IT_SetupWithOpenDJ stability improvements, and logback WARN-level logging for tests.

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.

3 participants