Move test code out of "test" package
authorNiki Roo <niki@nikiroo.be>
Tue, 23 Apr 2019 05:44:22 +0000 (07:44 +0200)
committerNiki Roo <niki@nikiroo.be>
Tue, 23 Apr 2019 05:44:22 +0000 (07:44 +0200)
12 files changed:
configure.sh
src/be/nikiroo/utils/test/TestLauncher.java
src/be/nikiroo/utils/test_code/BundleTest.java [moved from src/be/nikiroo/utils/test/BundleTest.java with 97% similarity]
src/be/nikiroo/utils/test_code/IOUtilsTest.java [moved from src/be/nikiroo/utils/test/IOUtilsTest.java with 79% similarity]
src/be/nikiroo/utils/test_code/ProgressTest.java [moved from src/be/nikiroo/utils/test/ProgressTest.java with 98% similarity]
src/be/nikiroo/utils/test_code/SerialServerTest.java [moved from src/be/nikiroo/utils/test/SerialServerTest.java with 89% similarity]
src/be/nikiroo/utils/test_code/SerialTest.java [moved from src/be/nikiroo/utils/test/SerialTest.java with 98% similarity]
src/be/nikiroo/utils/test_code/StringUtilsTest.java [moved from src/be/nikiroo/utils/test/StringUtilsTest.java with 98% similarity]
src/be/nikiroo/utils/test_code/TempFilesTest.java [moved from src/be/nikiroo/utils/test/TempFilesTest.java with 95% similarity]
src/be/nikiroo/utils/test_code/Test.java [moved from src/be/nikiroo/utils/test/Test.java with 94% similarity]
src/be/nikiroo/utils/test_code/VersionTest.java [moved from src/be/nikiroo/utils/test/VersionTest.java with 97% similarity]
src/be/nikiroo/utils/test_code/bundle_test.properties [moved from src/be/nikiroo/utils/test/bundle_test.properties with 100% similarity]

index 4105d93af276c9420f87a8e7569576d5544b2a3b..6179aae888887bf44e0be8ddbffbac9d7201bbaf 100755 (executable)
@@ -71,9 +71,9 @@ else
 fi;
 
 
-echo "MAIN = be/nikiroo/utils/test/Test" > Makefile
+echo "MAIN = be/nikiroo/utils/test_code/Test" > Makefile
 echo "MORE = $UI $ANDROID" >> Makefile
-echo "TEST = be/nikiroo/utils/test/Test" >> Makefile
+echo "TEST = be/nikiroo/utils/test_code/Test" >> Makefile
 echo "TEST_PARAMS = $cols $ok $ko" >> Makefile
 echo "NAME = nikiroo-utils" >> Makefile
 echo "PREFIX = $PREFIX" >> Makefile
index 3741e976a54dada71bb9fa37f3fa7a07f5e5cafa..9b841a4a79a4da6a775697457b6384744f6fdd53 100644 (file)
@@ -96,7 +96,6 @@ public class TestLauncher {
         * @throws Exception
         *             in case of error
         */
-       @SuppressWarnings("unused")
        protected void start() throws Exception {
        }
 
@@ -106,7 +105,6 @@ public class TestLauncher {
         * @throws Exception
         *             in case of error
         */
-       @SuppressWarnings("unused")
        protected void stop() throws Exception {
        }
 
similarity index 97%
rename from src/be/nikiroo/utils/test/BundleTest.java
rename to src/be/nikiroo/utils/test_code/BundleTest.java
index c1c379f833bd0e114a54e367151b27a235217138..2e25eb0f4ddd9a0b77d5c053dbfbd8ebc4fcdd59 100644 (file)
@@ -1,4 +1,4 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -8,6 +8,8 @@ import be.nikiroo.utils.IOUtils;
 import be.nikiroo.utils.resources.Bundle;
 import be.nikiroo.utils.resources.Bundles;
 import be.nikiroo.utils.resources.Meta;
+import be.nikiroo.utils.test.TestCase;
+import be.nikiroo.utils.test.TestLauncher;
 
 class BundleTest extends TestLauncher {
        private File tmp;
similarity index 79%
rename from src/be/nikiroo/utils/test/IOUtilsTest.java
rename to src/be/nikiroo/utils/test_code/IOUtilsTest.java
index c62d44d3603624fc7407ab6bf5d6e691a194fd51..9f22896f0d6fcd5e09bd4dd8e9302981d7615636 100644 (file)
@@ -1,8 +1,10 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import java.io.InputStream;
 
 import be.nikiroo.utils.IOUtils;
+import be.nikiroo.utils.test.TestCase;
+import be.nikiroo.utils.test.TestLauncher;
 
 class IOUtilsTest extends TestLauncher {
        public IOUtilsTest(String[] args) {
similarity index 98%
rename from src/be/nikiroo/utils/test/ProgressTest.java
rename to src/be/nikiroo/utils/test_code/ProgressTest.java
index bd05bc5b4dbf2d6fb6cf9c4ca17735aa0fc0ef4d..22e36cb0cf19d69d70294c0058d60ff988701e5a 100644 (file)
@@ -1,6 +1,8 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import be.nikiroo.utils.Progress;
+import be.nikiroo.utils.test.TestCase;
+import be.nikiroo.utils.test.TestLauncher;
 
 class ProgressTest extends TestLauncher {
        public ProgressTest(String[] args) {
similarity index 89%
rename from src/be/nikiroo/utils/test/SerialServerTest.java
rename to src/be/nikiroo/utils/test_code/SerialServerTest.java
index a3f4f9ef4794455eac3862765fbbc8f3a684b33d..5f6222133706132e94079986a3070983a4745243 100644 (file)
@@ -1,4 +1,4 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import java.net.URL;
 
@@ -10,16 +10,41 @@ import be.nikiroo.utils.serial.server.ConnectActionServerString;
 import be.nikiroo.utils.serial.server.ServerBridge;
 import be.nikiroo.utils.serial.server.ServerObject;
 import be.nikiroo.utils.serial.server.ServerString;
+import be.nikiroo.utils.test.TestCase;
+import be.nikiroo.utils.test.TestLauncher;
 
 class SerialServerTest extends TestLauncher {
-       private TestLauncher createServerStringTestCases(final String[] args,
-                       final String key, final boolean bridge) {
-               final String skey = (key != null ? "(encrypted)" : "(plain text)");
-               final String bridges = (bridge ? " with bridge" : "");
-               TestLauncher series = new TestLauncher(
-                               "ServerString " + skey + bridges, args);
-
-               series.addTest(new TestCase("Simple connection " + skey) {
+       public SerialServerTest(String[] args) {
+               super("SerialServer test", args);
+
+               for (String key : new String[] { null, "",
+                               "some real key with a few bytes in it" }) {
+                       for (boolean bridge : new Boolean[] { false, true }) {
+                               final String skey = (key != null ? "(encrypted)"
+                                               : "(plain text)");
+                               final String sbridge = (bridge ? " with bridge" : "");
+
+                               addSeries(new SerialServerTest(args, key, skey, bridge,
+                                               sbridge, "ServerString"));
+
+                               addSeries(new SerialServerTest(args, key, skey, bridge,
+                                               sbridge, new Object() {
+                                                       @Override
+                                                       public String toString() {
+                                                               return "ServerObject";
+                                                       }
+                                               }));
+                       }
+               }
+       }
+
+       private SerialServerTest(final String[] args, final String key,
+                       final String skey, final boolean bridge, final String sbridge,
+                       final String title) {
+
+               super(title + " " + skey + sbridge, args);
+
+               addTest(new TestCase("Simple connection " + skey) {
                        @Override
                        public void test() throws Exception {
                                final String[] rec = new String[1];
@@ -79,7 +104,7 @@ class SerialServerTest extends TestLauncher {
                        }
                });
 
-               series.addTest(new TestCase("Simple exchange " + skey) {
+               addTest(new TestCase("Simple exchange " + skey) {
                        final String[] sent = new String[1];
                        final String[] recd = new String[1];
                        final Exception[] err = new Exception[1];
@@ -141,7 +166,7 @@ class SerialServerTest extends TestLauncher {
                        }
                });
 
-               series.addTest(new TestCase("Multiple exchanges " + skey) {
+               addTest(new TestCase("Multiple exchanges " + skey) {
                        final String[] sent = new String[3];
                        final String[] recd = new String[3];
                        final Exception[] err = new Exception[1];
@@ -208,7 +233,7 @@ class SerialServerTest extends TestLauncher {
                        }
                });
 
-               series.addTest(new TestCase("Multiple call from client " + skey) {
+               addTest(new TestCase("Multiple call from client " + skey) {
                        final String[] sent = new String[3];
                        final String[] recd = new String[3];
                        final Exception[] err = new Exception[1];
@@ -275,18 +300,15 @@ class SerialServerTest extends TestLauncher {
                                assertEquals("4", recd[2]);
                        }
                });
-
-               return series;
        }
 
-       private TestLauncher createServerObjectTestCases(final String[] args,
-                       final String key, final boolean bridge) {
-               final String skey = (key != null ? "(encrypted)" : "(plain text)");
-               final String bridges = (bridge ? " with bridge" : "");
-               TestLauncher series = new TestLauncher(
-                               "ServerObject " + skey + bridges, args);
+       private SerialServerTest(final String[] args, final String key,
+                       final String skey, final boolean bridge, final String sbridge,
+                       final Object title) {
+
+               super(title + " " + skey + sbridge, args);
 
-               series.addTest(new TestCase("Simple connection " + skey) {
+               addTest(new TestCase("Simple connection " + skey) {
                        @Override
                        public void test() throws Exception {
                                final Object[] rec = new Object[1];
@@ -345,7 +367,7 @@ class SerialServerTest extends TestLauncher {
                        }
                });
 
-               series.addTest(new TestCase("Simple exchange " + skey) {
+               addTest(new TestCase("Simple exchange " + skey) {
                        final Object[] sent = new Object[1];
                        final Object[] recd = new Object[1];
                        final Exception[] err = new Exception[1];
@@ -407,7 +429,7 @@ class SerialServerTest extends TestLauncher {
                        }
                });
 
-               series.addTest(new TestCase("Multiple exchanges " + skey) {
+               addTest(new TestCase("Multiple exchanges " + skey) {
                        final Object[] sent = new Object[3];
                        final Object[] recd = new Object[3];
                        final Exception[] err = new Exception[1];
@@ -474,7 +496,7 @@ class SerialServerTest extends TestLauncher {
                        }
                });
 
-               series.addTest(new TestCase("Object array of URLs " + skey) {
+               addTest(new TestCase("Object array of URLs " + skey) {
                        final Object[] sent = new Object[1];
                        final Object[] recd = new Object[1];
                        final Exception[] err = new Exception[1];
@@ -546,7 +568,7 @@ class SerialServerTest extends TestLauncher {
                        }
                });
 
-               series.addTest(new TestCase("Multiple call from client " + skey) {
+               addTest(new TestCase("Multiple call from client " + skey) {
                        final Object[] sent = new Object[3];
                        final Object[] recd = new Object[3];
                        final Exception[] err = new Exception[1];
@@ -613,18 +635,5 @@ class SerialServerTest extends TestLauncher {
                                assertEquals(4, recd[2]);
                        }
                });
-
-               return series;
-       }
-
-       public SerialServerTest(String[] args) {
-               super("SerialServer test", args);
-
-               for (String key : new String[] { null, "" }) {
-                       for (boolean bridge : new Boolean[] { false, true }) {
-                               addSeries(createServerObjectTestCases(args, key, bridge));
-                               addSeries(createServerStringTestCases(args, key, bridge));
-                       }
-               }
        }
 }
similarity index 98%
rename from src/be/nikiroo/utils/test/SerialTest.java
rename to src/be/nikiroo/utils/test_code/SerialTest.java
index fdf599216bfb56522aa87f20efe7ef51c3bd951f..f3ed346a5f68fb52cc2b37ee3b3f628029cf1d5d 100644 (file)
@@ -1,9 +1,11 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import java.net.URL;
 
 import be.nikiroo.utils.serial.Exporter;
 import be.nikiroo.utils.serial.Importer;
+import be.nikiroo.utils.test.TestCase;
+import be.nikiroo.utils.test.TestLauncher;
 
 class SerialTest extends TestLauncher {
        /**
similarity index 98%
rename from src/be/nikiroo/utils/test/StringUtilsTest.java
rename to src/be/nikiroo/utils/test_code/StringUtilsTest.java
index e3be298f9b897863da57bd20f94f5884c827317a..f9c52726cf75c7fb5158d369ed2005fec5995816 100644 (file)
@@ -1,4 +1,4 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import java.util.Arrays;
 import java.util.Date;
@@ -9,6 +9,8 @@ import java.util.Map.Entry;
 
 import be.nikiroo.utils.StringUtils;
 import be.nikiroo.utils.StringUtils.Alignment;
+import be.nikiroo.utils.test.TestCase;
+import be.nikiroo.utils.test.TestLauncher;
 
 class StringUtilsTest extends TestLauncher {
        public StringUtilsTest(String[] args) {
similarity index 95%
rename from src/be/nikiroo/utils/test/TempFilesTest.java
rename to src/be/nikiroo/utils/test_code/TempFilesTest.java
index 460d396edfde962f5de5861c6d61bf80ca774c6d..dad4cacb6e51044c131892e441b48ea248871153 100644 (file)
@@ -1,9 +1,11 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import java.io.File;
 import java.io.IOException;
 
 import be.nikiroo.utils.TempFiles;
+import be.nikiroo.utils.test.TestCase;
+import be.nikiroo.utils.test.TestLauncher;
 
 class TempFilesTest extends TestLauncher {
        public TempFilesTest(String[] args) {
similarity index 94%
rename from src/be/nikiroo/utils/test/Test.java
rename to src/be/nikiroo/utils/test_code/Test.java
index 1897196f314a4b4cb44bac7b44045bfce414eb27..d6d4f4d6954d01e2e61982271d750594d5e1a349 100644 (file)
@@ -1,4 +1,4 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import be.nikiroo.utils.Cache;
 import be.nikiroo.utils.CacheMemory;
@@ -6,6 +6,7 @@ import be.nikiroo.utils.Downloader;
 import be.nikiroo.utils.main.bridge;
 import be.nikiroo.utils.main.img2aa;
 import be.nikiroo.utils.main.justify;
+import be.nikiroo.utils.test.TestLauncher;
 
 /**
  * Tests for nikiroo-utils.
similarity index 97%
rename from src/be/nikiroo/utils/test/VersionTest.java
rename to src/be/nikiroo/utils/test_code/VersionTest.java
index 75e1a1cf261b4f7eaebeb931045bdebd447be118..2d8447635fbb13427331ddcd89a8851b6904e074 100644 (file)
@@ -1,6 +1,8 @@
-package be.nikiroo.utils.test;
+package be.nikiroo.utils.test_code;
 
 import be.nikiroo.utils.Version;
+import be.nikiroo.utils.test.TestCase;
+import be.nikiroo.utils.test.TestLauncher;
 
 class VersionTest extends TestLauncher {
        public VersionTest(String[] args) {