Package org.springframework.webflow.config

Source Code of org.springframework.webflow.config.AbstractFlowExecutorConfigurationTests$ExceptionThrowingConversationManager

package org.springframework.webflow.config;

import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;
import org.springframework.webflow.conversation.Conversation;
import org.springframework.webflow.conversation.ConversationException;
import org.springframework.webflow.conversation.ConversationId;
import org.springframework.webflow.conversation.ConversationManager;
import org.springframework.webflow.conversation.ConversationParameters;
import org.springframework.webflow.core.collection.AttributeMap;
import org.springframework.webflow.definition.FlowDefinition;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.executor.FlowExecutor;
import org.springframework.webflow.executor.FlowExecutorImpl;
import org.springframework.webflow.test.MockExternalContext;

public abstract class AbstractFlowExecutorConfigurationTests extends TestCase {

  private ApplicationContext context;

  public void setUp() {
    context = initApplicationContext();
  }

  protected abstract ApplicationContext initApplicationContext();


  public void testConfigOk() {
    FlowExecutor executor = context.getBean("flowExecutor", FlowExecutor.class);
    executor.launchExecution("flow", null, new MockExternalContext());
    FlowExecutor executor2 = context.getBean("flowExecutorSimpleRepo", FlowExecutor.class);
    executor2.launchExecution("flow", null, new MockExternalContext());
  }

  public void testCustomConversationManager() {
    FlowExecutorImpl executor = context.getBean("flowExecutor", FlowExecutorImpl.class);
    try {
      executor.getExecutionRepository().parseFlowExecutionKey("e1s1");
      fail("ExceptionThrowingConversationManager would have raised an exception");
    } catch (UnsupportedOperationException e) {
    }
  }

  public static class ConfigurationListener extends FlowExecutionListenerAdapter {

    public void sessionCreating(RequestContext context, FlowDefinition definition) {
      AttributeMap<Object> attributes = context.getFlowExecutionContext().getAttributes();
      assertEquals(4, attributes.size());
      assertEquals(Boolean.FALSE, attributes.getBoolean("alwaysRedirectOnPause"));
      assertEquals(Boolean.TRUE, attributes.getBoolean("redirectInSameState"));
      assertEquals("bar", attributes.get("foo"));
      assertEquals(new Integer(2), attributes.get("bar"));
    }
  }

  public static class ExceptionThrowingConversationManager implements ConversationManager {

    public Conversation beginConversation(ConversationParameters params) throws ConversationException {
      throw new UnsupportedOperationException();
    }

    public Conversation getConversation(ConversationId id) throws ConversationException {
      throw new UnsupportedOperationException();
    }

    public ConversationId parseConversationId(String encodedId) throws ConversationException {
      throw new UnsupportedOperationException();
    }
  }

}
TOP

Related Classes of org.springframework.webflow.config.AbstractFlowExecutorConfigurationTests$ExceptionThrowingConversationManager

TOP
Copyright © 2018 www.massapi.com. 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.