Package org.springframework.beans

Examples of org.springframework.beans.DirectFieldAccessor


  @Test
  public void testReturnValueHandlers() {
    loadBeanDefinitions("mvc-config-return-value-handlers.xml");
    RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
    assertNotNull(adapter);
    Object value = new DirectFieldAccessor(adapter).getPropertyValue("customReturnValueHandlers");
    assertNotNull(value);
    assertTrue(value instanceof List);
    List<HandlerMethodReturnValueHandler> handlers = (List<HandlerMethodReturnValueHandler>) value;
    assertEquals(2, handlers.size());
    assertEquals(TestHandlerMethodReturnValueHandler.class, handlers.get(0).getClass());
View Full Code Here


  }

  @SuppressWarnings("unchecked")
  private void verifyMessageConverters(Object bean, boolean hasDefaultRegistrations) {
    assertNotNull(bean);
    Object value = new DirectFieldAccessor(bean).getPropertyValue("messageConverters");
    assertNotNull(value);
    assertTrue(value instanceof List);
    List<HttpMessageConverter<?>> converters = (List<HttpMessageConverter<?>>) value;
    if (hasDefaultRegistrations) {
      assertTrue("Default converters are registered in addition to custom ones", converters.size() > 2);
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  private void verifyResponseBodyAdvice(Object bean) {
    assertNotNull(bean);
    Object value = new DirectFieldAccessor(bean).getPropertyValue("responseBodyAdvice");
    assertNotNull(value);
    assertTrue(value instanceof List);
    List<ResponseBodyAdvice> converters = (List<ResponseBodyAdvice>) value;
    assertTrue(converters.get(0) instanceof JsonViewResponseBodyAdvice);
  }
View Full Code Here

    GroovyMarkupView view = new GroovyMarkupView();
    view.setTemplateEngine(new TestTemplateEngine());
    view.setApplicationContext(this.webAppContext);

    DirectFieldAccessor accessor = new DirectFieldAccessor(view);
    TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
    assertNotNull(engine);
    assertEquals(TestTemplateEngine.class, engine.getClass());
  }
View Full Code Here

    GroovyMarkupView view = new GroovyMarkupView();

    view.setTemplateEngine(new TestTemplateEngine());
    view.setApplicationContext(this.webAppContext);

    DirectFieldAccessor accessor = new DirectFieldAccessor(view);
    TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
    assertNotNull(engine);
    assertEquals(TestTemplateEngine.class, engine.getClass());
  }
View Full Code Here

    ContentNegotiationManager manager = mapping.getContentNegotiationManager();
    assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(webRequest));

    RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
    assertNotNull(adapter);
    assertEquals(false, new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect"));

    List<HttpMessageConverter<?>> converters = adapter.getMessageConverters();
    assertTrue(converters.size() > 0);
    for(HttpMessageConverter<?> converter : converters) {
      if (converter instanceof AbstractJackson2HttpMessageConverter) {
View Full Code Here

    assertNotNull(mapping);
    assertFalse(mapping.getUrlPathHelper().shouldRemoveSemicolonContent());

    RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
    assertNotNull(adapter);
    assertEquals(true, new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect"));

    // default web binding initializer behavior test
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("date", "2009-10-31");
    MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

    loadBeanDefinitions("mvc-config-async-support.xml", 14);

    RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
    assertNotNull(adapter);

    DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);
    assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass());
    assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout"));

    CallableProcessingInterceptor[] callableInterceptors =
        (CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
    assertEquals(1, callableInterceptors.length);

    DeferredResultProcessingInterceptor[] deferredResultInterceptors =
        (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
    assertEquals(1, deferredResultInterceptors.length);
  }
View Full Code Here

    List<ViewResolver> resolvers = compositeResolver.getViewResolvers();
    assertEquals(BeanNameViewResolver.class, resolvers.get(0).getClass());

    ViewResolver resolver = resolvers.get(1);
    assertEquals(InternalResourceViewResolver.class, resolver.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(resolver);
    assertEquals(InternalResourceView.class, accessor.getPropertyValue("viewClass"));

    assertEquals(TilesViewResolver.class, resolvers.get(2).getClass());

    resolver = resolvers.get(3);
    FreeMarkerViewResolver freeMarkerViewResolver = (FreeMarkerViewResolver) resolver;
    accessor = new DirectFieldAccessor(resolver);
    assertEquals("freemarker-", accessor.getPropertyValue("prefix"));
    assertEquals(".freemarker", accessor.getPropertyValue("suffix"));
    assertArrayEquals(new String[] {"my*", "*Report"}, (String[]) accessor.getPropertyValue("viewNames"));
    assertEquals(1024, accessor.getPropertyValue("cacheLimit"));

    resolver = resolvers.get(4);
    VelocityViewResolver velocityViewResolver = (VelocityViewResolver) resolver;
    accessor = new DirectFieldAccessor(resolver);
    assertEquals("", accessor.getPropertyValue("prefix"));
    assertEquals(".vm", accessor.getPropertyValue("suffix"));
    assertEquals(0, accessor.getPropertyValue("cacheLimit"));

    resolver = resolvers.get(5);
    GroovyMarkupViewResolver groovyMarkupViewResolver = (GroovyMarkupViewResolver) resolver;
    accessor = new DirectFieldAccessor(resolver);
    assertEquals("", accessor.getPropertyValue("prefix"));
    assertEquals(".tpl", accessor.getPropertyValue("suffix"));
    assertEquals(1024, accessor.getPropertyValue("cacheLimit"));

    assertEquals(InternalResourceViewResolver.class, resolvers.get(6).getClass());
    assertEquals(InternalResourceViewResolver.class, resolvers.get(7).getClass());


    TilesConfigurer tilesConfigurer = appContext.getBean(TilesConfigurer.class);
    assertNotNull(tilesConfigurer);
    String[] definitions = {
        "/org/springframework/web/servlet/resource/tiles/tiles1.xml",
        "/org/springframework/web/servlet/resource/tiles/tiles2.xml"
    };
    accessor = new DirectFieldAccessor(tilesConfigurer);
    assertArrayEquals(definitions, (String[]) accessor.getPropertyValue("definitions"));
    assertTrue((boolean)accessor.getPropertyValue("checkRefresh"));

    FreeMarkerConfigurer freeMarkerConfigurer = appContext.getBean(FreeMarkerConfigurer.class);
    assertNotNull(freeMarkerConfigurer);
    accessor = new DirectFieldAccessor(freeMarkerConfigurer);
    assertArrayEquals(new String[]{"/", "/test"}, (String[]) accessor.getPropertyValue("templateLoaderPaths"));

    VelocityConfigurer velocityConfigurer = appContext.getBean(VelocityConfigurer.class);
    assertNotNull(velocityConfigurer);
    accessor = new DirectFieldAccessor(velocityConfigurer);
    assertEquals("/test", accessor.getPropertyValue("resourceLoaderPath"));

    GroovyMarkupConfigurer groovyMarkupConfigurer = appContext.getBean(GroovyMarkupConfigurer.class);
    assertNotNull(groovyMarkupConfigurer);
    assertEquals("/test", groovyMarkupConfigurer.getResourceLoaderPath());
    assertTrue(groovyMarkupConfigurer.isAutoIndent());
View Full Code Here

    assertEquals(6, cnvr.getViewResolvers().size());
    assertEquals(1, cnvr.getDefaultViews().size());
    assertTrue(cnvr.isUseNotAcceptableStatusCode());

    String beanName = "contentNegotiationManager";
    DirectFieldAccessor accessor = new DirectFieldAccessor(cnvr);
    ContentNegotiationManager manager = (ContentNegotiationManager) accessor.getPropertyValue(beanName);
    assertNotNull(manager);
    assertSame(manager, this.appContext.getBean(ContentNegotiationManager.class));
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.DirectFieldAccessor

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.