Package org.springframework.binding.message

Examples of org.springframework.binding.message.DefaultMessageContext$DefaultTextFallbackMessageSource


    }
    assertEquals(3, iterationCount);
  }

  public final void testMessagesAreSerializable() throws Exception {
    DefaultMessageContext messageContext = new DefaultMessageContext();
    EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(messageContext);
    EasyMock.replay(new Object[] { this.requestContext });

    this.facesContext.addMessage("TESTID", new FacesMessage("summary1"));
    FacesMessage sourceMessage = this.facesContext.getMessages("TESTID").next();
    sourceMessage.setSummary("summary2");
    sourceMessage.setSeverity(FacesMessage.SEVERITY_FATAL);

    Serializable mementoWrite = messageContext.createMessagesMemento();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(mementoWrite);
    oos.flush();
    byte[] byteArray = bos.toByteArray();
    oos.close();

    ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
    ObjectInputStream ois = new ObjectInputStream(bis);
    Serializable mementoRead = (Serializable) ois.readObject();
    ois.close();

    messageContext.restoreMessages(mementoRead);
    EasyMock.reset(new Object[] { this.requestContext });
    EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(messageContext);
    EasyMock.replay(new Object[] { this.requestContext });

    FacesContext newFacesContext = new FlowFacesContext(this.requestContext, this.jsf.facesContext());
View Full Code Here


    assertNotNull(this.facesContext.getELContext());
    assertSame(this.facesContext, this.facesContext.getELContext().getContext(FacesContext.class));
  }

  public final void testValidationFailed() {
    this.messageContext = new DefaultMessageContext();
    EasyMock.expect(this.requestContext.getMessageContext()).andStubReturn(this.messageContext);
    EasyMock.replay(new Object[] { this.requestContext });

    this.facesContext.addMessage("foo", new FacesMessage(FacesMessage.SEVERITY_ERROR, "foo", "bar"));
View Full Code Here

    assertEquals(true, this.facesContext.isValidationFailed());
  }

  private void setupMessageContext() {
    this.prepopulatedMessageContext = new DefaultMessageContext();
    this.prepopulatedMessageContext.addMessage(new FlowFacesContext.FlowFacesMessage(new FacesMessageSource(null),
        new FacesMessage("foo")));
    this.prepopulatedMessageContext.addMessage(new FlowFacesContext.FlowFacesMessage(new FacesMessageSource(
        "componentId"), new FacesMessage("componentId_summary1", "componentId_detail1")));
    this.prepopulatedMessageContext.addMessage(new FlowFacesContext.FlowFacesMessage(new FacesMessageSource(
View Full Code Here

  TestBean testBean;
  ExpressionParser expressionParser;

  public void setUp() {
    testBean = new TestBean();
    messages = new DefaultMessageContext();
    conversionService = new DefaultConversionService();
    expressionParser = getExpressionParser();
    model = new BindingModel("testBean", testBean, expressionParser, conversionService, messages);
  }
View Full Code Here

  public void testGetFieldValueWithInvalidBeanWrapperExpression() throws Exception {
    Question question = new Question();
    converterRegistry.addConverter(new QuestionConverter(question));
    BindingModel model = new BindingModel("theTestBean", new TestBeanWithQuestionResponseMap(question),
        expressionParser, conversionService, new DefaultMessageContext());
    assertEquals("111", model.getFieldValue("responses[1].value"));
  }
View Full Code Here

   * </ul>
   */
  public MockRequestContext(ParameterMap requestParameterMap) {
    this.flowExecutionContext = new MockFlowExecutionContext();
    this.externalContext = new MockExternalContext(requestParameterMap);
    this.messageContext = new DefaultMessageContext();
  }
View Full Code Here

   * @param flowExecutionContext the flow execution context
   */
  public MockRequestContext(FlowExecutionContext flowExecutionContext) {
    this.flowExecutionContext = flowExecutionContext;
    this.externalContext = new MockExternalContext();
    this.messageContext = new DefaultMessageContext();
  }
View Full Code Here

  }

  // internal helpers

  private MessageContext createMessageContext(MessageSource messageSource) {
    StateManageableMessageContext messageContext = new DefaultMessageContext(messageSource);
    Serializable messagesMemento = (Serializable) getFlashScope().extract("messagesMemento");
    if (messagesMemento != null) {
      messageContext.restoreMessages(messagesMemento);
    }
    return messageContext;
  }
View Full Code Here

TOP

Related Classes of org.springframework.binding.message.DefaultMessageContext$DefaultTextFallbackMessageSource

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.