[ 
https://jira.jboss.org/browse/JBSEAM-4728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12565004#comment-12565004
 ] 

Flavio Costa commented on JBSEAM-4728:
--------------------------------------

Adding one more thing, I don't think that using 2.2.1.CR2 will fix anything 
since I don't see any change to this part of the code between the two versions.

If someone can come up with an ideia on how to solve this I can try to 
implement with a patch.

I know SeamTest has a getRenderedMail() but it doesn't accomplish what I need 
(maybe I'm missing something...)

> NPE involving o.j.s.mock.AbstractSeamTest.Request.init() and 
> o.j.s.ui.facelet.RendererRequest.cleanup()
> -------------------------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-4728
>                 URL: https://jira.jboss.org/browse/JBSEAM-4728
>             Project: Seam
>          Issue Type: Bug
>          Components: Mail, Test Harness
>    Affects Versions: 2.2.0.GA
>         Environment: java version "1.6.0_22"
> Seam 2.2.0.GA
>            Reporter: Flavio Costa
>            Assignee: Pete Muir
>              Labels: faces, mail, mock, seam, wiser
>
> I'm trying to come up with a solution to integrate Wiser 
> (http://code.google.com/p/subethasmtp/wiki/Wiser) and Seam Mail (so that I 
> can create tests asserting that the e-mail is actually sent) but I stumbled 
> into a problem.
> Seam Mail uses the "o.j.s.ui.facelet.RendererRequest" which sets up some mock 
> objects to be able to render a XHTML in a String and send the e-mail.
> This works fine in production, I can call it several times during a single 
> request. It works like a charm.
> The problems happens when trying to test the given method using SeamTest and 
> its infrastructure.
> What happens is, during o.j.s.mock.AbstractSeamTest.Request.init() it creates 
> a new MockFacesContext and saves it so that whenever you call 
> FacesContext.getInstance() or MockFacesContextFactory.getFacesContext() this 
> same instance will be returned.
> That's ok... for now.
> Things get messier now.
> Below code is extracted from RendererRequest.init()
>       .....
>       originalFacesContext = FacesContext.getCurrentInstance();
>       facesContext = 
> RendererFacesContextFactory.instance().getFacesContext(request, response);
>       ....
> Problem here is that, due to AbstractSeamTest.Request.init() 
> 'originalFacesContext == facesContext' and when RendererRequest.cleanup() is 
> eventually called 'facesContext.release()' what happens is:
> (Extracted from MockFacesContext.release())
>       setCurrentInstance(null);
>       MockFacesContextFactory.setFacesContext(null);
> The next time someone calls MockFacesContext.getInstance() or 
> MockFacesContextFactory.getFacesContext() they will return null and 
> eventually this will result in a NPE.
> Which is exactly what happens with me due to the fact that I call 
> "Renderer.instance().render("mail.xhtml")" multiple times inside a method. 

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
seam-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-issues

Reply via email to