|
Tomas Radej |
53a8d80 |
diff --git a/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java b/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java
|
|
Tomas Radej |
53a8d80 |
deleted file mode 100644
|
|
Tomas Radej |
53a8d80 |
index 32ea917..0000000
|
|
Tomas Radej |
53a8d80 |
--- a/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java
|
|
Tomas Radej |
53a8d80 |
+++ /dev/null
|
|
Tomas Radej |
53a8d80 |
@@ -1,89 +0,0 @@
|
|
Tomas Radej |
53a8d80 |
-/*
|
|
Tomas Radej |
53a8d80 |
- * Licensed to the Apache Software Foundation (ASF) under one
|
|
Tomas Radej |
53a8d80 |
- * or more contributor license agreements. See the NOTICE file
|
|
Tomas Radej |
53a8d80 |
- * distributed with this work for additional information
|
|
Tomas Radej |
53a8d80 |
- * regarding copyright ownership. The ASF licenses this file
|
|
Tomas Radej |
53a8d80 |
- * to you under the Apache License, Version 2.0 (the
|
|
Tomas Radej |
53a8d80 |
- * "License"); you may not use this file except in compliance
|
|
Tomas Radej |
53a8d80 |
- * with the License. You may obtain a copy of the License at
|
|
Tomas Radej |
53a8d80 |
- *
|
|
Tomas Radej |
53a8d80 |
- * http://www.apache.org/licenses/LICENSE-2.0
|
|
Tomas Radej |
53a8d80 |
- *
|
|
Tomas Radej |
53a8d80 |
- * Unless required by applicable law or agreed to in writing,
|
|
Tomas Radej |
53a8d80 |
- * software distributed under the License is distributed on an
|
|
Tomas Radej |
53a8d80 |
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
Tomas Radej |
53a8d80 |
- * KIND, either express or implied. See the License for the
|
|
Tomas Radej |
53a8d80 |
- * specific language governing permissions and limitations
|
|
Tomas Radej |
53a8d80 |
- * under the License.
|
|
Tomas Radej |
53a8d80 |
- */
|
|
Tomas Radej |
53a8d80 |
-package org.apache.felix.gogo.runtime.threadio;
|
|
Tomas Radej |
53a8d80 |
-
|
|
Tomas Radej |
53a8d80 |
-import junit.framework.TestCase;
|
|
Tomas Radej |
53a8d80 |
-
|
|
Tomas Radej |
53a8d80 |
-import java.io.ByteArrayOutputStream;
|
|
Tomas Radej |
53a8d80 |
-import java.io.PrintStream;
|
|
Tomas Radej |
53a8d80 |
-import java.util.ArrayList;
|
|
Tomas Radej |
53a8d80 |
-import java.util.List;
|
|
Tomas Radej |
53a8d80 |
-
|
|
Tomas Radej |
53a8d80 |
-public class TestThreadIO extends TestCase
|
|
Tomas Radej |
53a8d80 |
-{
|
|
Tomas Radej |
53a8d80 |
-
|
|
Tomas Radej |
53a8d80 |
- /**
|
|
Tomas Radej |
53a8d80 |
- * Test if the threadio works in a nested fashion. We first push
|
|
Tomas Radej |
53a8d80 |
- * ten markers on the stack and print a message for each, capturing
|
|
Tomas Radej |
53a8d80 |
- * the output in a ByteArrayOutputStream. Then we pop them, also printing
|
|
Tomas Radej |
53a8d80 |
- * a message identifying the level. Then we verify the output for each level.
|
|
Tomas Radej |
53a8d80 |
- */
|
|
Tomas Radej |
53a8d80 |
- public void testNested()
|
|
Tomas Radej |
53a8d80 |
- {
|
|
Tomas Radej |
53a8d80 |
- ThreadIOImpl tio = new ThreadIOImpl();
|
|
Tomas Radej |
53a8d80 |
- tio.start();
|
|
Tomas Radej |
53a8d80 |
- List<ByteArrayOutputStream> list = new ArrayList<ByteArrayOutputStream>();
|
|
Tomas Radej |
53a8d80 |
- for (int i = 0; i < 10; i++)
|
|
Tomas Radej |
53a8d80 |
- {
|
|
Tomas Radej |
53a8d80 |
- ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
Tomas Radej |
53a8d80 |
- list.add(out);
|
|
Tomas Radej |
53a8d80 |
- tio.setStreams(System.in, new PrintStream(out), System.err);
|
|
Tomas Radej |
53a8d80 |
- System.out.print("b" + i);
|
|
Tomas Radej |
53a8d80 |
- }
|
|
Tomas Radej |
53a8d80 |
- for (int i = 9; i >= 0; i--)
|
|
Tomas Radej |
53a8d80 |
- {
|
|
Tomas Radej |
53a8d80 |
- System.out.println("e" + i);
|
|
Tomas Radej |
53a8d80 |
- tio.close();
|
|
Tomas Radej |
53a8d80 |
- }
|
|
Tomas Radej |
53a8d80 |
- tio.stop();
|
|
Tomas Radej |
53a8d80 |
- for (int i = 0; i < 10; i++)
|
|
Tomas Radej |
53a8d80 |
- {
|
|
Tomas Radej |
53a8d80 |
- String message = list.get(i).toString().trim();
|
|
Tomas Radej |
53a8d80 |
- assertEquals("b" + i + "e" + i, message);
|
|
Tomas Radej |
53a8d80 |
- }
|
|
Tomas Radej |
53a8d80 |
- }
|
|
Tomas Radej |
53a8d80 |
-
|
|
Tomas Radej |
53a8d80 |
- /**
|
|
Tomas Radej |
53a8d80 |
- * Simple test too see if the basics work.
|
|
Tomas Radej |
53a8d80 |
- */
|
|
Tomas Radej |
53a8d80 |
- public void testSimple()
|
|
Tomas Radej |
53a8d80 |
- {
|
|
Tomas Radej |
53a8d80 |
- ThreadIOImpl tio = new ThreadIOImpl();
|
|
Tomas Radej |
53a8d80 |
- tio.start();
|
|
Tomas Radej |
53a8d80 |
- System.out.println("Hello World");
|
|
Tomas Radej |
53a8d80 |
- ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
Tomas Radej |
53a8d80 |
- ByteArrayOutputStream err = new ByteArrayOutputStream();
|
|
Tomas Radej |
53a8d80 |
- tio.setStreams(System.in, new PrintStream(out), new PrintStream(err));
|
|
Tomas Radej |
53a8d80 |
- try
|
|
Tomas Radej |
53a8d80 |
- {
|
|
Tomas Radej |
53a8d80 |
- System.out.println("Simple Normal Message");
|
|
Tomas Radej |
53a8d80 |
- System.err.println("Simple Error Message");
|
|
Tomas Radej |
53a8d80 |
- }
|
|
Tomas Radej |
53a8d80 |
- finally
|
|
Tomas Radej |
53a8d80 |
- {
|
|
Tomas Radej |
53a8d80 |
- tio.close();
|
|
Tomas Radej |
53a8d80 |
- }
|
|
Tomas Radej |
53a8d80 |
- tio.stop();
|
|
Tomas Radej |
53a8d80 |
- String normal = out.toString().trim();
|
|
Tomas Radej |
53a8d80 |
- //String error = err.toString().trim();
|
|
Tomas Radej |
53a8d80 |
- assertEquals("Simple Normal Message", normal);
|
|
Tomas Radej |
53a8d80 |
- //assertEquals("Simple Error Message", error );
|
|
Tomas Radej |
53a8d80 |
- System.out.println("Goodbye World");
|
|
Tomas Radej |
53a8d80 |
- }
|
|
Tomas Radej |
53a8d80 |
-}
|