@Override public InputStream openBufferedStream() throws IOException { return sliceStream(ByteSource.this.openBufferedStream()); }
@Override public InputStream openBufferedStream() throws IOException { return sliceStream(ByteSource.this.openBufferedStream()); }
@Override public InputStream openBufferedStream() throws IOException { return sliceStream(ByteSource.this.openBufferedStream()); }
public void testOpenBufferedStream() throws IOException { InputStream in = source.openBufferedStream(); try { byte[] readBytes = ByteStreams.toByteArray(in); assertExpectedBytes(readBytes); } finally { in.close(); } }
private InputStream getTestResource(String name) throws IOException { return Resources.asByteSource(this.getClass().getResource(this.getClass().getSimpleName() + "/" + name)) .openBufferedStream(); }
@Test public void testParseServerResponse() throws IOException { ScannerWsClient wsClient = mock(ScannerWsClient.class); InputStream is = Resources.asByteSource(this.getClass().getResource("DefaultRulesLoaderTest/response.protobuf")).openBufferedStream(); WsTestUtil.mockStream(wsClient, is); DefaultRulesLoader loader = new DefaultRulesLoader(wsClient); List<Rule> ruleList = loader.load(); assertThat(ruleList).hasSize(318); }
@Test public void testError() throws IOException { ScannerWsClient wsClient = mock(ScannerWsClient.class); InputStream is = ByteSource.wrap(new String("trash").getBytes()).openBufferedStream(); WsTestUtil.mockStream(wsClient, is); DefaultRulesLoader loader = new DefaultRulesLoader(wsClient); exception.expect(IllegalStateException.class); exception.expectMessage("Unable to get rules"); loader.load(); } }
payload.writeTo(writer); try (InputStream rawIn = os.asByteSource().openBufferedStream(); BufferedInputStream contentStream = new BufferedInputStream(rawIn)) {
public InputStream openBufferedStream() { try { return delegate.openBufferedStream(); } catch (IOException ex) { throw new AssertionError("An illegal IOException was throw"); } }
public InputStream openBufferedStream() { try { return delegate.openBufferedStream(); } catch (IOException ex) { throw new AssertionError("An illegal IOException was throw"); } }
public InputStream openBufferedStream() { try { return delegate.openBufferedStream(); } catch (IOException ex) { throw new AssertionError("An illegal IOException was throw"); } }
public InputStream openBufferedStream() { try { return delegate.openBufferedStream(); } catch (IOException ex) { throw new AssertionError("An illegal IOException was throw"); } }
private static <T> T readFromSource(ByteSource bs) throws IOException, ClassNotFoundException { try (ObjectInputStream ois = new ObjectInputStream(bs.openBufferedStream())) { return (T) ois.readObject(); } }
private static Properties loadProperties(String filename) throws IOException { URL url = Resources.getResource(filename); final Properties props = new Properties(); final ByteSource byteSource = Resources.asByteSource(url); InputStream inputStream = null; inputStream = byteSource.openBufferedStream(); props.load(inputStream); return props; }
@Override public InputStream openBufferedStream() throws IOException { return sliceStream(ByteSource.this.openBufferedStream()); }
@Override public InputStream openBufferedStream() throws IOException { return get().openBufferedStream(); }
/** * Analyze the source file, looking for public method, possibly annotated * with cucumber annotations * @param sourceFile * @return * @throws IOException */ public List<TestStep> analyzeFile(File sourceFile) throws IOException { return analyzeFile(Files.asByteSource(sourceFile).openBufferedStream()); } public List<TestStep> analyzeFile(InputStream inputStream) {
public void testOpenBufferedStream() throws IOException { InputStream in = source.openBufferedStream(); try { byte[] readBytes = ByteStreams.toByteArray(in); assertExpectedBytes(readBytes); } finally { in.close(); } }
@Before public void setup() throws IOException { MockitoAnnotations.initMocks(this); doReturn(mockFiledBackedStream).when(mockFiledBackedStreamFactory).newInstance(); setupMockFiledBackedStream(mockFiledBackedStream); doReturn(mockByteSource).when(mockFiledBackedStream).asByteSource(); doReturn(mockInputStream).when(mockByteSource).openStream(); doReturn(mockInputStream).when(mockByteSource).openBufferedStream(); doReturn(10L).when(mockByteSource).size(); doReturn(0).when(mockInputStream).read(any(byte[].class)); }
private static InputStream stringToInputStream(String contents) throws IOException { return CharSource.wrap(contents).asByteSource(Charsets.UTF_8).openBufferedStream(); }