@Test public void testConverter() { ClassConverter.log = Mockito.mock(Logger.class); final ClassConverter converter = new ClassConverter(); assertNull(converter.fromString(null)); assertNull(converter.fromString("")); assertNull(converter.fromString("\t \n")); assertEquals(ClassConverterTest.class, converter.fromString("org.projectforge.framework.xstream.converter.ClassConverterTest")); assertEquals(null, converter.fromString("org.projectforge.xml.stream.converter.NotFound")); }
@Override public Class< ? > fromString(final String str) { if (StringUtils.isBlank(str) || XmlConstants.NULL_IDENTIFIER.equals(str)) { return null; } try { final Class< ? > clazz = Class.forName(str); return clazz; } catch (final ClassNotFoundException ex) { log.warn("Can't convert value '" + str + "' to class (no such class found)."); return null; } }
ClassConverter implements IConverter<Class< ? >> { @Override public Class< ? > fromString(final String str) { if (StringUtils.isBlank(str) || XmlConstants.NULL_IDENTIFIER.equals(str)) { return null; } try { final Class< ? > clazz = Class.forName(str); return clazz; } catch (final ClassNotFoundException ex) { log.warn("Can't convert value '" + str + "' to class (no such class found)."); return null; } } }
ClassConverter implements IConverter<Class< ? >> { @Override public Class< ? > fromString(final String str) { if (StringUtils.isBlank(str) || XmlConstants.NULL_IDENTIFIER.equals(str)) { return null; } try { final Class< ? > clazz = Class.forName(str); return clazz; } catch (final ClassNotFoundException ex) { log.warn("Can't convert value '" + str + "' to class (no such class found)."); return null; } }  }
ClassConverter implements IConverter<Class< ? >> { @Override public Class< ? > fromString(final String str) { if (StringUtils.isBlank(str) || XmlConstants.NULL_IDENTIFIER.equals(str)) { return null; } try { final Class< ? > clazz = Class.forName(str); return clazz; } catch (final ClassNotFoundException ex) { log.warn("Can't convert value '" + str + "' to class (no such class found)."); return null; } }  @Override Class< ? > fromString(final String str); @Override String toString(final Object obj); }
ClassConverter implements IConverter<Class< ? >> { @Override public Class< ? > fromString(final String str) { if (StringUtils.isBlank(str) || XmlConstants.NULL_IDENTIFIER.equals(str)) { return null; } try { final Class< ? > clazz = Class.forName(str); return clazz; } catch (final ClassNotFoundException ex) { log.warn("Can't convert value '" + str + "' to class (no such class found)."); return null; } }  @Override Class< ? > fromString(final String str); @Override String toString(final Object obj);  }