Exemplo n.º 1
0
  /**
   * This test verifies that the DateProvider is used for date string conversion instead of string
   * constructor that would be invoking deprecated Date(String) constructor.
   */
  @Test
  public void testDateParamConverterIsChosenForDateString() {
    initiateWebApplication();
    final ParamConverter<Date> converter =
        new ParamConverters.AggregatedProvider(app().getServiceLocator())
            .getConverter(Date.class, Date.class, null);

    assertEquals(
        "Unexpected date converter provider class",
        ParamConverters.DateProvider.class,
        converter.getClass().getEnclosingClass());
  }
Exemplo n.º 2
0
  protected String convertParamValue(Object pValue, Annotation[] anns) {
    if (pValue == null) {
      return null;
    }
    ProviderFactory pf = ClientProviderFactory.getInstance(cfg.getBus());
    if (pf != null) {
      Class<?> pClass = pValue.getClass();

      @SuppressWarnings("unchecked")
      ParamConverter<Object> prov =
          (ParamConverter<Object>) pf.createParameterHandler(pClass, anns);
      if (prov != null) {
        return prov.toString(pValue);
      }
    }
    return pValue.toString();
  }