[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
This is the part of my bean: @Name("register") | @Stateful | @Scope(ScopeType.CONVERSATION) | public class RegisterBean extends Controller implements IRegister { | | private static final long serialVersionUID = 7559006461204534425L; | | @PersistenceContext(type = PersistenceContextType.EXTENDED) | private EntityManager em; | | /** | * @see de.llynch.kingpin.IRegister#begin() | */ | @Begin(join = true, pageflow = "register") | public void begin() { | } | | This is the testcase (I'm using JUnit): /** | * @throws Exception | */ | @Test | @SuppressWarnings("synthetic-access") | public void testRegister() throws Exception { | String id = new NonFacesRequest("/public/register.xhtml") { | | @Override | protected void renderResponse() throws Exception { | invokeMethod("#{register.begin}"); | Pageflow pageflow = Pageflow.instance(); | assertEquals("register", pageflow.getNode().getName()); | assertTrue(isLongRunningConversation()); | assertEquals("/public/register.xhtml", getRenderedViewId()); | } | | }.run(); | | id = new FacesRequest("/public/register.xhtml", id) { | | @Override | protected void invokeApplication() throws Exception { | Pageflow pageflow = Pageflow.instance(); | pageflow.navigate(getFacesContext(), "next"); | assertEquals("confirm", pageflow.getNode().getName()); | } | | @Override | protected void renderResponse() throws Exception { | assertEquals("/public/confirm.xhtml", getViewId()); | assertTrue(isLongRunningConversation()); | } | | }.run(); | | id = new FacesRequest("/public/confirm.xhtml", id) { | | @Override | protected void invokeApplication() throws Exception { | Pageflow pageflow = Pageflow.instance(); | assertTrue(pageflow.isInProcess()); | assertEquals("confirm", pageflow.getNode().getName()); | pageflow.navigate(getFacesContext(), "next"); | assertEquals("invite", pageflow.getNode().getName()); | } | | @Override | protected void renderResponse() throws Exception { | assertEquals("/public/secure/invite.xhtml", getViewId()); | assertFalse(isLongRunningConversation()); | } | | }.run(); | } | | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4058148#4058148 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4058148 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
OK. You had put a comment on the pageflow-defintion.xml as it's not legal. I am using start-page to start my pageflow. So where i need to put the start node. I am starting my pageflow using the page rather than the start-state. | | | | | | | Also there is one concern. As i am moving from the page2 to page 3. Say the conversation id it shows is 1 but when it is on page3 the conversation-id changed to 2 and it remains the same for the subsequent flow. If i am on a same pageflow the conversation id should remain the same for back-forth flow navigation.But it gets changed when it moves from page2 to page3. | http://jboss.com/products/seam/pageflow"; | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; | xsi:schemaLocation= | "http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-1.2.xsd"; | name="pageflow1"> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also there are method in the Jbpm class in the seam. | getPageflowDefinitionFromResource(String resourceName) | getPageflowDefinitionFromXml(String pageflowDefinition) | getPageflowProcessDefinition(String pageflowName) | getProcessDefinitionFromResource(String resourceName) | How to get the pageflow definition.xml using these methods. I tried these methods but in vain. May be i m following the wrong path. Do you have any idea? Can you post your bean where you used the @Begin annotated method to start the pageflow ? Thanx View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4058106#4058106 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4058106 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
I have no idea what your use case is and no idea how to you solve your problem, but it does not sound like a unit test to me. If you want to create a unit test, extend your testclass from SeamTest which will boostrap an embedded container and the seam environment. Then do as I posted above and you have your pageflow running. With just Pageflow.instance() you don't start any pageflow. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057998#4057998 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057998 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
Ok. Let me clear my requirement for this pageflow. Here is somewhat i am trying to do. | public class Test{ | | public test() throws Exception{ | | | PageFlow pageflow = PageFlow.Instance(); <---Start the pageflow here---> | | And using this pageflow object i want to extract the view id of the current page and the next page to it. | } | | public static void main(String[] args){ | Test test1= new Test(); | test1.test(); | } | this is the idea..Whatever the pageflow is defined in the pageflow-definition.xml , I am able to find out the current page,current view id and all the related info. in a java file so that the method in it is accessible to the other class...In short i want this java class as a utility to fit into my application. Thanx, View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057996#4057996 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057996 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
Do use TestNG or JUnit for testing. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057988#4057988 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057988 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
hi Can we do this unit testing using simple public static void main(). ? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057968#4057968 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057968 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
String id = new NonFacesRequest("/public/register.xhtml") { | | @Override | protected void renderResponse() throws Exception { | Contexts.getSessionContext().set("person", new Person()); | invokeMethod("#{register.begin}"); // <-- This is my pageflow start method annoted with @Begin(...) | Pageflow pageflow = Pageflow.instance(); | assertEquals("register", pageflow.getNode().getName()); | assertTrue(isLongRunningConversation()); | assertEquals("/public/register.xhtml", getRenderedViewId()); | } | | }.run(); | | ... next FacesRequest... | | @Override | protected void invokeApplication() throws Exception { | Pageflow pageflow = Pageflow.instance(); | pageflow.navigate(getFacesContext(), "next"); | assertEquals("confirm", pageflow.getNode().getName()); | } | | | As you can see, I'll never start the pageflow directly. I'm using the annotations to start Converstation and seam automatically start my pageflow. As you further can see in subsequent requests I'll to the transition from node to node with calling pageflow.navigate(...) with my transition name I want to trigger. I hope this does help you. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057583#4057583 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057583 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
I would think as for me your pages.xml isn't processed. Therefore you need a method in your beans annotated with @Begin(join=true, pageflow="name"). This method should be called when you start your unit test in a NonFacesRequest instance. That should be all to get you running. I'll post my code later on when I'm at office. BTW: | | | | | This does not look leagal to be, since you do not define a node 'start' in your jpdl. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057564#4057564 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057564 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
Sorry for the last post as the code isn't displayed properly. Here it is submit2.jpdl.xml | | http://jboss.com/products/seam/pageflow"; | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; | xsi:schemaLocation= | "http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-1.2.xsd"; | name="submit2"> | | | | | | | | | | | | | | | | | | | | | | | | | | Can you tell me how to read this xml . Is it read internally by the seam? I had made the entry in pages.xml | | http://jboss.com/products/seam/pages-1.2.dtd";> | | | | | | | | | | | | | | Can you provide the sample test code for this submit2.jpdl.xml Here i need to find out the current page,current node and the next page. I tried like the jbpm way to read the submit2.jpdl.xml but with no result. | | ProcessDefinition pageflowDefinition =Jbpm.instance().getPageflowProcessDefinition("submit2"); | | Can anybody provide the sample test code for that. i m in urgency.. thanks, View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057550#4057550 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057550 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
@ knisterPeter hi i am getting the same problem. I'm also making a test class for the pageflow.Its a simple pageflow-definition Code : http://jboss.com/products/seam/pageflow"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation= "http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-1.2.xsd"; name="submit2"> Here is pages.xml Code: http://jboss.com/products/seam/pages-1.2.dtd";> I'm getting the error while doing the Pageflow.instance().begin() My converstaion gets start when i am on page3.jspx while i am starting the pageflow from the page.jspx. I am only making the simple java file rather than the junit test case. My purpose is to extract the CurrentPage and the NextPage. Could you provide the sample test code for this pageflow. Thanks, View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057548#4057548 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057548 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
Nope, the phase listener is registered and called, but I don't see the method call to afterRestoreView(). View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057371#4057371 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057371 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
Possibly this is caused by missing AbstractSeamJsfListener or ContextFilter, since test cases are not executing inside of a webapp. But both classes above call 'handleConversationPropagation' where the pageflow is validated and the conversation is restored (but I'm a noob to seam). View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057369#4057369 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057369 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
Since JBSEAM-1000 does not allow be to post a comment on this I'll do this here: Here is a part of my logfile related to this problem: [DEBUG] 15:43:42.965 jsf.SeamPhaseListener - after phase: RESTORE_VIEW 1 | [DEBUG] 15:43:42.965 core.Events - Processing event:org.jboss.seam.afterPhase | [DEBUG] 15:43:42.966 core.Manager- No stored conversation, or concurrent call to the stored conversation | [DEBUG] 15:43:42.968 core.Events - Processing event:org.jboss.seam.preSetVariable.org.jboss.seam.core.pageflow | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057355#4057355 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057355 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
If, as Denis says, that bug exists, then it's not going to work! View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057349#4057349 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057349 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
BTW: Here is my pageflow definition: | http://jboss.com/products/seam/pageflow"; | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; | xsi:schemaLocation="http://jboss.com/products/seam/pageflow pageflow-1.2.xsd" | name="register"> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057345#4057345 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057345 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
The pageflow testing does not work for me. On subsequent requests the pageflow is lost and set to null. Below is my code. Anyone can give me a hint on how to do this the correct way? There are no examples in seam releases or even cvs. String id = new NonFacesRequest("/public/register.xhtml") { | | @Override | protected void beforeRequest() { | setParameter("c", "1"); | } | | @Override | protected void renderResponse() throws Exception { | Contexts.getSessionContext().set("person", new Person()); | Contexts.getSessionContext().set( | "soapMailingJobCollectionAccess", | mailingJobCollectionAccess); | Contexts.getSessionContext().set("soapMailingJob", mailingJob); | // setValue("#{campaign.id}", 1); | | Pageflow pageflow = Pageflow.instance(); //<-- Here the process instance is null (correct) | pageflow.begin("register"); //<-- Here the process instance is 'register' (correct) | assertEquals("register", pageflow.getNode().getName()); | | assertEquals("/public/register.xhtml", getRenderedViewId()); | } | | }.run(); | | id = new FacesRequest("/public/register.xhtml", id) { | | @Override | protected void processValidations() throws Exception { | assertTrue(validateValue("#{person.id.email}", email)); | assertTrue(validateValue("#{person.salutation}", "MR")); | assertTrue(validateValue("#{person.mobile}", mobile)); | assertFalse(isValidationFailure()); | } | | @Override | protected void updateModelValues() throws Exception { | setValue("#{person.id.email}", email); | setValue("#{person.salutation}", Salutation.MR); | setValue("#{person.mobile}", mobile); | } | | @Override | protected void invokeApplication() throws Exception { | Pageflow pageflow = Pageflow.instance(); //<-- Here the process instance is null (WRONG!!!) | pageflow.navigate(getFacesContext(), "next"); | assertEquals("confirm", pageflow.getNode().getName()); | } | | @Override | protected void renderResponse() throws Exception { | assertEquals("Test Campaign", | getValue("#{person.id.campaign.name}")); | // XXX: (JBSEAM-1529) Gives NPE | // assertTrue(FacesMessages.instance().getCurrentGlobalMessages() | // .isEmpty()); | | Iterator messages = FacesContext | .getCurrentInstance().getMessages(); | assertTrue(messages.hasNext()); | assertEquals("msgPasswordSend", messages.next().getSummary()); | assertEquals("/public/confirm.xhtml", getViewId()); | assertTrue(isLongRunningConversation()); | } | | }.run(); | | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057343#4057343 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057343 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
I think there is bug in testing(mock) environment (propagation of conversations with pageflow does not work) http://jira.jboss.org/jira/browse/JBSEAM-1000 View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057265#4057265 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057265 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
It does work, but you really have to carefully simulate the browser to make it work. Note that those methods are all in SeamTest (now no doubt in BaseSeamTest). You'll find methods there to set request parameters and other things that simulate the browser. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057035#4057035 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057035 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
Thanks for your help. I'll give that all a try on monday. :) View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056997#4056997 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056997 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow
It's definitely possible, but I don't know how to make it pretty. Here's an example from one of my tests: log.info("Begin testing initial mapping"); | setViewId(MappingViewId.APPLICABLE_FIELDS.id); | invokeMethod("#{catalogMapping.beginForInitialMapping()}"); | | Pageflow pageFlow = Pageflow.instance(); | assert pageFlow.getNode().getName().equals(MappingViewId.APPLICABLE_FIELDS.node) | : "found " + pageFlow.getNode().getName(); | log.info("current view-id is #0, nodename is #1", pageFlow.getPageViewId(), pageFlow.getNode().getName()); | pageFlow.navigate(getFacesContext(), "continue"); | assert pageFlow.getNode().getName().equals(MappingViewId.SELECT_FILE.node) | : "found " + pageFlow.getNode().getName(); | setViewId(MappingViewId.SELECT_FILE.id); | log.info("current view-id is #0, nodename is #1", pageFlow.getPageViewId(), pageFlow.getNode().getName()); | | setValue("#{catalogMapping.uploadFileInputStream}", new ByteArrayInputStream(CsvData.SMALL.getBytes())); | setValue("#{catalogMapping.uploadFileName}", "master.csv"); | | // Verify that the merchant is there | Merchant merchant = (Merchant) lookup("merchant"); | assert merchant != null: "no merchant!"; | | pageFlow.navigate(getFacesContext(), "submit"); | // the #{catalogMapping.initForInitialMapping()} should now take place in the pageflow | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056987#4056987 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056987 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user