Package org.springframework.binding.expression.support

Examples of org.springframework.binding.expression.support.StaticExpression


    MockRequestContext context = new MockRequestContext();
    context.putRequestParameter("_eventId", "submit");
    context.putRequestParameter("booleanProperty", "bogus");
    context.putRequestParameter("_booleanProperty", "whatever");
    BindBean bindBean = new BindBean();
    StaticExpression modelObject = new StaticExpression(bindBean);
    modelObject.setExpressionString("bindBean");
    context.getCurrentState().getAttributes().put("model", modelObject);
    context.getFlowScope().put("bindBean", bindBean);
    context.getMockExternalContext().setNativeContext(new MockServletContext());
    context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest());
    context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse());
View Full Code Here


  public void testRenderWithBindingModel() throws Exception {
    MockRequestControlContext context = new MockRequestControlContext();
    context.setCurrentState(new ViewState(context.getRootFlow(), "test", new StubViewFactory()));
    Object bindBean = new BindBean();
    StaticExpression modelObject = new StaticExpression(bindBean);
    modelObject.setExpressionString("bindBean");
    context.getCurrentState().getAttributes().put("model", modelObject);
    context.getFlowScope().put("bindBean", bindBean);
    context.getMockExternalContext().setNativeContext(new MockServletContext());
    context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest());
    context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse());
View Full Code Here

    context.putRequestParameter("stringArrayProperty", new String[] { "foo", "bar", "baz" });
    context.putRequestParameter("integerArrayProperty", new String[] { "1", "2", "3" });
    context.putRequestParameter("primitiveArrayProperty", new String[] { "1", "2", "3" });
    context.putRequestParameter("listProperty", new String[] { "1", "2", "3" });
    BindBean bindBean = new BindBean();
    StaticExpression modelObject = new StaticExpression(bindBean);
    modelObject.setExpressionString("bindBean");
    context.getCurrentState().getAttributes().put("model", modelObject);
    context.getFlowScope().put("bindBean", bindBean);
    context.getMockExternalContext().setNativeContext(new MockServletContext());
    context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest());
    context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse());
View Full Code Here

    MockRequestControlContext context = new MockRequestControlContext();
    context.putRequestParameter("_eventId", "submit");
    context.putRequestParameter("integerProperty", "bogus 1");
    context.putRequestParameter("dateProperty", "bogus 2");
    BindBean bindBean = new BindBean();
    StaticExpression modelObject = new StaticExpression(bindBean);
    modelObject.setExpressionString("bindBean");
    context.getCurrentState().getAttributes().put("model", modelObject);
    context.getFlowScope().put("bindBean", bindBean);
    context.getMockExternalContext().setNativeContext(new MockServletContext());
    context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest());
    context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse());
View Full Code Here

    MockRequestControlContext context = new MockRequestControlContext();
    context.putRequestParameter("_eventId", "submit");
    context.putRequestParameter("integerProperty", "bogus 1");
    context.putRequestParameter("dateProperty", "bogus 2");
    BindBean bindBean = new BindBean();
    StaticExpression modelObject = new StaticExpression(bindBean);
    modelObject.setExpressionString("bindBean");
    context.getCurrentState().getAttributes().put("model", modelObject);
    context.getFlowScope().put("bindBean", bindBean);
    context.getMockExternalContext().setNativeContext(new MockServletContext());
    context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest());
    context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse());
    context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1"));
    org.springframework.web.servlet.View mvcView = new MockView();
    AbstractMvcView view = new MockMvcView(mvcView, context);
    view.setExpressionParser(createExpressionParser());
    view.setMessageCodesResolver(new WebFlowMessageCodesResolver());
    context.setAlwaysRedirectOnPause(true);
    assertTrue(view.userEventQueued());
    view.processUserEvent();
    assertFalse(view.userEventQueued());
    assertFalse(view.hasFlowEvent());
    Object viewActionState = view.getUserEventState();
    assertNotNull(viewActionState);

    MockRequestControlContext context2 = new MockRequestControlContext();
    context2.getFlashScope().put(org.springframework.webflow.execution.View.USER_EVENT_STATE_ATTRIBUTE,
        viewActionState);
    BindBean bindBean2 = new BindBean();
    StaticExpression modelObject2 = new StaticExpression(bindBean2);
    modelObject2.setExpressionString("bindBean");
    context2.getCurrentState().getAttributes().put("model", modelObject);
    context2.getFlowScope().put("bindBean", bindBean);
    context2.getMockExternalContext().setNativeContext(new MockServletContext());
    context2.getMockExternalContext().setNativeRequest(new MockHttpServletRequest());
    context2.getMockExternalContext().setNativeResponse(new MockHttpServletResponse());
View Full Code Here

  protected void addEmptyValueMapping(DefaultMapper mapper, String field, Object model) {
    ParserContext parserContext = new FluentParserContext().evaluate(model.getClass());
    Expression target = expressionParser.parseExpression(field, parserContext);
    try {
      Class<?> propertyType = target.getValueType(model);
      Expression source = new StaticExpression(getEmptyValue(propertyType));
      DefaultMapping mapping = new DefaultMapping(source, target);
      if (logger.isDebugEnabled()) {
        logger.debug("Adding empty value mapping for parameter '" + field + "'");
      }
      mapper.addMapping(mapping);
View Full Code Here

  /**
   * Creates a new target state resolver that always returns the same target state id.
   * @param targetStateId a static target target state
   */
  public DefaultTargetStateResolver(String targetStateId) {
    this(new StaticExpression(targetStateId));
  }
View Full Code Here

public class FlowDefinitionRedirectActionTests extends TestCase {
  private FlowDefinitionRedirectAction action;

  public void testExecute() throws Exception {
    Expression flowId = new StaticExpression("user?foo=bar");
    action = new FlowDefinitionRedirectAction(flowId);
    MockRequestContext context = new MockRequestContext();
    action.execute(context);
    assertEquals("user", context.getMockExternalContext().getFlowRedirectFlowId());
    assertEquals("bar", context.getMockExternalContext().getFlowRedirectFlowInput().get("foo"));
View Full Code Here

    assertEquals("user", context.getMockExternalContext().getFlowRedirectFlowId());
    assertEquals("bar", context.getMockExternalContext().getFlowRedirectFlowInput().get("foo"));
  }

  public void testExecuteWithNullRequestFields() throws Exception {
    Expression flowId = new StaticExpression("user");
    action = new FlowDefinitionRedirectAction(flowId);
    MockRequestContext context = new MockRequestContext();
    action.execute(context);
    assertEquals("user", context.getMockExternalContext().getFlowRedirectFlowId());
  }
View Full Code Here

  }

  public void testBeanArg() {
    Parameters parameters = new Parameters();
    Bean bean = new Bean();
    parameters.add(new Parameter(Bean.class, new StaticExpression(bean)));
    MethodSignature method = new MethodSignature("testBeanArg", parameters);
    assertSame(bean, methodInvoker.invoke(method, new TestObject(), null));
  }
View Full Code Here

TOP

Related Classes of org.springframework.binding.expression.support.StaticExpression

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.