8 Replies Latest reply on Aug 21, 2007 7:10 AM by Pete Muir

    Seam Email and Embeddedable EJB3 for testing

    Bradley Smith Master

      hello,

      I've been trying to run a SeamTest that sends email using the Seam 1.1.6 email and the Alpha9 Embeddable EJB3 container. I get the following exception each time it tries to render:

      test_sendSeamEmailMessage Time elapsed: 0.422 sec <<< FAILURE!
      javax.ejb.EJBException: org.jboss.seam.RequiredException: In attribute requires value for component: mailSenderBean.rend
      erer
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:211)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
       at $Proxy114.sendSeamEmail(Unknown Source)
       at com.evergreen.accesscontrol.MailSender$$FastClassByCGLIB$$8991d937.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:74)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
       at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
       at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
       at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:83)
       at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:52)
       at org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$e67f1e35.sendSeamEmail(<generated>)
       at com.evergreen.accesscontrol.MailSenderBeanTest$2.invokeApplication(MailSenderBeanTest.java:126)
       at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:478)
       at com.evergreen.accesscontrol.MailSenderBeanTest.test_sendSeamEmailMessage(MailSenderBeanTest.java:114)
      


      Does anyone have a suggestion for how I can make the embeddable resolve that reference to the renderer?

       @In(create = true)
       private Renderer renderer;
      


      Is it possible? and the SeamTest I am running is a FacesRequest.

      Thanks,
      Brad Smith

        • 1. Re: Seam Email and Embeddedable EJB3 for testing
          Gavin King Master

          You would need to make sure you have facelets in your classpath.

          • 2. Re: Seam Email and Embeddedable EJB3 for testing
            Bradley Smith Master

            I made sure facelets is in my testing classpath. Now it looks like MockRenderKit doesn't want to play along...

            12:13:08,170 ERROR com.evergreen.accesscontrol.impl.MailSenderBean.(error:119) - java.lang.UnsupportedOperationException
            
            java.lang.UnsupportedOperationException
             at org.jboss.seam.mock.MockRenderKit.createResponseWriter(MockRenderKit.java:34)
             at org.jboss.seam.ui.facelet.FaceletsRenderer.wrapResponseWriter(FaceletsRenderer.java:95)
             at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:52)
             at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:38)
             at com.evergreen.accesscontrol.impl.MailSenderBean.sendSeamEmail(MailSenderBean.java:165)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:121)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:110)
             at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
             at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:37)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
             at org.jboss.seam.interceptors.BijectionInterceptor.bijectNonreentrantComponent(BijectionInterceptor.java:79)
             at org.jboss.seam.interceptors.BijectionInterceptor.bijectComponent(BijectionInterceptor.java:58)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
             at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
             at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
             at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
             at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor
            .java:52)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
             at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
             at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
             at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
             at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
             at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
             at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
             at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
             at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerIntercep
            tor.java:54)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
             at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
             at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:211)
             at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
             at $Proxy114.sendSeamEmail(Unknown Source)
             at com.evergreen.accesscontrol.MailSender$$FastClassByCGLIB$$8991d937.invoke(<generated>)
             at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
             at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
             at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:74)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
             at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
             at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
             at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
             at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:83)
             at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:52)
             at com.evergreen.accesscontrol.MailSender$$EnhancerByCGLIB$$210ec914.sendSeamEmail(<generated>)
             at com.evergreen.accesscontrol.MailSenderBeanTest$2.invokeApplication(MailSenderBeanTest.java:126)
             at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:478)
             at com.evergreen.accesscontrol.MailSenderBeanTest.test_sendSeamEmailMessage(MailSenderBeanTest.java:114)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
             at org.testng.internal.Invoker.invokeMethod(Invoker.java:407)
             at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:778)
             at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
             at org.testng.TestRunner.privateRun(TestRunner.java:682)
             at org.testng.TestRunner.run(TestRunner.java:566)
             at org.testng.SuiteRunner.privateRun(SuiteRunner.java:220)
             at org.testng.SuiteRunner.run(SuiteRunner.java:146)
             at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:713)
             at org.testng.TestNG.runSuitesLocally(TestNG.java:676)
             at org.apache.maven.surefire.testng.TestNGExecutor.executeTestNG(TestNGExecutor.java:64)
             at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
             at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
             at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
            



            • 3. Re: Seam Email and Embeddedable EJB3 for testing
              Gavin King Master

              OK, I committed a mock response writer to CVS for you guys. Caveats:

              (1) I did not test this at all, please let me know if I screwed up
              (2) It does not actually *do* anything ... if you wanted to get an actual email out the end, then I need you guys to contribute a patch to MockResponseWriter that actually does stuff. What is there is hopefully enough that your integration tests don't just crap out.
              (3) There are breaking changes to the FacesMessage component - you may need to migrate some code to the new API, depending upon which APIs you were using previously (yes, of course I would prefer deprecation, but that was not going to solve the "ambiguous overload" problem we had).

              • 4. Re: Seam Email and Embeddedable EJB3 for testing
                RefuX Zanzeebarr Newbie

                I'm writing a similar integration test.
                However I'm running into a different issue (user error no doubt!).

                Using Seam 1.2.1GA.

                So I have a MailService component that has a line like this

                @In(create = true)
                private Renderer renderer;
                


                In my test I'm doing this:
                 new FacesRequest() {
                 protected void invokeApplication() throws Exception {
                 MailService mailService = (MailService) Component.getInstance("mailService", true);
                
                 mailService.send("view/emailLoggedIn.xhtml");
                 }
                 }.run();
                


                Unfortunately the MockRenderKit never seems to come into play for me. My error is:

                [testng] FAILED: testIfWeCanRender
                [testng] java.lang.UnsupportedOperationException
                [testng] at org.jboss.seam.mock.MockApplication.createComponent(MockApplication.java:154)
                [testng] at org.jboss.seam.jsf.SeamApplication11.createComponent(SeamApplication11.java:71)
                [testng] at com.sun.facelets.tag.jsf.ComponentHandler.createComponent(ComponentHandler.java:243)
                [testng] at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:139)
                [testng] at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
                [testng] at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
                [testng] at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
                [testng] at org.jboss.seam.ui.facelet.FaceletsRenderer.renderFacelet(FaceletsRenderer.java:149)
                [testng] at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:112)
                [testng] at refux.service.impl.MailServiceImpl.send(MailServiceImpl.java:41)
                [testng] at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
                [testng] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                [testng] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
                [testng] at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
                [testng] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
                [testng] at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
                [testng] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
                [testng] at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
                [testng] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
                [testng] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
                [testng] at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
                [testng] at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
                [testng] at refux.service.impl.MailServiceImpl_$$_javassist_0.send(MailServiceImpl_$$_javassist_0.java)
                [testng] at refux.service.impl.MailServiceImplTest_Integration$1.invokeApplication(MailServiceImplTest_Integration.java:44)
                [testng] at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:489)
                [testng] at refux.service.impl.MailServiceImplTest_Integration.testIfWeCanRender(MailServiceImplTest_Integration.java:37)
                [testng] ... Removed 26 stack frames


                Thanks for any help!

                • 5. Re: Seam Email and Embeddedable EJB3 for testing
                  Chris Lowe Apprentice

                  If memory serves, I don't think you can completely send an e-mail since the Facelet renderer is not created under the mock environment. Try out my mock object suggestion at the end of this post:

                  http://www.jboss.com/index.html?module=bb&op=viewtopic&t=108860

                  I hope this helps.

                  Chris.

                  • 6. Re: Seam Email and Embeddedable EJB3 for testing
                    Pete Muir Master

                    You can't correctly integration test Seam Mail at the moment, because, as Chris says, there is no way to redirect the rendered output to mock object. I think to do this properly we would need to mock out the JavaMail session and allow you to redirect where the rendererd emails were sent (i.e. to an in memory object perhaps). You can create a feature request in JIRA for this and see how popular it is.

                    • 7. Re: Seam Email and Embeddedable EJB3 for testing
                      Alexander Torstling Newbie

                       

                      "pete.muir@jboss.org" wrote:
                      You can't correctly integration test Seam Mail at the moment, because, as Chris says, there is no way to redirect the rendered output to mock object. I think to do this properly we would need to mock out the JavaMail session and allow you to redirect where the rendererd emails were sent (i.e. to an in memory object perhaps). You can create a feature request in JIRA for this and see how popular it is.


                      I know that this might not be considered the best solution, and I haven't tried
                      it, but for people who are impatient, I beleive that Wiser might work:

                      http://subethasmtp.tigris.org/wiser.html