You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2016/03/21 17:57:18 UTC

svn commit: r1736034 - in /felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime: ./ expr/ threadio/

Author: gnodet
Date: Mon Mar 21 16:57:18 2016
New Revision: 1736034

URL: http://svn.apache.org/viewvc?rev=1736034&view=rev
Log:
Convert to junit4

Modified:
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java?rev=1736034&r1=1736033&r2=1736034&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java Mon Mar 21 16:57:18 2016
@@ -24,19 +24,19 @@ import java.io.InputStream;
 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 @@ public abstract class AbstractParserTest
         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 {

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java?rev=1736034&r1=1736033&r2=1736034&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestCoercion.java Mon Mar 21 16:57:18 2016
@@ -21,6 +21,11 @@ package org.apache.felix.gogo.runtime;
 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 @@ public class TestCoercion extends Abstra
         return s;
     }
 
+    @Test
     public void testSimpleTypes() throws Exception
     {
         Context c = new Context();
@@ -118,6 +124,7 @@ public class TestCoercion extends Abstra
         return "string";
     }
 
+    @Test
     public void testBestCoercion() throws Exception
     {
         Context c = new Context();
@@ -145,6 +152,7 @@ public class TestCoercion extends Abstra
         return flag;
     }
 
+    @Test
     public void testParameter0() throws Exception
     {
         Context c = new Context();
@@ -173,6 +181,7 @@ public class TestCoercion extends Abstra
         return parm1;
     }
 
+    @Test
     public void testParameter1() throws Exception
     {
         Context c = new Context();

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java?rev=1736034&r1=1736033&r2=1736034&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java Mon Mar 21 16:57:18 2016
@@ -33,11 +33,17 @@ import org.apache.felix.gogo.runtime.Par
 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 @@ public class TestParser extends Abstract
         assertEquals("a", c.execute("((echo a)) | capture"));
     }
 
+    @Test
     public void testUnknownCommand() throws Exception
     {
         Context c = new Context();
@@ -63,6 +70,7 @@ public class TestParser extends Abstract
         }
     }
 
+    @Test
     public void testSpecialValues() throws Exception
     {
         Context c = new Context();
@@ -71,6 +79,7 @@ public class TestParser extends Abstract
         assertEquals(null, c.execute("null"));
     }
 
+    @Test
     public void testQuotes() throws Exception
     {
         Context c = new Context();
@@ -97,6 +106,7 @@ public class TestParser extends Abstract
         assertEquals("a  b ", c.execute("echo \"$d\""));
     }
 
+    @Test
     public void testScope() throws Exception
     {
         Context c = new Context();
@@ -105,6 +115,7 @@ public class TestParser extends Abstract
         assertEquals("file://poo", c.execute("test:echo file://poo"));
     }
 
+    @Test
     public void testPipe() throws Exception
     {
         Context c = new Context();
@@ -126,6 +137,7 @@ public class TestParser extends Abstract
         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 @@ public class TestParser extends Abstract
         assertEquals("a", c.execute("a = a; echo ${$a}"));
     }
 
+    @Test
     public void testComment() throws Exception
     {
         Context c = new Context();
@@ -148,6 +161,7 @@ public class TestParser extends Abstract
         assertEquals("1", c.execute("echo 1 // hello"));
     }
 
+    @Test
     public void testClosure() throws Exception
     {
         Context c = new Context();
@@ -162,6 +176,7 @@ public class TestParser extends Abstract
         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 @@ public class TestParser extends Abstract
         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 @@ public class TestParser extends Abstract
         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 @@ public class TestParser extends Abstract
         return sw.toString();
     }
 
+    @Test
     public void testVars() throws Exception
     {
         Context c = new Context();
@@ -230,6 +248,7 @@ public class TestParser extends Abstract
         assertEquals("a", c.execute("a = a; echo ${a}"));
     }
 
+    @Test
     public void testFunny() throws Exception
     {
         Context c = new Context();
@@ -265,6 +284,7 @@ public class TestParser extends Abstract
         System.out.println(echo(args));
     }
 
+    @Test
     public void testContext() throws Exception
     {
         Context c = new Context();
@@ -311,6 +331,7 @@ public class TestParser extends Abstract
         System.out.println("]");
     }
 
+    @Test
     public void testProgram()
     {
         Program x = new Parser("abc def|ghi jkl;mno pqr|stu vwx").program();
@@ -333,6 +354,7 @@ public class TestParser extends Abstract
         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 @@ public class TestParser extends Abstract
         assertEquals("pqr", s02.tokens().get(1).toString());
     }
 
+    @Test
     public void testPipeRedir()
     {
         Program x = new Parser("abc def|&ghi").program();
@@ -360,6 +383,7 @@ public class TestParser extends Abstract
         assertEquals("ghi", s01.tokens().get(0).toString());
     }
 
+    @Test
     public void testPipeAndOr()
     {
         Program x = new Parser("abc|def&&ghi || jkl").program();
@@ -377,6 +401,7 @@ public class TestParser extends Abstract
         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 @@ public class TestParser extends Abstract
         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 @@ public class TestParser extends Abstract
         assertEquals("bar", s0.redirections().get(1).toString());
     }
 
+    @Test
     public void testSimpleValue()
     {
         Program p = new Parser(

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java?rev=1736034&r1=1736033&r2=1736034&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser2.java Mon Mar 21 16:57:18 2016
@@ -20,12 +20,19 @@ package org.apache.felix.gogo.runtime;
 
 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 @@ public class TestParser2 extends Abstrac
 //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 @@ public class TestParser2 extends Abstrac
         assertEquals("null x", c.execute("echo $expandsToNull x"));
     }
 
+    @Test
     public void testStringExecution() throws Exception
     {
         Context c = new Context();

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java?rev=1736034&r1=1736033&r2=1736034&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser3.java Mon Mar 21 16:57:18 2016
@@ -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();

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java?rev=1736034&r1=1736033&r2=1736034&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java Mon Mar 21 16:57:18 2016
@@ -27,6 +27,10 @@ import java.nio.file.Files;
 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 @@ public class TestParser4 extends Abstrac
         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 @@ public class TestParser4 extends Abstrac
         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 @@ public class TestParser4 extends Abstrac
         assertEquals("a\nb\n", c.execute("cat <fooa <foob | tac"));
     }
 
+    @Test
     public void testMultiInput() throws Exception {
         Context c = new Context();
         c.addCommand("echo", this);

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java?rev=1736034&r1=1736033&r2=1736034&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/expr/ExpressionTest.java Mon Mar 21 16:57:18 2016
@@ -21,11 +21,13 @@ package org.apache.felix.gogo.runtime.ex
 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 @@ public class ExpressionTest extends Test
         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());
     }
 
 }

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java?rev=1736034&r1=1736033&r2=1736034&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/threadio/TestThreadIO.java Mon Mar 21 16:57:18 2016
@@ -23,10 +23,10 @@ import java.io.PrintStream;
 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 @@ public class TestThreadIO extends TestCa
      * 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 @@ public class TestThreadIO extends TestCa
         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 @@ public class TestThreadIO extends TestCa
         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");
     }