Skip to content

Conversation

@arunans23
Copy link
Member

@arunans23 arunans23 commented Nov 21, 2025

Related to wso2/product-micro-integrator#4494

As part of the effort, the following changes have been made.

  • Migrated Unit tests from PowerMockito to Mockito
  • NashornJS related implementation are removed.
  • ScriptMediator tests related Ruby language have been commented.
  • Since jaxb-api dependency is outdated, jakarta.xml.bind-api dependency is used instead.
  • Jacoco agent dependency was updated from 0.8.6 to 0.8.12.
  • Maven war plugin version was increased from 2.6 to 3.5.0
  • Glassfish jersey dependency used in unit test was updated from 2.35 to 2.41.
  • Due Mockito limitations, two test case files (RequestResponseTest.java & NHttpTransportListenerTest.java) have been removed.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for endorsed JAR handling in startup scripts for Java 9+ compatibility.
    • Enhanced JNDI datasource resolution with automatic dereferencing support.
  • Bug Fixes

    • Migrated JavaScript engine from Nashorn to GraalVM for improved compatibility.
    • Updated code to support Java 21 and later versions.
  • Chores

    • Upgraded Java compiler target to version 21.
    • Migrated JAXB API from javax.xml.bind to jakarta.xml.bind.
    • Updated testing framework from PowerMock to Mockito.

✏️ Tip: You can customize this high-level summary in your review settings.

As part of the effort, the following changes have been done.
- Migrated Unit tests from PowerMockito to Mockito
- Due Mockito limitations, some two testcase files (RequestResponseTest.java & NHttpTransportListenerTest.java) have been removed.
- NashornJS related implementation are removed.
- ScriptMediator tests related Ruby language have been commented.
- Since jaxb-api dependency is outdated, jakarta.xml.bind-api dependency is used instead.
- Jacoco agent dependency was updated from 0.8.6 to 0.8.12.
- Maven war plugin version was increased from 2.6 to 3.5.0
- Glassfish jersey dependency used in unit test was updated from 2.35 to 2.41.
@arunans23 arunans23 requested a review from chanikag as a code owner November 21, 2025 10:50
@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2025

Walkthrough

This pull request modernizes the Apache Synapse codebase by migrating from javax.xml.bind (JAXB) to jakarta.xml.bind, replacing PowerMock test framework with Mockito, upgrading Java target to version 21, removing Nashorn JavaScript support in favor of GraalVM, updating build tooling versions, and adapting shell scripts for Java 9+ endorsed directory handling.

Changes

Cohort / File(s) Summary
JAXB API Migration (javax → jakarta)
modules/commons/pom.xml, modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/*, modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/*, modules/integration/pom.xml
Updated JAXB dependencies from javax.xml.bind to jakarta.xml.bind across POM files and Java source/test files. Changed imports from javax.xml.bind.* to jakarta.xml.bind.* in JAXB-related classes and test files. Added test-scoped JAXB runtime dependencies (jaxb-api, jaxb-runtime, javax.activation-api).
PowerMock to Mockito Migration
modules/core/pom.xml, modules/core/src/test/java/org/apache/synapse/*/...*Test.java, modules/tasks/pom.xml, modules/transports/*/pom.xml, modules/transports/*/src/test/java/org/apache/synapse/transport/*/...Test.java
Removed powermock-* dependencies and replaced with Mockito equivalents (mockito-core, mockito-inline). Converted test classes from PowerMockRunner to MockitoJUnitRunner, replaced PowerMockito.mock/when/mockStatic with Mockito equivalents, and introduced MockedStatic try-with-resources blocks for static method mocking.
JaCoCo Configuration Cleanup
modules/commons/pom.xml, modules/core/pom.xml, modules/extensions/pom.xml, modules/coverage-report/pom.xml
Removed jacoco-maven-plugin execution blocks from module POMs. Updated coverage-report fileset targets from coverage-reports directory pattern to target/jacoco.exec simplified paths.
Root POM & Core Build Config
pom.xml
Upgraded Maven compiler plugin from Java 1.8 to Java 21. Updated plugin versions: maven-jacoco-plugin (0.8.6 → 0.8.12), maven-war-plugin (2.6 → 3.5.0). Updated dependency versions: mockito (3.0.0 → 5.3.1), glassfish.jersey (2.35 → 2.41), jaxb (2.3.0 → 4.0.6). Added jakarta.xml.bind.version property (4.0.4).
Java 9+ Endorsed Directories
modules/distribution/src/main/bin/ciphertool.sh, modules/distribution/src/main/bin/synapse-config-migrator.sh, modules/distribution/src/main/bin/synapse.sh, modules/samples/src/main/scripts/axis2Server/axis2server.sh
Replaced deprecated -Djava.endorsed.dirs JVM parameter with dynamic classpath inclusion of endorsed JARs from SYNAPSE_HOME/lib/endorsed (or AXIS2_HOME equivalent).
Nashorn to GraalVM Migration
modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ScriptMediator.java, modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/NashornJavaScriptMessageContext.java, modules/extensions/src/test/java/org/apache/synapse/mediators/bsf/ScriptMediatorSerializationTest.java
Removed NashornJavaScriptMessageContext class entirely. Updated ScriptMediator to remove Nashorn-specific branches and unify JavaScript handling via GraalVM-based contexts. Added runtime skip guard in serialization test for Ruby engine availability.
FIX Transport Changes
modules/transports/optional/fix/src/main/java/org/apache/synapse/transport/fix/FIXTransportSender.java, modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportSenderTest.java
Changed visibility of sendUsingEPR method from private to protected. Updated corresponding test to use Mockito spy for method invocation instead of PowerMock reflection.
JNDI DataSource Resolution
modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceFinder.java
Enhanced find() method to support JNDI Reference dereferencing via NamingManager.getObjectInstance. Added general exception handling with broader catch clause for Exception wrapping into RuntimeException.
Test Infrastructure Updates
modules/core/src/test/java/org/apache/synapse/endpoints/resolvers/ResolverFactoryTest.java, modules/integration/src/test/java/org/apache/synapse/samples/framework/TestSamplesHandlerSuite.java, modules/transports/core/nhttp/src/test/resources/log4j.properties
Converted ResolverFactoryTest from JUnit 3 (TestCase) to JUnit 4 style. Commented out sample entries 353 and 354 in mediation samples. Added log4j.properties for test console logging.
Test File Removals
modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/nhttp/NHttpTransportListenerTest.java, modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/RequestResponseTest.java
Removed integration-style test classes for NHTTP listener and request/response flows.

Sequence Diagram(s)

sequenceDiagram
    participant Code as Application Code
    participant DS as DataSourceFinder
    participant JNDICtx as JNDI Context
    participant NM as NamingManager
    participant Ref as javax.naming.Reference
    
    Code->>DS: find(dsName, context)
    DS->>JNDICtx: lookup(dsName)
    JNDICtx-->>DS: Object (may be Reference)
    
    alt Object is null
        DS-->>Code: null return
    else Object is non-null
        DS->>NM: getObjectInstance(object, context)
        NM->>Ref: dereference if Reference
        Ref-->>NM: dereferenced object
        NM-->>DS: actual DataSource or object
        
        alt Dereferenced object is DataSource
            DS-->>Code: return DataSource
        else Not a DataSource
            DS->>DS: throw SynapseCommonsException
            DS-->>Code: exception
        end
    end
Loading
sequenceDiagram
    participant Test as Test Code
    participant MockStatic as MockedStatic
    participant SM as ScriptMediator
    participant SE as ScriptEngine
    
    rect rgba(200, 220, 255, 0.5)
    Note over Test,SE: PowerMock Approach (Old)
    Test->>Test: `@RunWith`(PowerMockRunner)
    Test->>Test: `@PrepareForTest`({...})
    Test->>Test: PowerMockito.mockStatic(TargetClass)
    end
    
    rect rgba(200, 255, 220, 0.5)
    Note over Test,SE: Mockito Approach (New)
    Test->>MockStatic: mockStatic(TargetClass)
    MockStatic-->>Test: MockedStatic instance
    Test->>Test: try-with-resources(MockedStatic)
    Test->>SM: execute method under test
    SM->>SE: use mocked static
    SE-->>SM: stubbed response
    SM-->>Test: result
    Test->>Test: exit try-with-resources
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Areas requiring extra attention:

  • DataSourceFinder JNDI dereferencing logic (modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceFinder.java) — New exception handling and NamingManager integration require verification of null-safety and error propagation.
  • ScriptMediator Nashorn removal (modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ScriptMediator.java) — Significant control-flow changes unifying JavaScript handling via GraalVM; verify backward compatibility and JSON processing paths.
  • Comprehensive PowerMock→Mockito migrations — Multiple test files with similar patterns but varying context; verify that static mocking scopes (try-with-resources) are correctly applied and test assertions remain equivalent.
  • Build configuration across modules — Version upgrades (Java 21, Mockito 5.3.1, JaCoCo 0.8.12) require verification that all modules compile and run correctly with new tool versions.
  • Endorsed directory handling in shell scripts — Verify that classpath construction correctly includes endorsed JARs and behaves identically on Java 9+ systems.

Poem

🐰 From javax to jakarta, we leap with grace,
PowerMock steps aside; Mockito takes its place,
Java 21 awaits, while Nashorn fades to green,
GraalVM scripts dance in our Synapse machine,
Endorsed paths renewed for modern Java's way,
A cleaner, swifter codebase greets the day!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The pull request description provides context about the issue, lists specific changes made, and references the related GitHub issue. However, it does not follow the repository's template structure with sections like Purpose, Goals, Approach, etc. Consider aligning the description with the repository template by adding structured sections such as Purpose, Goals, Approach, and other relevant sections defined in the template to improve clarity and consistency.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Introduce JDK 21 compilation support' accurately reflects the main objective of the pull request, which is to upgrade the project to support Java 21 compilation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
modules/tasks/src/test/java/org/apache/synapse/task/service/TaskSchedulerTest.java (1)

38-87: PowerMock migration verified; update deprecated Assert import.

PowerMock removal is correct—the file contains no PowerMock imports or annotations. All mocking uses standard Mockito for instance methods (isInitialized(), getRunningTaskCount(), schedule()), which Mockito handles natively.

However, line 20 imports deprecated junit.framework.Assert. Update to org.junit.Assert for consistency with JUnit 4 test framework.

modules/distribution/src/main/bin/ciphertool.sh (1)

105-105: Remove dead code: unused JAVA_ENDORSED_DIRS Cygwin conversion.

The conversion of JAVA_ENDORSED_DIRS on line 105 is no longer needed since endorsed directories are now handled via classpath augmentation (lines 92–98) rather than the JVM option.

  CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
fi
modules/transports/core/nhttp/pom.xml (1)

244-257: Remove duplicate mockito-core dependency.

The mockito-core dependency is declared twice (lines 244-247 and 254-257), both with test scope. Remove one of the duplicate entries.

Apply this diff to remove the duplicate:

         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-inline</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <scope>test</scope>
-        </dependency>
🧹 Nitpick comments (25)
modules/integration/src/test/java/org/apache/synapse/samples/framework/TestSamplesHandlerSuite.java (2)

28-29: Remove or comment out unused imports.

Since Sample353 and Sample354 are no longer registered in the suite (lines 277-278 are commented out), these imports are now unused and should be removed or commented out for consistency.

Apply this diff to comment out the unused imports:

-import org.apache.synapse.samples.framework.tests.advanced.Sample353;
-import org.apache.synapse.samples.framework.tests.advanced.Sample354;
+//import org.apache.synapse.samples.framework.tests.advanced.Sample353;
+//import org.apache.synapse.samples.framework.tests.advanced.Sample354;

Alternatively, remove the imports entirely if these samples won't be re-enabled.


277-278: Add explanatory comment for disabled samples.

The commented lines lack context about why Sample353 and Sample354 are disabled. Adding a brief explanation would help future maintainers understand this is related to JDK 21 compatibility and Ruby language support removal.

Apply this diff to add context:

+        // Samples 353 and 354 are disabled due to Ruby language support removal in JDK 21
 //        sampleClassRepo.put("353", Sample353.class);
 //        sampleClassRepo.put("354", Sample354.class);
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportListenerTest.java (1)

89-89: Remove redundant mock initialization.

MockitoAnnotations.initMocks(this) is unnecessary when using @RunWith(MockitoJUnitRunner.class), which automatically initializes the @Mock and @InjectMocks annotations.

Apply this diff:

-        MockitoAnnotations.initMocks(this);
modules/tasks/src/test/java/org/apache/synapse/task/service/TaskSchedulerTest.java (1)

21-21: Consider updating to JUnit 4 Assert.

The junit.framework.Assert class is from JUnit 3 and deprecated. Since the tests use JUnit 4 (@Test annotation), consider updating to org.junit.Assert.

Apply this diff to modernize the import:

-import junit.framework.Assert;
+import org.junit.Assert;

Alternatively, use static imports for cleaner assertions:

-import junit.framework.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;

Then update the assertion calls to remove the Assert. prefix (e.g., assertTrue(...) instead of Assert.assertTrue(...)).

modules/distribution/src/main/bin/ciphertool.sh (1)

92-92: Add deprecation context to comment for consistency with other distribution scripts.

While the comment explains what is being done, it omits context about why this pattern replaced the older approach. Other distribution scripts clarify that -Djava.endorsed.dirs was removed in Java 9+.

-# Add endorsed JARs to classpath (for Java 9+ compatibility)
+# endorsed dir - Note: -Djava.endorsed.dirs is removed in Java 9+
+# Endorsed JARs are now added to classpath instead
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXIncomingMessageHandlerTest.java (1)

65-65: Remove redundant mock initialization.

The initMocks(this) call is unnecessary because MockitoJUnitRunner (line 45) automatically initializes all @Mock annotated fields before each test method executes.

Apply this diff:

     @Test
     public void testToAdmin() throws Exception {
-        initMocks(this);
         SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"),
modules/transports/optional/fix/src/main/java/org/apache/synapse/transport/fix/FIXTransportSender.java (1)

277-278: Prefer package-private over protected for test-only visibility.

Since the test class resides in the same package (org.apache.synapse.transport.fix), package-private (default) visibility would suffice and provide better encapsulation than protected. The protected modifier unnecessarily exposes this method to all subclasses, which may not align with the intended API surface.

Apply this diff to use package-private visibility:

-    protected boolean sendUsingEPR(String targetEPR, String serviceName, Message fixMessage,
+    boolean sendUsingEPR(String targetEPR, String serviceName, Message fixMessage,
                                  String srcSession, int counter, MessageContext msgCtx) throws AxisFault {
modules/core/src/test/java/org/apache/synapse/endpoints/auth/oauth/OAuthClientTest.java (4)

42-45: Mockito runner and static mocking setup look correct; runner is optional here

Using MockedStatic with a try‑with‑resources block is the right way to scope the HttpClientBuilder static mock, and the imports are consistent. Since this test only uses locally created mocks (no @Mock / @InjectMocks fields), @RunWith(MockitoJUnitRunner.class) is not strictly necessary, though it doesn’t hurt. You could drop the runner later to simplify the class or, conversely, migrate fully away from junit.framework.TestCase to a pure JUnit 4/5 style when convenient.

Also applies to: 55-55


66-79: Static mocking of HttpClientBuilder and fluent chain matches production code

The mocking setup for HttpClientBuilder.create() and the fluent calls (setDefaultRequestConfig, setConnectionManager, setSSLSocketFactory, build) correctly mirrors the production getSecureClientWithoutProxy implementation, and returning mockHttpClient from build() plus stubbing execute(HttpPost) is sufficient for the test to exercise OAuthClient.generateToken without hitting the network. Consider optionally adding a Mockito.verify(mockHttpClient).execute(any(HttpPost.class)); to ensure the test would fail if the HTTP call path is refactored away, but the current behavior is functionally sound.


80-89: Response/status stubbing is consistent and narrowly scoped

Stubbing the StatusLine to return 200, attaching it to mockResponse, and providing a small JSON payload via entity.getContent() is a clean way to drive the happy‑path token parsing. The use of ByteArrayInputStream with simple ASCII JSON is safe here. If you later extend coverage, you might add separate tests for non‑200 responses or malformed JSON, but that’s outside the scope of this migration.


90-101: Context setup is adequate; minor SynapseConfiguration reuse improvement possible

The Axis2/Synapse context wiring is sufficient for OAuthClient.generateToken to run, and the parameters (timeouts set to -1, new ProxyConfigs and TrustStoreConfigs) match the expected usage. One small clean‑up: you create a SynapseConfiguration for synapseEnvironment, then pass a new SynapseConfiguration() instance into Axis2MessageContext. Reusing the same synapseConfiguration instance in both places would be slightly clearer and avoid allocating an extra config object, though behavior is currently correct.

modules/core/src/test/java/org/apache/synapse/util/ResourceMapTest.java (1)

89-89: Simplify the matcher for evaluateValue

The explicit cast in ((MessageContext) any()) is unnecessary; generics will infer the type. You can make this more idiomatic and type-safe as:

Mockito.when(value.evaluateValue(any(MessageContext.class))).thenReturn(helloKey);

This keeps the matcher type explicit and avoids the extra cast.

Please recompile the test after this tweak to confirm there are no import or overload resolution issues.

modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceFinder.java (1)

90-91: Consider preserving exception context in RuntimeException.

The broad Exception catch wraps any non-NamingException into a bare RuntimeException, which loses the original exception message and context.

Apply this diff to preserve exception details:

         } catch (Exception e) {
-            throw new RuntimeException(e);
+            throw new RuntimeException("Error dereferencing DataSource: " + dsName, e);
         }
modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/PassThroughHttpSenderTest.java (1)

36-40: Remove unused @After import on line 40.

The import is confirmed to be unused—no method in the test class is annotated with @After. Removing this import will clean up the imports section.

modules/core/src/test/java/org/apache/synapse/mediators/bean/Enterprise/EJBMediatorTest.java (1)

36-38: Mockito-based static mocking migration is consistent and scoped correctly

The switch to MockitoJUnitRunner plus MockedStatic<BeanUtils> in a try‑with‑resources block is clean and matches the pattern used elsewhere in the suite. Stubbing beanstalkManager/beanstalk before calling ejbMediator.init(...) and then mediating with a real Axis2MessageContext keeps the test behaviorally equivalent to the prior PowerMock version.

One minor, non‑blocking thought: ejbMediator and beanstalk are static fields; if more tests are ever added to this class, you may want to make them instance fields or reinitialize in a @Before method to avoid cross‑test state bleed, but this is not introduced by this PR.

Please confirm the test passes under the Mockito version configured for this PR, as static mocking support is version‑sensitive.

Also applies to: 49-49, 87-105

modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLMapper.java (1)

28-30: Jakarta JAXB switch changes public API surface – confirm this is an intentional break

JsonXMLMapper now depends on jakarta.xml.bind.JAXBContext/JAXBException instead of javax.xml.bind.*. Functionally this is fine and aligns with the Jakarta migration, but it does change the public API types exposed by this class, which can break external consumers compiled against the old javax types.

If this class is part of your supported public API, consider:

  • Explicitly documenting this as a breaking change in release notes, and/or
  • Aligning versioning (e.g., major bump) to reflect the Jakarta migration.

Please verify that all modules (and external integrations, if any) using JsonXMLMapper are updated to jakarta.xml.bind before releasing this change.

modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/TargetHandlerTest.java (1)

59-148: PowerMock → Mockito static mocking migration preserves behaviour

The three tests now use try (MockedStatic<TargetContext> = mockStatic(...)) with appropriate stubbing of TargetContext static methods and rely on the same interaction patterns as before, so test intent and coverage are preserved while dropping PowerMock.

If you ever touch these again, you might consider adding explicit verify calls on DeliveryAgent / TargetContext to assert behaviour rather than just “no exception”, but that’s outside this PR’s scope.

modules/commons/pom.xml (2)

56-59: Jacoco plugin now declared without executions

The jacoco-maven-plugin is present but has no module-local <executions>; if coverage for this module is meant to be driven from the parent POM, this is fine, otherwise you may want to confirm that you’re still instrumenting and reporting coverage for synapse-commons.

If coverage drops unexpectedly for this module after the change, consider either re-adding executions here or centralising all Jacoco configuration in the parent POM.


237-247: Ensure JAXB runtime matches Jakarta API

You’ve switched the API dependency to jakarta.xml.bind:jakarta.xml.bind-api while still depending on com.sun.xml.bind:jaxb-core and jaxb-impl. Please verify that the effective versions of those runtime artifacts are compatible with the Jakarta JAXB API (and not only with the legacy javax.xml.bind API), otherwise you may see runtime failures when creating JAXBContext.

You can check the resolved versions and their package names (javax.xml.bind vs jakarta.xml.bind) via your dependency tree (mvn dependency:tree) and by consulting the library documentation or release notes.

modules/integration/pom.xml (1)

457-474: Mix of javax JAXB test deps and Jakarta migration—verify classpath behaviour

These new test‑scoped dependencies bring in the classic javax.xml.bind / javax.activation stack for integration tests, while other modules (e.g. commons) now use the Jakarta JAXB API. That’s reasonable if tests still rely on javax‑based libraries, but please double‑check that:

  • You don’t accidentally satisfy Jakarta jakarta.xml.bind expectations with only javax providers, and
  • There are no conflicting JAXB providers on the test classpath.

Running mvn -pl modules/integration dependency:tree and cross‑checking provider packages (javax vs jakarta) against your usage is a good way to confirm this.

modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/TargetResponseTest.java (1)

66-89: Unused mock variable in testFalse().

The targetContextMock is created but never used for stubbing or verification. If the static mock is not needed for this test, consider removing it to simplify the test.

Apply this diff if the mock is not needed:

     @Test
     public void testFalse() throws Exception {
-        try (MockedStatic<TargetContext> targetContextMock = mockStatic(TargetContext.class)) {
-            ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
-            WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
-            PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
+        ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
+        WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
+        PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
 
-            TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool,
-                    metrics, null);
-            HttpResponse response = mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS);
-            NHttpClientConnection conn = mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
-            TargetConnections connections = mock(TargetConnections.class);
-            targetConfiguration.setConnections(connections);
+        TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool,
+                metrics, null);
+        HttpResponse response = mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS);
+        NHttpClientConnection conn = mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
+        TargetConnections connections = mock(TargetConnections.class);
+        targetConfiguration.setConnections(connections);
 
-            HttpRequest httpRequest = new BasicHttpRequest("GET", "test.com");
-            when(conn.getContext().getAttribute("http.request")).thenReturn(httpRequest);
+        HttpRequest httpRequest = new BasicHttpRequest("GET", "test.com");
+        when(conn.getContext().getAttribute("http.request")).thenReturn(httpRequest);
 
-            TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, false, false);
+        TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, false, false);
 
-            try {
-                targetResponse.start(conn);
-            } catch (Exception e) {
-                logger.error(e);
-                Assert.fail("Unable to start the target response!");
-            }
+        try {
+            targetResponse.start(conn);
+        } catch (Exception e) {
+            logger.error(e);
+            Assert.fail("Unable to start the target response!");
         }
     }
pom.xml (1)

1152-1162: Consider aligning mockito-inline version with mockito.version property.

The mockito-inline dependency uses a hardcoded version 5.2.0 (line 1160), while mockito-core uses the ${mockito.version} property set to 5.3.1 (line 1598). Using different versions of the same library might lead to compatibility issues.

Apply this diff to use the property for consistency:

         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-inline</artifactId>
-            <version>5.2.0</version>
+            <version>${mockito.version}</version>
             <scope>test</scope>
         </dependency>

Before applying this change, verify that mockito-inline 5.3.1 is compatible with the codebase by checking the Mockito release notes.

modules/extensions/src/test/java/org/apache/synapse/mediators/bsf/ScriptMediatorSerializationTest.java (1)

57-63: Ruby-engine guard avoids false negatives on JDK 21

The runtime check cleanly avoids failing this test when no Ruby ScriptEngine is present, which is useful on newer JDKs. If you want clearer test reporting and less console noise, consider using a test-framework skip/assumption mechanism instead of System.out.println + return.

modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ScriptMediator.java (2)

432-445: JS vs non-JS message context split looks consistent

Routing JAVA_SCRIPT/GRAAL_JAVA_SCRIPT through GraalVMJavaScriptMessageContext and everything else through CommonScriptMessageContext lines up with how JSON payloads and input arguments are now handled for JS. Only minor nit: the Javadoc above still references “Nashorn” even though the JS path now uses the Graal-based context; consider updating it for clarity.


667-672: Nashorn → Graal mapping works but leaves dead Nashorn-specific branches

Rewriting NASHORN_JAVA_SCRIPT to GRAAL_JAVA_SCRIPT here is a sensible compatibility move for JDK 21, and ensures all “nashornJs” usages are executed on the Graal engine. However, after this reassignment:

  • Later checks for NASHORN_JAVA_SCRIPT (e.g., in helper selection, getScriptEngineSupplier, getNewScriptEngine) become effectively unreachable.
  • oracleNashornFactory and the helper methods around it no longer influence behavior.

Consider either removing the now-dead Nashorn-specific branches and unused helpers, or adding a brief comment explaining why they remain, to avoid confusion for future maintainers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d30dd3c and 3a5773d.

📒 Files selected for processing (52)
  • modules/commons/pom.xml (1 hunks)
  • modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceFinder.java (1 hunks)
  • modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinder.java (1 hunks)
  • modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLMapper.java (1 hunks)
  • modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLRootProvider.java (1 hunks)
  • modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinderTest.java (1 hunks)
  • modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLRootProviderTest.java (1 hunks)
  • modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/ObjectFactory.java (1 hunks)
  • modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleRootElement.java (1 hunks)
  • modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleType.java (1 hunks)
  • modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleTypeWithNamespace.java (1 hunks)
  • modules/core/pom.xml (0 hunks)
  • modules/core/src/test/java/org/apache/synapse/aspects/flow/statistics/util/StatisticDataCollectionHelperTest.java (3 hunks)
  • modules/core/src/test/java/org/apache/synapse/config/xml/SynapseXMLConfigurationSerializerTest.java (2 hunks)
  • modules/core/src/test/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiverTest.java (1 hunks)
  • modules/core/src/test/java/org/apache/synapse/endpoints/DynamicLoadBalanceEndpointTest.java (2 hunks)
  • modules/core/src/test/java/org/apache/synapse/endpoints/HttpEndpointTest.java (1 hunks)
  • modules/core/src/test/java/org/apache/synapse/endpoints/RecipientListEndpointTest.java (2 hunks)
  • modules/core/src/test/java/org/apache/synapse/endpoints/auth/oauth/OAuthClientTest.java (2 hunks)
  • modules/core/src/test/java/org/apache/synapse/endpoints/resolvers/ResolverFactoryTest.java (4 hunks)
  • modules/core/src/test/java/org/apache/synapse/mediators/bean/Enterprise/EJBMediatorTest.java (3 hunks)
  • modules/core/src/test/java/org/apache/synapse/message/store/RabbitMQStoreTest.java (1 hunks)
  • modules/core/src/test/java/org/apache/synapse/util/ResourceMapTest.java (4 hunks)
  • modules/coverage-report/pom.xml (1 hunks)
  • modules/distribution/src/main/bin/ciphertool.sh (1 hunks)
  • modules/distribution/src/main/bin/synapse-config-migrator.sh (1 hunks)
  • modules/distribution/src/main/bin/synapse.sh (1 hunks)
  • modules/extensions/pom.xml (0 hunks)
  • modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/NashornJavaScriptMessageContext.java (0 hunks)
  • modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ScriptMediator.java (3 hunks)
  • modules/extensions/src/test/java/org/apache/synapse/mediators/bsf/ScriptMediatorSerializationTest.java (2 hunks)
  • modules/integration/pom.xml (2 hunks)
  • modules/integration/src/test/java/org/apache/synapse/samples/framework/TestSamplesHandlerSuite.java (1 hunks)
  • modules/samples/src/main/scripts/axis2Server/axis2server.sh (2 hunks)
  • modules/tasks/pom.xml (0 hunks)
  • modules/tasks/src/test/java/org/apache/synapse/task/service/TaskSchedulerTest.java (1 hunks)
  • modules/transports/core/nhttp/pom.xml (1 hunks)
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/nhttp/NHttpTransportListenerTest.java (0 hunks)
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/DeliveryAgentTest.java (2 hunks)
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/PassThroughHttpSenderTest.java (5 hunks)
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/RequestResponseTest.java (0 hunks)
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/TargetHandlerTest.java (4 hunks)
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/TargetResponseTest.java (4 hunks)
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/connections/HostConnectionsTest.java (2 hunks)
  • modules/transports/core/nhttp/src/test/resources/log4j.properties (1 hunks)
  • modules/transports/optional/fix/pom.xml (0 hunks)
  • modules/transports/optional/fix/src/main/java/org/apache/synapse/transport/fix/FIXTransportSender.java (1 hunks)
  • modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXIncomingMessageHandlerTest.java (3 hunks)
  • modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXOutgoingMessageHandlerTest.java (3 hunks)
  • modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportListenerTest.java (2 hunks)
  • modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportSenderTest.java (3 hunks)
  • pom.xml (6 hunks)
💤 Files with no reviewable changes (7)
  • modules/transports/optional/fix/pom.xml
  • modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/NashornJavaScriptMessageContext.java
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/RequestResponseTest.java
  • modules/tasks/pom.xml
  • modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/nhttp/NHttpTransportListenerTest.java
  • modules/extensions/pom.xml
  • modules/core/pom.xml
🧰 Additional context used
🧬 Code graph analysis (18)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinderTest.java (2)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleType.java (1)
  • XmlType (21-25)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleTypeWithNamespace.java (1)
  • XmlType (21-25)
modules/core/src/test/java/org/apache/synapse/aspects/flow/statistics/util/StatisticDataCollectionHelperTest.java (3)
modules/core/src/main/java/org/apache/synapse/aspects/flow/statistics/collectors/RuntimeStatisticCollector.java (1)
  • RuntimeStatisticCollector (36-429)
modules/core/src/main/java/org/apache/synapse/aspects/flow/statistics/util/StatisticsConstants.java (1)
  • StatisticsConstants (26-202)
modules/core/src/main/java/org/apache/synapse/aspects/flow/statistics/util/StatisticDataCollectionHelper.java (1)
  • StatisticDataCollectionHelper (32-162)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXIncomingMessageHandlerTest.java (2)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXOutgoingMessageHandlerTest.java (1)
  • RunWith (41-70)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportListenerTest.java (1)
  • RunWith (43-98)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLRootProviderTest.java (4)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleRootElement.java (1)
  • XmlRootElement (26-34)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinderTest.java (1)
  • XmlType (58-60)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleType.java (1)
  • XmlType (21-25)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleTypeWithNamespace.java (1)
  • XmlType (21-25)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportListenerTest.java (2)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXIncomingMessageHandlerTest.java (1)
  • RunWith (45-125)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXOutgoingMessageHandlerTest.java (1)
  • RunWith (41-70)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXOutgoingMessageHandlerTest.java (2)
modules/core/src/test/java/org/apache/synapse/aspects/flow/statistics/util/StatisticDataCollectionHelperTest.java (1)
  • RunWith (46-167)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXIncomingMessageHandlerTest.java (1)
  • RunWith (45-125)
modules/core/src/test/java/org/apache/synapse/endpoints/resolvers/ResolverFactoryTest.java (1)
modules/commons/src/main/java/org/apache/synapse/commons/resolvers/ResolverFactory.java (1)
  • ResolverFactory (29-139)
modules/core/src/test/java/org/apache/synapse/mediators/bean/Enterprise/EJBMediatorTest.java (3)
modules/core/src/test/java/org/apache/synapse/aspects/flow/statistics/util/StatisticDataCollectionHelperTest.java (1)
  • RunWith (46-167)
modules/core/src/test/java/org/apache/synapse/endpoints/auth/oauth/OAuthClientTest.java (1)
  • RunWith (55-106)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXOutgoingMessageHandlerTest.java (1)
  • RunWith (41-70)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportSenderTest.java (2)
modules/core/src/test/java/org/apache/synapse/aspects/flow/statistics/util/StatisticDataCollectionHelperTest.java (1)
  • RunWith (46-167)
modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXOutgoingMessageHandlerTest.java (1)
  • RunWith (41-70)
modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/TargetHandlerTest.java (1)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetContext.java (1)
  • TargetContext (34-258)
modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinder.java (4)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleRootElement.java (1)
  • XmlRootElement (26-34)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinderTest.java (1)
  • XmlType (58-60)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleType.java (1)
  • XmlType (21-25)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleTypeWithNamespace.java (1)
  • XmlType (21-25)
modules/core/src/test/java/org/apache/synapse/config/xml/SynapseXMLConfigurationSerializerTest.java (1)
modules/core/src/main/java/org/apache/synapse/config/Entry.java (1)
  • Entry (35-251)
modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/PassThroughHttpSenderTest.java (1)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/config/PassThroughConfiguration.java (1)
  • PassThroughConfiguration (38-411)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleType.java (2)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinderTest.java (1)
  • XmlType (58-60)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleTypeWithNamespace.java (1)
  • XmlType (21-25)
modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/TargetResponseTest.java (1)
modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetContext.java (1)
  • TargetContext (34-258)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleTypeWithNamespace.java (2)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinderTest.java (1)
  • XmlType (58-60)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleType.java (1)
  • XmlType (21-25)
modules/core/src/test/java/org/apache/synapse/endpoints/auth/oauth/OAuthClientTest.java (1)
modules/core/src/main/java/org/apache/synapse/endpoints/auth/oauth/OAuthClient.java (1)
  • OAuthClient (98-464)
modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLRootProvider.java (5)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/ObjectFactory.java (1)
  • XmlRegistry (23-38)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleRootElement.java (1)
  • XmlRootElement (26-34)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinderTest.java (1)
  • XmlType (58-60)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleType.java (1)
  • XmlType (21-25)
modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleTypeWithNamespace.java (1)
  • XmlType (21-25)
🔇 Additional comments (60)
modules/transports/core/nhttp/src/test/resources/log4j.properties (1)

1-8: Verify Log4j v1 compatibility with JDK 21 modernization effort.

This test resource uses Log4j v1 (org.apache.log4j.*) configuration, which reached end-of-life in 2015. Given that this PR is a broad modernization effort to support JDK 21, please verify:

  1. Whether the project intends to continue using Log4j v1 or has plans to migrate to Log4j v2
  2. That Log4j v1 is explicitly tested and compatible with JDK 21
  3. How this aligns with other test logging configurations across the codebase

The configuration itself is structurally sound—it properly sets the root logger to INFO with a ConsoleAppender and includes a reasonable timestamp-based pattern layout suitable for tests.

modules/core/src/test/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiverTest.java (1)

88-88: LGTM! Clean migration from PowerMockito to Mockito.

The replacement of PowerMockito.mock with Mockito.mock is correct for this use case. Since Axis2SynapseEnvironment is instantiated directly elsewhere in the test (line 102) and only instance methods are being stubbed, standard Mockito is sufficient and no PowerMockito features are needed.

modules/core/src/test/java/org/apache/synapse/endpoints/DynamicLoadBalanceEndpointTest.java (2)

76-77: LGTM! Clean migration from PowerMockito to Mockito.

The migration from PowerMockito.mock() to Mockito.mock() is correct and aligns with the PR objective of supporting JDK 21 compilation by removing PowerMock dependencies.


103-103: LGTM! Consistent migration approach.

The migration to Mockito.mock() is correctly applied, maintaining consistency with the other mock creation in this test class.

modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportListenerTest.java (3)

37-39: LGTM! Standard Mockito imports added.

The imports are correctly updated to support the migration from PowerMockito to Mockito.


43-43: LGTM! Correct test runner for Mockito.

The migration from PowerMockRunner to MockitoJUnitRunner is appropriate for this test class.


92-92: LGTM! Correct migration to Mockito.

The change from PowerMockito.when to Mockito.when is correct for mocking the instance method.

modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/connections/HostConnectionsTest.java (2)

33-33: LGTM!

The addition of the Field import is necessary for the reflection-based approach that replaces PowerMockito's field injection.


62-64: Field exists and reflection access is correct.

Verification confirms that the freeConnections field exists as a declared private field in the HostConnections class (line 69). The migration from PowerMockito to standard Java reflection is implemented correctly, and the field name in the reflection code matches the actual declaration.

modules/distribution/src/main/bin/synapse.sh (1)

120-128: LGTM: Endorsed JAR classpath handling is correctly implemented.

The transition from -Djava.endorsed.dirs to runtime classpath augmentation is well-structured, with proper directory existence checks and consistent variable naming. This aligns with Java 9+ requirements.

modules/distribution/src/main/bin/synapse-config-migrator.sh (1)

107-115: LGTM: Endorsed JAR classpath handling mirrors best practices from synapse.sh.

Consistent implementation with proper checks and clear deprecation comments.

modules/samples/src/main/scripts/axis2Server/axis2server.sh (2)

116-124: LGTM: Endorsed JAR classpath handling is correct and consistent.

Proper implementation with clear deprecation context.


169-169: No verification needed—arguments are already fully supported.

The SampleAxis2Server class correctly accepts -repo and -conf arguments. The SampleAxis2ServerManager.start() method implements robust argument parsing using CommandLineOptionParser with explicit validation that only "repo" and "conf" options are accepted. Existing unit tests already invoke SampleAxis2Server.main() with these exact arguments and pass successfully, confirming the implementation works. No breaking changes will occur.

modules/core/src/test/java/org/apache/synapse/message/store/RabbitMQStoreTest.java (1)

21-47: PowerMock removal is appropriate; tests run fine under the default JUnit runner

This class no longer uses any PowerMock APIs or features, so removing PowerMockRunner / @PrepareForTest and relying on the standard JUnit runner is safe and reduces complexity. The tests only use reflection and regular JUnit assertions, so behavior should remain unchanged. Repository-wide verification confirms no remaining PowerMock usages exist.

modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXIncomingMessageHandlerTest.java (2)

32-33: LGTM! Migration setup is correct.

The migration from PowerMockRunner to MockitoJUnitRunner is properly configured with the necessary imports. This aligns with the PR objective to modernize the test framework.

Also applies to: 45-45


76-79: LGTM! Mockito stubbing correctly replaces PowerMockito.

The migration from PowerMockito.when to Mockito.when is correct and follows standard Mockito patterns for method stubbing.

modules/core/src/test/java/org/apache/synapse/config/xml/SynapseXMLConfigurationSerializerTest.java (2)

40-40: LGTM! Import migration is correct.

The migration from PowerMockito to Mockito is appropriate and correctly implemented.


177-180: Confirm the test passes with current mock setup and verify if getType() stubbing is needed.

Based on verification of the EntrySerializer code and mock behavior, the review comment's analysis is accurate. When calling setIntegerValue(50) on a Mockito mock, getIntegerValue() still returns 0, not 50—Mockito just doesn't match the getter and setter.

Since EntrySerializer.serializeEntry() explicitly calls entry.getType() and checks if it equals Entry.URL_SRC (value 2), the mock will return 0 (the default for int methods) instead. The test currently passes only because it verifies only the key attribute, which is always serialized regardless of type.

The suggestion to add Mockito.doReturn(Entry.URL_SRC).when(entry).getType(); is valid and improves test correctness. However, verify whether this is truly necessary by checking if the test intentionally verifies only partial serialization or if fuller verification is expected.

modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXTransportSenderTest.java (3)

32-33: LGTM!

Clean migration to standard Mockito imports.


60-60: LGTM!

Appropriate test runner for Mockito-based testing.


109-114: Spy test is fragile and relies on stubbing to avoid NPEs; verify and improve with proper initialization.

The spy is created without calling init(), leaving cfgCtx (inherited from AbstractTransportSender) uninitialized. While the test currently passes because sendUsingEPR is stubbed (preventing its body at line 277 from executing), this approach is fragile:

  • Line 286 in sendUsingEPR accesses cfgCtx.getAxisConfiguration(), which would throw NPE if the method body executed
  • The test depends entirely on stubbing to work; any refactor removing or delaying the stub would cause failures
  • Similar tests in the codebase (e.g., FIXOutgoingMessageHandlerTest.java) use @Mock and @InjectMocks for proper dependency injection

Consider initializing the spy with required dependencies or using the @Mock/@InjectMocks pattern to avoid fragility.

modules/core/src/test/java/org/apache/synapse/util/ResourceMapTest.java (2)

28-32: Mockito import migration looks correct

Using org.mockito.Mockito together with static ArgumentMatchers.any/anyString matches the usages below and removes the PowerMockito dependency without changing behavior.

Please ensure the project’s Mockito version matches this API (e.g., run a quick compile on the test sources).


65-65: Mockito.when(...) stubs correctly replace PowerMockito

The instance-method stubs for synapseConfiguration.getEntry(anyString()) and synapsePath.getExpression() are straightforward Mockito equivalents of the old PowerMockito calls, and they keep the tests focused on ResourceMap behavior rather than exact key values.

If you want slightly stricter tests later, you could replace anyString() with eq(helloKey) to assert that ResourceMap uses the expected registry key, but this is not required for correctness.

Also applies to: 76-78, 88-88

modules/transports/optional/fix/src/test/java/org/apache/synapse/transport/fix/FIXOutgoingMessageHandlerTest.java (2)

27-29: Mockito migration wiring looks correct

Using @RunWith(MockitoJUnitRunner.class) together with @Mock and @InjectMocks, plus MockedStatic for static calls, is a good replacement for the previous PowerMockito-based setup and is consistent with other updated tests in this codebase. No functional issues spotted in this part.

Also applies to: 41-50


59-67: Add explicit verification to the Session.sendToTarget mock invocation

The static stub signature correctly matches production usage—FIXOutgoingMessageHandler.sendMessage delegates to its private sendToTarget method, which calls Session.sendToTarget(message, sessionID) (line 138). This matches your stubbed overload.

However, the test currently verifies only the absence of exceptions. Add an explicit mock verification to ensure the handler properly invokes the QuickFIX session:

         try (MockedStatic<Session> mockedSession = Mockito.mockStatic(Session.class)) {
             mockedSession.when(() -> Session.sendToTarget(any(Message.class), any(SessionID.class)))
                     .thenReturn(true);
             SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"),
                     new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI");

             spy.sendMessage(message, id, SESSION_ID, SEQ_NUM, msgCtx, "fix://sample");
+            mockedSession.verify(() -> Session.sendToTarget(message, id));
         }
modules/core/src/test/java/org/apache/synapse/endpoints/HttpEndpointTest.java (1)

162-162: LGTM! PowerMock to Mockito migration applied correctly.

The change from PowerMockito.mock to Mockito.mock is correct and aligns with the PR's objective to migrate away from PowerMock.

modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/DeliveryAgentTest.java (2)

31-31: LGTM! Import updated for Mockito migration.

Correctly replaced PowerMockito import with standard Mockito static import.


49-51: LGTM! Mock creation updated to use Mockito.

The migration from PowerMockito.mock(...) to mock(...) is correct and consistent with the broader Mockito migration.

modules/core/src/test/java/org/apache/synapse/endpoints/RecipientListEndpointTest.java (1)

185-185: LGTM! Mockito migration applied correctly.

The migration from PowerMockito.mock to Mockito.mock is correct.

modules/coverage-report/pom.xml (1)

95-115: LGTM! JaCoCo reporting consolidated effectively.

The refactoring simplifies coverage collection by:

  • Pointing directly to module target directories instead of coverage-reports subdirectories
  • Using a single jacoco.exec file per module instead of multiple jacoco-unit*.exec files

This aligns with the PR's JaCoCo upgrade to 0.8.12 and improves maintainability.

modules/core/src/test/java/org/apache/synapse/aspects/flow/statistics/util/StatisticDataCollectionHelperTest.java (4)

31-33: LGTM! Correct imports for Mockito static mocking.

Added the necessary imports for MockedStatic which replaces PowerMock's static mocking capabilities.


46-46: LGTM! Test runner updated for Mockito.

The switch to MockitoJUnitRunner is correct and consistent with the PowerMock to Mockito migration.


136-148: LGTM! Static method mocking implemented correctly.

The use of try-with-resources with MockedStatic is the proper pattern for mocking static methods in Mockito. This ensures the static mock is automatically cleaned up after the test.


156-165: LGTM! Static mocking pattern applied consistently.

The static mocking of RuntimeStatisticCollector methods follows the correct Mockito pattern with proper scoping via try-with-resources.

modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceFinder.java (1)

73-84: LGTM! JNDI dereferencing implemented correctly.

The automatic dereferencing of javax.naming.Reference objects using NamingManager.getObjectInstance is the correct approach for JNDI lookups that may return references instead of direct objects.

modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/PassThroughHttpSenderTest.java (3)

45-49: LGTM! Test infrastructure updated for Mockito.

The migration includes:

  • Correct static imports for Mockito methods
  • Addition of PassThroughTestUtils for configuration setup
  • Proper initialization of passThroughConfiguration

Also applies to: 78-78


111-113: LGTM! Spy creation migrated to Mockito.

The change from PowerMockito.spy to Mockito.spy is correct, and the mock configuration properly uses when(...).thenReturn(...).


135-148: LGTM! Mock and spy usage updated consistently.

All PowerMock calls have been correctly replaced with their Mockito equivalents while preserving test behavior.

modules/core/src/test/java/org/apache/synapse/endpoints/resolvers/ResolverFactoryTest.java (4)

26-33: LGTM! JUnit 3 to JUnit 4 migration completed correctly.

The changes properly modernize the test:

  • Removed extends TestCase dependency
  • Switched to JUnit 4 static assertion imports
  • Test structure now follows JUnit 4 conventions

35-50: LGTM! Test assertions enhanced.

The migration adds explicit @Test annotations and improves assertions by verifying both the resolver type and its resolution behavior.


52-68: LGTM! Consistent test improvements applied.

Additional tests properly migrated with enhanced assertions that verify resolver type and default resolution behavior.


76-83: LGTM! SystemResolver test updated.

The test correctly migrates to JUnit 4 and maintains type verification for SystemResolver.

modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleRootElement.java (1)

20-22: JAXB annotation namespace migration looks good

Imports cleanly switch to jakarta.xml.bind.annotation.* with no other changes; the DTO and its annotations remain semantically identical.

Please ensure the test module’s POM is wired to jakarta.xml.bind-api so these annotations resolve under JDK 21.

modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinder.java (1)

24-29: Mechanical JAXB → Jakarta import migration; binder behavior unchanged

The move from javax.xml.bind.* to jakarta.xml.bind.* in this binder is straightforward, and the rest of the logic (bindability checks, marshal/unmarshal, array handling) remains untouched.

Please ensure the runtime includes a Jakarta JAXB implementation compatible with jakarta.xml.bind-api for these types.

modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/ObjectFactory.java (1)

18-20: ObjectFactory JAXB imports correctly migrated to Jakarta

Updating JAXBElement, XmlElementDecl, and XmlRegistry to the jakarta.xml.bind namespace is consistent with the rest of the Jakarta migration; the factory methods and QNames remain the same.

Please confirm the corresponding tests still pass with the Jakarta JAXB runtime under JDK 21.

modules/commons/src/main/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLRootProvider.java (1)

21-28: JAXB javax→jakarta namespace switch looks correct

Imports now consistently use jakarta.xml.bind.* and jakarta.xml.bind.annotation.* while the rest of the class logic is unchanged, so behaviour is preserved assuming a Jakarta JAXB runtime is present on the classpath.

modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLRootProviderTest.java (1)

21-25: Test imports aligned with Jakarta JAXB

Using jakarta.xml.bind.* and JAXB annotations here matches the main-class migration and keeps the tests semantically identical.

modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/JsonXMLBinderTest.java (1)

26-30: Jakarta JAXB usage in tests is consistent

The switch to jakarta.xml.bind APIs and @XmlType here matches the main JAXB migration; all calls to JAXBContext, Marshaller and Unmarshaller remain valid.

modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleType.java (1)

18-19: SampleType annotations migrated cleanly to Jakarta

@XmlElement and @XmlType now come from jakarta.xml.bind.annotation, which is consistent with the rest of the JAXB migration.

modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/TargetHandlerTest.java (1)

38-45: Mockito static-mocking imports are correct

MockedStatic and the static imports from Mockito are exactly what you need for the new static-mocking pattern used below.

modules/commons/src/test/java/org/apache/synapse/commons/staxon/core/json/jaxb/sample/SampleTypeWithNamespace.java (1)

18-19: Namespace-aware sample type updated to Jakarta JAXB

The move to jakarta.xml.bind.annotation for @XmlElement and @XmlType keeps the existing namespace configuration (urn:staxon:jaxb:test) unaffected.

modules/integration/pom.xml (1)

295-295: Updated Surefire JVM args are JDK‑21 friendly

Switching from MaxPermSize to Metaspace options in <argLine> aligns with post‑PermGen JVMs and is compatible with Java 21; no issues from the POM side.

modules/transports/core/nhttp/src/test/java/org/apache/synapse/transport/passthru/TargetResponseTest.java (3)

99-122: LGTM! Proper Mockito migration.

The static mocking is correctly implemented using try-with-resources and the mock is properly stubbed to return a TargetContext instance.


130-163: LGTM! Static mocking properly implemented.

The migration to Mockito is correct with proper use of try-with-resources and static method stubbing.


172-203: LGTM! Excellent Mockito migration with constructor mocking.

The test demonstrates proper use of both static and constructor mocking. The verification of TargetContext.updateState() ensures the expected state transition occurs.

pom.xml (3)

221-222: LGTM! Java 21 compilation target set correctly.

The compiler plugin is properly configured for JDK 21, aligning with the PR objectives.


1475-1475: LGTM! Build tooling versions updated appropriately.

The updates to JaCoCo (0.8.12), Maven WAR Plugin (3.5.0), and Glassfish Jersey (2.41) align with JDK 21 requirements and are consistent across the POM.

Also applies to: 1482-1482, 1606-1607, 1638-1638


1355-1357: Version compatibility confirmed—no action required.

jaxb-impl 4.0.6 is compatible with jakarta.xml.bind-api 4.0.4, as minor/patch bumps within the 4.0.x releases are intended to work together. The version difference noted is not a concern.

modules/extensions/src/test/java/org/apache/synapse/mediators/bsf/ScriptMediatorSerializationTest.java (1)

24-24: Import addition is appropriate

ScriptEngineManager is used in the Ruby engine availability guard below; the import is correct and scoped to its only usage.

modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ScriptMediator.java (1)

470-498: JSON payload handling correctly prefers Graal path for JS languages

The updated condition in processJSONPayload ensures that JAVA_SCRIPT and GRAAL_JAVA_SCRIPT use the GraalVMJavaScriptMessageContext’s JSON serializer, while non-JS languages continue to use the generic jsEngine-based parsing path. This keeps JSON handling consistent with the new JS message context and the preprocessJSONInputArgument logic.

Comment on lines +172 to 183
/**
* Create a mock SynapseEnvironment object
*
* @return Axis2SynapseEnvironment instance
* @throws AxisFault on creating/mocking object
*/
/**
* Create a mock SynapseEnvironment object
*
* @return Axis2SynapseEnvironment instance
* @throws AxisFault on creating/mocking object
*/
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove duplicate JavaDoc comment.

The same JavaDoc block appears twice (lines 172-177 and 178-183). Remove the first occurrence to eliminate duplication.

Apply this diff:

-    /**
-     * Create a mock SynapseEnvironment object
-     *
-     * @return Axis2SynapseEnvironment instance
-     * @throws AxisFault on creating/mocking object
-     */
     /**
      * Create a mock SynapseEnvironment object
      *
      * @return Axis2SynapseEnvironment instance
      * @throws AxisFault on creating/mocking object
      */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Create a mock SynapseEnvironment object
*
* @return Axis2SynapseEnvironment instance
* @throws AxisFault on creating/mocking object
*/
/**
* Create a mock SynapseEnvironment object
*
* @return Axis2SynapseEnvironment instance
* @throws AxisFault on creating/mocking object
*/
/**
* Create a mock SynapseEnvironment object
*
* @return Axis2SynapseEnvironment instance
* @throws AxisFault on creating/mocking object
*/
🤖 Prompt for AI Agents
modules/core/src/test/java/org/apache/synapse/endpoints/RecipientListEndpointTest.java
around lines 172-183: remove the first duplicate JavaDoc block (lines 172-177)
so only a single JavaDoc remains immediately above the method; delete the
redundant comment lines and leave the second/remaining JavaDoc intact.

SYNAPSE_HOME=`cygpath --absolute --windows "$SYNAPSE_HOME"`
AXIS2_HOME=`cygpath --absolute --windows "$SYNAPSE_HOME"`
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Remove dead code: unused JAVA_ENDORSED_DIRS Cygwin conversion.

The conversion of JAVA_ENDORSED_DIRS on line 105 is no longer needed since endorsed directories are now handled via classpath augmentation (lines 107–115) rather than the JVM option.

  CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
fi
🤖 Prompt for AI Agents
In modules/distribution/src/main/bin/synapse-config-migrator.sh around line 105,
remove the now-dead conversion of JAVA_ENDORSED_DIRS via cygpath since endorsed
dirs are handled through classpath augmentation (lines 107–115); delete the line
that assigns JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
and ensure no other references to that converted variable remain, leaving
classpath-based handling intact.

SYNAPSE_HOME=`cygpath --absolute --windows "$SYNAPSE_HOME"`
AXIS2_HOME=`cygpath --absolute --windows "$SYNAPSE_HOME"`
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Remove dead code: unused JAVA_ENDORSED_DIRS Cygwin conversion.

Since endorsed directories are now handled via classpath augmentation (lines 120–128) rather than the -Djava.endorsed.dirs JVM option, the conversion of JAVA_ENDORSED_DIRS on line 118 is no longer needed and should be removed.

  CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
fi
🤖 Prompt for AI Agents
In modules/distribution/src/main/bin/synapse.sh around line 118, remove the
now-unused Cygwin conversion of JAVA_ENDORSED_DIRS (the `cygpath --path
--windows "$JAVA_ENDORSED_DIRS"` invocation) because endorsed dirs are handled
via classpath augmentation later (lines 120–128); delete that line and any
direct references to JAVA_ENDORSED_DIRS nearby if they become unused, leaving
classpath-based handling intact and ensuring the script still passes
shellcheck/sanity checks after removal.

JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
AXIS2_HOME=`cygpath --absolute --windows "$AXIS2_HOME"`
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Remove dead code: unused JAVA_ENDORSED_DIRS Cygwin conversion.

The conversion of JAVA_ENDORSED_DIRS on line 113 is no longer needed since endorsed directories are now handled via classpath augmentation (lines 116–124) rather than the JVM option.

  CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
fi
🤖 Prompt for AI Agents
In modules/samples/src/main/scripts/axis2Server/axis2server.sh around line 113,
remove the dead Cygwin conversion of JAVA_ENDORSED_DIRS (`cygpath --path
--windows "$JAVA_ENDORSED_DIRS"`) because endorsed dirs are now handled via
classpath augmentation (lines 116–124); delete that line and ensure no other
remaining references to JAVA_ENDORSED_DIRS rely on the converted value (if any,
update them to use the classpath augmentation logic instead).

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.

1 participant