Convert to junit4

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1736034 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java
index 5d74295..1d8c4d7 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java
@@ -24,19 +24,19 @@
 import java.io.OutputStream;
 import java.io.PrintStream;
 
-import junit.framework.TestCase;
 import org.apache.felix.gogo.runtime.threadio.ThreadIOImpl;
+import org.junit.After;
+import org.junit.Before;
 
-public abstract class AbstractParserTest extends TestCase {
+public abstract class AbstractParserTest {
 
     private ThreadIOImpl threadIO;
     private InputStream sin;
     private PrintStream sout;
     private PrintStream serr;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         sin = new NoCloseInputStream(System.in);
         sout = new NoClosePrintStream(System.out);
         serr = new NoClosePrintStream(System.err);
@@ -44,10 +44,9 @@
         threadIO.start();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         threadIO.stop();
-        super.tearDown();
     }
 
     public class Context extends org.apache.felix.gogo.runtime.Context {
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java
index f4ea27c..475596e 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java
@@ -21,6 +21,11 @@
 import org.apache.felix.service.command.CommandSession;
 import org.apache.felix.service.command.Descriptor;
 import org.apache.felix.service.command.Parameter;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 public class TestCoercion extends AbstractParserTest
 {
@@ -55,6 +60,7 @@
         return s;
     }
 
+    @Test
     public void testSimpleTypes() throws Exception
     {
         Context c = new Context();
@@ -118,6 +124,7 @@
         return "string";
     }
 
+    @Test
     public void testBestCoercion() throws Exception
     {
         Context c = new Context();
@@ -145,6 +152,7 @@
         return flag;
     }
 
+    @Test
     public void testParameter0() throws Exception
     {
         Context c = new Context();
@@ -173,6 +181,7 @@
         return parm1;
     }
 
+    @Test
     public void testParameter1() throws Exception
     {
         Context c = new Context();
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
index 239fba4..34e6400 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
@@ -33,11 +33,17 @@
 import org.apache.felix.gogo.runtime.Parser.Statement;
 import org.apache.felix.service.command.CommandSession;
 import org.apache.felix.service.command.Function;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 public class TestParser extends AbstractParserTest
 {
     int beentheredonethat = 0;
 
+    @Test
     public void testEvaluatation() throws Exception
     {
         Context c = new Context();
@@ -49,6 +55,7 @@
         assertEquals("a", c.execute("((echo a)) | capture"));
     }
 
+    @Test
     public void testUnknownCommand() throws Exception
     {
         Context c = new Context();
@@ -63,6 +70,7 @@
         }
     }
 
+    @Test
     public void testSpecialValues() throws Exception
     {
         Context c = new Context();
@@ -71,6 +79,7 @@
         assertEquals(null, c.execute("null"));
     }
 
+    @Test
     public void testQuotes() throws Exception
     {
         Context c = new Context();
@@ -97,6 +106,7 @@
         assertEquals("a  b ", c.execute("echo \"$d\""));
     }
 
+    @Test
     public void testScope() throws Exception
     {
         Context c = new Context();
@@ -105,6 +115,7 @@
         assertEquals("file://poo", c.execute("test:echo file://poo"));
     }
 
+    @Test
     public void testPipe() throws Exception
     {
         Context c = new Context();
@@ -126,6 +137,7 @@
         assertEquals("defghi", c.execute("(echoout abc; echoout def; echoout ghi)|grep 'def|ghi'|capture"));
     }
 
+    @Test
     public void testAssignment() throws Exception
     {
         Context c = new Context();
@@ -141,6 +153,7 @@
         assertEquals("a", c.execute("a = a; echo ${$a}"));
     }
 
+    @Test
     public void testComment() throws Exception
     {
         Context c = new Context();
@@ -148,6 +161,7 @@
         assertEquals("1", c.execute("echo 1 // hello"));
     }
 
+    @Test
     public void testClosure() throws Exception
     {
         Context c = new Context();
@@ -162,6 +176,7 @@
         assertEquals("ca  b", c.execute("e = { echo c$args } ; e 'a  b'"));
     }
 
+    @Test
     public void testArray() throws Exception
     {
         Context c = new Context();
@@ -174,6 +189,7 @@
         assertEquals(5, c.execute("[1 2 [3 4] 5 6] size"));
     }
 
+    @Test
     public void testParentheses()
     {
         Parser parser = new Parser("(a|b)|(d|f)");
@@ -185,6 +201,7 @@
         assertEquals("d.*", ((Sequence)((Statement) ((Pipeline) p.tokens().get(0)).tokens().get(0)).tokens().get(1)).program().toString());
     }
 
+    @Test
     public void testEcho() throws Exception
     {
         Context c = new Context();
@@ -220,6 +237,7 @@
         return sw.toString();
     }
 
+    @Test
     public void testVars() throws Exception
     {
         Context c = new Context();
@@ -230,6 +248,7 @@
         assertEquals("a", c.execute("a = a; echo ${a}"));
     }
 
+    @Test
     public void testFunny() throws Exception
     {
         Context c = new Context();
@@ -265,6 +284,7 @@
         System.out.println(echo(args));
     }
 
+    @Test
     public void testContext() throws Exception
     {
         Context c = new Context();
@@ -311,6 +331,7 @@
         System.out.println("]");
     }
 
+    @Test
     public void testProgram()
     {
         Program x = new Parser("abc def|ghi jkl;mno pqr|stu vwx").program();
@@ -333,6 +354,7 @@
         assertEquals("vwx", s11.tokens().get(1).toString());
     }
 
+    @Test
     public void testStatements()
     {
         Program x = new Parser("abc def|ghi jkl|mno pqr").program();
@@ -348,6 +370,7 @@
         assertEquals("pqr", s02.tokens().get(1).toString());
     }
 
+    @Test
     public void testPipeRedir()
     {
         Program x = new Parser("abc def|&ghi").program();
@@ -360,6 +383,7 @@
         assertEquals("ghi", s01.tokens().get(0).toString());
     }
 
+    @Test
     public void testPipeAndOr()
     {
         Program x = new Parser("abc|def&&ghi || jkl").program();
@@ -377,6 +401,7 @@
         assertEquals("jkl", s2.tokens().get(0).toString());
     }
 
+    @Test
     public void testBackground() {
         Program x = new Parser("echo foo&echo bar").program();
         Statement s0 = (Statement) x.tokens().get(0);
@@ -388,6 +413,7 @@
         assertEquals("bar", s1.tokens().get(1).toString());
     }
 
+    @Test
     public void testRedir() {
         Program x = new Parser("echo foo&>bar").program();
         Statement s0 = (Statement) x.tokens().get(0);
@@ -411,6 +437,7 @@
         assertEquals("bar", s0.redirections().get(1).toString());
     }
 
+    @Test
     public void testSimpleValue()
     {
         Program p = new Parser(
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java
index 09b8928..207dcd8 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java
@@ -20,12 +20,19 @@
 
 import java.io.EOFException;
 
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 /*
  * Test features of the new parser/tokenizer, many of which are not supported
  * by the original parser.
  */
 public class TestParser2 extends AbstractParserTest
 {
+    @Test
     public void testComment() throws Exception
     {
         Context c = new Context();
@@ -55,6 +62,7 @@
 //CHANGE        assertEquals("ok", c.execute("x = {// can't quote\necho ok\n}; x"));
     }
 
+    @Test
     public void testCoercion() throws Exception
     {
         Context c = new Context();
@@ -63,6 +71,7 @@
         assertEquals("null x", c.execute("echo $expandsToNull x"));
     }
 
+    @Test
     public void testStringExecution() throws Exception
     {
         Context c = new Context();
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java
index 4021fdb..2fb4609 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java
@@ -18,12 +18,17 @@
  */
 package org.apache.felix.gogo.runtime;
 
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
 /*
  * Test features of the new parser/tokenizer, many of which are not supported
  * by the original parser.
  */
 public class TestParser3 extends AbstractParserTest
 {
+    @Test
     public void testArithmetic() throws Exception
     {
         Context c = new Context();
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java
index 6a5821d..3931452 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java
@@ -27,6 +27,10 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
 /*
  * Test features of the new parser/tokenizer, many of which are not supported
  * by the original parser.
@@ -44,6 +48,7 @@
         assertEquals("hello\n", c.execute("echoerr hello|& tac"));
     }
 
+    @Test
     public void testRedir() throws Exception {
         Context c = new Context();
         c.addCommand("echo", this);
@@ -58,6 +63,7 @@
         assertEquals("hello\n", new String(Files.readAllBytes(path.resolve("foo"))));
     }
 
+    @Test
     public void testRedirInput() throws Exception {
         Context c = new Context();
         c.addCommand("echo", this);
@@ -75,6 +81,7 @@
         assertEquals("a\nb\n", c.execute("cat <fooa <foob | tac"));
     }
 
+    @Test
     public void testMultiInput() throws Exception {
         Context c = new Context();
         c.addCommand("echo", this);
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java
index c99a5ba..b5d907a 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java
@@ -21,11 +21,13 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
 import org.apache.felix.gogo.runtime.Expression;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class ExpressionTest extends TestCase {
+public class ExpressionTest {
 
+    @Test
     public void testExpr() {
 
         Map<String, Object> variables = new HashMap<String, Object>();
@@ -36,23 +38,23 @@
         variables.put("s", " foo ");
         variables.put("t", "bar");
 
-        assertEquals(4l, new Expression("c+=1, d+=2").eval(variables));
+        Assert.assertEquals(4l, new Expression("c+=1, d+=2").eval(variables));
 
-        assertEquals(" foo ", new Expression("\" foo \"").eval());
-        assertEquals(" foo bar", new Expression("s + t").eval(variables));
-        assertEquals(1l, new Expression("s < t").eval(variables));
-        assertEquals(1l, new Expression("s > t || t == \"bar\"").eval(variables));
+        Assert.assertEquals(" foo ", new Expression("\" foo \"").eval());
+        Assert.assertEquals(" foo bar", new Expression("s + t").eval(variables));
+        Assert.assertEquals(1l, new Expression("s < t").eval(variables));
+        Assert.assertEquals(1l, new Expression("s > t || t == \"bar\"").eval(variables));
 
-        assertEquals(3l, new Expression("a += 1").eval(variables));
-        assertEquals(3l, variables.get("a"));
+        Assert.assertEquals(3l, new Expression("a += 1").eval(variables));
+        Assert.assertEquals(3l, variables.get("a"));
 
-        assertEquals(30l, new Expression("10 + 20 | 30").eval());
+        Assert.assertEquals(30l, new Expression("10 + 20 | 30").eval());
 
-        assertEquals(8l, new Expression("a + b").eval(variables));
-        assertEquals(3l, new Expression("if(a < b, a, b)").eval(variables));
+        Assert.assertEquals(8l, new Expression("a + b").eval(variables));
+        Assert.assertEquals(3l, new Expression("if(a < b, a, b)").eval(variables));
 
-        assertEquals(16l, new Expression("2 + 2 << 2").eval());
-        assertEquals(8l, new Expression("2 | 2 << 2").eval());
+        Assert.assertEquals(16l, new Expression("2 + 2 << 2").eval());
+        Assert.assertEquals(8l, new Expression("2 | 2 << 2").eval());
     }
 
 }
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java
index f7afab7..babe72c 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java
@@ -23,10 +23,10 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestThreadIO extends TestCase
-{
+public class TestThreadIO {
 
     /**
      * Test if the threadio works in a nested fashion. We first push
@@ -34,6 +34,7 @@
      * the output in a ByteArrayOutputStream. Then we pop them, also printing
      * a message identifying the level. Then we verify the output for each level.
      */
+    @Test
     public void testNested()
     {
         ThreadIOImpl tio = new ThreadIOImpl();
@@ -55,13 +56,14 @@
         for (int i = 0; i < 10; i++)
         {
             String message = list.get(i).toString().trim();
-            assertEquals("b" + i + "e" + i, message);
+            Assert.assertEquals("b" + i + "e" + i, message);
         }
     }
 
     /**
      * Simple test too see if the basics work.
      */
+    @Test
     public void testSimple()
     {
         ThreadIOImpl tio = new ThreadIOImpl();
@@ -82,7 +84,7 @@
         tio.stop();
         String normal = out.toString().trim();
         //String error = err.toString().trim();
-        assertEquals("Simple Normal Message", normal);
+        Assert.assertEquals("Simple Normal Message", normal);
         //assertEquals("Simple Error Message", error );
         System.out.println("Goodbye World");
     }