Follow-up to #456 (merged in PR #457).
PR #457 added two cheap guard tests: a render-strategy assertion in WicketApplicationTest, and reflection-based field-architecture tests in SpacePageTest / MaintainedResourcePageTest. Three higher-fidelity tests were discussed but not added because they involve more setup. Filing here so we don't lose them.
1. LDM serialization round-trip
Build a LoadableDetachableModel<Space> exactly like the one in SpacePage, mock SpaceRepository.findById to return distinct objects across two calls, and assert:
getObject() returns the first instance.
- After
detach(), getObject() returns the second instance — i.e. it actually re-loads.
- After Java serialization round-trip, the previously-loaded instance is not reachable from the deserialized model.
Pins the contract that the LDM doesn't smuggle a snapshot into the page store.
2. WicketTester page-store round-trip (closest thing to F5 in a test)
WicketTester tester = new WicketTester(new WicketApplication());
// mock SpaceRepository.findById(...) to return a Space stub
tester.startPage(SpacePage.class, new PageParameters().set("id", "https://w3id.org/spaces/test"));
tester.assertRenderedPage(SpacePage.class);
Page p = tester.getLastRenderedPage();
byte[] bytes = SerializationUtils.serialize(p);
SpacePage restored = (SpacePage) SerializationUtils.deserialize(bytes);
// mutate the mocked Space's label, then detach + re-render and assert HTML reflects the *new* label
Higher cost (needs SpaceRepository / MaintainedResourceRepository stubbing — MockedStatic from Mockito works, see DownloadRdfPageTest.RetrieveResponseWithWaitTest for a pattern). But this is the test that would have caught the original regression behind #401.
3. SerializationCheckerObjectOutputStream smoke
Wicket ships a debug serialization checker that fails fast on non-serializable references in a page tree. Wire it up once in a test that constructs each touched page; catches accidental non-serializable captures (e.g. anonymous inner class holding a non-Serializable) at test time instead of runtime.
Priority
Medium. #1 and #3 are cheap and high-leverage. #2 has the highest fidelity but requires more scaffolding.
Follow-up to #456 (merged in PR #457).
PR #457 added two cheap guard tests: a render-strategy assertion in
WicketApplicationTest, and reflection-based field-architecture tests inSpacePageTest/MaintainedResourcePageTest. Three higher-fidelity tests were discussed but not added because they involve more setup. Filing here so we don't lose them.1. LDM serialization round-trip
Build a
LoadableDetachableModel<Space>exactly like the one inSpacePage, mockSpaceRepository.findByIdto return distinct objects across two calls, and assert:getObject()returns the first instance.detach(),getObject()returns the second instance — i.e. it actually re-loads.Pins the contract that the LDM doesn't smuggle a snapshot into the page store.
2. WicketTester page-store round-trip (closest thing to F5 in a test)
Higher cost (needs
SpaceRepository/MaintainedResourceRepositorystubbing —MockedStaticfrom Mockito works, seeDownloadRdfPageTest.RetrieveResponseWithWaitTestfor a pattern). But this is the test that would have caught the original regression behind #401.3. SerializationCheckerObjectOutputStream smoke
Wicket ships a debug serialization checker that fails fast on non-serializable references in a page tree. Wire it up once in a test that constructs each touched page; catches accidental non-serializable captures (e.g. anonymous inner class holding a non-Serializable) at test time instead of runtime.
Priority
Medium. #1 and #3 are cheap and high-leverage. #2 has the highest fidelity but requires more scaffolding.