Search in sources :

Example 71 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.

the class WebMvcConfigurationSupportTests method emptyViewControllerHandlerMapping.

@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"));
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) AbstractHandlerMapping(org.springframework.web.servlet.handler.AbstractHandlerMapping) Test(org.junit.Test)

Example 72 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.

the class WebMvcConfigurationSupportTests method uriComponentsContributor.

@Test
public void uriComponentsContributor() throws Exception {
    ApplicationContext context = initContext(WebConfig.class);
    CompositeUriComponentsContributor uriComponentsContributor = context.getBean(MvcUriComponentsBuilder.MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME, CompositeUriComponentsContributor.class);
    assertNotNull(uriComponentsContributor);
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) CompositeUriComponentsContributor(org.springframework.web.method.support.CompositeUriComponentsContributor) Test(org.junit.Test)

Example 73 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.

the class WebMvcConfigurationSupportTests method emptyDefaultServletHandlerMapping.

@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"));
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) AbstractHandlerMapping(org.springframework.web.servlet.handler.AbstractHandlerMapping) Test(org.junit.Test)

Example 74 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.

the class WebMvcConfigurationSupportTests method mvcViewResolver.

@Test
public void mvcViewResolver() {
    ApplicationContext context = initContext(WebConfig.class);
    ViewResolverComposite resolver = context.getBean("mvcViewResolver", ViewResolverComposite.class);
    assertNotNull(resolver);
    assertEquals(1, resolver.getViewResolvers().size());
    assertEquals(InternalResourceViewResolver.class, resolver.getViewResolvers().get(0).getClass());
    assertEquals(Ordered.LOWEST_PRECEDENCE, resolver.getOrder());
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ViewResolverComposite(org.springframework.web.servlet.view.ViewResolverComposite) Test(org.junit.Test)

Example 75 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.

the class WebMvcConfigurationSupportTests method customArgumentResolvers.

@Test
public void customArgumentResolvers() {
    ApplicationContext context = initContext(CustomArgumentResolverConfig.class);
    RequestMappingHandlerAdapter adapter = context.getBean(RequestMappingHandlerAdapter.class);
    HandlerExceptionResolverComposite composite = context.getBean(HandlerExceptionResolverComposite.class);
    assertNotNull(adapter);
    assertEquals(1, adapter.getCustomArgumentResolvers().size());
    assertEquals(TestArgumentResolver.class, adapter.getCustomArgumentResolvers().get(0).getClass());
    assertEquals(1, adapter.getCustomReturnValueHandlers().size());
    assertEquals(TestReturnValueHandler.class, adapter.getCustomReturnValueHandlers().get(0).getClass());
    assertNotNull(composite);
    assertEquals(3, composite.getExceptionResolvers().size());
    assertEquals(ExceptionHandlerExceptionResolver.class, composite.getExceptionResolvers().get(0).getClass());
    ExceptionHandlerExceptionResolver resolver = (ExceptionHandlerExceptionResolver) composite.getExceptionResolvers().get(0);
    assertEquals(1, resolver.getCustomArgumentResolvers().size());
    assertEquals(TestArgumentResolver.class, resolver.getCustomArgumentResolvers().get(0).getClass());
    assertEquals(1, resolver.getCustomReturnValueHandlers().size());
    assertEquals(TestReturnValueHandler.class, resolver.getCustomReturnValueHandlers().get(0).getClass());
}
Also used : ExceptionHandlerExceptionResolver(org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) HandlerExceptionResolverComposite(org.springframework.web.servlet.handler.HandlerExceptionResolverComposite) RequestMappingHandlerAdapter(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter) Test(org.junit.Test)

Aggregations

ApplicationContext (org.springframework.context.ApplicationContext)578 Test (org.junit.Test)262 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)179 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)44 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)37 ConfigurableMessenger (org.springframework.scripting.ConfigurableMessenger)28 File (java.io.File)25 DataSource (javax.sql.DataSource)24 Messenger (org.springframework.scripting.Messenger)24 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)21 Refreshable (org.springframework.aop.target.dynamic.Refreshable)20 StubCloudConnectorTest (org.springframework.cloud.StubCloudConnectorTest)17 HashMap (java.util.HashMap)16 SchedulerException (org.quartz.SchedulerException)16 ArrayList (java.util.ArrayList)14 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)14 WebApplicationContext (org.springframework.web.context.WebApplicationContext)14 MovieMapper (com.mapper.MovieMapper)13 Map (java.util.Map)13 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)13