Tabnine Logo
StreamGobbler.isAlive
Code IndexAdd Tabnine to your IDE (free)

How to use
isAlive
method
in
org.apache.brooklyn.util.stream.StreamGobbler

Best Java code snippets using org.apache.brooklyn.util.stream.StreamGobbler.isAlive (Showing top 2 results out of 315)

origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testGobbleStream() throws Exception {
  byte[] bytes = new byte[] {'a','b','c'};
  InputStream stream = new ByteArrayInputStream(bytes);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  StreamGobbler gobbler = new StreamGobbler(stream, out, null);
  gobbler.start();
  try {
    gobbler.join(10*1000);
    assertFalse(gobbler.isAlive());
    assertEquals(new String(out.toByteArray()), "abc" + NL);
  } finally {
    gobbler.close();
    gobbler.interrupt();
  }
}

origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testGobbleMultiLineBlockingStream() throws Exception {
  PipedOutputStream pipedOutputStream = new PipedOutputStream();
  PipedInputStream stream = new PipedInputStream(pipedOutputStream);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  StreamGobbler gobbler = new StreamGobbler(stream, out, null);
  gobbler.start();
  try {
    pipedOutputStream.write("line1\n".getBytes());
    pipedOutputStream.flush();
    assertEqualsEventually(out, "line1" + NL);
    pipedOutputStream.write("line2\n".getBytes());
    pipedOutputStream.flush();
    assertEqualsEventually(out, "line1" + NL + "line2" + NL);
    pipedOutputStream.write("line".getBytes());
    pipedOutputStream.write("3\n".getBytes());
    pipedOutputStream.flush();
    assertEqualsEventually(out, "line1" + NL + "line2" + NL + "line3" + NL);
    pipedOutputStream.close();
    
    gobbler.join(10*1000);
    assertFalse(gobbler.isAlive());
    assertEquals(new String(out.toByteArray()), "line1" + NL + "line2" + NL + "line3" + NL);
  } finally {
    gobbler.close();
    gobbler.interrupt();
  }
}

org.apache.brooklyn.util.streamStreamGobblerisAlive

Popular methods of StreamGobbler

  • <init>
  • start
  • close
  • blockUntilFinished
    convenience -- equivalent to calling join()
  • interrupt
  • join
  • setLogPrefix
  • onChar
  • onClose
  • onLine
  • setPrintPrefix
  • setPrintPrefix

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • getSharedPreferences (Context)
  • setContentView (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • JTextField (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now