### Question:
SourceFactory { public Source createSource(final Object from) { Source source; if (from instanceof String) { source = new StreamSource(new StringReader((String) from)); } else if (from instanceof InputStream) { source = new StreamSource((InputStream) from); } else if (from instanceof Reader) { source = new StreamSource((Reader) from); } else if (from instanceof Node) { source = new DOMSource((Node) from); } else if (from instanceof Source) { source = (Source) from; } else if (from instanceof byte[]) { source = new StreamSource(new ByteArrayInputStream((byte[]) from)); } else { source = new JavaSource(from); } return source; } private  SourceFactory(); static SourceFactory getInstance(); Source createSource(final Object from);  }### Answer:
@Test public void createStreamSourceStreamFromString() { Source source = factory.createSource( "testing" ); assertNotNull( source ); assertTrue( source instanceof StreamSource ); }
@Test public void getSourceByteArray() { Source source = factory.createSource( "test".getBytes() ); assertNotNull( source ); assertTrue( source instanceof StreamSource ); }
@Test public void getSourceReader() { Source source = factory.createSource( new StringReader( "testing" )); assertNotNull( source ); assertTrue( source instanceof StreamSource ); }
@Test public void getSourceInputStream() { Source source = factory.createSource( new ByteArrayInputStream( "testing".getBytes() ) ); assertNotNull( source ); assertTrue( source instanceof StreamSource ); }