faces icon indicating copy to clipboard operation
faces copied to clipboard

TCK Challenge: Application API GetSetViewHanderTest doesn't accommodate ViewHandlerWrappers

Open brideck opened this issue 2 years ago • 2 comments

Challenged Tests: com.sun.ts.tests.jsf.api.jakarta_faces.application.application.URLClient#applicationGetSetViewHandlerTest com.sun.ts.tests.jsf.api.jakarta_faces.application,applicationwrapper.URLClient#applicationWrapperGetSetViewHandlerTest

TCK Version: Jakarta Faces 4.0.x

Tested Implementation: Open Liberty -- containing MyFaces 4.0

Description: These are both preexisting tests from the Platform TCK that now run differently in Faces 4.0 due to the metadata changes made to involve CDI in the testing performed in the TCK. The tests set a ViewHandler through the appropriate API and then call the corresponding get method. They then check to see if the object received from the get is the same as the one that was just set.

This seems reasonable on its face, but it fails to account for the fact that an implementation might choose to wrap the ViewHandler in another object to make it CDI aware. Open Liberty does this by using a wrapper for the ViewHandler that extends org.jboss.weld.jsf.ConversationAwareViewHandler when CDI is enabled in the server.

The Javadoc for the API under test states that these methods are to set and get "the ViewHandler instance that will be utilized during the Restore View and Render Response phases of the request processing lifecycle." These methods do indeed do as required, as this instance is used in those phases, but they enhance the functionality of what the user provides in an appropriate manner.

brideck avatar Nov 18 '22 18:11 brideck

The test could be updated to handle this case by using getWrapped to ensure that the wrapped class is indeed what the test set. @volosied will have a PR showing how this could be done shortly.

brideck avatar Nov 18 '22 18:11 brideck

Commit with a potential fix : https://github.com/jakartaee/faces/commit/5e47009fc1cae30e52583981454c7567e2bffc42

Note: I haven't tested this change locally yet as I've encountered unrelated TCK build errors.

volosied avatar Nov 18 '22 20:11 volosied

Note that this check in face of an implementation wrapping is something that also theoretically happens for similar tests for jakarta.faces.application.Application#getExpressionFactory().

arjantijms avatar Nov 24 '22 22:11 arjantijms

@volosied

java } else if(resolver instanceof ViewHandlerWrapper && ((ViewHandlerWrapper)resolver).getWrapped().equals(tckHandler)){ matches = true; }

We can start with that, though ultimately maybe we should unwrap in a loop? As nothing forbids a single wrapping, technically nothing would prevent multiple wrappings either.

arjantijms avatar Nov 24 '22 22:11 arjantijms

Commit with a potential fix : https://github.com/jakartaee/faces/commit/5e47009fc1cae30e52583981454c7567e2bffc42

Ps, where was the commit done? Would be best to make it a PR instead.

arjantijms avatar Nov 24 '22 22:11 arjantijms

Sure, I'll update my commit and make a PR instead. Thanks!

volosied avatar Nov 25 '22 15:11 volosied

@arjantijms @brideck I've created the PR 1744

volosied avatar Nov 28 '22 21:11 volosied