Package org.springframework.format.support

Examples of org.springframework.format.support.FormattingConversionService


  @Test
  public void shouldLoadConverter() throws Exception {
    FormattingConversionServiceFactoryBean bean = this.applicationContext
        .getBean(FormattingConversionServiceFactoryBean.class);
    FormattingConversionService conversionService = bean.getObject();
    TypeDescriptor targetType = TypeDescriptor.valueOf(ClassWithConverter.class);
    assertThat(conversionService.convert(this.source, this.sourceType, targetType), is(equalTo(this.converted)));
  }
View Full Code Here


  private FormattingConversionService conversionService;

  @Before
  public void setup() {
    this.conversionService = new FormattingConversionService();
    this.conversionService.addConverter(new CustomTypeToStringConverter());
    this.conversionService.addConverter(new StringToCustomTypeConverter());
  }
View Full Code Here

    this.context.register(AllResources.class, Config.class,
        WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    FormattingConversionService cs = this.context
        .getBean(FormattingConversionService.class);
    Date date = new DateTime(1988, 6, 25, 20, 30).toDate();
    // formatting cs should use simple toString()
    assertThat(cs.convert(date, String.class), equalTo(date.toString()));
  }
View Full Code Here

    this.context.register(AllResources.class, Config.class,
        WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    FormattingConversionService cs = this.context
        .getBean(FormattingConversionService.class);
    Date date = new DateTime(1988, 6, 25, 20, 30).toDate();
    assertThat(cs.convert(date, String.class), equalTo("25*06*1988"));
  }
 
View Full Code Here

 
  private MockMvc mockMvc;

  @Before
  public void setup() throws Exception {
    FormattingConversionService cs = new DefaultFormattingConversionService();
    cs.addFormatterForFieldAnnotation(new MaskFormatAnnotationFormatterFactory());

    this.mockMvc = standaloneSetup(new ConvertController())
        .setConversionService(cs)
        .alwaysExpect(status().isOk())
        .build();
View Full Code Here

    ContentNegotiationConfigurer contentNegotiationConfigurer = new ContentNegotiationConfigurer( servletContext );
    contentNegotiationConfigurer.mediaTypes( getDefaultMediaTypes() );

    ResourceHandlerRegistry resourceHandlerRegistry =
        new ResourceHandlerRegistry( applicationContext, servletContext );
    FormattingConversionService conversionService = mvcConversionService();

    for ( WebMvcConfigurer configurer : webMvcConfigurers ) {
      configurer.addArgumentResolvers( argumentResolvers );
      configurer.addReturnValueHandlers( returnValueHandlers );
      configurer.configureMessageConverters( messageConverters );
View Full Code Here

TOP

Related Classes of org.springframework.format.support.FormattingConversionService

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.