Example usage for org.apache.commons.io.output NullOutputStream nullOutputStream

List of usage examples for org.apache.commons.io.output NullOutputStream nullOutputStream

Introduction

In this page you can find the example usage for org.apache.commons.io.output NullOutputStream nullOutputStream.

Prototype

public static OutputStream nullOutputStream() 

Source Link

Document

Returns a new OutputStream which discards all bytes.

Usage

From source file:fi.jumi.core.suite.InternalErrorReportingExecutorTest.java

@Test
public void the_toString_of_the_original_commands_should_not_be_hidden() {
    SpyExecutor backingExecutor = new SpyExecutor();
    InternalErrorReportingExecutor executor = new InternalErrorReportingExecutor(backingExecutor, suiteListener,
            new PrintStream(new NullOutputStream()));
    Runnable originalCommand = () -> {
    };/*from   w w w. j a  v  a 2  s. c  om*/

    executor.execute(originalCommand);

    assertThat(backingExecutor.lastCommand.toString(), containsString(originalCommand.toString()));
}

From source file:hudson.slaves.ComputerLauncherTest.java

@Test(expected = IOException.class)
public void jdk5() throws IOException {
    ComputerLauncher.checkJavaVersion(new PrintStream(new NullOutputStream()), "-",
            new BufferedReader(new StringReader(
                    "java version \"1.5.0_22\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)\nJava HotSpot(TM) Server VM (build 1.5.0_22-b03, mixed mode)\n")));
}

From source file:fi.jumi.core.testbench.TestBench.java

public void run(SuiteListener suiteListener, Class<?>... testClasses) {
    SingleThreadedActors actors = new SingleThreadedActors(new DynamicEventizerProvider(), actorsFailureHandler,
            actorsMessageListener);//from   w  w w . j  a  va 2s  .  com
    ActorThread actorThread = actors.startActorThread();
    Executor testExecutor = actors.getExecutor();

    RunIdSequence runIdSequence = new RunIdSequence();
    ClassLoader classLoader = getClass().getClassLoader();

    ActorRef<TestFileFinderListener> suiteRunner = actorThread.bindActor(TestFileFinderListener.class,
            new SuiteRunner(
                    new DriverFactory(suiteListener, actorThread, outputCapturer, driverFinder, runIdSequence,
                            classLoader),
                    suiteListener, actorThread, testExecutor, new PrintStream(new NullOutputStream())));

    suiteListener.onSuiteStarted();
    testExecutor.execute(new TestFileFinderRunner(new StubTestFileFinder(testClasses), suiteRunner));
    actors.processEventsUntilIdle();
}

From source file:fi.jumi.core.stdout.SynchronizedPrintStreamTest.java

@Test
public void does_not_expose_the_CGLIB_Factory_interface() {
    PrintStream printStream = SynchronizedPrintStream.create(new NullOutputStream(), Charset.defaultCharset(),
            lock);//from  w  w w  .  j  a  va2  s  .c o m

    assertThat(printStream, not(instanceOf(Factory.class)));
}

From source file:com.thoughtworks.go.server.dashboard.AbstractDashboardGroup.java

protected String digest(String permissionsSegment) {
    try {//from  ww w.  j a  va  2s  .c  o  m
        MessageDigest digest = DigestUtils.getSha256Digest();
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
                new DigestOutputStream(new NullOutputStream(), digest));
        outputStreamWriter.write(getClass().getSimpleName());
        outputStreamWriter.write("$");
        outputStreamWriter.write(name());
        outputStreamWriter.write("/");
        outputStreamWriter.write(permissionsSegment);
        outputStreamWriter.write("[");

        for (GoDashboardPipeline pipeline : allPipelines()) {
            outputStreamWriter.write(pipeline.cacheSegment());
            outputStreamWriter.write(",");
        }

        outputStreamWriter.write("]");
        outputStreamWriter.flush();

        return Hex.encodeHexString(digest.digest());
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.qwazr.server.InFileSessionPersistenceManager.java

private void writeSession(final Path deploymentDir, final String sessionId,
        final PersistentSession persistentSession) {
    final Date expDate = persistentSession.getExpiration();
    if (expDate == null)
        return; // No expiry date? no serialization
    final Map<String, Object> sessionData = persistentSession.getSessionData();
    if (sessionData == null)
        return; // No sessionData? no serialization
    final File sessionFile = deploymentDir.resolve(sessionId).toFile();
    try (final ObjectOutputStream draftOutputStream = new ObjectOutputStream(new NullOutputStream())) {
        try (final ObjectOutputStream sessionOutputStream = new ObjectOutputStream(
                new FileOutputStream(sessionFile))) {
            sessionOutputStream.writeLong(expDate.getTime()); // The date is stored as long
            sessionData.forEach((attribute, object) -> writeSessionAttribute(draftOutputStream,
                    sessionOutputStream, attribute, object));
        }/*from w  w  w .ja  v  a 2s.  c o  m*/
    } catch (IOException | CancellationException e) {
        LOGGER.log(Level.SEVERE, e, () -> "Cannot save sessions in " + sessionFile);
    }
}

From source file:fi.jumi.launcher.JumiLauncherBuilder.java

protected OutputStream createDaemonOutputListener() {
    return new NullOutputStream();
}

From source file:hudson.slaves.ComputerLauncherTest.java

@Test(expected = IOException.class)
public void j2sdk4() throws IOException {
    ComputerLauncher.checkJavaVersion(new PrintStream(new NullOutputStream()), "-",
            new BufferedReader(new StringReader(
                    "java version \"1.4.2_19\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)\nJava HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)\n")));
}

From source file:com.thoughtworks.go.agent.launcher.ServerBinaryDownloaderTest.java

@Test
public void shouldSetMd5AndSSLPortHeaders() throws Exception {
    ServerBinaryDownloader downloader = new ServerBinaryDownloader(
            ServerUrlGeneratorMother.generatorFor("localhost", server.getPort()), null,
            SslVerificationMode.NONE);/*  w  w  w. j ava2  s. com*/
    downloader.downloadIfNecessary(DownloadableFile.AGENT);

    MessageDigest digester = MessageDigest.getInstance("MD5");
    try (BufferedInputStream stream = new BufferedInputStream(
            new FileInputStream(DownloadableFile.AGENT.getLocalFile()))) {
        try (DigestInputStream digest = new DigestInputStream(stream, digester)) {
            IOUtils.copy(digest, new NullOutputStream());
        }
        assertThat(downloader.getMd5(), is(Hex.encodeHexString(digester.digest()).toLowerCase()));
    }
}

From source file:net.itransformers.idiscover.v2.core.bgpdiscoverer.BGPMapNetworkDiscoverer.java

@Override
public NetworkDiscoveryResult discoverNetwork(List<ConnectionDetails> connectionDetailsList, int depth) {
    NetworkDiscoveryResult result = new NetworkDiscoveryResult();

    for (ConnectionDetails connectionDetails : connectionDetailsList) {

        if (!"javaMRT".equals(connectionDetails.getConnectionType())) {
            logger.debug("Connection details are not for javaMRTfile");

            return null;
        }//  ww w . j ava 2 s  .c o  m

        String pathToFile = connectionDetails.getParam("pathToFile");
        String version = connectionDetails.getParam("version");

        String[] args = new String[4];
        args[0] = "-f";

        args[1] = pathToFile;

        args[2] = "-o";
        String outputFile = "network.graphml";
        args[3] = outputFile;

        Map<String, String> params = CmdLineParser.parseCmdLine(args);

        StringWriter writer = new StringWriter();

        String file = null;
        OutputStream logOutputStream = new NullOutputStream();

        if (params.containsKey("-f")) {
            file = params.get("-f");
        } else {
            logger.info("no file passed");
            System.exit(1);
        }

        ASContainer ases = new ASContainer();
        System.out.println("Start reading MRT file");
        File tmpEdgeFile = null;
        try {
            tmpEdgeFile = File.createTempFile("test" + "_", ".txt");
            System.out.println("Creating edge tmp file: " + tmpEdgeFile.getAbsolutePath());
            Writer edgeWriter = new PrintWriter(tmpEdgeFile);

            Route2GraphmlDumper.dumpToXmlString(new String[] { file }, new PrintWriter(logOutputStream),
                    edgeWriter, ases);
            edgeWriter.close();
            Route2GraphmlDumper.dumpGraphml(ases, writer, tmpEdgeFile);

        } catch (IOException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.

        } finally {
            tmpEdgeFile.delete();

        }

        NodeDiscoveryResult result1 = new NodeDiscoveryResult();

        result1.setDiscoveredData("version", version);
        result1.setDiscoveredData("graphml", writer.toString().getBytes());
        result1.setDiscoveredData("discoverer", "javaMRT");

        result.addDiscoveredData(file, result1);

    }
    fireNetworkDiscoveredEvent(result);

    return result;
}