Package org.springframework.mock.web.portlet

Examples of org.springframework.mock.web.portlet.MockPortletContext


    }
  }
 
  public void testParseConfigWithBang() {
   
    MockPortletContext portletContext = new MockPortletContext();
    MockPortletConfig portletConfig = new MockPortletConfig(portletContext);

    portletConfig.addInitParameter("viewNamespace", "/view");
    portletConfig.addInitParameter("defaultViewAction", "index!input");
View Full Code Here


  public void testRender() throws Exception {
    RenderRequest request = new MockRenderRequest();
    RenderResponse response = new MockRenderResponse();
    MockRequestContext context = new MockRequestContext();
    context.getMockExternalContext().setNativeContext(new MockPortletContext());
    context.getMockExternalContext().setNativeRequest(request);
    context.getMockExternalContext().setNativeResponse(response);
    context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1"));
    org.springframework.web.servlet.View mvcView = (org.springframework.web.servlet.View) EasyMock
        .createMock(org.springframework.web.servlet.View.class);
View Full Code Here

        }
      }
    };
    controller.setFlowExecutor(flowExecutor);
    controller.setApplicationContext(new StaticWebApplicationContext());
    portletContext = new MockPortletContext();
    controller.setPortletContext(portletContext);
    controller.afterPropertiesSet();

    actionRequest = new MockActionRequest();
    actionResponse = new MockActionResponse();
View Full Code Here

  private MockPortletContext context;

  protected void setUp() throws Exception {
    super.setUp();
    context = new MockPortletContext();
    // a fresh MockPortletContext seems to already contain an element;
    // that's confusing, so we remove it
    context.removeAttribute("javax.servlet.context.tempdir");
    tested = new PortletContextMap(context);
    tested.put("SomeKey", "SomeValue");
View Full Code Here

  private MockPortletResponse renderResponse;

  private PortletExternalContext renderContext;

  protected void setUp() {
    portletContext = new MockPortletContext();
    request = new MockActionRequest();
    response = new MockActionResponse();
    context = new PortletExternalContext(portletContext, request, response);
    renderRequest = new MockRenderRequest();
    renderResponse = new MockRenderResponse();
View Full Code Here

   
    abstract protected String getScriptMimeType();
   
    public void setUp() throws Exception
    {
        portletContext = new MockPortletContext(new DefaultResourceLoader());
        portletConfig = new MockPortletConfig(portletContext);
       
        for (Map.Entry<String, String> entry : getPortletInitParameters().entrySet())
        {
            portletConfig.addInitParameter(entry.getKey(), entry.getValue());
View Full Code Here

       
        /*
         * 1. initialize script engine by script engine name
         */
       
        PortletContext portletContext = new MockPortletContext(new DefaultResourceLoader());
        MockPortletConfig portletConfig = new MockPortletConfig(portletContext);
        portletConfig.addInitParameter(ScriptPortlet.ENGINE, scriptEngine);
        if (evalPortletKey != null)
        {
            portletConfig.addInitParameter(ScriptPortlet.EVAL_KEY, evalPortletKey);
        }
        portletConfig.addInitParameter(ScriptPortlet.SOURCE, scriptSource);
       
        ScriptPortlet helloScriptPortlet = new ScriptPortlet();
       
        try
        {
            helloScriptPortlet.init(portletConfig);
            assertTrue(helloScriptPortlet.getScriptSourceLastEvaluated() > 0L);
        }
        catch (PortletException e)
        {
            e.printStackTrace();
            fail("Failed to initialize portlet: " + e);
        }
       
        /*
         * 2. initialize script engine by script file extension
         */
       
        portletContext = new MockPortletContext(new DefaultResourceLoader());
        portletConfig = new MockPortletConfig(portletContext);
        if (evalPortletKey != null)
        {
            portletConfig.addInitParameter(ScriptPortlet.EVAL_KEY, evalPortletKey);
        }
        portletConfig.addInitParameter(ScriptPortlet.SOURCE, scriptSource);
       
        helloScriptPortlet = new ScriptPortlet();
       
        try
        {
            helloScriptPortlet.init(portletConfig);
            assertTrue(helloScriptPortlet.getScriptSourceLastEvaluated() > 0L);
        }
        catch (PortletException e)
        {
            e.printStackTrace();
            fail("Failed to initialize portlet: " + e);
        }
       
        /*
         * 3. initialize script engine by script mime type
         */
       
        portletContext = new MockPortletContext(new DefaultResourceLoader())
        {
            @Override
            public String getMimeType(String filePath)
            {
                return getScriptMimeType();
View Full Code Here

    registerSingleton("portletMultipartResolver", MockMultipartResolver.class);
    registerSingleton("portletPostProcessor", SimplePortletPostProcessor.class);
    registerSingleton("testListener", TestApplicationListener.class);
   
    ConstructorArgumentValues cvs = new ConstructorArgumentValues();
    cvs.addIndexedArgumentValue(0, new MockPortletContext());
    cvs.addIndexedArgumentValue(1, "complex");
    registerBeanDefinition("portletConfig", new RootBeanDefinition(MockPortletConfig.class, cvs, null));
   
    UserRoleAuthorizationInterceptor userRoleInterceptor = new UserRoleAuthorizationInterceptor();
    userRoleInterceptor.setAuthorizedRoles(new String[] {"role1", "role2"});
View Full Code Here

* @author Mark Fisher
*/
public class PortletContextAwareProcessorTests extends TestCase {

  public void testPortletContextAwareWithPortletContext() {
    PortletContext portletContext = new MockPortletContext();
    PortletContextAwareProcessor processor = new PortletContextAwareProcessor(portletContext);
    PortletContextAwareBean bean = new PortletContextAwareBean();
    assertNull(bean.getPortletContext());
    processor.postProcessBeforeInitialization(bean, "testBean");
    assertNotNull("PortletContext should have been set", bean.getPortletContext());
View Full Code Here

    assertNotNull("PortletContext should have been set", bean.getPortletContext());
    assertEquals(portletContext, bean.getPortletContext());
  }
 
  public void testPortletContextAwareWithPortletConfig() {
    PortletContext portletContext = new MockPortletContext();
    PortletConfig portletConfig = new MockPortletConfig(portletContext);
    PortletContextAwareProcessor processor = new PortletContextAwareProcessor(portletConfig);
    PortletContextAwareBean bean = new PortletContextAwareBean();
    assertNull(bean.getPortletContext());
    processor.postProcessBeforeInitialization(bean, "testBean");
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.portlet.MockPortletContext

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.