AbstractConverter implements Converter { @Override public void convert(Object source, Object target, String... tags) throws JTransfoException { try { doConvert(source, target, tags); } catch (IllegalAccessException iae) { throw new JTransfoException(accessExceptionMessage(), iae); } catch (IllegalArgumentException iae) { if (null != iae.getStackTrace() && iae.getStackTrace().length > 0) { String throwingClass = iae.getStackTrace()[0].getClassName(); if (throwingClass.startsWith("sun.reflect.") || iae.getMessage().contains("Can not set ")) { throw new JTransfoException(argumentExceptionMessage(), iae); } } throw new JTransfoException(accessExceptionMessage(), iae); } }  abstract void doConvert(Object source, Object target, String... tags); abstract String accessExceptionMessage(); abstract String argumentExceptionMessage(); @Override void convert(Object source, Object target, String... tags);  }
@Test public void testConvertNothing() throws Exception { abstractConverter.convert(null, null); }
@Test public void testConvertJTransfoException() throws Exception { doConvertResult = 1; exception.expect(JTransfoException.class); exception.expectMessage("jte"); abstractConverter.convert(null, null); }
@Test public void testConvertIllegalAccessException() throws Exception { doConvertResult = 2; exception.expect(JTransfoException.class); exception.expectMessage("NoAccess"); abstractConverter.convert(null, null); }
@Test public void testConvertIllegalArgumentException() throws Exception { doConvertResult = 3; exception.expect(JTransfoException.class); exception.expectMessage("NoAccess"); abstractConverter.convert(null, null); }