Package de.odysseus.calyxo.control.impl

Examples of de.odysseus.calyxo.control.impl.DefaultDispatcher


  public void testDispatcher() throws ConfigException {
    ServletConfig config = new TestServletConfig("test");
    ControlModuleMapping mapping = new ControlModuleMapping("/test/*");
    ControlModuleContext module = new ControlModuleContext(config, mapping, null);
    PluginContext context = new PluginContext(module, DefaultAction.class, new DefaultDispatcher(module));
    DefaultDispatcher dispatcher = new DefaultDispatcher(context.getModuleContext());

    assertNull(context.getDispatcher("foo"));
    context.setDispatcher("foo", dispatcher);
    assertSame(dispatcher, context.getDispatcher("foo"));
    context.setDefaultDispatcher(dispatcher);
    assertSame(dispatcher, context.getDefaultDispatcher());   
    try {
      context.setDefaultDispatcher(new DefaultDispatcher(context.getModuleContext()));
      fail("Exception expected (default dispatcher already set)");
    } catch (Exception e) {
    }
    try {
      context.setDispatcher("foo", new DefaultDispatcher(context.getModuleContext()));
      fail("Exception expected (dispatcher 'foo' already set)");
    } catch (Exception e) {
    }
  }
View Full Code Here


  public void testFilterClass() throws ConfigException {
    ServletConfig config = new TestServletConfig("test");
    ControlModuleMapping mapping = new ControlModuleMapping("/test/*");
    ControlModuleContext module = new ControlModuleContext(config, mapping, null);
    PluginContext context = new PluginContext(module, DefaultAction.class, new DefaultDispatcher(module));

    assertNull(context.getFilterClass("foo"));
    context.setFilterClass("foo", CancelFilter.class);
    try {
      context.setFilterClass("foo", Object.class);
View Full Code Here

    // say, we're in module1
    group.setTestModuleContext(request, module1);
  }

  public void testPath() throws Exception {
    DefaultDispatcher dispatcher = new DefaultDispatcher(module1);
    DispatchConfig dispatch = new DynamicDispatchConfig("/path", false);
    TestResponse response = new TestResponse(false);
    dispatcher.dispatch(request, response, dispatch);
    assertEquals("/path", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }
View Full Code Here

    assertEquals("/path", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }

  public void testPathRedirect() throws Exception {
    DefaultDispatcher dispatcher = new DefaultDispatcher(module1);
    DispatchConfig dispatch = new DynamicDispatchConfig("/path", true);
    TestResponse response = new TestResponse(false);
    dispatcher.dispatch(request, response, dispatch);
    assertNull(request.getRecentRequestDispatchPath());
    assertEquals("encodeRedirect(/context/path)", response.getRedirectURL());
  }
View Full Code Here

    assertNull(request.getRecentRequestDispatchPath());
    assertEquals("encodeRedirect(/context/path)", response.getRedirectURL());
  }

  public void testQuery() throws Exception {
    DefaultDispatcher dispatcher = new DefaultDispatcher(module1);
    DispatchConfig dispatch = new DynamicDispatchConfig("/path?foo=bar", false);
    TestResponse response = new TestResponse(false);
    dispatcher.dispatch(request, response, dispatch);
    assertEquals("/path?foo=bar", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }
View Full Code Here

    assertEquals("/path?foo=bar", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }

  public void testParamConfigs() throws Exception {
    DefaultDispatcher dispatcher = new DefaultDispatcher(module1);
    DynamicDispatchConfig dispatch = new DynamicDispatchConfig("/path", false);
    TestResponse response = new TestResponse(false);

    dispatch.addParam("foo", "bar");
    dispatcher.dispatch(request, response, dispatch);
    assertEquals("/path?foo=bar", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());

    dispatch.addParam("foo2", "bar2");
    dispatcher.dispatch(request, response, dispatch);
    assertEquals("/path?foo=bar&foo2=bar2", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }
View Full Code Here

    assertEquals("/path?foo=bar&foo2=bar2", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }

  public void testQueryAndParamConfig() throws Exception {
    DefaultDispatcher dispatcher = new DefaultDispatcher(module1);
    DynamicDispatchConfig dispatch = new DynamicDispatchConfig("/path?foo=bar", false);
    TestResponse response = new TestResponse(false);

    dispatch.addParam("foo2", "bar2");
    dispatcher.dispatch(request, response, dispatch);
    assertEquals("/path?foo=bar&foo2=bar2", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }
View Full Code Here

    assertEquals("/path?foo=bar&foo2=bar2", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }

  public void testAnchor() throws Exception {
    DefaultDispatcher dispatcher = new DefaultDispatcher(module1);
    DispatchConfig dispatch = new DynamicDispatchConfig("/path#abc", false);
    TestResponse response = new TestResponse(false);
    dispatcher.dispatch(request, response, dispatch);
    assertEquals("/path#abc", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }
View Full Code Here

    assertEquals("/path#abc", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }

  public void testQueryAndAnchorAndParamConfig() throws Exception {
    DefaultDispatcher dispatcher = new DefaultDispatcher(module1);
    DynamicDispatchConfig dispatch = new DynamicDispatchConfig("/path?foo=bar#abc", false);
    TestResponse response = new TestResponse(false);

    dispatch.addParam("foo2", "bar2");
    dispatcher.dispatch(request, response, dispatch);
    assertEquals("/path?foo=bar&foo2=bar2#abc", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }
View Full Code Here

    assertEquals("/path?foo=bar&foo2=bar2#abc", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }

  public void testAction() throws Exception {
    DefaultDispatcher dispatcher = new DefaultDispatcher(module1);
    DispatchConfig dispatch = new DynamicDispatchConfig(null, "/action", false);
    TestResponse response = new TestResponse(false);
    dispatcher.dispatch(request, response, dispatch);
    assertEquals("/module1/action", request.getRecentRequestDispatchPath());
    assertNull(response.getRedirectURL());
  }
View Full Code Here

TOP

Related Classes of de.odysseus.calyxo.control.impl.DefaultDispatcher

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.