Java Code Examples for java.io.PipedOutputStream#flush()

The following examples show how to use java.io.PipedOutputStream#flush() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangeLoader.java    From bireme with Apache License 2.0 6 votes vote down vote up
private void tupleWriter(PipedOutputStream pipeOut, Set<String> tuples) throws BiremeException {
  byte[] data = null;

  try {
    Iterator<String> iterator = tuples.iterator();

    while (iterator.hasNext() && !cxt.stop) {
      data = iterator.next().getBytes("UTF-8");
      pipeOut.write(data);
    }

    pipeOut.flush();
  } catch (IOException e) {
    throw new BiremeException("I/O error occurs while write to pipe.", e);
  } finally {
    try {
      pipeOut.close();
    } catch (IOException ignore) {
    }
  }
}
 
Example 2
Source File: TestTerminalConnection.java    From aesh-readline with Apache License 2.0 6 votes vote down vote up
@Test
public void testRead() throws IOException, InterruptedException {
    PipedOutputStream outputStream = new PipedOutputStream();
    PipedInputStream pipedInputStream = new PipedInputStream(outputStream);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    TerminalConnection connection = new TerminalConnection(Charset.defaultCharset(), pipedInputStream, byteArrayOutputStream);

    final ArrayList<int[]> result = new ArrayList<>();
    connection.setStdinHandler(result::add);

    outputStream.write(("FOO").getBytes());
    outputStream.flush();
    outputStream.close();
    Thread.sleep(150);
    connection.openBlocking();

    assertArrayEquals(result.get(0), new int[] {70,79,79});
}
 
Example 3
Source File: TestTerminalConnection.java    From aesh-readline with Apache License 2.0 6 votes vote down vote up
@Test
public void testSignal() throws IOException, InterruptedException {
    PipedOutputStream outputStream = new PipedOutputStream();
    PipedInputStream pipedInputStream = new PipedInputStream(outputStream);
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    TerminalConnection connection = new TerminalConnection(Charset.defaultCharset(), pipedInputStream, out);
    Attributes attributes = new Attributes();
    attributes.setLocalFlag(Attributes.LocalFlag.ECHOCTL, true);
    connection.setAttributes(attributes);

    Readline readline = new Readline();
    readline.readline(connection, new Prompt(""), s -> {  });

    connection.openNonBlocking();
    outputStream.write(("FOO").getBytes());
    outputStream.flush();
    Thread.sleep(100);
    connection.getTerminal().raise(Signal.INT);
    connection.close();

    Assert.assertEquals("FOO^C"+ Config.getLineSeparator(), new String(out.toByteArray()));
}
 
Example 4
Source File: TestTerminalConnection.java    From aesh-readline with Apache License 2.0 6 votes vote down vote up
@Test
public void testSignalEchoCtlFalse() throws IOException, InterruptedException {
    PipedOutputStream outputStream = new PipedOutputStream();
    PipedInputStream pipedInputStream = new PipedInputStream(outputStream);
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    TerminalConnection connection = new TerminalConnection(Charset.defaultCharset(), pipedInputStream, out);

    Readline readline = new Readline();
    readline.readline(connection, new Prompt(""), s -> {  });

    connection.openNonBlocking();
    outputStream.write(("FOO").getBytes());
    outputStream.flush();
    Thread.sleep(100);
    connection.getTerminal().raise(Signal.INT);
    connection.close();

    Assert.assertEquals(new String(out.toByteArray()), "FOO"+ Config.getLineSeparator());
}
 
Example 5
Source File: StreamPumperTest.java    From gocd with Apache License 2.0 6 votes vote down vote up
@Test public void shouldKnowIfPumperExpired() throws Exception {
    PipedOutputStream output = new PipedOutputStream();
    InputStream inputStream = new PipedInputStream(output);
    try {
        TestingClock clock = new TestingClock();
        StreamPumper pumper = new StreamPumper(inputStream, new TestConsumer(), "", "utf-8", clock);
        new Thread(pumper).start();

        output.write("line1\n".getBytes());
        output.flush();

        long timeoutDuration = 2L;
        assertThat(pumper.didTimeout(timeoutDuration, TimeUnit.SECONDS), is(false));
        clock.addSeconds(5);
        assertThat(pumper.didTimeout(timeoutDuration, TimeUnit.SECONDS), is(true));
    } finally {
        output.close();
    }
}
 
Example 6
Source File: DownloadSchema.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@ApiResponses({@ApiResponse(code = 200, response = File.class, message = "")})
@GetMapping(path = "/slowInputStream")
public ResponseEntity<InputStream> slowInputStream() throws IOException {
  PipedInputStream in = new PipedInputStream();
  PipedOutputStream out = new PipedOutputStream();
  in.connect(out);

  slowInputStreamThread = new Thread(() -> {
    Thread.currentThread().setName("download thread");
    byte[] bytes = "1".getBytes();
    for (; ; ) {
      try {
        out.write(bytes);
        out.flush();
        Thread.sleep(1000);
      } catch (Throwable e) {
        break;
      }
    }
    try {
      out.close();
    } catch (final IOException ioe) {
      // ignore
    }
  });
  slowInputStreamThread.start();

  ResponseEntity<InputStream> responseEntity = ResponseEntity
      .ok()
      .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE)
      .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=slowInputStream.txt")
      .body(in);
  return responseEntity;
}
 
Example 7
Source File: SSHServerTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 10000L)
public void call() throws Exception {
    final SshClient client = SshClient.setUpDefaultClient();
    client.start();
    try {
        final ClientSession session = client.connect("jonathan", "localhost", 4222).verify().getSession();
        session.addPasswordIdentity("secret");
        session.auth().verify(FactoryManager.DEFAULT_AUTH_TIMEOUT);

        final ClientChannel channel = session.createChannel("shell");
        ByteArrayOutputStream sent = new ByteArrayOutputStream();
        PipedOutputStream pipedIn = new TeePipedOutputStream(sent);
        channel.setIn(new PipedInputStream(pipedIn));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayOutputStream err = new ByteArrayOutputStream();
        channel.setOut(out);
        channel.setErr(err);
        channel.open();

        pipedIn.write("properties\r\n".getBytes());
        pipedIn.flush();

        pipedIn.write("exit\r\n".getBytes());
        pipedIn.flush();

        channel.waitFor(Collections.singleton(ClientChannelEvent.CLOSED), 0);
        channel.close(false);
        client.stop();

        assertTrue(new String(sent.toByteArray()).contains("properties\r\nexit\r\n"));
        assertTrue(new String(out.toByteArray()).contains("ServerService(id=ssh)"));
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
 
Example 8
Source File: ArduinoDouble.java    From Ardulink-2 with Apache License 2.0 5 votes vote down vote up
public ArduinoDouble(final Protocol protocol) throws IOException {
	this.protocol = protocol;
	PipedInputStream is1 = new PipedInputStream();
	os1 = new PipedOutputStream(is1);
	is2 = new PipedInputStream();

	os2 = new PipedOutputStream(is2);
	streamReader = new StreamReader(is1) {
		@Override
		protected void received(byte[] bytes) throws Exception {
			String received = new String(bytes);
			logger.info("Received {}", received);

			for (ReponseGenerator generator : data) {
				if (generator.matches(received)) {
					String response = generator.getResponse();
					logger.info("Responding {}", response);
					send(response);
					os2.flush();
				} else {
					logger.warn("No responder for {}", received);
				}
			}

		}

	};
	streamReader.runReaderThread(protocol.getSeparator());
}
 
Example 9
Source File: ReadlineAliasTest.java    From aesh-readline with Apache License 2.0 5 votes vote down vote up
@Test
public void alias() throws Exception {
    PipedOutputStream outputStream = new PipedOutputStream();
    PipedInputStream pipedInputStream = new PipedInputStream(outputStream);
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    TerminalConnection connection = new TerminalConnection(Charset.defaultCharset(), pipedInputStream, out);
    Readline readline = new Readline();

    File aliasFile = Config.isOSPOSIXCompatible() ?
            new File("src/test/resources/alias1") : new File("src\\test\\resources\\alias1");
    AliasManager aliasManager = new AliasManager(aliasFile, false);
    AliasPreProcessor aliasPreProcessor = new AliasPreProcessor(aliasManager);
    List<Function<String, Optional<String>>> preProcessors = new ArrayList<>();
    preProcessors.add(aliasPreProcessor);

    readline.readline(connection, new Prompt(""),
            s -> {
                //first check this
                assertEquals("ls -alF", s);
                //then call readline again, to check the next line
                readline.readline(connection, new Prompt(""),
                        t -> assertEquals("grep --color=auto -l", t),
                        null, preProcessors);
            } , null, preProcessors);

    outputStream.write(("ll"+Config.getLineSeparator()).getBytes());
    outputStream.write(("grep -l"+Config.getLineSeparator()).getBytes());
    outputStream.flush();
    connection.openNonBlocking();
    Thread.sleep(200);
}
 
Example 10
Source File: TestTerminalConnection.java    From aesh-readline with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomSignal() throws IOException, InterruptedException {
    PipedOutputStream outputStream = new PipedOutputStream();
    PipedInputStream pipedInputStream = new PipedInputStream(outputStream);
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    TerminalConnection connection = new TerminalConnection(Charset.defaultCharset(), pipedInputStream, out);
    connection.setSignalHandler( signal -> {
        if(signal == Signal.INT) {
            connection.write("BAR");
            connection.stdoutHandler().accept(Config.CR);
            connection.close();
        }
    });

    Readline readline = new Readline();
    readline.readline(connection, new Prompt(""), s -> {  });

    connection.openNonBlocking();
    outputStream.write(("GAH"+Config.getLineSeparator()).getBytes());
    outputStream.flush();
    Thread.sleep(250);
    assertEquals(new String(out.toByteArray()), "GAH"+Config.getLineSeparator());

    readline.readline(connection, new Prompt(""), s -> {  });
    outputStream.write(("FOO").getBytes());
    outputStream.flush();
    connection.getTerminal().raise(Signal.INT);
    Thread.sleep(250);

    assertEquals(new String(out.toByteArray()), "GAH"+Config.getLineSeparator()+"FOOBAR"+ Config.getLineSeparator());
}
 
Example 11
Source File: StreamGobblerTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 12
Source File: StreamPumperTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Test public void shouldNotHaveExpiredTimeoutWhenCompleted() throws Exception {
    PipedOutputStream output = new PipedOutputStream();
    InputStream inputStream = new PipedInputStream(output);
    TestingClock clock = new TestingClock();
    StreamPumper pumper = new StreamPumper(inputStream, new TestConsumer(), "", "utf-8", clock);
    new Thread(pumper).start();

    output.write("line1\n".getBytes());
    output.flush();
    output.close();
    pumper.readToEnd();
    clock.addSeconds(2);
    assertThat(pumper.didTimeout(1L, TimeUnit.SECONDS), is(false));
}
 
Example 13
Source File: OldPipedOutputStreamTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void test_flush() throws Exception {
    out = new PipedOutputStream();
    rt = new Thread(reader = new PReader(out));
    rt.start();
    out.write(testString.getBytes(), 0, 10);
    assertTrue("Test 1: Bytes have been written before flush.", reader.available() != 0);
    out.flush();
    assertEquals("Test 2: Flush failed. ",
            testString.substring(0, 10), reader.read(10));
}
 
Example 14
Source File: ReplaceInStringExample.java    From ExpectIt with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    PipedInputStream pipedInputStream = new PipedInputStream();
    PipedOutputStream pipedOutputStream = new PipedOutputStream();

    System.out.println("Connecting pipes");
    pipedInputStream.connect(pipedOutputStream);

    System.out.println("Building expect");
    Expect expect = new ExpectBuilder()
            .withInputs(pipedInputStream)
            .withTimeout(30, TimeUnit.SECONDS)
            .withExceptionOnFailure()
            .withInputFilters(myFilter())
            .build();

    System.out.println("Writing data to output");
    for (int i = 0; i < 1500; i++) {
        pipedOutputStream.write("removeSome text hereremove\n".getBytes());
    }
    pipedOutputStream.write("done\n".getBytes());

    System.out.println("Flushing output");
    pipedOutputStream.flush();

    System.out.println("Waiting for 'done'");
    Result r = expect.expect(Matchers.contains("done"));

    System.out.println("Printing data");
    System.out.println(r.getBefore());

    System.out.println("Done");

    expect.close();
}
 
Example 15
Source File: AsyncHttpClientTest.java    From vw-webservice with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void doTest(Request request) throws InterruptedException, ExecutionException, IOException {
	final PipedOutputStream pipedOutputStream = new PipedOutputStream();
	final PipedInputStream pipedInputStream = new PipedInputStream(pipedOutputStream);

	AsyncHandler<Response> asyncHandler = new AsyncHandler<Response>() {
		private final Response.ResponseBuilder builder = new Response.ResponseBuilder();

		@Override
		public STATE onBodyPartReceived(final HttpResponseBodyPart content) throws Exception {
			content.writeTo(pipedOutputStream);
			return STATE.CONTINUE;
		}

		@Override
		public STATE onStatusReceived(final HttpResponseStatus status) throws Exception {
			builder.accumulate(status);
			return STATE.CONTINUE;
		}

		@Override
		public STATE onHeadersReceived(final HttpResponseHeaders headers) throws Exception {
			builder.accumulate(headers);
			return STATE.CONTINUE;
		}

		@Override
		public Response onCompleted() throws Exception {

			LOGGER.info("On complete called!");

			pipedOutputStream.flush();
			pipedOutputStream.close();

			return builder.build();

		}

		@Override
		public void onThrowable(Throwable arg0) {
			// TODO Auto-generated method stub
			LOGGER.error("Error: {}", arg0);
			onTestFailed();
		}

	};

	Future<Void> readingThreadFuture = Executors.newCachedThreadPool().submit(new Callable<Void>() {

		@Override
		public Void call() throws Exception {
			BufferedReader reader = new BufferedReader(new InputStreamReader(pipedInputStream));

			String readPrediction;

			int numPredictionsRead = 0;

			while ((readPrediction = reader.readLine()) != null) {
				//LOGGER.info("Got prediction: {}", readPrediction);
				numPredictionsRead++;
			}

			LOGGER.info("Read a total of {} predictions", numPredictionsRead);
			Assert.assertEquals(roundsOfDataToSubmit * 272274, numPredictionsRead);

			return null;
		}
	});

	Builder config = new AsyncHttpClientConfig.Builder();

	config.setRequestTimeoutInMs(-1); //need to set this to -1, to indicate wait forever. setting to 0 actually means a 0 ms timeout!

	AsyncHttpClient client = new AsyncHttpClient(config.build());

	client.executeRequest(request, asyncHandler).get();

	readingThreadFuture.get(); //verify no exceptions occurred when reading predictions

	client.close();

	Assert.assertFalse(getTestFailed());
}
 
Example 16
Source File: DhlXTeeServiceImpl.java    From j-road with Apache License 2.0 4 votes vote down vote up
/**
 * @param <OS> OutputStream that is used as an output for <code>content</code> from the inputStream that was transformed
 *            <code>base64Encode(gzip(content))</code>
 * @param attachments input to parse
 * @param responseClass destination class of the type to parse input
 * @param hasRootElement - if attachment bodies contain xml-fragments witout single root element set it to false so that root element would be created to be
 *            able to parse document correctly
 * @return list of attachments parsed to given type
 */
private static <OS extends OutputStream> OS getUnzipAndDecodeOutputStream(InputStream inputStream, final OS outputStream) {
    final PipedOutputStream pipedOutputStream = new PipedOutputStream();
    final List<Throwable> ungzipThreadThrowableList = new LinkedList<Throwable>();
    Writer decoderWriter = null;
    Thread ungzipThread = null;
    try {
        final PipedInputStream pipedInputStream = new PipedInputStream(pipedOutputStream);
        ungzipThread = new Thread(new Runnable() {
            public void run() {
                GZIPInputStream gzipInputStream = null;
                try {
                    // (3) pipedInputStream'i käsitletakse zip'itud voona, mida gzipInputStream unzip'ib
                    gzipInputStream = new GZIPInputStream(pipedInputStream);
                    // (4) gzipInputStream edastab temasse kirjutatud zip'itud andmed byteArrayOutputStream'i, unzippides
                    IOUtils.copy(gzipInputStream, outputStream);
                } catch (Throwable t) {
                    ungzipThreadThrowableList.add(t);
                } finally {
                    IOUtils.closeQuietly(gzipInputStream);
                    IOUtils.closeQuietly(pipedInputStream);
                }
            }
        });
        decoderWriter = Base64.newDecoder(pipedOutputStream);// (2) decoderWriter edastab temasse kirjutatu pipedInputStream'i, eemaldades base64 kodeeringu
        ungzipThread.start();
        IOUtils.copy(inputStream, decoderWriter, DVK_MESSAGE_CHARSET); // (1) - inputStream'ist base64 decoderWriter'isse kirjutamine,
        decoderWriter.flush();
        pipedOutputStream.flush();
    } catch (IOException e) {
        throw new RuntimeException("failed to unzip and decode input", e);
    } finally {
        IOUtils.closeQuietly(decoderWriter);
        IOUtils.closeQuietly(pipedOutputStream);
        if (ungzipThread != null) {
            try {
                ungzipThread.join();
            } catch (InterruptedException ie) {
                throw new RuntimeException("thread interrupted while for ungzip thread to finish", ie);
            }
        }
    }
    if (!ungzipThreadThrowableList.isEmpty()) {
        throw new RuntimeException("ungzip failed", ungzipThreadThrowableList.get(0));
    }
    return outputStream;
}
 
Example 17
Source File: RunESBRuntimeProcess.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
public RunESBRuntimeProcess(IProcess process, int statisticsPort, int tracePort, IProgressMonitor monitor) {
    this.process = process;
    this.monitor = monitor;

    stdInputStream = new PipedInputStream();
    errInputStream = new PipedInputStream();
    // runtimeLogQueue = new LinkedBlockingQueue<FelixLogsModel>(10);
    try {
        stdOutputStream = new PipedOutputStream(stdInputStream);
        errOutputStream = new PipedOutputStream(errInputStream);
    } catch (IOException e) {
        e.printStackTrace();
    }

    logListener = new RuntimeLogHTTPAdapter() {

        @Override
        public synchronized void logReceived(FelixLogsModel log) {
            if (startLogging) {
                try {
                    if (INFO.equals(log.getLevel())) {
                        stdOutputStream.write(log.toString().getBytes());
                        stdOutputStream.write(LINE_SEPARATOR.getBytes());
                        stdOutputStream.flush();
                    } else {
                        errOutputStream.write(log.toString().getBytes());
                        errOutputStream.write(LINE_SEPARATOR.getBytes());
                        errOutputStream.flush();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        @Override
        public void logReceived(String logs, boolean isError) {
            try {
                if (isError) {
                    errOutputStream.write(logs.getBytes());
                    errOutputStream.write(LINE_SEPARATOR.getBytes());
                    errOutputStream.flush();
                } else {
                    stdOutputStream.write(logs.getBytes());
                    stdOutputStream.write(LINE_SEPARATOR.getBytes());
                    stdOutputStream.flush();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    artifactManager = new ArtifactDeployManager();
}
 
Example 18
Source File: TarGenerator.java    From evosql with Apache License 2.0 4 votes vote down vote up
/**
 * After instantiating a TarEntrySupplicant, the user must either invoke
 * write() or close(), to release system resources on the input
 * File/Stream.
 * <P>
 * <B>WARNING:</B>
 * Do not use this method unless the quantity of available RAM is
 * sufficient to accommodate the specified maxBytes all at one time.
 * This constructor loads all input from the specified InputStream into
 * RAM before anything is written to disk.
 * </P>
 *
 * @param maxBytes This method will fail if more than maxBytes bytes
 *                 are supplied on the specified InputStream.
 *                 As the type of this parameter enforces, the max
 *                 size you can request is 2GB.
 */
public TarEntrySupplicant(String path, InputStream origStream,
                          int maxBytes, char typeFlag,
                          TarFileOutputStream tarStream)
        throws IOException, TarMalformatException {

    /*
     * If you modify this, make sure to not intermix reading/writing of
     * the PipedInputStream and the PipedOutputStream, or you could
     * cause dead-lock.  Everything is safe if you close the
     * PipedOutputStream before reading the PipedInputStream.
     */
    this(path, typeFlag, tarStream, 0100000000000L);

    if (maxBytes < 1) {
        throw new IllegalArgumentException(RB.read_lt_1.getString());
    }

    int               i;
    PipedOutputStream outPipe = new PipedOutputStream();

    /*
     *  This constructor not available until Java 1.6:
     * inputStream = new PipedInputStream(outPipe, maxBytes);
     */
    try {
        inputStream =
            new InputStreamWrapper(new PipedInputStream(outPipe));

        while ((i =
                origStream.read(tarStream.writeBuffer, 0,
                                tarStream.writeBuffer.length)) > 0) {
            outPipe.write(tarStream.writeBuffer, 0, i);
        }

        outPipe.flush();    // Do any good on a pipe?
        dataSize = inputStream.available();

        if (TarFileOutputStream.debug) {
            System.out.println(
                RB.stream_buffer_report.getString(
                    Long.toString(dataSize)));
        }
    } catch (IOException ioe) {
        close();

        throw ioe;
    } finally {
        try {
            outPipe.close();
        } finally {
            outPipe = null;    // Encourage buffer GC
        }
    }

    modTime = new java.util.Date().getTime() / 1000L;
}
 
Example 19
Source File: ClientConnectionTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Test
public void unicodeTest() throws Exception {
    final boolean[] success = new boolean[] { true };
    LastResponseListener lrl = new LastResponseListener();
    PipedOutputStream pos = createPipedConnection(success, lrl);
    int[] codePoints = new int[] { 0 };
    for (int c = Character.MIN_CODE_POINT; c <= Character.MAX_CODE_POINT; c++) {
        if (0xD800 <= c && c <= 0xDFFF) {
            // Invalid unicode characters
            continue;
        }
        if ('\"' == c || '\\' == c) {
            continue;
        }
        codePoints[0] = c;
        String str = new String(codePoints, 0, 1);
        String msg = EVENT1 + str + EVENT2;
        byte[] messageBytes = msg.getBytes(DebuggerConnection.CHAR_SET);
        pos.write("Content-Length: ".getBytes());
        pos.write(Integer.toString(messageBytes.length).getBytes());
        pos.write(DebuggerConnection.EOL);
        pos.write(DebuggerConnection.EOL);
        pos.write(messageBytes);
        // Write something more so that we do not stuck when trying to read more bytes...
        pos.write("Content-Length: ".getBytes());
        pos.write(Integer.toString(CONTINUE.length()).getBytes());
        pos.write(DebuggerConnection.EOL);
        pos.write(DebuggerConnection.EOL);
        pos.write(CONTINUE.getBytes(DebuggerConnection.CHAR_SET));
        pos.flush();
        V8Event event = lrl.getLastEvent();
        String line = "abc('"+str+"');";
        Assert.assertTrue("Failure detected.", success[0]);
        String eventText = ((BreakEventBody) event.getBody()).getSourceLineText();
        Assert.assertEquals("Failure for code point = U+"+Integer.toHexString(c)+" = '"+str+"'"+
                            ", but event code point = "+
                               (eventText.length() > 6 ?
                                       "U+"+Integer.toHexString(eventText.codePointAt(6)) :
                                       "none."),
                            line, eventText);
    }
}