privatestaticfinalStringPHRASE="like turkeys voting for (an early) Christmas";
Straight up Java
@Testpublicvoidconvert_string_to_inputstream()throwsIOException{InputStreaminputStream=newByteArrayInputStream(PHRASE.getBytes());// now to do some work w/ itStringBufferphraseThroughStream=newStringBuffer();intc;while((c=inputStream.read())!=-1){phraseThroughStream.append((char)c);}assertEquals(phraseThroughStream.toString(),PHRASE);}
@Testpublicvoidconvert_string_to_inputstream_apache()throwsIOException{InputStreaminputStream=IOUtils.toInputStream(PHRASE);// now to do some work w/ itStringBufferphraseThroughStream=newStringBuffer();intc;while((c=inputStream.read())!=-1){phraseThroughStream.append((char)c);}assertEquals(phraseThroughStream.toString(),PHRASE);}