[jboss-user] [JBoss Seam] - Re: UnitTesting and jBPM pageflow

KnisterPeter do-not-reply at jboss.com
Mon Jun 25 09:32:40 EDT 2007


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<FacesMessage> 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



More information about the jboss-user mailing list