Hi,

I am working on Seam Integration testing.

my simple java class

Stateful
@Name("catalogueMasterSearch")
@Scope(ScopeType.CONVERSATION)
public class CatalogueMasterSearchAction implements CatalogueMasterSearch{
@org.jboss.seam.annotations.Logger
        Log log;

        AuditLogger auditLog = AuditLogger.getLogger();
        
        @In(value = EprocConstants.Session.CURRENT_STAFF_INFO, scope = 
ScopeType.SESSION)
        StaffGeneralInfo staff;
        
        static final String CLIENT_MSG_ID = "pageMsg";
        
        static final String CLIENT_MSG_ID1 = "pageMsg1";

        @PersistenceContext(type = PersistenceContextType.EXTENDED)
        private EntityManager em;

        @In(create = true)
        FacesMessages facesMessages;

@Create 
        @Begin(join = true)
        public String create() {
}
@Destroy
        @Remove @End
        public void destroy() {
                
                log.info("--------- Destroy --> CatalogueMastarSearchAction ");
                
        }
public void searchItem() {
                log.info("--------- In Search --> CatalogueMastarSearchAction 
");

}


my test class




import javax.faces.model.DataModel;

import org.jboss.seam.Component;
import org.jboss.seam.ComponentType;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.contexts.Contexts;


import org.jboss.seam.mock.SeamTest;
import org.jboss.seam.mock.SeamTest.FacesRequest;
import org.jboss.seam.security.Identity;
import org.testng.annotations.Test;

import com.hp.eproc.action.catalogue.CatalogueMasterSearch;
import com.hp.eproc.action.catalogue.CatalogueMasterSearchAction;
import com.hp.eproc.action.catalogue.ItemSearch;
import com.hp.eproc.security.Authenticator;


/* 
 * © Copyright 2006
 * Consulting & Integration
 * Hewlett-Packard India
 */

/**
 * @author mreddy - Apr 18, 2008
 */
public class CatalogueMasterSearchActionTest extends BaseTest{
         
                
        @Test
           public void testSearchItem() throws Exception
           {
                
                CatalogueMasterSearchAction catalogueMasterSearch;
                 new Script()
              {
                 
                         @Override
                 protected void invokeApplication() throws Exception
                 {
                                 
Contexts.getConversationContext().set("itemSearch;", new ItemSearch());
                 }
                 
              }.run();
                
             new Script("/jsf/catalogue/rate_master.xhtml") {
                        
                        @Override
                        protected void invokeApplication() throws Exception {
                                CatalogueMasterSearch 
catalogueMasterSearch=(CatalogueMasterSearch)Component.getInstance("catalogueMasterSearch");
                                
invokeMethod("#{catalogueMasterSearch.searchItem}");
                        }
                
        @Override
        protected void renderResponse() throws Exception {
                 DataModel itemRateList = (DataModel) 
Contexts.getSessionContext().get("itemRateContractList");
             assert itemRateList.getRowCount()>=1;
        }
                
                }.run();
                
                        
           }
        
}


when i am executing my test class, i am getting nullpointer exception
bcz Component.getInstance() returning null.

when seam component life cycle starts, how to start programatically?
any idea please help me
-------------------------------------------------------------------------
DEBUG [main] (Events.java:57) - Processing 
event:org.jboss.seam.postDestroyContext.APPLICATION
FAILED: testSearchItem
javax.el.PropertyNotFoundException: Target Unreachable, identifier 
'catalogueMasterSearch' resolved to null
        at com.sun.el.parser.AstValue.getTarget(AstValue.java:66)
        at com.sun.el.parser.AstValue.invoke(AstValue.java:147)
        at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
        at 
org.jboss.seam.util.UnifiedELMethodBinding.invoke(UnifiedELMethodBinding.java:36)
        at 
org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
        at 
org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
        at 
org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
        at 
org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
        at org.jboss.seam.mock.SeamTest$Request.invokeMethod(SeamTest.java:401)
        at 
com.hp.eproc.test.CatalogueMasterSearchActionTest$2.invokeApplication(CatalogueMasterSearchActionTest.java:59)
        at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:489)
        at 
com.hp.eproc.test.CatalogueMasterSearchActionTest.testSearchItem(CatalogueMasterSearchActionTest.java:68)
... Removed 22 stack frames

===============================================
    com.hp.eproc.test.CatalogueMasterSearchActionTest
    Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
eprocurement
Total tests run: 1, Failures: 1, Skips: 0
===============================================



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4150078#4150078

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4150078

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

Reply via email to