Examples of DefaultConversionService


Examples of org.springframework.core.convert.support.DefaultConversionService

  Spr7839Controller controller = new Spr7839Controller();

  @Before
  public void setUp() {
    ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
    GenericConversionService service = new DefaultConversionService();
    service.addConverter(new Converter<String, NestedBean>() {
      @Override
      public NestedBean convert(String source) {
        return new NestedBean(source);
      }
    });
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

    }
  }

  @Test
  public void testWithConversionService() {
    ConversionService conversionService = new DefaultConversionService();
    assertTrue(conversionService.canConvert(String.class, MediaType.class));
    MediaType mediaType = MediaType.parseMediaType("application/xml");
    assertEquals(mediaType, conversionService.convert("application/xml", MediaType.class));
  }
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

  }

  @Test
  public void testCustomConverter() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    GenericConversionService conversionService = new DefaultConversionService();
    conversionService.addConverter(new Converter<String, Float>() {
      @Override
      public Float convert(String source) {
        try {
          NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
          return nf.parse(source).floatValue();
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

  private ServletServerHttpResponse response;


  @Before
  public void setUp() {
    ConversionService conversionService = new DefaultConversionService();
    this.converter = new ObjectToStringHttpMessageConverter(conversionService);

    this.servletResponse = new MockHttpServletResponse();
    this.response = new ServletServerHttpResponse(this.servletResponse);
  }
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

  }

  @Test
  public void defaultCharsetModified() throws IOException {
    Charset charset = Charset.forName("UTF-16");
    ConversionService cs = new DefaultConversionService();
    ObjectToStringHttpMessageConverter converter = new ObjectToStringHttpMessageConverter(cs, charset);
    converter.write((byte) 31, null, this.response);

    assertEquals("UTF-16", this.servletResponse.getCharacterEncoding());
  }
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

  @Test
  @Deprecated
  public void test() throws Exception {
    AnnotationMethodHandlerAdapter adapter = new AnnotationMethodHandlerAdapter();
    ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
    GenericConversionService service = new DefaultConversionService();
    service.addConverter(new ColorConverter());
    binder.setConversionService(service);
    adapter.setWebBindingInitializer(binder);
    Spr7766Controller controller = new Spr7766Controller();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/colors");
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

   * @param beanFactory a bean factory to use for resolving {@code ${...}} placeholder
   * and {@code #{...}} SpEL expressions in default values, or {@code null} if default
   * values are not expected to contain expressions
   */
  protected AbstractNamedValueMethodArgumentResolver(ConversionService cs, ConfigurableBeanFactory beanFactory) {
    this.conversionService = (cs != null ? cs : new DefaultConversionService());
    this.configurableBeanFactory = beanFactory;
    this.expressionContext = (beanFactory != null ? new BeanExpressionContext(beanFactory, null) : null);
  }
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

    return this.beanFactory;
  }

  public ConversionService getConversionService() {
    if (this.conversionService == null) {
      this.conversionService = new DefaultConversionService();
    }
    return this.conversionService;
  }
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

  /**
   * Create a new instance with a default {@link ConversionService}.
   */
  public GenericMessageConverter() {
    this.conversionService = new DefaultConversionService();
  }
View Full Code Here

Examples of org.springframework.core.convert.support.DefaultConversionService

    assertEquals("Invalid charset", Charset.forName("UTF-8"), mimeType.getCharSet());
  }

  @Test
  public void testWithConversionService() {
    ConversionService conversionService = new DefaultConversionService();
    assertTrue(conversionService.canConvert(String.class, MimeType.class));
    MimeType mimeType = MimeType.valueOf("application/xml");
    assertEquals(mimeType, conversionService.convert("application/xml", MimeType.class));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.