Skip to content

Conversation

@joeyliechty
Copy link

Summary

Implement HTTP session support in MockHstRequest to enable testing of login flows and session-dependent features. Add comprehensive example test classes demonstrating session usage patterns with component, JAX-RS, and Page Model testing frameworks.

Changes

Core Implementation

  • MockHstRequest.java: Add HTTP session support with three methods:
    • getSession() - Auto-creates session if needed
    • getSession(boolean create) - Conditional session creation
    • setSession(HttpSession) - Manual session injection
    • Uses Spring's MockHttpSession for in-memory storage

Documentation & Examples

  • CLAUDE.md: Comprehensive developer guide with HTTP session section, usage patterns, and examples
  • AnnotatedComponentTest.java: Component testing example with session attributes
  • AnnotatedJaxrsTest.java: JAX-RS testing with session-aware request handling
  • AnnotatedPageModelTest.java: Page Model testing with session persistence

Key Features

  • Session attributes persist across multiple requests within a test
  • Enables realistic testing of authentication and authorization workflows
  • Zero breaking changes - fully backwards compatible
  • All existing tests continue to pass

Test Results

✅ 8/8 Tests Passing
✅ 0 Failures, 0 Errors
✅ BUILD SUCCESS

Files Changed

  • Modified: 1 file (MockHstRequest.java +48 lines)
  • Created: 4 files (CLAUDE.md, 3 example tests)
  • Total: 618 insertions

Ready for merge to develop.

Implement HTTP session support in MockHstRequest to enable testing of login
flows and session-dependent features. Add comprehensive example test classes
demonstrating session usage patterns with component, JAX-RS, and Page Model
testing frameworks.

- Add session lifecycle management (getSession, getSession(create), setSession)
- Use Spring's MockHttpSession for in-memory session storage
- Create AnnotatedComponentTest example with session attributes
- Create AnnotatedJaxrsTest example with session-aware request handling
- Create AnnotatedPageModelTest example with session persistence
- Add CLAUDE.md documentation with usage patterns and examples

Session attributes persist across multiple requests within a test, enabling
realistic testing of authentication and authorization workflows.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
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