Jinwoo Hwang created GEODE-10505:
------------------------------------

             Summary: Migrate MockRunner to Spring Test 6.x for Jakarta EE 10 
Compatibility
                 Key: GEODE-10505
                 URL: https://issues.apache.org/jira/browse/GEODE-10505
             Project: Geode
          Issue Type: Improvement
            Reporter: Jinwoo Hwang


h3. Background

As part of the Jakarta EE 10 migration, the geode-modules-session module's 
integration tests are currently failing because they depend on MockRunner, a 
servlet container testing framework that:
 # *Only supports javax.servlet* (not Jakarta EE)
 # *Is no longer maintained* (last release 2014)
 # *Has no Jakarta-compatible version* available
 # *Blocks test execution* in Jakarta-migrated codebase

The geode-modules-session tests use MockRunner to mock servlet container 
components (HttpServletRequest, HttpServletResponse, ServletContext, 
FilterChain) for testing Geode session management functionality.
h3. Proposed Solution

Migrate from MockRunner to *Spring Test 6.x* (spring-test module), which:
 * ✅ Fully supports Jakarta EE 10 (jakarta.servlet.*)
 * ✅ Actively maintained by Spring Framework team
 * ✅ Provides equivalent servlet mocking capabilities
 * ✅ Drop-in replacement with minimal code changes
 * ✅ Better integration with Spring ecosystem

----
h2. Scope
h3. Files to Migrate (5 files)
h4. Test Infrastructure
 # *SessionCookieConfigServletTestCaseAdapter.java* (~300 lines estimated)
 ** Complete rewrite required
 ** Currently extends MockRunner's {{BasicServletTestCaseAdapter}}
 ** Will implement custom adapter using Spring Test mocks

h4. Test Classes
 # *CommonTests.java*

 ** Cookie API changes (List → Array)
 ** Import statement updates
 ** API method name changes
 # *SessionReplicationJUnitTest.java*

 ** Import updates
 ** API compatibility fixes
 # *SessionReplicationLocalCacheJUnitTest.java*

 ** Import updates
 ** API compatibility fixes
 # *SessionReplicationIntegrationJUnitTest.java*

 ** Import updates
 ** Jetty 11 API compatibility (servlet registration)

h3. Dependencies to Update

*Remove:*

 

{{testImplementation 'com.mockrunner:mockrunner-servlet:2.0.6'}}

*Add:*

 

{{testImplementation 'org.springframework:spring-test:6.1.1'}}
----
h2. Migration Strategy
h3. Phase 1: Research & Planning

{*}Effort{*}: 2-3 days
 * [ ] Research MockRunner Jakarta support status
 * [ ] Evaluate alternative frameworks (Spring Test, WireMock, JMockit)
 * [ ] Create API mapping between MockRunner and Spring Test
 * [ ] Document migration approach and risks
 * [ ] Get stakeholder approval

h3. Phase 2: Test Adapter Rewrite

{*}Effort{*}: 4-6 days

Rewrite {{SessionCookieConfigServletTestCaseAdapter}} to use Spring Test:

*Tasks:*
 * [ ] Remove {{BasicServletTestCaseAdapter}} base class
 * [ ] Implement custom servlet context lifecycle management
 * [ ] Create Spring Test-based mock objects (request, response, context)
 * [ ] Preserve existing test API surface for backward compatibility
 * [ ] Implement custom {{SessionCookieConfig}} mock (not provided by Spring 
Test)
 * [ ] Implement filter chain execution logic{{}}

h3. Phase 3: API Translation

{*}Effort{*}: 1-2 days

Update API calls in test files (estimated ~30 locations):
||MockRunner API||Spring Test API||Est. Locations||
|{{getCookies().get(0)}}|{{getCookies()[0]}}|~7|
|{{addCookie(cookie)}}|{{setCookies(cookie)}}|~9|
|{{setRequestURL(url)}}|{{setRequestURI(url)}}|~3|
|{{factory.getMockFilterConfig()}}|{{new MockFilterConfig(context)}}|~3|
|{{addServlet(Class, path)}}|{{addServlet(Class.getName(), path)}}|~8|

*Tasks:*
 * [ ] Update cookie API calls (List → Array syntax)
 * [ ] Update request URL methods
 * [ ] Update filter config creation
 * [ ] Update servlet registration calls

h3. Phase 4: Import Updates

{*}Effort{*}: 1 day

Update all import statements in 5 test files:

*Tasks:*
 * [ ] Remove MockRunner imports: {{com.mockrunner.mock.web.*}}
 * [ ] Remove MockRunner imports: {{com.mockrunner.servlet.*}}
 * [ ] Add Spring Test imports: {{org.springframework.mock.web.*}}
 * [ ] Update servlet imports: {{javax.servlet.*}} → {{jakarta.servlet.*}}

h3. Phase 5: Compilation Verification

{*}Effort{*}: 1 day

*Tasks:*
 * [ ] Run: {{./gradlew 
:extensions:geode-modules-session:compileIntegrationTestJava}}
 * [ ] Verify zero compilation errors
 * [ ] Verify zero import resolution errors
 * [ ] Fix any compilation issues discovered
 * [ ] Document any API gaps or workarounds needed

*Success Criteria:*

 

{{BUILD SUCCESSFUL
Errors: 0
Warnings: 0}}
h3. Phase 6: Test Execution & Analysis

{*}Effort{*}: 2-3 days

*Tasks:*
 * [ ] Run: {{./gradlew :extensions:geode-modules-session:integrationTest}}
 * [ ] Analyze test results
 * [ ] Categorize failures: migration-related vs. infrastructure-related
 * [ ] Document expected vs. actual behavior
 * [ ] Create separate JIRAs for non-migration issues (if needed)

*Expected Outcomes:*
 * Servlet mocking functionality works (tests can execute)
 * Some tests may fail due to Geode infrastructure issues (separate concern)
 * Clear documentation of what works vs. what needs additional fixes

h3. Phase 7: Documentation

{*}Effort{*}: 2 days

*Tasks:*
 * [ ] Create migration completion summary
 * [ ] Document API translation guide for future reference
 * [ ] List known issues and limitations
 * [ ] Create troubleshooting guide
 * [ ] Update project README with new test dependencies

 
h3. Success Criteria
 * ✅ Build successful (zero compilation errors)
 * ✅ No deprecated API warnings
 * ✅ Mock objects created correctly
 * ✅ Filter lifecycle works (init → doFilter → destroy)
 * ✅ Request/Response state preserved
 * ✅ Cookie handling works correctly
 * ✅ Session management API accessible

 

 
----



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to