You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2014/01/09 18:54:51 UTC

svn commit: r1556900 - in /commons/proper/exec/trunk/src/test/java/org/apache/commons/exec: ./ environment/ util/

Author: britter
Date: Thu Jan  9 17:54:51 2014
New Revision: 1556900

URL: http://svn.apache.org/r1556900
Log:
Convert JUnit 3 TestCases to JUnit 4 annotation based tests

Removed:
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TestRunner.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TestUtilTest.java
Modified:
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/StandAloneTest.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TestUtil.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
    commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java Thu Jan  9 17:54:51 2014
@@ -18,34 +18,35 @@
 
 package org.apache.commons.exec;
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.File;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
 import org.apache.commons.exec.util.StringUtils;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * @version $Id$
  */
-public class CommandLineTest extends TestCase {
+public class CommandLineTest {
 
-    private void assertEquals(final String[] expected, final String[] actual) {
-        if (!Arrays.equals(expected, actual)) {
-            throw new AssertionFailedError("Arrays not equal");
-        }
-    }
 
+    @Test
     public void testExecutable() {
         final CommandLine cmdl = new CommandLine("test");
         assertEquals("[test]", cmdl.toString());
-        assertEquals(new String[] {"test"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test"}, cmdl.toStrings());
         assertEquals("test", cmdl.getExecutable());
         assertTrue(cmdl.getArguments().length == 0);
     }
 
+    @Test
     public void testExecutableZeroLengthString() {
         try {
             new CommandLine("");
@@ -55,6 +56,7 @@ public class CommandLineTest extends Tes
         }
     }
 
+    @Test
     public void testExecutableWhitespaceString() {
         try {
             new CommandLine("   ");
@@ -64,6 +66,7 @@ public class CommandLineTest extends Tes
         }
     }
 
+    @Test
     public void testNullExecutable() {
         try {
             new CommandLine((String)null);
@@ -73,58 +76,65 @@ public class CommandLineTest extends Tes
         }
     }
 
+    @Test
     public void testAddArgument() {
         final CommandLine cmdl = new CommandLine("test");
 
         cmdl.addArgument("foo");
         cmdl.addArgument("bar");
         assertEquals("[test, foo, bar]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "bar"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "bar"}, cmdl.toStrings());
     }
 
+    @Test
     public void testAddNullArgument() {
         final CommandLine cmdl = new CommandLine("test");
 
         cmdl.addArgument(null);
         assertEquals("[test]", cmdl.toString());
-        assertEquals(new String[] {"test"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test"}, cmdl.toStrings());
     }
 
+    @Test
     public void testAddArgumentWithSpace() {
         final CommandLine cmdl = new CommandLine("test");
         cmdl.addArgument("foo");
         cmdl.addArgument("ba r");
         assertEquals("[test, foo, \"ba r\"]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "\"ba r\""}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "\"ba r\""}, cmdl.toStrings());
     }
 
+    @Test
     public void testAddArgumentWithQuote() {
         final CommandLine cmdl = new CommandLine("test");
         cmdl.addArgument("foo");
         cmdl.addArgument("ba\"r");
         assertEquals("[test, foo, 'ba\"r']", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "'ba\"r'"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "'ba\"r'"}, cmdl.toStrings());
     }
 
+    @Test
     public void testAddArgumentWithQuotesAround() {
         final CommandLine cmdl = new CommandLine("test");
         cmdl.addArgument("\'foo\'");
         cmdl.addArgument("\"bar\"");
         cmdl.addArgument("\"fe z\"");
         assertEquals("[test, foo, bar, \"fe z\"]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "bar", "\"fe z\""}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "bar", "\"fe z\""}, cmdl.toStrings());
     }
 
+    @Test
     public void testAddArgumentWithSingleQuote() {
         final CommandLine cmdl = new CommandLine("test");
 
         cmdl.addArgument("foo");
         cmdl.addArgument("ba'r");
         assertEquals("[test, foo, \"ba'r\"]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "\"ba\'r\""}, cmdl
+        assertArrayEquals(new String[]{"test", "foo", "\"ba\'r\""}, cmdl
                 .toStrings());
     }
 
+    @Test
     public void testAddArgumentWithBothQuotes() {
         final CommandLine cmdl = new CommandLine("test");
 
@@ -136,40 +146,45 @@ public class CommandLineTest extends Tes
         }
     }
 
+    @Test
     public void testAddArguments() {
         final CommandLine cmdl = new CommandLine("test");
         cmdl.addArguments("foo bar");
         assertEquals("[test, foo, bar]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "bar"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "bar"}, cmdl.toStrings());
     }
 
+    @Test
     public void testAddArgumentsWithQuotes() {
         final CommandLine cmdl = new CommandLine("test");
         cmdl.addArguments("'foo' \"bar\"");
         assertEquals("[test, foo, bar]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "bar"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "bar"}, cmdl.toStrings());
     }
 
+    @Test
     public void testAddArgumentsWithQuotesAndSpaces() {
         final CommandLine cmdl = new CommandLine("test");
         cmdl.addArguments("'fo o' \"ba r\"");
         assertEquals("[test, \"fo o\", \"ba r\"]", cmdl.toString());
-        assertEquals(new String[] {"test", "\"fo o\"", "\"ba r\""}, cmdl
+        assertArrayEquals(new String[]{"test", "\"fo o\"", "\"ba r\""}, cmdl
                 .toStrings());
     }
 
+    @Test
     public void testAddArgumentsArray() {
         final CommandLine cmdl = new CommandLine("test");
         cmdl.addArguments(new String[] {"foo", "bar"});
         assertEquals("[test, foo, bar]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "bar"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "bar"}, cmdl.toStrings());
     }
 
+    @Test
     public void testAddArgumentsArrayNull() {
         final CommandLine cmdl = new CommandLine("test");
         cmdl.addArguments((String[]) null);
         assertEquals("[test]", cmdl.toString());
-        assertEquals(new String[] {"test"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test"}, cmdl.toStrings());
     }
 
     /**
@@ -177,6 +192,7 @@ public class CommandLineTest extends Tes
      * in one line, e.g. to make commenting out some options
      * less error prone.
      */
+    @Test
     public void testAddTwoArguments() {
 
         final CommandLine userAddCL1 = new CommandLine("useradd");
@@ -191,18 +207,21 @@ public class CommandLineTest extends Tes
         assertEquals(userAddCL1.toString(), userAddCL2.toString());
     }
 
+    @Test
     public void testParseCommandLine() {
         final CommandLine cmdl = CommandLine.parse("test foo bar");
         assertEquals("[test, foo, bar]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "bar"}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "bar"}, cmdl.toStrings());
     }
 
+    @Test
     public void testParseCommandLineWithQuotes() {
         final CommandLine cmdl = CommandLine.parse("test \"foo\" \'ba r\'");
         assertEquals("[test, foo, \"ba r\"]", cmdl.toString());
-        assertEquals(new String[] {"test", "foo", "\"ba r\""}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"test", "foo", "\"ba r\""}, cmdl.toStrings());
     }
 
+    @Test
     public void testParseCommandLineWithUnevenQuotes() {
         try {
             CommandLine.parse("test \"foo bar");
@@ -212,6 +231,7 @@ public class CommandLineTest extends Tes
         }
     }
 
+    @Test
     public void testParseCommandLineWithNull() {
         try {
             CommandLine.parse(null);
@@ -221,6 +241,7 @@ public class CommandLineTest extends Tes
         }
     }
 
+    @Test
     public void testParseCommandLineWithOnlyWhitespace() {
         try {
             CommandLine.parse("  ");
@@ -236,6 +257,7 @@ public class CommandLineTest extends Tes
      * a "500x>" parameter (including quotes) and it is simply not possible to
      * do that without adding a space, e.g. "500x> ".
      */
+    @Test
     public void testParseComplexCommandLine1() {
         final HashMap substitutionMap = new HashMap();
         substitutionMap.put("in", "source.jpg");
@@ -249,6 +271,7 @@ public class CommandLineTest extends Tes
      * far as I understand it there is no way to express that
      * in a one-line command string.
      */
+    @Test
     public void testParseComplexCommandLine2() {
 
         final String commandline = "./script/jrake cruise:publish_installers "
@@ -271,6 +294,7 @@ public class CommandLineTest extends Tes
      *
      * cmd.exe /C c:\was51\Web Sphere\AppServer\bin\versionInfo.bat
      */
+    @Test
     public void testParseRealLifeCommandLine_1() {
 
         final String commandline = "cmd.exe /C \"c:\\was51\\Web Sphere\\AppServer\\bin\\versionInfo.bat\"";
@@ -285,23 +309,25 @@ public class CommandLineTest extends Tes
     * Create a command line with pre-quoted strings to test SANDBOX-192,
     * e.g. "runMemorySud.cmd", "10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""
     */
+   @Test
     public void testComplexAddArgument() {
         final CommandLine cmdl = new CommandLine("runMemorySud.cmd");
         cmdl.addArgument("10", false);
         cmdl.addArgument("30", false);
         cmdl.addArgument("-XX:+UseParallelGC", false);
         cmdl.addArgument("\"-XX:ParallelGCThreads=2\"", false);
-        assertEquals(new String[] {"runMemorySud.cmd", "10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""}, cmdl.toStrings());
+        assertArrayEquals(new String[]{"runMemorySud.cmd", "10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""}, cmdl.toStrings());
     }
 
     /**
      * Create a command line with pre-quoted strings to test SANDBOX-192,
      * e.g. "runMemorySud.cmd", "10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""
      */
+    @Test
      public void testComplexAddArguments1() {
          final CommandLine cmdl = new CommandLine("runMemorySud.cmd");
          cmdl.addArguments(new String[] {"10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""}, false);
-         assertEquals(new String[] {"runMemorySud.cmd", "10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""}, cmdl.toStrings());
+         assertArrayEquals(new String[]{"runMemorySud.cmd", "10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""}, cmdl.toStrings());
      }
 
     /**
@@ -310,15 +336,17 @@ public class CommandLineTest extends Tes
      * Please not that we re forced to add additional single quotes to get the test working -
      * don't know if this is a bug or a feature.
      */
+    @Test
      public void testComplexAddArguments2() {
          final CommandLine cmdl = new CommandLine("runMemorySud.cmd");
          cmdl.addArguments("10 30 -XX:+UseParallelGC '\"-XX:ParallelGCThreads=2\"'", false);
-         assertEquals(new String[] {"runMemorySud.cmd", "10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""}, cmdl.toStrings());
+         assertArrayEquals(new String[]{"runMemorySud.cmd", "10", "30", "-XX:+UseParallelGC", "\"-XX:ParallelGCThreads=2\""}, cmdl.toStrings());
      }
 
     /**
      * Test expanding the command line based on a user-supplied map.
      */
+    @Test
     public void testCommandLineParsingWithExpansion1() {
 
         CommandLine cmdl;
@@ -335,24 +363,24 @@ public class CommandLineTest extends Tes
         // do not pass substitution map
         cmdl = CommandLine.parse("${JAVA_HOME}/bin/java ${appMainClass}");
         assertTrue(cmdl.getExecutable().indexOf("${JAVA_HOME}") == 0 );
-        assertEquals(new String[] {"${appMainClass}"}, cmdl.getArguments());
+        assertArrayEquals(new String[]{"${appMainClass}"}, cmdl.getArguments());
 
         // pass arguments with an empty map
         cmdl = CommandLine.parse("${JAVA_HOME}/bin/java ${appMainClass}", new HashMap());
         assertTrue(cmdl.getExecutable().indexOf("${JAVA_HOME}") == 0 );
-        assertEquals(new String[] {"${appMainClass}"}, cmdl.getArguments());
+        assertArrayEquals(new String[]{"${appMainClass}"}, cmdl.getArguments());
 
         // pass an complete substitution map
         cmdl = CommandLine.parse("${JAVA_HOME}/bin/java ${appMainClass}", substitutionMap);
         assertTrue(cmdl.getExecutable().indexOf("${JAVA_HOME}") < 0 );
         assertTrue(cmdl.getExecutable().indexOf("local") > 0 );
-        assertEquals(new String[] {"foo.bar.Main"}, cmdl.getArguments());
+        assertArrayEquals(new String[]{"foo.bar.Main"}, cmdl.getArguments());
 
         // pass an incomplete substitution map resulting in unresolved variables
         cmdl = CommandLine.parse("${JAVA_HOME}/bin/java ${appMainClass}", incompleteMap);
         assertTrue(cmdl.getExecutable().indexOf("${JAVA_HOME}") < 0 );
         assertTrue(cmdl.getExecutable().indexOf("local") > 0 );
-        assertEquals(new String[] {"${appMainClass}"}, cmdl.getArguments());
+        assertArrayEquals(new String[]{"${appMainClass}"}, cmdl.getArguments());
 
         // pass a file
         cmdl = CommandLine.parse("${JAVA_HOME}/bin/java ${appMainClass} ${file1} ${file2}", substitutionMap);
@@ -364,6 +392,7 @@ public class CommandLineTest extends Tes
      * goal of the test is to setup a command line using macros and reuse
      * it multiple times.
      */
+    @Test
     public void testCommandLineParsingWithExpansion2() {
 
         CommandLine cmdl;
@@ -408,9 +437,10 @@ public class CommandLineTest extends Tes
         assertEquals(StringUtils.fixFileSeparatorChar("C:\\Programme\\jdk1.5.0_12\\bin\\java"), result[0]);
         assertEquals("-class", result[1]);
         assertEquals("foo.bar.Main", result[2]);
-        assertEquals("\"C:\\Document And Settings\\documents\\432432.pdf\"", result[3]);                
+        assertEquals("\"C:\\Document And Settings\\documents\\432432.pdf\"", result[3]);
     }
 
+    @Test
     public void testCommandLineParsingWithExpansion3() {
         final CommandLine cmdl = CommandLine.parse("AcroRd32.exe");
         cmdl.addArgument("/p");
@@ -423,14 +453,15 @@ public class CommandLineTest extends Tes
         assertEquals("AcroRd32.exe", result[0]);
         assertEquals("/p", result[1]);
         assertEquals("/h", result[2]);
-        assertEquals("C:\\Document And Settings\\documents\\432432.pdf", result[3]);                
-        
+        assertEquals("C:\\Document And Settings\\documents\\432432.pdf", result[3]);
+
     }
     /**
      * Test the toString() method.
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testToString() throws Exception {
         CommandLine cmdl;
         final HashMap params = new HashMap();
@@ -455,6 +486,7 @@ public class CommandLineTest extends Tes
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testToStringTroubleshooting() throws Exception {
         System.out.println("testToStringTroubleshooting");
         // On HP-UX quotes handling leads to errors,
@@ -474,6 +506,8 @@ public class CommandLineTest extends Tes
      * Some complex real-life command line from
      * http://blogs.msdn.com/b/astebner/archive/2005/12/13/503471.aspx
      */
+    @Test
+    @Ignore
     public void _testExec36_1() throws Exception {
 
         CommandLine cmdl;
@@ -499,6 +533,8 @@ public class CommandLineTest extends Tes
      * Some complex real-life command line from
      * http://blogs.msdn.com/b/astebner/archive/2005/12/13/503471.aspx
      */
+    @Test
+    @Ignore
     public void _testExec36_2() {
 
         CommandLine cmdl;
@@ -519,6 +555,8 @@ public class CommandLineTest extends Tes
      *
      * C:\CVS_DB\WeightsEngine /f WeightsEngine.mak CFG="WeightsEngine - Win32Release"
      */
+    @Test
+    @Ignore
     public void _testExec36_3() {
 
         final String commandline = "C:\\CVS_DB\\WeightsEngine /f WeightsEngine.mak CFG=\"WeightsEngine - Win32Release\"";
@@ -530,6 +568,7 @@ public class CommandLineTest extends Tes
         assertEquals("CFG=\"WeightsEngine - Win32Release\"", args[2]);
     }
 
+    @Test
     public void testCopyConstructor()
     {
         final Map map = new HashMap();

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java Thu Jan  9 17:54:51 2014
@@ -18,8 +18,12 @@
 
 package org.apache.commons.exec;
 
-import junit.framework.TestCase;
-import org.apache.commons.exec.environment.EnvironmentUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -34,10 +38,17 @@ import java.io.PipedOutputStream;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.commons.exec.environment.EnvironmentUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
 /**
  * @version $Id$
  */
-public class DefaultExecutorTest extends TestCase {
+public class DefaultExecutorTest {
 
     /** Maximum time to wait (15s) */
     private static final int WAITFOR_TIMEOUT = 15000;
@@ -61,10 +72,11 @@ public class DefaultExecutorTest extends
 
 
     // Get suitable exit codes for the OS
-    private static final int SUCCESS_STATUS; // test script successful exit code
-    private static final int ERROR_STATUS;   // test script error exit code
+    private static int SUCCESS_STATUS; // test script successful exit code
+    private static int ERROR_STATUS;   // test script error exit code
 
-    static{
+    @BeforeClass
+    public static void classSetUp() {
 
         final int statuses[] = TestUtil.getTestScriptCodesForOS();
         SUCCESS_STATUS=statuses[0];
@@ -75,7 +87,8 @@ public class DefaultExecutorTest extends
         System.setProperty("org.apache.commons.exec.debug", "true");
     }
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
 
         // delete the marker file
         this.foreverOutputFile.getParentFile().mkdirs();
@@ -88,7 +101,8 @@ public class DefaultExecutorTest extends
         this.exec.setStreamHandler(new PumpStreamHandler(baos, baos));
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         this.baos.close();
         foreverOutputFile.delete();
     }
@@ -104,6 +118,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecute() throws Exception {
         final CommandLine cl = new CommandLine(testScript);
         final int exitValue = exec.execute(cl);
@@ -112,6 +127,7 @@ public class DefaultExecutorTest extends
         assertEquals(new File("."), exec.getWorkingDirectory());
     }
 
+    @Test
     public void testExecuteWithWorkingDirectory() throws Exception {
         final File workingDir = new File("./target");
         final CommandLine cl = new CommandLine(testScript);
@@ -122,6 +138,7 @@ public class DefaultExecutorTest extends
         assertEquals(exec.getWorkingDirectory(), workingDir);
     }
 
+    @Test
     public void testExecuteWithInvalidWorkingDirectory() throws Exception {
         final File workingDir = new File("/foo/bar");
         final CommandLine cl = new CommandLine(testScript);
@@ -135,6 +152,7 @@ public class DefaultExecutorTest extends
         }
     }
 
+    @Test
     public void testExecuteWithError() throws Exception {
         final CommandLine cl = new CommandLine(errorTestScript);
 
@@ -146,6 +164,7 @@ public class DefaultExecutorTest extends
         }
     }
 
+    @Test
     public void testExecuteWithArg() throws Exception {
         final CommandLine cl = new CommandLine(testScript);
         cl.addArgument("BAR");
@@ -159,8 +178,9 @@ public class DefaultExecutorTest extends
      * Execute the test script and pass a environment containing
      * 'TEST_ENV_VAR'.
      */
+    @Test
     public void testExecuteWithSingleEnvironmentVariable() throws Exception {
-    	final Map env = new HashMap();
+        final Map env = new HashMap();
         env.put("TEST_ENV_VAR", "XYZ");
 
         final CommandLine cl = new CommandLine(testScript);
@@ -177,6 +197,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteAsync() throws Exception {
         final CommandLine cl = new CommandLine(testScript);
         final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
@@ -194,6 +215,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteAsyncWithError() throws Exception {
         final CommandLine cl = new CommandLine(errorTestScript);
         final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
@@ -211,6 +233,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteAsyncWithTimelyUserTermination() throws Exception {
         final CommandLine cl = new CommandLine(foreverTestScript);
         final ExecuteWatchdog watchdog = new ExecuteWatchdog(Integer.MAX_VALUE);
@@ -238,6 +261,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteAsyncWithTooLateUserTermination() throws Exception {
         final CommandLine cl = new CommandLine(foreverTestScript);
         final DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
@@ -265,6 +289,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteWatchdogSync() throws Exception {
 
         if (OS.isFamilyOpenVms()) {
@@ -309,6 +334,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteWatchdogAsync() throws Exception {
 
         final long timeout = 10000;
@@ -337,6 +363,7 @@ public class DefaultExecutorTest extends
      * @throws Exception
      *             the test failed
      */
+    @Test
     public void testExecuteWatchdogVeryLongTimeout() throws Exception {
         final long timeout = Long.MAX_VALUE;
 
@@ -361,6 +388,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteNonExistingApplication() throws Exception {
         final CommandLine cl = new CommandLine(nonExistingTestScript);
         final DefaultExecutor executor = new DefaultExecutor();
@@ -379,6 +407,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteAsyncWithNonExistingApplication() throws Exception {
         final CommandLine cl = new CommandLine(nonExistingTestScript);
         final DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
@@ -394,6 +423,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteWithCustomExitValue1() throws Exception {
         exec.setExitValue(ERROR_STATUS);
         final CommandLine cl = new CommandLine(errorTestScript);
@@ -406,6 +436,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteWithCustomExitValue2() throws Exception {
         final CommandLine cl = new CommandLine(errorTestScript);
         exec.setExitValue(SUCCESS_STATUS);
@@ -423,6 +454,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteWithProcessDestroyer() throws Exception {
 
       final CommandLine cl = new CommandLine(testScript);
@@ -447,6 +479,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteAsyncWithProcessDestroyer() throws Exception {
 
       final CommandLine cl = new CommandLine(foreverTestScript);
@@ -485,6 +518,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteWithFancyArg() throws Exception {
         final CommandLine cl = new CommandLine(testScript);
         cl.addArgument("test $;`(0)[1]{2}");
@@ -502,6 +536,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteWithRedirectedStreams() throws Exception {
         if (OS.isFamilyUnix()) {
             final FileInputStream fis = new FileInputStream("./NOTICE.txt");
@@ -533,6 +568,7 @@ public class DefaultExecutorTest extends
       *
       * @throws Exception the test failed
       */
+     @Test
     public void testExecuteWithStdOutErr() throws Exception {
         final CommandLine cl = new CommandLine(testScript);
         final PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(System.out, System.err);
@@ -548,6 +584,7 @@ public class DefaultExecutorTest extends
      * @throws Exception
      *             the test failed
      */
+    @Test
     public void testExecuteWithNullOutErr() throws Exception {
         final CommandLine cl = new CommandLine(testScript);
         final PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(null, null);
@@ -562,6 +599,7 @@ public class DefaultExecutorTest extends
       *
       * @throws Exception the test failed
       */
+     @Test
      public void testExecuteWithRedirectOutErr() throws Exception
      {
          final File outfile = File.createTempFile("EXEC", ".test");
@@ -581,6 +619,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExecuteWithComplexArguments() throws Exception {
         final CommandLine cl = new CommandLine(printArgsScript);
         cl.addArgument("gdal_translate");
@@ -598,6 +637,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testStdInHandling() throws Exception {
         // newline not needed; causes problems for VMS
         final ByteArrayInputStream bais = new ByteArrayInputStream("Foo".getBytes());
@@ -621,6 +661,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testEnvironmentVariables() throws Exception {
         exec.execute(new CommandLine(environmentSript));
         final String environment = baos.toString().trim();
@@ -634,6 +675,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testAddEnvironmentVariables() throws Exception {
         final Map myEnvVars = new HashMap();
         myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
@@ -644,6 +686,7 @@ public class DefaultExecutorTest extends
         assertTrue("Expecting NEW_VAL in "+environment,environment.indexOf("NEW_VAL") >= 0);
     }
 
+    @Test
     public void testAddEnvironmentVariableEmbeddedQuote() throws Exception {
         final Map myEnvVars = new HashMap();
         myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
@@ -667,6 +710,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec33() throws Exception {
         final CommandLine cl = new CommandLine(testScript);
         final PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(System.out, System.err, System.in);
@@ -685,6 +729,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec34_1() throws Exception {
 
         final CommandLine cmdLine = new CommandLine(pingScript);
@@ -708,6 +753,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec34_2() throws Exception {
 
         final CommandLine cmdLine = new CommandLine(pingScript);
@@ -731,6 +777,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec36_1() throws Exception {
 
         if (OS.isFamilyUnix()) {
@@ -778,6 +825,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec36_2() throws Exception {
 
         String expected;
@@ -832,6 +880,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec41WithStreams() throws Exception {
 
         CommandLine cmdLine;
@@ -891,6 +940,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec41WithoutStreams() throws Exception {
 
 		final CommandLine cmdLine = new CommandLine(pingScript);
@@ -934,6 +984,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec44() throws Exception {
 
         final CommandLine cl = new CommandLine(foreverTestScript);
@@ -963,6 +1014,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec49_1() throws Exception {
 
         if (OS.isFamilyUnix()) {
@@ -1003,6 +1055,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec49_2() throws Exception {
 
         if (OS.isFamilyUnix()) {
@@ -1044,6 +1097,7 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testExec_57() throws IOException {
 
         if (!OS.isFamilyUnix()) {
@@ -1083,6 +1137,7 @@ public class DefaultExecutorTest extends
      * note that a successful test is no proof that the issues was indeed fixed.
      *
      */
+    @Test
     public void testExec_60() throws Exception {
 
         final int start = 0;
@@ -1134,6 +1189,8 @@ public class DefaultExecutorTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
+    @Ignore
     public void _testExecuteStability() throws Exception {
 
         // make a plain-vanilla test

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java Thu Jan  9 17:54:51 2014
@@ -17,37 +17,43 @@
  */
 package org.apache.commons.exec;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
 
 import java.io.File;
 import java.io.OutputStream;
 
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
 /**
  * Test the LogOutputStream.
  *
  * @version $Id$
  */
-public class LogOutputStreamTest extends TestCase
-{
+public class LogOutputStreamTest {
 
     private final Executor exec = new DefaultExecutor();
     private final File testDir = new File("src/test/scripts");
     private OutputStream systemOut;
     private final File environmentScript = TestUtil.resolveScriptForOS(testDir + "/environment");
 
-    static{
+    @BeforeClass
+    public static void classSetUp() {
         // turn on debug mode and throw an exception for each encountered problem
         System.setProperty("org.apache.commons.exec.lenient", "false");
         System.setProperty("org.apache.commons.exec.debug", "true");
     }
 
-
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         this.systemOut = new SystemLogOutputStream(1);
         this.exec.setStreamHandler(new PumpStreamHandler(systemOut, systemOut));
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         this.systemOut.close();
     }
 
@@ -55,6 +61,7 @@ public class LogOutputStreamTest extends
     // Start of regression tests
     // ======================================================================
 
+    @Test
     public void testStdout() throws Exception {
         final CommandLine cl = new CommandLine(environmentScript);
         final int exitValue = exec.execute(cl);

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/StandAloneTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/StandAloneTest.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/StandAloneTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/StandAloneTest.java Thu Jan  9 17:54:51 2014
@@ -18,23 +18,28 @@
 
 package org.apache.commons.exec;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 
+import org.junit.BeforeClass;
+import org.junit.Test;
+
 /**
  * Placeholder for mailing list question - provided a minimal test case
  * to answer the question as sel-contained regression test.
  *
  * @version $Id$
  */
-public class StandAloneTest extends TestCase {
+public class StandAloneTest {
 
-    static{
+    @BeforeClass
+    public static void classSetUp() {
         System.setProperty("org.apache.commons.exec.lenient", "false");
         System.setProperty("org.apache.commons.exec.debug", "true");
     }
 
+    @Test
     public void testMe() throws Exception {
         if (OS.isFamilyUnix()) {
             final File testScript = TestUtil.resolveScriptForOS("./src/test/scripts/standalone");
@@ -43,6 +48,6 @@ public class StandAloneTest extends Test
             final CommandLine cl = new CommandLine(testScript);
             exec.execute(cl);
             assertTrue(new File("./target/mybackup.gz").exists());
-        }        
+        }
     }
 }

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TestUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TestUtil.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TestUtil.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TestUtil.java Thu Jan  9 17:54:51 2014
@@ -59,29 +59,5 @@ public final class TestUtil {
             throw new AssertionFailedError("Test not supported for this OS");
         }
     }
-    
-    
-    public static void assertEquals(final Object[] expected, final Object[] actual, final boolean orderSignificant) {
-        
-        if (expected == null && actual == null) {
-            // all good
-        } else if (actual == null) {
-            throw new AssertionFailedError("Expected non null array");
-        } else if (expected == null) {
-            throw new AssertionFailedError("Expected null array");
-        } else {
-            if (expected.length != actual.length) {
-                throw new AssertionFailedError("Arrays not of same length");
-            }
-            
-            if (!orderSignificant) {
-                Arrays.sort(expected);
-                Arrays.sort(actual);
-            }
-            
-            for (int i = 0; i < actual.length; i++) {
-                TestCase.assertEquals("Array element at " + i, expected[i], actual[i]);
-            }
-        }
-    }
+
 }

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/TutorialTest.java Thu Jan  9 17:54:51 2014
@@ -18,13 +18,15 @@
 
 package org.apache.commons.exec;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.junit.Test;
+
 /**
  * An example based on the tutorial where the user can can safely play with
  * <ul>
@@ -35,7 +37,7 @@ import java.util.Map;
  *
  * @version $Id$
  */
-public class TutorialTest extends TestCase {
+public class TutorialTest {
 
     /** the directory to pick up the test scripts */
     private final File testDir = new File("src/test/scripts");
@@ -43,6 +45,7 @@ public class TutorialTest extends TestCa
     /** simulates a PDF print job */
     private final File acroRd32Script = TestUtil.resolveScriptForOS(testDir + "/acrord32");
 
+    @Test
     public void testTutorialExample() throws Exception {
 
         final long printJobTimeout = 15000;

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java Thu Jan  9 17:54:51 2014
@@ -18,28 +18,31 @@
 
 package org.apache.commons.exec.environment;
 
+import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.exec.OS;
-import org.apache.commons.exec.TestUtil;
-
-import static org.junit.Assert.assertArrayEquals;
+import org.junit.Test;
 
 /**
  * @version $Id$
  */
-public class EnvironmentUtilTest extends TestCase {
+public class EnvironmentUtilTest {
 
     /**
      * Tests the behaviour of the EnvironmentUtils.toStrings()
      * when using a <code>null</code> environment.
      */
+    @Test
     public void testToStrings() {
         // check for a non-existing environment when passing null
         assertNull(EnvironmentUtils.toStrings(null));
@@ -60,6 +63,7 @@ public class EnvironmentUtilTest extends
      *
      * @throws IOException the test failed
      */
+    @Test
     public void testGetProcEnvironment() throws IOException {
         final Map procEnvironment = EnvironmentUtils.getProcEnvironment();
         // we assume that there is at least one environment variable
@@ -80,6 +84,7 @@ public class EnvironmentUtilTest extends
      *
      * @throws IOException the test failed
      */
+    @Test
     public void testGetProcEnvironmentCaseInsensitiveLookup() throws IOException {
         // run tests only on windows platforms
         if (!OS.isFamilyWindows()) {
@@ -111,6 +116,7 @@ public class EnvironmentUtilTest extends
      *
      * @throws Exception the test failed
      */
+    @Test
     public void testCaseInsensitiveVariableLookup() throws Exception {
         final Map procEnvironment = EnvironmentUtils.getProcEnvironment();
         // Check that case is preserved for values

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java Thu Jan  9 17:54:51 2014
@@ -18,21 +18,23 @@
 
 package org.apache.commons.exec.util;
 
-import org.apache.commons.exec.environment.EnvironmentUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
+import org.apache.commons.exec.environment.EnvironmentUtils;
+import org.junit.Test;
 
 /**
  * @version $Id$
  */
-public class MapUtilTest extends TestCase
-{
+public class MapUtilTest {
     /**
      * Test copying of map
      */
+    @Test
     public void testCopyMap() throws Exception {
 
         final HashMap procEnvironment = new HashMap();
@@ -51,6 +53,7 @@ public class MapUtilTest extends TestCas
     /**
      * Test merging of maps
      */
+    @Test
     public void testMergeMap() throws Exception {
 
         final Map procEnvironment = EnvironmentUtils.getProcEnvironment();
@@ -65,6 +68,7 @@ public class MapUtilTest extends TestCas
     /**
      * Test prefixing of map
      */
+    @Test
     public void testPrefixMap() throws Exception {
 
         final HashMap procEnvironment = new HashMap();

Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java?rev=1556900&r1=1556899&r2=1556900&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java Thu Jan  9 17:54:51 2014
@@ -18,19 +18,22 @@
 
 package org.apache.commons.exec.util;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  * @version $Id$
  */
-public class StringUtilTest extends TestCase
-{
+public class StringUtilTest {
     /**
      * Test no string substitution
      */
+    @Test
     public void testNoStringSubstitution() throws Exception
     {
         final Map vars = new HashMap();
@@ -44,6 +47,7 @@ public class StringUtilTest extends Test
      * Test a default string substitution, e.g. all placeholders
      * are expanded.
      */
+    @Test
     public void testDefaultStringSubstitution() throws Exception 
     {
         final Map vars = new HashMap();
@@ -58,6 +62,7 @@ public class StringUtilTest extends Test
      * Test an incomplete string substitution where not all placeholders
      * are expanded.
      */
+    @Test
     public void testIncompleteSubstitution() throws Exception {
 
         final Map vars = new HashMap();
@@ -79,6 +84,7 @@ public class StringUtilTest extends Test
     /**
      * Test a erroneous template.
      */
+    @Test
     public void testErroneousTemplate() throws Exception
     {
         final Map vars = new HashMap();