Examples of HandlerExecutionChain


Examples of org.springframework.web.servlet.HandlerExecutionChain

    assertEquals(this.wac.getBean("welcome"), chain.getHandler());
  }

  public void testWithMultiActionControllerMapping() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/admin/user");
    HandlerExecutionChain chain = this.hm.getHandler(request);
    assertEquals(this.wac.getBean("admin"), chain.getHandler());

    request = new MockHttpServletRequest("GET", "/admin/product");
    chain = this.hm.getHandler(request);
    assertEquals(this.wac.getBean("admin"), chain.getHandler());
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

    assertEquals(this.wac.getBean("admin"), chain.getHandler());
  }

  public void testWithoutControllerSuffix() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/buyform");
    HandlerExecutionChain chain = this.hm.getHandler(request);
    assertEquals(this.wac.getBean("buy"), chain.getHandler());
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

    assertEquals(this.wac.getBean("buy"), chain.getHandler());
  }

  public void testWithBasePackage() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myapp/mvc/mapping/welcome");
    HandlerExecutionChain chain = this.hm2.getHandler(request);
    assertEquals(this.wac.getBean("welcome"), chain.getHandler());
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

    assertEquals(this.wac.getBean("welcome"), chain.getHandler());
  }

  public void testWithBasePackageAndCaseSensitive() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myapp/mvc/mapping/buyForm");
    HandlerExecutionChain chain = this.hm2.getHandler(request);
    assertEquals(this.wac.getBean("buy"), chain.getHandler());
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

    assertEquals(this.wac.getBean("buy"), chain.getHandler());
  }

  public void testWithFullBasePackage() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myapp/welcome");
    HandlerExecutionChain chain = this.hm3.getHandler(request);
    assertEquals(this.wac.getBean("welcome"), chain.getHandler());
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

    assertEquals(this.wac.getBean("welcome"), chain.getHandler());
  }

  public void testWithRootAsBasePackage() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myapp/org/springframework/web/servlet/mvc/mapping/welcome");
    HandlerExecutionChain chain = this.hm4.getHandler(request);
    assertEquals(this.wac.getBean("welcome"), chain.getHandler());
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

  public void testRequestsWithHandlers() throws Exception {
    Object bean = wac.getBean("mainController");

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

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

    req = new MockHttpServletRequest("GET", "/bookseats.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

    Object bean = wac.getBean("mainController");
    Object defaultBean = wac.getBean("starController");

    // testing some normal behavior
    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/pathmatchingTest.html");
    HandlerExecutionChain hec = getHandler(req);
    assertTrue("Handler is null", hec != null);
    assertTrue("Handler is correct bean", hec.getHandler() == bean);
    assertEquals("pathmatchingTest.html", req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));

    // no match, no forward slash included
    req = new MockHttpServletRequest("GET", "welcome.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);
    assertEquals("welcome.html", req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));

    // testing some ????? behavior
    req = new MockHttpServletRequest("GET", "/pathmatchingAA.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
    assertEquals("pathmatchingAA.html", req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));

    // testing some ????? behavior
    req = new MockHttpServletRequest("GET", "/pathmatchingA.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);
    assertEquals("/pathmatchingA.html", req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));

    // testing some ????? behavior
    req = new MockHttpServletRequest("GET", "/administrator/pathmatching.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    // testing simple /**/behavior
    req = new MockHttpServletRequest("GET", "/administrator/test/pathmatching.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    // this should not match because of the administratorT
    req = new MockHttpServletRequest("GET", "/administratort/pathmatching.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

    // this should match because of *.jsp
    req = new MockHttpServletRequest("GET", "/bla.jsp");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    // this as well, because there's a **/in there as well
    req = new MockHttpServletRequest("GET", "/testing/bla.jsp");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    // should match because because exact pattern is there
    req = new MockHttpServletRequest("GET", "/administrator/another/bla.xml");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    // should not match, because there's not .gif extension in there
    req = new MockHttpServletRequest("GET", "/administrator/another/bla.gif");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

    // should match because there testlast* in there
    req = new MockHttpServletRequest("GET", "/administrator/test/testlastbit");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    // but this not, because it's testlast and not testla
    req = new MockHttpServletRequest("GET", "/administrator/test/testla");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

    req = new MockHttpServletRequest("GET", "/administrator/testing/longer/bla");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/administrator/testing/longer/test.jsp");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/administrator/testing/longer2/notmatching/notmatching");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

    req = new MockHttpServletRequest("GET", "/shortpattern/testing/toolong");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

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

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

    req = new MockHttpServletRequest("GET", "/XpathXXmatching.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

    req = new MockHttpServletRequest("GET", "/XXpathmatching.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

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

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

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

    req = new MockHttpServletRequest("GET", "/reallyGood-test-is-this.jpeg");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/reallyGood-tst-is-this.jpeg");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

    req = new MockHttpServletRequest("GET", "/testing/test.jpeg");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/testing/test.jpg");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

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

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

    // there outofpattern*yeah in the pattern, so this should fail
    req = new MockHttpServletRequest("GET", "/outofpattern*ye");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

    req = new MockHttpServletRequest("GET", "/test't est/path'm atching.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);

    req = new MockHttpServletRequest("GET", "/test%26t%20est/path%26m%20atching.html");
    hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == defaultBean);
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

  }

  public void testDefaultMapping() throws Exception {
    Object bean = wac.getBean("starController");
    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/goggog.html");
    HandlerExecutionChain hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
  }
View Full Code Here

Examples of org.springframework.web.servlet.HandlerExecutionChain

  }

  public void testMappingExposedInRequest() throws Exception {
    Object bean = wac.getBean("mainController");
    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/show.html");
    HandlerExecutionChain hec = getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
    assertEquals("Mapping not exposed", "show.html", req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));
  }
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.