Phase 2 continuation: ExpiredPasswordException, message bundles, and additional tests#35
Conversation
…and additional tests - Add ExpiredPasswordException as Spring-friendly RuntimeException (replaces Struts ModuleException) - Add messages.properties with all application message keys (EN, JA, RU locales) - Add ConstantsTest validating Constants class values and no Struts DATABASE_KEY - Add DatabaseConfigurationTest validating real XML loading from classpath - Add data persistence round-trip test (save & reload) for Phase 2 acceptance criteria - Add ExpiredPasswordExceptionTest unit tests All 114 tests pass with mvn clean test -f pom-spring-boot.xml Co-Authored-By: Jack Meigel <jack.meigel@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| # Standard error messages for validator framework checks | ||
| errors.required={0} \u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 | ||
| errors.minlength={0} \u306f {1} \u6587\u5b57\u4ee5\u4e0a\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002 | ||
| errors.maxlength={0} \u306f {2} \u6587\u5b57\u4ee5\u4e0b\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002 |
There was a problem hiding this comment.
🟡 Wrong MessageFormat placeholder {2} instead of {1} in Japanese errors.maxlength message
The Japanese errors.maxlength message uses {2} for the max length parameter, but the English version at messages.properties:130 correctly uses {1}. The errors.maxlength validation message is typically called with two arguments: {0} (field name) and {1} (max length). Using {2} means the max length value won't be substituted — Japanese users will see a literal {2} or no value in the validation error message. This bug was carried over from the original ApplicationResources_ja.properties.
| errors.maxlength={0} \u306f {2} \u6587\u5b57\u4ee5\u4e0b\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002 | |
| errors.maxlength={0} \u306f {1} \u6587\u5b57\u4ee5\u4e0b\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002 |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Continues Phase 2 (Data Layer & Domain Model Migration) for
apps/faces-example2/, following PR #16 which addedConstants.javaanddatabase.xml.New production code:
ExpiredPasswordException— framework-independentRuntimeExceptionreplacing the original StrutsModuleExceptionsubclass. Stores the username and produces an English diagnostic message.messages.properties(EN),messages_ja.properties,messages_ru.properties— SpringMessageSourcebundles ported from the originalApplicationResources*.properties, with HTML markup stripped for Thymeleaf compatibility. Referenced byspring.messages.basename=messagesinapplication.properties.New tests:
ConstantsTest— validates constant values and confirmsDATABASE_KEYwas removed during migration.ExpiredPasswordExceptionTest— verifies it's a plainRuntimeExceptionwith no Struts dependency.DatabaseConfigurationTest— loads the realDatabaseConfigurationbean fromclasspath:database.xml(unlikeDatabaseIntegrationTestwhich usesTestDatabaseConfiguration). Includes a save-and-reload round-trip test for Phase 2 acceptance criteria.All 114 tests pass (
mvn clean test -f pom-spring-boot.xml).Review & Testing Checklist for Human
messages.propertieswas hand-written, not mechanically diffed against the originalsrc/.../ApplicationResources.properties. Verify no keys are missing — especially keys used by Phase 3 controllers already on trunk (e.g.error.host.uniqueis absent and will causeNoSuchMessageExceptionat runtime).ApplicationResources_ja.properties/ApplicationResources_ru.properties.MemoryUserDatabase, not the Spring-managed bean, becauseMemoryUserDatabase.open()doesn't clear its internal map before loading (causing "Duplicate user" on re-open). This is a known limitation — the test validates the serialization format but not the Spring bean restart lifecycle. Decide if this is acceptable or ifopen()should be fixed to clear state first.Notes
ExpiredPasswordExceptionhardcodes an English message string. Controllers will need to catch it and resolve a localized message viaMessageSource— this is consistent with how Spring apps typically handle domain exceptions.target/directory from prior builds (containingRegistrationController.classandSubscriptionController.classfrom Phase 3) caused misleading test failures untilmvn cleanwas run. CI should be unaffected since it builds clean.Link to Devin session: https://jack-meigel.devinenterprise.com/sessions/5fe57190de1142b3be8637e6bbfc0e5a
Requested by: @cogjack