Package org.springframework.webflow.test

Examples of org.springframework.webflow.test.MockExternalContext


            new SimpleFlowExecutionSnapshotFactory(executionFactory, newMockFlowLocator(flow)));
        keyFactory.setAlwaysGenerateNewNextKey(true);
        executionFactory.setExecutionKeyFactory(keyFactory);
        final FlowExecution execution = executionFactory.createFlowExecution(flow);

        execution.start(null, new MockExternalContext());

        // Flow state: rendered subflow view
        assertTrue(execution.isActive());
        assertEquals("view", execution.getActiveSession().getScope().get("renderCalled"));
        final FlowExecutionKey key1 = execution.getKey();
        assertNotNull(key1);
        assertEquals(key1, keyFactory.parseFlowExecutionKey(key1.toString()));
      
        final MockExternalContext context1 = new MockExternalContext();
        context1.setEventId("submit");
        execution.resume(context1);

        // Flow state: rendered parent view (following subflow termination)
        assertTrue(execution.isActive());
        assertEquals("parentview", execution.getActiveSession().getScope().get("renderCalled"));
        final FlowExecutionKey key2 = execution.getKey();
        assertNotNull(key2);
        assertFalse(key1.equals(key2));
        assertEquals(key2, keyFactory.parseFlowExecutionKey(key2.toString()));

        final MockExternalContext context2 = new MockExternalContext();
        context2.setEventId("submit");
        execution.resume(context2);

        // Flow state: completed
        assertTrue(execution.hasEnded());
    }
View Full Code Here


    jsfMock.facesContext().getApplication().setViewHandler(viewHandler);
    lifecycle = new TestLifecycle(jsfMock.lifecycle());
    factory = new JsfViewFactory(parser.parseExpression("#{'" + VIEW_ID + "'}", new FluentParserContext()
        .template().evaluate(RequestContext.class).expectResult(String.class)), lifecycle);
    RequestContextHolder.setRequestContext(context);
    MockExternalContext ext = new MockExternalContext();
    ext.setNativeContext(new MockServletContext());
    ext.setNativeRequest(new MockHttpServletRequest());
    ext.setNativeResponse(new MockHttpServletResponse());
    EasyMock.expect(context.getExternalContext()).andStubReturn(ext);
    AttributeMap requestMap = new LocalAttributeMap();
    EasyMock.expect(context.getFlashScope()).andStubReturn(requestMap);
    EasyMock.expect(context.getRequestParameters()).andStubReturn(new LocalParameterMap(new HashMap()));
  }
View Full Code Here

  EasyMock.replay(bookingService);

  MutableAttributeMap input = new LocalAttributeMap();
  input.put("hotelId", "1");
  MockExternalContext context = new MockExternalContext();
  context.setCurrentUser("keith");
  startFlow(input, context);

  assertCurrentStateEquals("enterBookingDetails");
  assertResponseWrittenEquals("enterBookingDetails", context);
  assertTrue(getRequiredFlowAttribute("booking") instanceof Booking);
View Full Code Here

    public void testEnterBookingDetails_Proceed() {
  setCurrentState("enterBookingDetails");
  getFlowScope().put("booking", createTestBooking());

  MockExternalContext context = new MockExternalContext();
  context.setEventId("proceed");
  resumeFlow(context);

  assertCurrentStateEquals("reviewBooking");
  assertResponseWrittenEquals("reviewBooking", context);
    }
View Full Code Here

    }

    public void testReviewBooking_Confirm() {
  setCurrentState("reviewBooking");
  getFlowScope().put("booking", createTestBooking());
  MockExternalContext context = new MockExternalContext();
  context.setEventId("confirm");
  resumeFlow(context);
  assertFlowExecutionEnded();
  assertFlowExecutionOutcomeEquals("bookingConfirmed");
    }
View Full Code Here

    assertFalse(getErrors(context).hasErrors());
    assertFalse(getErrors(context, "otherTest").hasErrors());
    assertEquals("value", getFormObject(context).getProp());
    assertNull(getFormObject(context, "otherTest").getProp());

    context.setExternalContext(new MockExternalContext(blankParameters()));

    assertEquals(action.getEventFactorySupport().getErrorEventId(), otherAction.bindAndValidate(context).getId());

    assertEquals(3, context.getRequestScope().size());
    assertEquals(3, context.getFlowScope().size());
View Full Code Here

    assertEquals(action.getEventFactorySupport().getErrorEventId(), action.bindAndValidate(context).getId());

    assertSame(getFormObject(context), new FormObjectAccessor(context).getCurrentFormObject());
    assertSame(getErrors(context), new FormObjectAccessor(context).getCurrentFormErrors());

    context.setExternalContext(new MockExternalContext(parameters()));

    assertEquals(action.getEventFactorySupport().getSuccessEventId(), otherAction.bindAndValidate(context).getId());

    assertSame(getFormObject(context, "otherTest"), new FormObjectAccessor(context).getCurrentFormObject());
    assertSame(getErrors(context, "otherTest"), new FormObjectAccessor(context).getCurrentFormErrors());
View Full Code Here

    assertNotNull(test2);
    assertSame(test2, new FormObjectAccessor(context).getCurrentFormObject());

    MockParameterMap parameters = new MockParameterMap();
    parameters.put("prop", "12345");
    context.setExternalContext(new MockExternalContext(parameters));
    action1.bindAndValidate(context);
    TestBean test11 = (TestBean) context.getFlowScope().get("test1");
    assertSame(test1, test11);
    assertEquals("12345", test1.getProp());
    assertSame(test1, new FormObjectAccessor(context).getCurrentFormObject());

    parameters = new MockParameterMap();
    parameters.put("prop", "123456");
    context.setExternalContext(new MockExternalContext(parameters));
    action2.bindAndValidate(context);
    TestBean test22 = (TestBean) context.getFlowScope().get("test2");
    assertSame(test22, test2);
    assertEquals("123456", test2.getProp());
    assertSame(test2, new FormObjectAccessor(context).getCurrentFormObject());
View Full Code Here

      }
    };
    FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
    factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener));
    FlowExecution execution = factory.createFlowExecution(flow);
    execution.start(null, new MockExternalContext());
    assertTrue("Should have ended", !execution.isActive());
  }
View Full Code Here

    TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler();
    handler.add(TestException.class, "end");
    flow.getExceptionHandlerSet().add(handler);
    FlowExecution execution = new FlowExecutionImplFactory().createFlowExecution(flow);
    try {
      execution.start(null, new MockExternalContext());
      fail("Should have failed no such state");
    } catch (IllegalArgumentException e) {
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.webflow.test.MockExternalContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.