14package org.dartlang.vm.service;
16import com.google.common.base.Charsets;
18import java.io.BufferedReader;
19import java.io.IOException;
20import java.io.InputStream;
21import java.io.InputStreamReader;
27 private class LinesReaderThread
extends Thread {
28 public LinesReaderThread() {
29 setName(
"SampleOutPrinter.LinesReaderThread - " + prefix);
38 line = reader.readLine();
39 }
catch (IOException
e) {
40 System.out.println(
"Exception reading sample stream");
48 synchronized (currentLineLock) {
50 currentLineLock.notifyAll();
52 System.out.println(
"[" + prefix +
"] " +
line);
57 private String currentLine;
59 private final Object currentLineLock =
new Object();
61 private final String prefix;
62 private final BufferedReader reader;
66 this.reader =
new BufferedReader(
new InputStreamReader(
stream, Charsets.UTF_8));
67 new LinesReaderThread().start();
71 synchronized (currentLineLock) {
72 if (currentLine !=
null) {
73 throw new RuntimeException(
"Did not expect " + prefix +
": \"" + currentLine +
"\"");
79 synchronized (currentLineLock) {
81 if (currentLine !=
null) {
82 throw new RuntimeException(
"Did not expect " + prefix +
": \"" + currentLine +
"\"");
85 if (currentLine ==
null || !currentLine.contains(
text)) {
86 throw new RuntimeException(
"Expected current line to contain text\n"
87 +
"\nexpected: [" +
text +
"]"
88 +
"\nactual: [" + currentLine +
"]");
SampleOutPrinter(String prefix, InputStream stream)
void assertLastLine(String text)