diff options
Diffstat (limited to 'jack-tests/src')
4 files changed, 4 insertions, 322 deletions
diff --git a/jack-tests/src/com/android/jack/test/util/BytesStreamSucker.java b/jack-tests/src/com/android/jack/test/util/BytesStreamSucker.java deleted file mode 100644 index 3f74378..0000000 --- a/jack-tests/src/com/android/jack/test/util/BytesStreamSucker.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.jack.test.util; - -import com.google.common.io.NullOutputStream; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import javax.annotation.Nonnull; - -/** - * Class that continuously read an {@link InputStream} and optionally could write the input in a - * {@link OutputStream}. - */ -public class BytesStreamSucker { - - private static final int BUFFER_SIZE = 4096; - - @Nonnull - private final byte[] buffer = new byte[BUFFER_SIZE]; - - @Nonnull - private final InputStream is; - - @Nonnull - private final OutputStream os; - - private final boolean toBeClose; - - public BytesStreamSucker( - @Nonnull InputStream is, @Nonnull OutputStream os, boolean toBeClose) { - this.is = is; - this.os = os; - this.toBeClose = toBeClose; - } - - public BytesStreamSucker(@Nonnull InputStream is, @Nonnull OutputStream os) { - this(is, os, false); - } - - public BytesStreamSucker(@Nonnull InputStream is) { - this(is, new NullOutputStream(), false); - } - - public void suck() throws IOException { - try { - int bytesRead; - while ((bytesRead = is.read(buffer)) >= 0) { - os.write(buffer, 0, bytesRead); - os.flush(); - } - } finally { - if (toBeClose) { - os.close(); - } - } - } -}
\ No newline at end of file diff --git a/jack-tests/src/com/android/jack/test/util/CharactersStreamSucker.java b/jack-tests/src/com/android/jack/test/util/CharactersStreamSucker.java deleted file mode 100644 index 7e5b9f2..0000000 --- a/jack-tests/src/com/android/jack/test/util/CharactersStreamSucker.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.jack.test.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; - -import javax.annotation.Nonnull; - -/** - * Class that continuously read an {@link InputStream} and optionally could print the input in a - * {@link PrintStream}. - */ -public class CharactersStreamSucker { - - @Nonnull - private final InputStream is; - @Nonnull - private final PrintStream os; - - private final boolean toBeClose; - - public CharactersStreamSucker( - @Nonnull InputStream is, @Nonnull PrintStream os, boolean toBeClose) { - this.is = is; - this.os = os; - this.toBeClose = toBeClose; - } - - public CharactersStreamSucker(@Nonnull InputStream is, @Nonnull PrintStream os) { - this(is, os, false); - } - - public CharactersStreamSucker(@Nonnull InputStream is) { - this(is, new NullPrintStream(), false); - } - - public void suck() throws IOException { - int readChar; - try { - while ((readChar = is.read()) != -1) { - os.write(readChar); - } - } finally { - if (toBeClose) { - os.close(); - } - } - } -}
\ No newline at end of file diff --git a/jack-tests/src/com/android/jack/test/util/ExecuteFile.java b/jack-tests/src/com/android/jack/test/util/ExecuteFile.java index 1f59b63..5eb7291 100644 --- a/jack-tests/src/com/android/jack/test/util/ExecuteFile.java +++ b/jack-tests/src/com/android/jack/test/util/ExecuteFile.java @@ -17,6 +17,8 @@ package com.android.jack.test.util; import com.android.sched.util.log.LoggerFactory; +import com.android.sched.util.stream.ByteStreamSucker; +import com.android.sched.util.stream.CharacterStreamSucker; import java.io.File; import java.io.FileInputStream; @@ -255,7 +257,7 @@ public class ExecuteFile { } } - private static class ThreadBytesStreamSucker extends BytesStreamSucker implements Runnable { + private static class ThreadBytesStreamSucker extends ByteStreamSucker implements Runnable { public ThreadBytesStreamSucker(@Nonnull InputStream is, @Nonnull OutputStream os, boolean toBeClose) { @@ -272,7 +274,7 @@ public class ExecuteFile { } } - private static class ThreadCharactersStreamSucker extends CharactersStreamSucker implements + private static class ThreadCharactersStreamSucker extends CharacterStreamSucker implements Runnable { public ThreadCharactersStreamSucker(@Nonnull InputStream is, @Nonnull PrintStream ps, diff --git a/jack-tests/src/com/android/jack/test/util/NullPrintStream.java b/jack-tests/src/com/android/jack/test/util/NullPrintStream.java deleted file mode 100644 index 730153f..0000000 --- a/jack-tests/src/com/android/jack/test/util/NullPrintStream.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.jack.test.util; - -import com.google.common.io.NullOutputStream; - -import java.io.PrintStream; -import java.util.Locale; - -import javax.annotation.Nonnull; - -/** - * Implementation of {@link PrintStream} that simply discards all data. - */ -public class NullPrintStream extends PrintStream { - public NullPrintStream() { - super(new NullOutputStream()); - } - - @Override - public void flush() { - } - - @Override - public void close() { - } - - @Override - public boolean checkError() { - return false; - } - - @Override - protected void setError() { - } - - @Override - protected void clearError() { - } - - @Override - public void write(int b) { - } - - @Override - public void write(byte[] buf, int off, int len) { - } - - @Override - public void print(boolean b) { - } - - @Override - public void print(char c) { - } - - @Override - public void print(int i) { - } - - @Override - public void print(long l) { - } - - @Override - public void print(float f) { - } - - @Override - public void print(double d) { - } - - @Override - public void print(char[] s) { - } - - @Override - public void print(String s) { - } - - @Override - public void print(Object obj) { - } - - @Override - public void println() { - } - - @Override - public void println(boolean x) { - } - - @Override - public void println(char x) { - } - - @Override - public void println(int x) { - } - - @Override - public void println(long x) { - } - - @Override - public void println(float x) { - } - - @Override - public void println(double x) { - } - - @Override - public void println(char[] x) { - } - - @Override - public void println(String x) { - } - - @Override - public void println(Object x) { - } - - @Override - @Nonnull - public PrintStream printf(String format, Object... args) { - return this; - } - - @Override - @Nonnull - public PrintStream printf(Locale l, String format, Object... args) { - return this; - } - - @Override - @Nonnull - public PrintStream format(String format, Object... args) { - return this; - } - - @Override - @Nonnull - public PrintStream format(Locale l, String format, Object... args) { - return this; - } - - @Override - @Nonnull - public PrintStream append(CharSequence csq) { - return this; - } - - @Override - @Nonnull - public PrintStream append(CharSequence csq, int start, int end) { - return this; - } - - @Override - @Nonnull - public PrintStream append(char c) { - return this; - } - -} |