List of usage examples for org.apache.commons.io.output NullOutputStream NULL_OUTPUT_STREAM
NullOutputStream NULL_OUTPUT_STREAM
To view the source code for org.apache.commons.io.output NullOutputStream NULL_OUTPUT_STREAM.
Click Source Link
From source file:com.predic8.membrane.core.ws.relocator.RelocatorTest.java
@Override protected void setUp() throws Exception { relocator = new Relocator(new OutputStreamWriter(NullOutputStream.NULL_OUTPUT_STREAM, Constants.UTF_8), "http", "localhost", 3000, null); super.setUp(); }
From source file:acmi.l2.clientmod.l2_version_switcher.Util.java
public static boolean hashEquals(File file, String hashString) throws IOException { try {//from ww w . ja v a2 s. c om MessageDigest md = MessageDigest.getInstance("sha-1"); try (FileInputStream hashBytes = new FileInputStream(file)) { DigestInputStream dis = new DigestInputStream(hashBytes, md); IOUtils.copy(dis, NullOutputStream.NULL_OUTPUT_STREAM); } byte[] hash = md.digest(); return Arrays.equals(hash, parseHexBinary(hashString)); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
From source file:com.netflix.zeno.hash.HashOrderDependent.java
public HashOrderDependent() { try {//ww w . ja v a 2 s. co m digest = MessageDigest.getInstance("MD5"); } catch (Exception ex) { throw new RuntimeException(ex); } digestOutputStream = new DigestOutputStream(NullOutputStream.NULL_OUTPUT_STREAM, digest); dataOutputStream = new DataOutputStream(digestOutputStream); }
From source file:ch.cyberduck.core.http.DelayedHttpEntity.java
/** * @return The stream to write to after the entry signal was received. *//*from w ww . j a v a 2 s .co m*/ public OutputStream getStream() { if (null == stream) { // Nothing to write return NullOutputStream.NULL_OUTPUT_STREAM; } return stream; }
From source file:au.org.intersect.dms.wn.transports.impl.NullConnection.java
@Override public OutputStream openOutputStream(String to, long size) throws IOException { LOGGER.debug("Null OutputStream for: {}", to); return NullOutputStream.NULL_OUTPUT_STREAM; }
From source file:com.xpn.xwiki.internal.pdf.XHTML2FOTest.java
private void validateFOP(String transformedXML) throws Exception { // Run FOP to verify that the XML passed as input is some valid FO and doesn't generate errors Fop fop = fopFactory.newFop(new PdfExport.ExportType("application/pdf", "pdf").getMimeType(), foUserAgent, NullOutputStream.NULL_OUTPUT_STREAM); Transformer transformer = transformerFactory.newTransformer(); Source source = new StreamSource(new StringReader(transformedXML)); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(source, res);/*ww w . ja v a2s .c o m*/ }
From source file:com.googlecode.jmxtrans.model.output.LibratoWriter.java
private void writeToLibrato(Server server, Query query, List<Result> results) { HttpURLConnection urlConnection = null; try {//from ww w . ja v a 2s .co m if (proxy == null) { urlConnection = (HttpURLConnection) url.openConnection(); } else { urlConnection = (HttpURLConnection) url.openConnection(proxy); } urlConnection.setRequestMethod("POST"); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setReadTimeout(libratoApiTimeoutInMillis); urlConnection.setRequestProperty("content-type", "application/json; charset=utf-8"); urlConnection.setRequestProperty("Authorization", "Basic " + basicAuthentication); urlConnection.setRequestProperty("User-Agent", httpUserAgent); serialize(server, query, results, urlConnection.getOutputStream()); int responseCode = urlConnection.getResponseCode(); if (responseCode != 200) { logger.warn("Failure {}:'{}' to send result to Librato server '{}' with proxy {}, username {}", responseCode, urlConnection.getResponseMessage(), url, proxy, username); } if (logger.isTraceEnabled()) { StringWriter out = new StringWriter(); IOUtils.copy(urlConnection.getInputStream(), out); logger.trace(out.toString()); } } catch (Exception e) { logger.warn("Failure to send result to Librato server '{}' with proxy {}, username {}", url, proxy, username, e); } finally { if (urlConnection != null) { try { InputStream in = urlConnection.getInputStream(); IOUtils.copy(in, NullOutputStream.NULL_OUTPUT_STREAM); IOUtils.closeQuietly(in); InputStream err = urlConnection.getErrorStream(); if (err != null) { IOUtils.copy(err, NullOutputStream.NULL_OUTPUT_STREAM); IOUtils.closeQuietly(err); } } catch (IOException e) { logger.warn("Exception flushing http connection", e); } } } }
From source file:org.apache.hadoop.hdfs.server.namenode.snapshot.TestSnapshot.java
/** * Test if the OfflineImageViewerPB can correctly parse a fsimage containing * snapshots//from w w w. j a v a 2 s . c om */ @Test public void testOfflineImageViewer() throws Exception { runTestSnapshot(1); // retrieve the fsimage. Note that we already save namespace to fsimage at // the end of each iteration of runTestSnapshot. File originalFsimage = FSImageTestUtil.findLatestImageFile( FSImageTestUtil.getFSImage(cluster.getNameNode()).getStorage().getStorageDir(0)); assertNotNull("Didn't generate or can't find fsimage", originalFsimage); PrintStream o = new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM); PBImageXmlWriter v = new PBImageXmlWriter(new Configuration(), o); v.visit(new RandomAccessFile(originalFsimage, "r")); }
From source file:org.apereo.portal.portlet.container.cache.CachingPortletOutputHandlerTest.java
@Test public void testBasicStreamCaching() throws IOException { final CachingPortletOutputHandler cachingOutputHandler = new CachingPortletOutputHandler( portletOutputHandler, 10000); when(portletOutputHandler.getOutputStream()).thenReturn(NullOutputStream.NULL_OUTPUT_STREAM); final String output = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; final OutputStream outputStream = cachingOutputHandler.getOutputStream(); outputStream.write(output.getBytes()); final CachedPortletData<Long> cachedPortletData = cachingOutputHandler.getCachedPortletData(1l, new CacheControlImpl()); assertNotNull(cachedPortletData);//w w w .ja v a2s . co m assertArrayEquals(output.getBytes(), cachedPortletData.getCachedStreamOutput()); }
From source file:org.apereo.portal.portlet.container.cache.CachingPortletOutputHandlerTest.java
@Test public void testTooMuchStreamContent() throws IOException { final CachingPortletOutputHandler cachingOutputHandler = new CachingPortletOutputHandler( portletOutputHandler, 100);//from w ww . j av a 2s . c o m when(portletOutputHandler.getOutputStream()).thenReturn(NullOutputStream.NULL_OUTPUT_STREAM); final String output = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; final OutputStream outputStream = cachingOutputHandler.getOutputStream(); outputStream.write(output.getBytes()); outputStream.write(output.getBytes()); final CachedPortletData<Long> cachedPortletData = cachingOutputHandler.getCachedPortletData(1l, new CacheControlImpl()); assertNull(cachedPortletData); }