Package org.springframework.beans

Examples of org.springframework.beans.DirectFieldAccessor


    ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter)adapter.getMessageConverters().get(0)).getObjectMapper();
    assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
    assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
    assertFalse(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));

    DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);

    // Custom argument resolvers and return value handlers
    List<HandlerMethodArgumentResolver> argResolvers =
      (List<HandlerMethodArgumentResolver>) fieldAccessor.getPropertyValue("customArgumentResolvers");
    assertEquals(1, argResolvers.size());

    List<HandlerMethodReturnValueHandler> handlers =
      (List<HandlerMethodReturnValueHandler>) fieldAccessor.getPropertyValue("customReturnValueHandlers");
    assertEquals(1, handlers.size());

    // Async support options
    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);

    assertEquals(false, fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect"));
  }
View Full Code Here


  public void viewResolvers() throws Exception {
    ViewResolverComposite viewResolver = (ViewResolverComposite) this.config.mvcViewResolver();
    assertEquals(Ordered.HIGHEST_PRECEDENCE, viewResolver.getOrder());
    List<ViewResolver> viewResolvers = viewResolver.getViewResolvers();

    DirectFieldAccessor accessor = new DirectFieldAccessor(viewResolvers.get(0));
    assertEquals(1, viewResolvers.size());
    assertEquals(ContentNegotiatingViewResolver.class, viewResolvers.get(0).getClass());
    assertFalse((Boolean) accessor.getPropertyValue("useNotAcceptableStatusCode"));
    assertNotNull(accessor.getPropertyValue("contentNegotiationManager"));

    List<View> defaultViews = (List<View>)accessor.getPropertyValue("defaultViews");
    assertNotNull(defaultViews);
    assertEquals(1, defaultViews.size());
    assertEquals(MappingJackson2JsonView.class, defaultViews.get(0).getClass());

    viewResolvers = (List<ViewResolver>)accessor.getPropertyValue("viewResolvers");
    assertNotNull(viewResolvers);
    assertEquals(1, viewResolvers.size());
    assertEquals(InternalResourceViewResolver.class, viewResolvers.get(0).getClass());
    accessor = new DirectFieldAccessor(viewResolvers.get(0));
    assertEquals("/", accessor.getPropertyValue("prefix"));
    assertEquals(".jsp", accessor.getPropertyValue("suffix"));
  }
View Full Code Here

    assertEquals(resolverType, this.registry.getViewResolvers().get(0).getClass());
    return (T) registry.getViewResolvers().get(0);
  }

  private void checkPropertyValues(ViewResolver resolver, Object... nameValuePairs) {
    DirectFieldAccessor accessor =  new DirectFieldAccessor(resolver);
    for (int i = 0; i < nameValuePairs.length ; i++, i++) {
      Object expected = nameValuePairs[i + 1];
      Object actual = accessor.getPropertyValue((String) nameValuePairs[i]);
      assertEquals(expected, actual);
    }
  }
View Full Code Here

    Validator validator = initializer.getValidator();
    assertNotNull(validator);
    assertTrue(validator instanceof LocalValidatorFactoryBean);

    DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);
    List<Object> interceptors = (List<Object>) fieldAccessor.getPropertyValue("responseBodyAdvice");
    assertEquals(1, interceptors.size());
    assertEquals(JsonViewResponseBodyAdvice.class, interceptors.get(0).getClass());
  }
View Full Code Here

    assertEquals(DefaultHandlerExceptionResolver.class, expectedResolvers.get(2).getClass());

    ExceptionHandlerExceptionResolver eher = (ExceptionHandlerExceptionResolver) expectedResolvers.get(0);
    assertNotNull(eher.getApplicationContext());

    DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(eher);
    List<Object> interceptors = (List<Object>) fieldAccessor.getPropertyValue("responseBodyAdvice");
    assertEquals(1, interceptors.size());
    assertEquals(JsonViewResponseBodyAdvice.class, interceptors.get(0).getClass());

    LocaleContextHolder.setLocale(Locale.ENGLISH);
    try {
View Full Code Here

    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");
    DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);

    assertSame(backOff, new DirectFieldAccessor(container).getPropertyValue("backOff"));
  }
View Full Code Here

    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    endpoint.setConcurrency("5-10"); // simple implementation only support max value
    endpoint.setMessageListener(messageListener);

    endpoint.setupListenerContainer(container);
    assertEquals(10, new DirectFieldAccessor(container).getPropertyValue("concurrentConsumers"));
  }
View Full Code Here

    assertTrue("listener3 not found", containers.containsKey("listener3"));
    JmsMessageEndpointManager listener3 = containers.get("listener3");
    assertEquals("Wrong resource adapter",
        context.getBean("testResourceAdapter"), listener3.getResourceAdapter());
    assertEquals("Wrong activation spec factory", context.getBean("testActivationSpecFactory"),
        new DirectFieldAccessor(listener3).getPropertyValue("activationSpecFactory"));


    Object endpointFactory = new DirectFieldAccessor(listener3).getPropertyValue("endpointFactory");
    Object messageListener = new DirectFieldAccessor(endpointFactory).getPropertyValue("messageListener");
    assertEquals("Wrong message listener", MessageListenerAdapter.class, messageListener.getClass());
    MessageListenerAdapter adapter = (MessageListenerAdapter) messageListener;
    DirectFieldAccessor adapterFieldAccessor = new DirectFieldAccessor(adapter);
    assertEquals("Message converter not set properly", context.getBean("testMessageConverter"),
        adapterFieldAccessor.getPropertyValue("messageConverter"));
    assertEquals("Wrong delegate", context.getBean("testBean1"),
        adapterFieldAccessor.getPropertyValue("delegate"));
    assertEquals("Wrong method name", "setName",
        adapterFieldAccessor.getPropertyValue("defaultListenerMethod"));
  }
View Full Code Here

    assertEquals("wrong cache", DefaultMessageListenerContainer.CACHE_CONNECTION, container.getCacheLevel());
    assertEquals("wrong concurrency", 3, container.getConcurrentConsumers());
    assertEquals("wrong concurrency", 5, container.getMaxConcurrentConsumers());
    assertEquals("wrong prefetch", 50, container.getMaxMessagesPerTask());
    assertEquals("Wrong phase", 99, container.getPhase());
    assertSame(context.getBean("testBackOff"), new DirectFieldAccessor(container).getPropertyValue("backOff"));
  }
View Full Code Here

    return (MessageListener) container.getMessageListener();
  }

  private ErrorHandler getErrorHandler(String containerBeanName) {
    DefaultMessageListenerContainer container = this.context.getBean(containerBeanName, DefaultMessageListenerContainer.class);
    return (ErrorHandler) new DirectFieldAccessor(container).getPropertyValue("errorHandler");
  }
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.