Package org.springframework.web.servlet.handler

Examples of org.springframework.web.servlet.handler.AbstractHandlerMapping


    assertEquals(3, chain.getInterceptors().length);
    assertEquals(LocaleChangeInterceptor.class, chain.getInterceptors()[0].getClass());
    assertEquals(ConversionServiceExposingInterceptor.class, chain.getInterceptors()[1].getClass());
    assertEquals(ResourceUrlProviderExposingInterceptor.class, chain.getInterceptors()[2].getClass());

    AbstractHandlerMapping handlerMapping = (AbstractHandlerMapping) this.config.viewControllerHandlerMapping();
    handlerMapping.setApplicationContext(this.context);
    assertNotNull(handlerMapping);
    assertEquals(1, handlerMapping.getOrder());
    assertEquals(TestPathHelper.class, handlerMapping.getUrlPathHelper().getClass());
    assertEquals(TestPathMatcher.class, handlerMapping.getPathMatcher().getClass());
    chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/path"));
    assertNotNull(chain.getHandler());
    chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/bad"));
    assertNotNull(chain.getHandler());
    chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/old"));
    assertNotNull(chain.getHandler());

    handlerMapping = (AbstractHandlerMapping) this.config.resourceHandlerMapping();
    handlerMapping.setApplicationContext(this.context);
    assertNotNull(handlerMapping);
    assertEquals(Integer.MAX_VALUE - 1, handlerMapping.getOrder());
    assertEquals(TestPathHelper.class, handlerMapping.getUrlPathHelper().getClass());
    assertEquals(TestPathMatcher.class, handlerMapping.getPathMatcher().getClass());
    chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/resources/foo.gif"));
    assertNotNull(chain.getHandler());
    assertEquals(Arrays.toString(chain.getInterceptors()), 2, chain.getInterceptors().length);
    // PathExposingHandlerInterceptor at chain.getInterceptors()[0]
    assertEquals(ResourceUrlProviderExposingInterceptor.class, chain.getInterceptors()[1].getClass());

    handlerMapping = (AbstractHandlerMapping) this.config.defaultServletHandlerMapping();
    handlerMapping.setApplicationContext(this.context);
    assertNotNull(handlerMapping);
    assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());
    chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/anyPath"));
    assertNotNull(chain.getHandler());
  }
View Full Code Here


  @Test
  public void emptyViewControllerHandlerMapping() {
    ApplicationContext context = initContext(WebConfig.class);
    String name = "viewControllerHandlerMapping";
    AbstractHandlerMapping handlerMapping = context.getBean(name, AbstractHandlerMapping.class);

    assertNotNull(handlerMapping);
    assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());
    assertTrue(handlerMapping.getClass().getName().endsWith("EmptyHandlerMapping"));
  }
View Full Code Here

  }

  @Test
  public void emptyResourceHandlerMapping() {
    ApplicationContext context = initContext(WebConfig.class);
    AbstractHandlerMapping handlerMapping = context.getBean("resourceHandlerMapping", AbstractHandlerMapping.class);

    assertNotNull(handlerMapping);
    assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());
    assertTrue(handlerMapping.getClass().getName().endsWith("EmptyHandlerMapping"));
  }
View Full Code Here

  @Test
  public void emptyDefaultServletHandlerMapping() {
    ApplicationContext context = initContext(WebConfig.class);
    String name = "defaultServletHandlerMapping";
    AbstractHandlerMapping handlerMapping = context.getBean(name, AbstractHandlerMapping.class);

    assertNotNull(handlerMapping);
    assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());
    assertTrue(handlerMapping.getClass().getName().endsWith("EmptyHandlerMapping"));
  }
View Full Code Here

  public AbstractHandlerMapping getHandlerMapping() {
    return super.getHandlerMapping();
  }

  public Map<String, ?> getUrlMap() {
    AbstractHandlerMapping mapping = getHandlerMapping();

    if ( mapping instanceof SimpleUrlHandlerMapping ) {
      return ( (SimpleUrlHandlerMapping) mapping ).getUrlMap();
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.handler.AbstractHandlerMapping

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.