List of usage examples for org.apache.commons.io.input NullInputStream NullInputStream
public NullInputStream(long size)
From source file:ch.cyberduck.core.dav.DAVUploadFeatureTest.java
@Test public void testDecorate() throws Exception { final NullInputStream n = new NullInputStream(1L); final DAVSession session = new DAVSession(new Host(new DAVProtocol(), "h")); assertSame(NullInputStream.class, new DAVUploadFeature(new DAVWriteFeature(session)).decorate(n, null).getClass()); }
From source file:com.netflix.imfutility.util.conversion.executor.FakeProcess.java
@Override public InputStream getInputStream() { return new NullInputStream(100); }
From source file:ch.cyberduck.core.onedrive.OneDriveReadFeature.java
@Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try {//from w w w . j a v a2 s.c o m if (file.getType().contains(Path.Type.placeholder)) { final DescriptiveUrl link = new OneDriveUrlProvider().toUrl(file).find(DescriptiveUrl.Type.http); if (DescriptiveUrl.EMPTY.equals(link)) { log.warn(String.format("Missing web link for file %s", file)); return new NullInputStream(file.attributes().getSize()); } // Write web link file return IOUtils.toInputStream(UrlFileWriterFactory.get().write(link), Charset.defaultCharset()); } else { if (status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); final String header; if (-1 == range.getEnd()) { header = String.format("%d-", range.getStart()); } else { header = String.format("%d-%d", range.getStart(), range.getEnd()); } if (log.isDebugEnabled()) { log.debug(String.format("Add range header %s for file %s", header, file)); } return session.toFile(file).download(header); } return session.toFile(file).download(); } } catch (OneDriveAPIException e) { throw new OneDriveExceptionMappingService().map("Download {0} failed", e, file); } catch (IOException e) { throw new DefaultIOExceptionMappingService().map("Download {0} failed", e, file); } }
From source file:hudson.cli.CopyJobCommandTest.java
@Test public void copyBetweenFolders() throws Exception { MockFolder dir1 = j.createFolder("dir1"); MockFolder dir2 = j.createFolder("dir2"); FreeStyleProject p = dir1.createProject(FreeStyleProject.class, "p1"); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream outS = new PrintStream(out); int result = new CopyJobCommand().main(Arrays.asList("dir1/p1", "dir2/p2"), Locale.ENGLISH, new NullInputStream(0), outS, outS); outS.flush();/*from w ww . j a v a2s .c o m*/ assertEquals(out.toString(), 0, result); assertEquals("", out.toString()); assertNotNull(j.jenkins.getItemByFullName("dir2/p2")); // TODO test copying from/to root, or into nonexistent folder }
From source file:hudson.cli.GetJobCommandTest.java
@Issue("JENKINS-20236") @Test/* w w w.j a v a 2 s. c om*/ public void withFolders() throws Exception { MockFolder d = j.createFolder("d"); FreeStyleProject p = d.createProject(FreeStyleProject.class, "p"); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream outS = new PrintStream(out); int result = new GetJobCommand().main(Collections.singletonList("d/p"), Locale.ENGLISH, new NullInputStream(0), outS, outS); outS.flush(); String output = out.toString(); assertEquals(output, 0, result); assertEquals(p.getConfigFile().asString(), output); out = new ByteArrayOutputStream(); outS = new PrintStream(out); result = new GetJobCommand().main(Collections.singletonList("d"), Locale.ENGLISH, new NullInputStream(0), outS, outS); outS.flush(); output = out.toString(); assertEquals(output, 0, result); assertEquals(d.getConfigFile().asString(), output); }
From source file:com.talis.storage.SubmittedItemTest.java
@Test public void metadataIsEmptyAfterIfNotSuppliedInConstructor() { SubmittedItem submittedItem = new SubmittedItem(MediaType.TEXT_XML_TYPE, new NullInputStream(1024)); assertTrue(submittedItem.getMetadata().isEmpty()); }
From source file:com.netflix.imfutility.util.conversion.executor.FakeProcess.java
@Override public InputStream getErrorStream() { return new NullInputStream(100); }
From source file:eu.scape_project.arc2warc.PayloadContent.java
public PayloadContent(InputStream inputStream, long length, byte[] buffer) { this.length = length; this.buffer = buffer; identifiedPayLoadType = MIME_UNKNOWN; identified = false;// www . ja v a2s.c o m consumed = false; identifier = null; doPayloadIdentification = false; this.inputStream = (length != 0 ? inputStream : new NullInputStream(0)); }
From source file:net.krotscheck.dfr.stream.AbstractStreamDecoderTest.java
/** * Assert that the input field may be set. * * @throws Exception Should not throw an exception. */// www . j a va 2 s . com @Test public void testGetSetInput() throws Exception { IStreamDecoder decoder = new TestStreamDecoder(testData); Assert.assertNull(decoder.getInputStream()); // Test input stream InputStream stream = new NullInputStream(100); decoder.setInputStream(stream); Assert.assertEquals(stream, decoder.getInputStream()); }
From source file:com.github.sleroy.junit.mail.server.MailSaverTest.java
@SuppressWarnings("deprecation") // TEST WITH CORRECT CONFIG AND INVALID INPUT @Test//from w w w . j av a 2 s. c om public void testSaveEmailAndNotify_correct_config_invalid_input() throws Exception { // GIVEN I have a server accurately configured (relay domains) ServerConfiguration serverConfiguration = new ServerConfiguration(); MailSaver mailSaver = new MailSaver(serverConfiguration); serverConfiguration.relayDomains("data.org"); MailServerModel mailServerModel = new MailServerModel(); // AND I don't forget to register the mailServerModel mailSaver.addObserver(mailServerModel); // WHEN I sent a mail mailSaver.saveEmailAndNotify(FROM, TO, new NullInputStream(10)); // THEN Assert.assertEquals(1, mailServerModel.getEmailModels().size()); EmailModel emailModel = mailServerModel.getEmailModels().get(0); assertNotNull(emailModel); assertEquals("", emailModel.getSubject()); // }