Package org.apache.wicket

Examples of org.apache.wicket.IConverterLocator


  /**
   * Test generalized conversion
   */
  public void testConversion()
  {
    final IConverterLocator converter = new ConverterLocator();
    assertEquals("7", converter.getConverter(Integer.class).convertToString(7, Locale.US));
    assertEquals("7.1", converter.getConverter(Double.class).convertToString(7.1, Locale.US));
    assertEquals("7,1", converter.getConverter(Double.class).convertToString(7.1, DUTCH_LOCALE));

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2002, Calendar.OCTOBER, 24);
    Date date = cal.getTime();

    assertEquals(date, converter.getConverter(Date.class).convertToObject("24-10-02",
      DUTCH_LOCALE));
    assertEquals("24-10-02", converter.getConverter(Date.class).convertToString(date,
      DUTCH_LOCALE));

    // empty strings should return null, NOT throw NPEs
    assertNull(converter.getConverter(Integer.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Byte.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Character.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Float.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Long.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Short.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Date.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Double.class).convertToObject("", Locale.US));
    assertEquals(Boolean.FALSE, converter.getConverter(Boolean.class).convertToObject("",
      Locale.US));
    assertNotNull(converter.getConverter(String.class).convertToObject("", Locale.US));
  }
View Full Code Here


  /**
   * Test generalized conversion
   */
  public void testConversion()
  {
    final IConverterLocator converter = new ConverterLocator();
    assertEquals("7", converter.getConverter(Integer.class).convertToString(new Integer(7),
      Locale.US));
    assertEquals("7.1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      Locale.US));
    assertEquals("7,1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      DUTCH_LOCALE));

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2002, Calendar.OCTOBER, 24);
    Date date = cal.getTime();

    assertEquals(date, converter.getConverter(Date.class).convertToObject("24-10-02",
      DUTCH_LOCALE));
    assertEquals("24-10-02", converter.getConverter(Date.class).convertToString(date,
      DUTCH_LOCALE));

    // empty strings should return null, NOT throw NPEs
    assertNull(converter.getConverter(Integer.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Byte.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Character.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Float.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Long.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Short.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Date.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Double.class).convertToObject("", Locale.US));
    assertEquals(Boolean.FALSE, converter.getConverter(Boolean.class).convertToObject("",
      Locale.US));
    assertNotNull(converter.getConverter(String.class).convertToObject("", Locale.US));
  }
View Full Code Here

public class ConverterTest extends GeoServerWicketTestSupport {

    public void testConvertEmtpyString() {
        // Wicket forms rely on converters returning null from an empty string conversion
        IConverterLocator locator = tester.getApplication().getConverterLocator();
        IConverter convert = locator.getConverter(Integer.class);
        assertNotNull(convert);
        assertNull(convert.convertToObject("", Locale.getDefault()));
    }
View Full Code Here

  /**
   * WICKET-3441
   */
  public void testDateToStringConverting()
  {
    IConverterLocator converterLocator = new ConverterLocator();
    Locale locale = Locale.GERMAN;
    PropertyResolverConverter converter = new PropertyResolverConverter(converterLocator,
      locale);

    Calendar calDate = Calendar.getInstance();
    calDate.clear();
    calDate.set(2011, Calendar.APRIL, 17);
    Date date = calDate.getTime();

    Object actual = converter.convert(date, String.class);
    String expected = converterLocator.getConverter(Date.class).convertToString(date, locale);
    assertEquals(expected, actual);
  }
View Full Code Here

  /**
   * Test generalized conversion
   */
  public void testConversion()
  {
    final IConverterLocator converter = new ConverterLocator();
    assertEquals("7", converter.getConverter(Integer.class).convertToString(new Integer(7),
      Locale.US));
    assertEquals("7.1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      Locale.US));
    assertEquals("7,1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      DUTCH_LOCALE));

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2002, Calendar.OCTOBER, 24);
    Date date = cal.getTime();

    assertEquals(date, converter.getConverter(Date.class).convertToObject("24-10-02",
      DUTCH_LOCALE));
    assertEquals("24-10-02", converter.getConverter(Date.class).convertToString(date,
      DUTCH_LOCALE));

    // empty strings should return null, NOT throw NPEs
    assertNull(converter.getConverter(Integer.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Byte.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Character.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Float.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Long.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Short.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Date.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Double.class).convertToObject("", Locale.US));
    assertEquals(Boolean.FALSE, converter.getConverter(Boolean.class).convertToObject("",
      Locale.US));
    assertNotNull(converter.getConverter(String.class).convertToObject("", Locale.US));
  }
View Full Code Here

  /**
   * Test generalized conversion
   */
  public void testConversion()
  {
    final IConverterLocator converter = new ConverterLocator();
    assertEquals("7", converter.getConverter(Integer.class).convertToString(new Integer(7),
      Locale.US));
    assertEquals("7.1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      Locale.US));
    assertEquals("7,1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      DUTCH_LOCALE));

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2002, Calendar.OCTOBER, 24);
    Date date = cal.getTime();

    assertEquals(date, converter.getConverter(Date.class).convertToObject("24-10-02",
      DUTCH_LOCALE));
    assertEquals("24-10-02", converter.getConverter(Date.class).convertToString(date,
      DUTCH_LOCALE));

    // empty strings should return null, NOT throw NPEs
    assertNull(converter.getConverter(Integer.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Byte.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Character.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Float.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Long.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Short.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Date.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Double.class).convertToObject("", Locale.US));
    assertEquals(Boolean.FALSE, converter.getConverter(Boolean.class).convertToObject("",
      Locale.US));
    assertNotNull(converter.getConverter(String.class).convertToObject("", Locale.US));
  }
View Full Code Here

  /**
   * Test generalized conversion
   */
  public void testConversion()
  {
    final IConverterLocator converter = new ConverterLocator();
    assertEquals("7", converter.getConverter(Integer.class).convertToString(new Integer(7),
      Locale.US));
    assertEquals("7.1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      Locale.US));
    assertEquals("7,1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      DUTCH_LOCALE));

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2002, Calendar.OCTOBER, 24);
    Date date = cal.getTime();

    assertEquals(date, converter.getConverter(Date.class).convertToObject("24-10-02",
      DUTCH_LOCALE));
    assertEquals("24-10-02", converter.getConverter(Date.class).convertToString(date,
      DUTCH_LOCALE));

    // empty strings should return null, NOT throw NPEs
    assertNull(converter.getConverter(Integer.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Byte.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Character.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Float.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Long.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Short.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Date.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Double.class).convertToObject("", Locale.US));
    assertEquals(Boolean.FALSE, converter.getConverter(Boolean.class).convertToObject("",
      Locale.US));
    assertNotNull(converter.getConverter(String.class).convertToObject("", Locale.US));
  }
View Full Code Here

  /**
   * Test generalized conversion
   */
  public void testConversion()
  {
    final IConverterLocator converter = new ConverterLocator();
    assertEquals("7", converter.getConverter(Integer.class).convertToString(new Integer(7),
        Locale.US));
    assertEquals("7.1", converter.getConverter(Double.class).convertToString(new Double(7.1),
        Locale.US));
    assertEquals("7,1", converter.getConverter(Double.class).convertToString(new Double(7.1),
        DUTCH_LOCALE));

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2002, Calendar.OCTOBER, 24);
    Date date = cal.getTime();

    assertEquals(date, converter.getConverter(Date.class).convertToObject("24-10-02",
        DUTCH_LOCALE));
    assertEquals("24-10-02", converter.getConverter(Date.class).convertToString(date,
        DUTCH_LOCALE));

    // empty strings should return null, NOT throw NPEs
    assertNull(converter.getConverter(Integer.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Byte.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Character.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Float.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Long.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Short.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Date.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Double.class).convertToObject("", Locale.US));
    assertEquals(Boolean.FALSE, converter.getConverter(Boolean.class).convertToObject("",
        Locale.US));
    assertNotNull(converter.getConverter(String.class).convertToObject("", Locale.US));
  }
View Full Code Here

  /**
   * Test generalized conversion
   */
  public void testConversion()
  {
    final IConverterLocator converter = new ConverterLocator();
    assertEquals("7", converter.getConverter(Integer.class).convertToString(new Integer(7),
      Locale.US));
    assertEquals("7.1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      Locale.US));
    assertEquals("7,1", converter.getConverter(Double.class).convertToString(new Double(7.1),
      DUTCH_LOCALE));

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2002, Calendar.OCTOBER, 24);
    Date date = cal.getTime();

    assertEquals(date, converter.getConverter(Date.class).convertToObject("24-10-02",
      DUTCH_LOCALE));
    assertEquals("24-10-02", converter.getConverter(Date.class).convertToString(date,
      DUTCH_LOCALE));

    // empty strings should return null, NOT throw NPEs
    assertNull(converter.getConverter(Integer.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Byte.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Character.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Float.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Long.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Short.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Date.class).convertToObject("", Locale.US));
    assertNull(converter.getConverter(Double.class).convertToObject("", Locale.US));
    assertEquals(Boolean.FALSE, converter.getConverter(Boolean.class).convertToObject("",
      Locale.US));
    assertNotNull(converter.getConverter(String.class).convertToObject("", Locale.US));
  }
View Full Code Here

//        assertThat(newRequestCycle, is(WebRequestCycleForIsis.class));
    }

    @Test
    public void providesConverterLocatorRegistersIsisSpecificConverters() {
        final IConverterLocator converterLocator = application.newConverterLocator();
        assertThat(converterLocator.getConverter(ObjectAdapter.class), is(not(nullValue())));
        assertThat(converterLocator.getConverter(ObjectAdapterMemento.class), is(not(nullValue())));
    }
View Full Code Here

TOP

Related Classes of org.apache.wicket.IConverterLocator

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.