Examples of HandlerMapping


Examples of org.springframework.web.portlet.HandlerMapping

    pac.setConfigLocations(new String[] {CONF});
    pac.refresh();
  }

  public void testParameterMapping() throws Exception {
    HandlerMapping hm = (HandlerMapping)pac.getBean("handlerMapping");

    MockPortletRequest addRequest = new MockPortletRequest();
    addRequest.addParameter("action", "add");

    MockPortletRequest removeRequest = new MockPortletRequest();
    removeRequest.addParameter("action", "remove");

    Object addHandler = hm.getHandler(addRequest).getHandler();
    Object removeHandler = hm.getHandler(removeRequest).getHandler();

    assertEquals(pac.getBean("addItemHandler"), addHandler);
    assertEquals(pac.getBean("removeItemHandler"), removeHandler);
  }
View Full Code Here

Examples of org.springframework.web.portlet.HandlerMapping

    assertEquals(pac.getBean("addItemHandler"), addHandler);
    assertEquals(pac.getBean("removeItemHandler"), removeHandler);
  }

  public void testUnregisteredHandlerWithNoDefault() throws Exception {
    HandlerMapping hm = (HandlerMapping)pac.getBean("handlerMapping");

    MockPortletRequest request = new MockPortletRequest();
    request.addParameter("action", "modify");

    assertNull(hm.getHandler(request));
  }
View Full Code Here

Examples of org.springframework.web.portlet.HandlerMapping

    pac.setConfigLocations(new String[] {CONF});
    pac.refresh();
  }

  public void testPortletModeViewWithParameter() throws Exception {
    HandlerMapping hm = (HandlerMapping)pac.getBean("handlerMapping");

    MockPortletRequest addRequest = new MockPortletRequest();
    addRequest.setPortletMode(PortletMode.VIEW);
    addRequest.setParameter("action", "add");

    MockPortletRequest removeRequest = new MockPortletRequest();
    removeRequest.setPortletMode(PortletMode.VIEW);
    removeRequest.setParameter("action", "remove");

    Object addHandler = hm.getHandler(addRequest).getHandler();
    Object removeHandler = hm.getHandler(removeRequest).getHandler();

    assertEquals(pac.getBean("addItemHandler"), addHandler);
    assertEquals(pac.getBean("removeItemHandler"), removeHandler);
  }
View Full Code Here

Examples of org.springframework.web.portlet.HandlerMapping

    assertEquals(pac.getBean("addItemHandler"), addHandler);
    assertEquals(pac.getBean("removeItemHandler"), removeHandler);
  }

  public void testPortletModeEditWithParameter() throws Exception {
    HandlerMapping hm = (HandlerMapping)pac.getBean("handlerMapping");

    MockPortletRequest request = new MockPortletRequest();
    request.setPortletMode(PortletMode.EDIT);
    request.setParameter("action", "prefs");

    Object handler = hm.getHandler(request).getHandler();
    assertEquals(pac.getBean("preferencesHandler"), handler);
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerMapping

    wac.setConfigLocations(new String[] {CONF});
    wac.refresh();
  }

  public void testRequestsWithoutHandlers() throws Exception {
    HandlerMapping hm = (HandlerMapping) wac.getBean("handlerMapping");

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/mypath/nonsense.html");
    req.setContextPath("/myapp");
    Object h = hm.getHandler(req);
    assertTrue("Handler is null", h == null);

    req = new MockHttpServletRequest("GET", "/foo/bar/baz.html");
    h = hm.getHandler(req);
    assertTrue("Handler is null", h == null);
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerMapping

    h = hm.getHandler(req);
    assertTrue("Handler is null", h == null);
  }

  public void testRequestsWithSubPaths() throws Exception {
    HandlerMapping hm = (HandlerMapping) wac.getBean("handlerMapping");
    doTestRequestsWithSubPaths(hm);
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerMapping

    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
  }

  public void testAsteriskMatches() throws Exception {
    HandlerMapping hm = (HandlerMapping) wac.getBean("handlerMapping");
    Object bean = wac.getBean("godCtrl");

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/mypath/test.html");
    HandlerExecutionChain hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/mypath/testarossa");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/mypath/tes");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec == null);
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerMapping

    wac.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map2.xml"});
    wac.refresh();
    Object bean = wac.getBean("mainController");
    Object otherBean = wac.getBean("otherController");
    Object defaultBean = wac.getBean("starController");
    HandlerMapping hm = (HandlerMapping) wac.getBean(beanName);

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/welcome.html");
    HandlerExecutionChain hec = getHandler(hm, req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
    assertEquals("/welcome.html", req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));
View Full Code Here

Examples of org.springframework.web.servlet.HandlerMapping

    verify(springMVCRequestNameDeterminerAspect, times(useNameDeterminerAspect ? 1 : 0))
        .aroundGetHandler(any(HttpServletRequest.class), any(HandlerExecutionChain.class));
  }

  private HandlerMapping createExceptionThrowingHandlerMapping() throws Exception {
    HandlerMapping requestMappingHandlerMapping = mock(HandlerMapping.class);
    when(requestMappingHandlerMapping.getHandler((HttpServletRequest) any())).thenThrow(new Exception("This is a test exeption"));
    return requestMappingHandlerMapping;
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerMapping

    when(requestMappingHandlerMapping.getHandler((HttpServletRequest) any())).thenThrow(new Exception("This is a test exeption"));
    return requestMappingHandlerMapping;
  }

  private HandlerMapping createHandlerMappingNotReturningHandlerMethod() throws Exception {
    HandlerMapping requestMappingHandlerMapping = mock(HandlerMapping.class);
    HandlerExecutionChain handlerExecutionChain = mock(HandlerExecutionChain.class);

    when(handlerExecutionChain.getHandler()).thenReturn(new Object());
    when(requestMappingHandlerMapping.getHandler((HttpServletRequest) any())).thenReturn(handlerExecutionChain);
    return requestMappingHandlerMapping;
  }
View Full Code Here
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.