From: Niki Roo Date: Tue, 23 Apr 2019 05:44:22 +0000 (+0200) Subject: Move test code out of "test" package X-Git-Tag: nikiroo-utils-4.7.3~95 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=fbcc2a2acb39e4c0bbbc805ece1f8ecf2206f951;p=nikiroo-utils.git Move test code out of "test" package --- diff --git a/configure.sh b/configure.sh index 4105d93..6179aae 100755 --- a/configure.sh +++ b/configure.sh @@ -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 diff --git a/src/be/nikiroo/utils/test/TestLauncher.java b/src/be/nikiroo/utils/test/TestLauncher.java index 3741e97..9b841a4 100644 --- a/src/be/nikiroo/utils/test/TestLauncher.java +++ b/src/be/nikiroo/utils/test/TestLauncher.java @@ -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 { } diff --git a/src/be/nikiroo/utils/test/BundleTest.java b/src/be/nikiroo/utils/test_code/BundleTest.java similarity index 97% rename from src/be/nikiroo/utils/test/BundleTest.java rename to src/be/nikiroo/utils/test_code/BundleTest.java index c1c379f..2e25eb0 100644 --- a/src/be/nikiroo/utils/test/BundleTest.java +++ b/src/be/nikiroo/utils/test_code/BundleTest.java @@ -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; diff --git a/src/be/nikiroo/utils/test/IOUtilsTest.java b/src/be/nikiroo/utils/test_code/IOUtilsTest.java similarity index 79% rename from src/be/nikiroo/utils/test/IOUtilsTest.java rename to src/be/nikiroo/utils/test_code/IOUtilsTest.java index c62d44d..9f22896 100644 --- a/src/be/nikiroo/utils/test/IOUtilsTest.java +++ b/src/be/nikiroo/utils/test_code/IOUtilsTest.java @@ -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) { diff --git a/src/be/nikiroo/utils/test/ProgressTest.java b/src/be/nikiroo/utils/test_code/ProgressTest.java similarity index 98% rename from src/be/nikiroo/utils/test/ProgressTest.java rename to src/be/nikiroo/utils/test_code/ProgressTest.java index bd05bc5..22e36cb 100644 --- a/src/be/nikiroo/utils/test/ProgressTest.java +++ b/src/be/nikiroo/utils/test_code/ProgressTest.java @@ -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) { diff --git a/src/be/nikiroo/utils/test/SerialServerTest.java b/src/be/nikiroo/utils/test_code/SerialServerTest.java similarity index 89% rename from src/be/nikiroo/utils/test/SerialServerTest.java rename to src/be/nikiroo/utils/test_code/SerialServerTest.java index a3f4f9e..5f62221 100644 --- a/src/be/nikiroo/utils/test/SerialServerTest.java +++ b/src/be/nikiroo/utils/test_code/SerialServerTest.java @@ -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)); - } - } } } diff --git a/src/be/nikiroo/utils/test/SerialTest.java b/src/be/nikiroo/utils/test_code/SerialTest.java similarity index 98% rename from src/be/nikiroo/utils/test/SerialTest.java rename to src/be/nikiroo/utils/test_code/SerialTest.java index fdf5992..f3ed346 100644 --- a/src/be/nikiroo/utils/test/SerialTest.java +++ b/src/be/nikiroo/utils/test_code/SerialTest.java @@ -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 { /** diff --git a/src/be/nikiroo/utils/test/StringUtilsTest.java b/src/be/nikiroo/utils/test_code/StringUtilsTest.java similarity index 98% rename from src/be/nikiroo/utils/test/StringUtilsTest.java rename to src/be/nikiroo/utils/test_code/StringUtilsTest.java index e3be298..f9c5272 100644 --- a/src/be/nikiroo/utils/test/StringUtilsTest.java +++ b/src/be/nikiroo/utils/test_code/StringUtilsTest.java @@ -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) { diff --git a/src/be/nikiroo/utils/test/TempFilesTest.java b/src/be/nikiroo/utils/test_code/TempFilesTest.java similarity index 95% rename from src/be/nikiroo/utils/test/TempFilesTest.java rename to src/be/nikiroo/utils/test_code/TempFilesTest.java index 460d396..dad4cac 100644 --- a/src/be/nikiroo/utils/test/TempFilesTest.java +++ b/src/be/nikiroo/utils/test_code/TempFilesTest.java @@ -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) { diff --git a/src/be/nikiroo/utils/test/Test.java b/src/be/nikiroo/utils/test_code/Test.java similarity index 94% rename from src/be/nikiroo/utils/test/Test.java rename to src/be/nikiroo/utils/test_code/Test.java index 1897196..d6d4f4d 100644 --- a/src/be/nikiroo/utils/test/Test.java +++ b/src/be/nikiroo/utils/test_code/Test.java @@ -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. diff --git a/src/be/nikiroo/utils/test/VersionTest.java b/src/be/nikiroo/utils/test_code/VersionTest.java similarity index 97% rename from src/be/nikiroo/utils/test/VersionTest.java rename to src/be/nikiroo/utils/test_code/VersionTest.java index 75e1a1c..2d84476 100644 --- a/src/be/nikiroo/utils/test/VersionTest.java +++ b/src/be/nikiroo/utils/test_code/VersionTest.java @@ -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) { diff --git a/src/be/nikiroo/utils/test/bundle_test.properties b/src/be/nikiroo/utils/test_code/bundle_test.properties similarity index 100% rename from src/be/nikiroo/utils/test/bundle_test.properties rename to src/be/nikiroo/utils/test_code/bundle_test.properties