Search in sources :

Example 1 with OutputStreamSink

use of streamer.OutputStreamSink in project cloudstack by apache.

the class Vnc33Hello method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    InputStream is = new ByteArrayInputStream("RFB 003.007\ntest".getBytes(RfbConstants.US_ASCII_CHARSET));
    ByteArrayOutputStream initOS = new ByteArrayOutputStream();
    ByteArrayOutputStream mainOS = new ByteArrayOutputStream();
    InputStreamSource inputStreamSource = new InputStreamSource("source", is);
    OutputStreamSink outputStreamSink = new OutputStreamSink("mainSink", mainOS);
    Vnc33Hello hello = new Vnc33Hello("hello");
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(inputStreamSource, hello, outputStreamSink);
    pipeline.add(new OutputStreamSink("initSink", initOS));
    pipeline.link("hello >" + OneTimeSwitch.OTOUT, "initSink");
    pipeline.runMainLoop("source", STDOUT, false, false);
    String initOut = new String(initOS.toByteArray(), RfbConstants.US_ASCII_CHARSET);
    String mainOut = new String(mainOS.toByteArray(), RfbConstants.US_ASCII_CHARSET);
    if (!"RFB 003.003\n".equals(initOut))
        System.err.println("Unexpected value for hello response: \"" + initOut + "\".");
    if (!"test".equals(mainOut))
        System.err.println("Unexpected value for main data: \"" + mainOut + "\".");
}
Also used : InputStreamSource(streamer.InputStreamSource) PipelineImpl(streamer.PipelineImpl) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStreamSink(streamer.OutputStreamSink) Pipeline(streamer.Pipeline)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 InputStreamSource (streamer.InputStreamSource)1 OutputStreamSink (streamer.OutputStreamSink)1 Pipeline (streamer.Pipeline)1 PipelineImpl (streamer.PipelineImpl)1