DrawableWriterFactory extends AbstractIOFactory<DrawableWriter> { @Override public DrawableWriter get(String mimeType) { DrawableWriter writer = null; Class<? extends DrawableWriter> clazz = getTypeClass(mimeType); try { if (clazz != null) { Constructor<? extends DrawableWriter> constructor = clazz.getDeclaredConstructor(String.class); writer = constructor.newInstance(mimeType); } } catch (SecurityException | InvocationTargetException | IllegalAccessException | InstantiationException | IllegalArgumentException | NoSuchMethodException e) { e.printStackTrace(); } if (writer == null) { throw new IllegalArgumentException(MessageFormat.format( "Unsupported MIME type: {0}", mimeType)); } return writer; } private  DrawableWriterFactory(); static DrawableWriterFactory getInstance(); @Override DrawableWriter get(String mimeType);  }
@Test public void testGet() { DrawableWriterFactory f = DrawableWriterFactory.getInstance(); try { f.get("fail"); fail("Expected IllegalArgumentException."); } catch (IllegalArgumentException e) { } }