List of usage examples for org.apache.commons.io IOUtils toInputStream
public static InputStream toInputStream(String input)
From source file:ld.ldhomework.crawler.DownloadedFile.java
public InputStream getContent() { return IOUtils.toInputStream(content); }
From source file:edu.purdue.cybercenter.dm.util.Helper.java
public static void stringToFile(String string, String filename) throws FileNotFoundException, IOException { try (OutputStream os = new FileOutputStream(filename); InputStream is = IOUtils.toInputStream(string)) { IOUtils.copy(is, os);//from w ww .jav a 2 s.c o m } }
From source file:com.allogy.io.NoNewEditsInputStreamTest.java
@Test public void stream_should_return_inner_stream_followed_by_comma_new_edits_false() throws IOException { String innerString = "[" + UUID.randomUUID().toString() + "]"; InputStream innerInputStream = IOUtils.toInputStream(innerString); String stringFromObjectUnderTest = IOUtils.toString(new NoNewEditsInputStream(innerInputStream)); assertThat(stringFromObjectUnderTest, notNullValue()); assertThat(stringFromObjectUnderTest.startsWith(innerString), is(true)); String prependedString = stringFromObjectUnderTest.substring(innerString.length()); assertThat(prependedString, is(", \"new_edits\": false")); }
From source file:com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptorParserTest.java
@Test public void shouldPerformPluginXsdValidationAndFailWhenIDIsNotPresent() throws Exception { InputStream pluginXml = IOUtils.toInputStream("<go-plugin version=\"1\"></go-plugin>"); try {/*from ww w .j a va 2s .co m*/ GoPluginDescriptorParser.parseXML(pluginXml, "/tmp/", new File("/tmp/"), true); fail("xsd validation should have failed"); } catch (SAXException e) { assertThat(e.getMessage(), is("XML Schema validation of Plugin Descriptor(plugin.xml) failed")); } }
From source file:com.cazcade.billabong.store.impl.MapBasedBinaryStoreTest.java
@Test public void testMapBasedBinaryStore() throws IOException { BinaryStore store = new MapBasedBinaryStore(); InputStream storeEntry = IOUtils.toInputStream("TESTY"); Assert.assertTrue(store.placeInStore(STORE_KEY, storeEntry, false)); storeEntry = IOUtils.toInputStream("TESTY2"); Assert.assertTrue(store.placeInStore(STORE_KEY2, storeEntry, true)); Assert.assertEquals("TESTY", IOUtils.toString(store.retrieveFromStore(STORE_KEY).getContent())); storeEntry = IOUtils.toInputStream("TESTY3"); Assert.assertFalse(store.placeInStore(STORE_KEY, storeEntry, false)); Assert.assertEquals("TESTY", IOUtils.toString(store.retrieveFromStore(STORE_KEY).getContent())); Assert.assertTrue(store.placeInStore(STORE_KEY, storeEntry, true)); Assert.assertEquals("TESTY2", IOUtils.toString(store.retrieveFromStore(STORE_KEY2).getContent())); Assert.assertEquals("TESTY3", IOUtils.toString(store.retrieveFromStore(STORE_KEY).getContent())); }
From source file:com.collective.celos.ci.testing.fixtures.convert.UpperCaseStringFixFileConverter.java
@Override public FixFile convert(TestRun tr, FixFile ff) throws IOException { String newContent = IOUtils.toString(ff.getContent()).toUpperCase(); return new FixFile(IOUtils.toInputStream(newContent)); }
From source file:com.allogy.couch.importers.command.BufferedImportCommand.java
public InputStream getDataStream() { return IOUtils.toInputStream(dataString); }
From source file:com.collective.celos.ci.testing.fixtures.convert.ConversionCreatorTest.java
@Test public void testConversionCreatorForFile() throws Exception { FixObjectCreator<FixFile> creator = Utils.wrap(new FixFile(IOUtils.toInputStream("lowercase"))); AbstractFixObjectConverter<FixFile, FixFile> fixObjectConverter = new UpperCaseStringFixFileConverter(); ConversionCreator<FixFile, FixFile> conversionCreator = new ConversionCreator(creator, fixObjectConverter); FixFile result = conversionCreator.create(null); Assert.assertEquals("LOWERCASE", IOUtils.toString(result.getContent())); }
From source file:de.eidottermihi.rpicheck.test.mocks.CommandMocker.java
public CommandMocker withResponse(String output) { Mockito.when(command.getInputStream()).thenReturn(IOUtils.toInputStream(output)); return this; }
From source file:com.norconex.importer.handler.filter.impl.RegexContentFilterTest.java
@Test public void testAcceptDocument() throws IOException, ImporterHandlerException { RegexContentFilter filter = new RegexContentFilter(); filter.setRegex(".*string.*"); filter.setOnMatch(OnMatch.EXCLUDE);/*from www . ja v a2s . c o m*/ Assert.assertFalse("test1 not filtered properly.", filter.acceptDocument("n/a", IOUtils.toInputStream("a string to match"), null, false)); Assert.assertTrue("test2 not filtered properly.", filter.acceptDocument("n/a", IOUtils.toInputStream("another one not to match"), null, false)); }