Package java.nio.channels.Pipe

Examples of java.nio.channels.Pipe.SinkChannel


  public void testUnzipZipInputStreamFile() throws IOException {
    // Test on an unseekable input steam
    File targetFolder = _temporaryFolder.newFolder("unpacked4");

    final Pipe zipPipe = Pipe.open();
    final SinkChannel sink = zipPipe.sink();
    final SourceChannel source = zipPipe.source();
    final InputStream sourceIn = Channels.newInputStream(source);
    final OutputStream sourceOut = Channels.newOutputStream(sink);
    final ZipInputStream zis = new ZipInputStream(sourceIn);
    final FileInputStream fis = new FileInputStream(TestResources.SHARD1);
View Full Code Here


        super();
        this.logger = logger;
        try
        {
            Pipe p = Pipe.open();
            SinkChannel sink = p.sink();
            SourceChannel source = p.source();
            writer = Channels.newWriter( sink, Charset.defaultCharset().name() );
            reader = Channels.newReader( source, Charset.defaultCharset().name() );
            parser.setInput( reader );
View Full Code Here

  /**
   * @tests java.nio.channels.Pipe#sink()
   */
  public void test_sink() throws IOException {
    Pipe pipe = Pipe.open();
    SinkChannel sink = pipe.sink();
    assertTrue(sink.isBlocking());
  }
View Full Code Here

  @Test
  public void testInputFlow() throws IOException {
    final Pipe pipeFromDisco = Pipe.open();

    final DiscoWorker discoWorker = new DiscoWorker(pipeFromDisco.source(), new NullByteChannel());
    final SinkChannel disco = pipeFromDisco.sink();

    // Put messages in the input pipeline (from the disco master)
    final String okStr = "OK 4 \"ok\"\n";
    disco.write(ByteBuffer.wrap(okStr.getBytes()));
    final String taskStr = "TASK 327 {\"taskid\":0,\"master\":\"http://lhoersten-66113:8989\",\"disco_port\":8989,\"put_port\":8990,\"ddfs_data\":\"/srv/disco/ddfs\",\"disco_data\":\"/srv/disco/data\",\"mode\":\"map\",\"jobfile\":\"/srv/disco/data/localhost/5a/lhoersten-FunshineSimulator@524:7310e:1cb44/jobfile\",\"jobname\":\"lhoersten-FunshineSimulator@524:7310e:1cb44\",\"host\":\"localhost\"}\n";
    disco.write(ByteBuffer.wrap(taskStr.getBytes()));
    final String inputStr = "INPUT 110 [\"done\",[[0,\"ok\",[[0,\"raw://eyJlbnRyeWV4aXRsZXZlbCI6WyJERUMiLDEuNV0sInFyMiI6WyJERUMiLDFdLCJxcjEiOlsiREVD\"]]]]]\n";
    disco.write(ByteBuffer.wrap(inputStr.getBytes()));

    discoWorker.requestTask();
    final ReadableByteChannel mapInput = discoWorker.getMapInput();

    final String input = DiscoUtils.channelLineToString(mapInput);
View Full Code Here

  @Test
  public void testChannelToString() throws IOException {
    final Pipe pipe = Pipe.open();

    final SinkChannel sink = pipe.sink();
    final String expected = "12345678\n";
    sink.write(ByteBuffer.wrap(expected.getBytes()));

    final String actual = DiscoUtils.channelLineToString(pipe.source());

    assertEquals(expected, actual);
  }
View Full Code Here

        super();
        this.logger = logger;
        try
        {
            Pipe p = Pipe.open();
            SinkChannel sink = p.sink();
            SourceChannel source = p.source();
            writer = Channels.newWriter( sink, Charset.defaultCharset().name() );
            reader = Channels.newReader( source, Charset.defaultCharset().name() );
            parser.setInput( reader );
View Full Code Here

  /**
   * @tests java.nio.channels.Pipe#sink()
   */
  public void test_sink() throws IOException {
    Pipe pipe = Pipe.open();
    SinkChannel sink = pipe.sink();
    assertTrue(sink.isBlocking());
  }
View Full Code Here

TOP

Related Classes of java.nio.channels.Pipe.SinkChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.