4 Replies Latest reply on Dec 9, 2010 7:08 PM by senthilnz

    Target Unreachable in Seam Integration Test

    boopet

      Hi, i am just trying to test some components as described in the documentation using a FacesRequest:


      ...
                new FacesRequest() {
      
                     @Override
                     protected void updateModelValues() throws Exception {
                          
                          setValue("#{QAdsUser.firstName}", "Georg");
      }
                     
      ...
      



      but i am always getting this exception:


      java.lang.AssertionError: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'QAdsUser' resolved to null
           at org.jboss.seam.mock.BaseSeamTest$Request.onException(BaseSeamTest.java:488)
           at org.jboss.seam.mock.BaseSeamTest$Request$2.doFilter(BaseSeamTest.java:537)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:524)
           at de.luminea.qads.service.UserServiceIntegrationTest.testCreateUser(UserServiceIntegrationTest.java:91)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
           at org.testng.internal.Invoker.invokeMethod(Invoker.java:478)
           at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:607)
           at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:874)
           at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
           at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
           at org.testng.TestRunner.runWorkers(TestRunner.java:689)
           at org.testng.TestRunner.privateRun(TestRunner.java:566)
           at org.testng.TestRunner.run(TestRunner.java:466)
           at org.testng.SuiteRunner.runTest(SuiteRunner.java:301)
           at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296)
           at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276)
           at org.testng.SuiteRunner.run(SuiteRunner.java:191)
           at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
           at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
           at org.testng.TestNG.run(TestNG.java:701)
           at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
           at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
      Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'QAdsUser' resolved to null
           at org.jboss.el.parser.AstValue.getTarget(AstValue.java:38)
           at org.jboss.el.parser.AstValue.setValue(AstValue.java:83)
           at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
           at org.jboss.seam.mock.BaseSeamTest$Request.setValue(BaseSeamTest.java:463)
           at de.luminea.qads.service.UserServiceIntegrationTest$1.updateModelValues(UserServiceIntegrationTest.java:67)
           at org.jboss.seam.mock.BaseSeamTest$Request.updateModelValuesPhase(BaseSeamTest.java:684)
           at org.jboss.seam.mock.BaseSeamTest$Request.emulateJsfLifecycle(BaseSeamTest.java:606)
           at org.jboss.seam.mock.BaseSeamTest$Request.access$300(BaseSeamTest.java:184)
           at org.jboss.seam.mock.BaseSeamTest$Request$2.doFilter(BaseSeamTest.java:530)
           ... 36 more
      
      



      The entity bean is annotated correctly:


      @Name("QAdsUser")
      



      What could be wrong?


        • 1. Re: Target Unreachable in Seam Integration Test
          hasan_muhstaq

          Are your beans properly loaded at the start of your tests? If your log is properly configured you should see something like this:


          INFO  [org.jboss.ejb3.MCKernelAbstraction]      Class:com.toto.session.BeanNameInterface
          INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: com.toto.session.DocumentManagerBean ejbName: BeanNameImplementation



          • 2. Re: Target Unreachable in Seam Integration Test
            boopet

            i cant really check this. since seam 2 i dont get any output in the console when the embedded container is starting up inside the SeamTest.


            is there a way to see the output?

            • 3. Re: Target Unreachable in Seam Integration Test
              boopet

              ok i solved the problem now:
              to see the full trace of the embedded container i needed to change the log4j severity in the /bootstrap log4j.xml.


              the problem was that i didnt run the ant target compiletest before running the testng testcase with the eclipse plugin.


              now it works :)

              • 4. Re: Target Unreachable in Seam Integration Test
                senthilnz
                Hi,

                I have this below code,

                public class AuthenticatorBeanTest extends SeamTest{

                        @Test
                           public void testLoginComponent() throws Exception
                           {
                              new ComponentTest() {

                                 @Override
                                 protected void testComponents() throws Exception
                                 {
                                         assert getValue("#{identity.loggedIn}").equals(false);
                                     setValue("#{identity.username}", "simplerun");
                                     setValue("#{identity.password}", "changepwd");
                                     invokeMethod("#{identity.login}");

                                 }
                                
                              }.run();
                           }
                               
                           @Test
                           public void testBookHotel() throws Exception
                           {

                             
                              //@Test
                            new FacesRequest("/customer/filter.xhtml") {
                               
                                @Override
                                protected void updateModelValues() throws Exception
                                {

                                    setValue("#{customerManager.filter.name}", "testingName");
                                }
                       
                                @Override
                                protected void invokeApplication()
                                {
                                   assert invokeAction("#{customerManager.loadResultList}")==null;
                                }
                       
                                @Override
                                protected void renderResponse()
                                {
                                   DataModel hotels = (DataModel) Contexts.getSessionContext().get("booking");
                                   assert hotels.getRowCount()==1;
                                   assert getValue("#{bookingManager.getResultList}").equals("");
                                   assert !Manager.instance().isLongRunningConversation();
                                }
                               
                             }.run();
                        }


                }

                The filter.xhtml is located under folder of view/customer/filter.xhtml with the following below code,

                <rich:simpleTogglePanel xmlns="http://www.w3.org/1999/xhtml"
                        xmlns:s="http://jboss.com/products/seam/taglib"
                        xmlns:ui="http://java.sun.com/jsf/facelets"
                        xmlns:f="http://java.sun.com/jsf/core"
                        xmlns:h="http://java.sun.com/jsf/html"
                        xmlns:rich="http://richfaces.org/rich"
                        xmlns:a4j="http://richfaces.org/a4j" label="Customer Filter" opened="true" switchType="client">

                        <h:form id="form_filter" >
                       
                        <table>
                        <tr>
                        <td><h:outputLabel value="Customer Surname:" /></td>
                        <td>
                                <h:inputText value="#{customerManager.filter.name}" />
                        </td>
                         <td><a4j:commandButton action="#{customerManager.loadResultList()}" reRender="list_customer" value="Search" style="margin-bottom: 4px;" /></td>
                        <td><a4j:commandButton action="#{customerManager.resetFilter()}" reRender="list_customer,form_filter" value="Reset" style="margin-bottom: 4px;" />
                         </td>
                        </tr>
                        </table>
                       
                </h:form>

                </rich:simpleTogglePanel>



                Where my testLoginComponent is working but the testBookHotel is not working and it throws the below exception,

                java.lang.AssertionError: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'customerManager' resolved to null
                        at org.jboss.seam.mock.AbstractSeamTest$Request.onException(AbstractSeamTest.java:455)
                        at org.jboss.seam.mock.AbstractSeamTest$Request$2.doFilter(AbstractSeamTest.java:504)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                        at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

                Can anyone help me please, I already spent two days on this but no breakthrough.

                Thanks in advance!

                Regards,
                Senthil