use of streamer.InputStreamSource 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 + "\".");
}
Aggregations