[JBoss Seam] - injection in tests ?
by berkay
Hi.
Want to test my action classes with hibernateSession instead of EntityManager and my actions like below..
@In(create=true)
| private Session hibernateSession;
|
| @Out @In(required=false)
| Category category;
|
| public String save(){
| //bla bla
| hibernateSession.saveOrUpdate(category);
| hibernateSession.flush();
| return "success";
| }
when i want to test this action with testNG, hibernate session doesnt initialize..
@Test
| public void testAddCategory() throws Exception {
| Category cat = new Category();
| cat.setName("test");
| CategoryAction action = new CategoryAction();
| action.setCategory(cat);
| //
| assert "categoryTree".equals(action.save());//throws nullpointer because of the not initialized hibernate session
| }
and according to me seam doesn't works while testing because Logger and In annotation doesnt works either..
All the examples are about EntityManagerFactory & EntityManager..
How can i find a solution for this test case with hibernate session ??
thanx.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115864#4115864
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115864
17 years
[JBoss Seam] - State of Injected Objects in a Conversation
by neilac333
I have a SearchAction class (ScopeType.CONVERSATION) which has its properties bound to the user interface (for such things as "name" and "key words" to search on) and passes these off to a class called Finder that actually does the search and returns the results to SearchAction to pass back to the client. Essentially, when I call searchAction.setName(), for example, that calls finder.setName() with the same value. An instance of Finder is injected into SearchAction with @In(create = true).
Here is where things get interesting--at least to me. I am running a SeamTest where I am testing the operation of SearchAction between between faces requests, and it is using a mock implementation of Finder. In the first request, searchAction.setName() is called, which as mentioned calls finder.setName() with the same given value. The funny thing is that in the next request, finder.getName(), which once had the given value, is now null.
I have tried applying @Out to the Finder instance within SearchAction to no avail. I applied ScopeType.CONVERSATION to the mock Finder class to no avail.
The question then is how I maintain the state between faces requests for this Finder object injected into SearchAction.
Please let me know if I need to be more clear. Thanks for any insight.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115863#4115863
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115863
17 years
[JBoss jBPM] - Re: number of swimlanes retrieved by taskMgmntInstance.getSw
by Marc321a
Hi Anuragpaliwal,
Here is the processdefinition. The loggingActionHandlers report
1 swimlane, 2 swimlanes, 2 swimlanes. They are also called when the application starts, then they report swimlanes = null.
thx,
Marc
| <?xml version="1.0" encoding="UTF-8"?>
| <!-- jBPM process definition for syfact. Created with
| jBPM eclipse plugin, Eclipse 3.3.0 and jBPM JPDL 3.2.2.-->
|
| <process-definition xmlns="urn:jbpm.org:jpdl-3.2"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://docs.jboss.org/jbpm/xsd/jpdl-3.2.xsd"
| name="reassign-dossier-processdefinition">
|
| <swimlane name="initialUser">
| <assignment config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy">
| <targetBean>currentUserAssignmentHandler</targetBean>
| </assignment>
| </swimlane>
|
| <swimlane name="investigator">
| <assignment config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy">
| <targetBean>currentUserAssignmentHandler</targetBean>
| </assignment>
| </swimlane>
|
| <swimlane name="assignedUser">
| <assignment class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>usernameInContextAssignmentHandler_AssignedUser</targetBean>
| </assignment>
| </swimlane>
|
| <start-state name="start">
| <transition name="" to="Reassign dossier for first user"></transition>
| </start-state>
| <task-node name="Reassign dossier for first user">
| <event type="node-enter">
| <action class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>loggingActionHandler</targetBean>
| </action>
| </event>
| <task name="Reassign dossier" blocking="true" swimlane="initialUser">
| <event type="task-assign">
| <action name="Put first users username in context"
| class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>putUsernameInContextActionHandler_Investigator</targetBean>
| </action>
| </event>
| <controller>
| <variable name="comment" access=",write,required" mapped-name="Comment:STRING"></variable>
| <variable name="assignedUsername" access=",write,required" mapped-name="username:STRING"></variable>
| </controller>
| </task>
| <transition name="" to="Accept dossier"></transition>
| </task-node>
| <task-node name="Accept dossier">
| <event type="node-enter">
| <action class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>copyInvestigatorToAssigningUsername</targetBean>
| </action>
| <action class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>loggingActionHandler</targetBean>
| </action>
| </event>
| <task name="Accept dossier" blocking="true" swimlane="assignedUser">
| <controller>
| <variable name="comment" access="read" mapped-name="Comment:STRING"></variable>
| <variable name="acceptDossier" access="read,write,required"
| mapped-name="Accept dossier:BOOL"></variable>
| </controller>
| </task>
| <transition name="" to="Decision for Accept dossier">
| <action class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>loggingActionHandler</targetBean>
| </action>
| <action class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>copyAssignedUsernameToInvestigatorIfDossierAccepted</targetBean>
| </action>
| </transition>
| </task-node>
| <decision name="Decision for Accept dossier">
| <transition name="Reject dossier" to="Reassign dossier for subsequent users">
| <condition>#{not acceptDossier}</condition>
| <action name="Notify assigning user of rejection" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy"
| config-type="bean">
| <targetBean>notifyAssigningUserActionHandler_Rejection</targetBean>
| </action>
| </transition>
| <transition name="Accept dossier" to="Reassign dossier for subsequent users">
| <condition>#{acceptDossier}</condition>
| <action class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>reassignDossierActionHandler</targetBean>
| </action>
| <action class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>reassignDossierActionHandler</targetBean>
| </action>
| <action name="Notify assigning user of acceptance"
| class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy">
| <targetBean>notifyAssigningUserActionHandler_Acceptance</targetBean>
| </action>
| </transition>
| </decision>
|
| <task-node name="Reassign dossier for subsequent users">
| <task name="Reassign dossier" blocking="true" swimlane="investigator">
| <event type="task-start">
| <action class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
| <targetBean>reassignDossierActionHandler</targetBean>
| </action>
| </event>
| <controller>
| <variable name="comment" access=",write,required" mapped-name="Comment:STRING"></variable>
| <variable name="assignedUsername" access=",write,required" mapped-name="username:STRING"></variable>
| </controller>
| </task>
| <transition name="" to="Accept dossier"></transition>
| </task-node>
|
| </process-definition>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115862#4115862
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115862
17 years