From 97e180b35a9802f31014bde613b7a3c3b3eed31f Mon Sep 17 00:00:00 2001 From: brinn <brinn> Date: Sat, 6 Aug 2011 09:51:10 +0000 Subject: [PATCH] change: make AllTests really run all unit test classes change: move test package exceptions to ch.systemsx.cisd.exceptions SVN: 22382 --- .../java/ch/systemsx/cisd/base/AllTests.java | 20 +++++-- .../cisd/base/convert/NativeDataTests.java | 2 + .../base/convert/NativeTaggedArrayTests.java | 1 + .../exceptions/IOExceptionUncheckedTests.java | 52 +++++++++++++++++- .../io/ByteBufferRandomAccessFileTests.java | 55 +++++++++++++++++++ .../base/io/RandomAccessFileImplTests.java | 55 +++++++++++++++++++ .../cisd/base/mdarray/MDArraytest.java | 52 ++++++++++++++++-- .../ch/systemsx/cisd/base/unix/UnixTests.java | 1 + 8 files changed, 228 insertions(+), 10 deletions(-) rename base/sourceTest/java/{ => ch/systemsx/cisd/base}/exceptions/IOExceptionUncheckedTests.java (59%) diff --git a/base/sourceTest/java/ch/systemsx/cisd/base/AllTests.java b/base/sourceTest/java/ch/systemsx/cisd/base/AllTests.java index f486b95131e..1e3fa2600fb 100644 --- a/base/sourceTest/java/ch/systemsx/cisd/base/AllTests.java +++ b/base/sourceTest/java/ch/systemsx/cisd/base/AllTests.java @@ -18,6 +18,10 @@ package ch.systemsx.cisd.base; import ch.systemsx.cisd.base.convert.NativeDataTests; import ch.systemsx.cisd.base.convert.NativeTaggedArrayTests; +import ch.systemsx.cisd.base.exceptions.IOExceptionUncheckedTests; +import ch.systemsx.cisd.base.io.ByteBufferRandomAccessFileTests; +import ch.systemsx.cisd.base.io.RandomAccessFileImplTests; +import ch.systemsx.cisd.base.mdarray.MDArraytest; import ch.systemsx.cisd.base.unix.Unix; import ch.systemsx.cisd.base.unix.UnixTests; @@ -31,14 +35,22 @@ public class AllTests public static void main(String[] args) throws Throwable { + NativeDataTests.main(args); + System.out.println(); + NativeTaggedArrayTests.main(args); + System.out.println(); + IOExceptionUncheckedTests.main(args); + System.out.println(); + ByteBufferRandomAccessFileTests.main(args); + System.out.println(); + RandomAccessFileImplTests.main(args); + System.out.println(); + MDArraytest.main(args); + System.out.println(); if (Unix.isOperational()) { UnixTests.main(args); } - System.out.println(); - NativeDataTests.main(args); - System.out.println(); - NativeTaggedArrayTests.main(args); } } diff --git a/base/sourceTest/java/ch/systemsx/cisd/base/convert/NativeDataTests.java b/base/sourceTest/java/ch/systemsx/cisd/base/convert/NativeDataTests.java index 18a88a2f4c0..7307dd53070 100644 --- a/base/sourceTest/java/ch/systemsx/cisd/base/convert/NativeDataTests.java +++ b/base/sourceTest/java/ch/systemsx/cisd/base/convert/NativeDataTests.java @@ -421,9 +421,11 @@ public class NativeDataTests { } + @SuppressWarnings("null") public static void main(String[] args) throws Throwable { System.out.println(BuildAndEnvironmentInfo.INSTANCE); + System.out.println("Test class: " + NativeDataTests.class.getSimpleName()); System.out.println(); NativeData.ensureNativeLibIsLoaded(); final NativeDataTests test = new NativeDataTests(); diff --git a/base/sourceTest/java/ch/systemsx/cisd/base/convert/NativeTaggedArrayTests.java b/base/sourceTest/java/ch/systemsx/cisd/base/convert/NativeTaggedArrayTests.java index 36edde52eeb..13b0115b979 100644 --- a/base/sourceTest/java/ch/systemsx/cisd/base/convert/NativeTaggedArrayTests.java +++ b/base/sourceTest/java/ch/systemsx/cisd/base/convert/NativeTaggedArrayTests.java @@ -424,6 +424,7 @@ public class NativeTaggedArrayTests public static void main(String[] args) throws Throwable { System.out.println(BuildAndEnvironmentInfo.INSTANCE); + System.out.println("Test class: " + NativeTaggedArrayTests.class.getSimpleName()); System.out.println(); NativeData.ensureNativeLibIsLoaded(); final NativeTaggedArrayTests test = new NativeTaggedArrayTests(); diff --git a/base/sourceTest/java/exceptions/IOExceptionUncheckedTests.java b/base/sourceTest/java/ch/systemsx/cisd/base/exceptions/IOExceptionUncheckedTests.java similarity index 59% rename from base/sourceTest/java/exceptions/IOExceptionUncheckedTests.java rename to base/sourceTest/java/ch/systemsx/cisd/base/exceptions/IOExceptionUncheckedTests.java index f4b234b4286..468eb5da1e1 100644 --- a/base/sourceTest/java/exceptions/IOExceptionUncheckedTests.java +++ b/base/sourceTest/java/ch/systemsx/cisd/base/exceptions/IOExceptionUncheckedTests.java @@ -14,17 +14,24 @@ * limitations under the License. */ -package exceptions; +package ch.systemsx.cisd.base.exceptions; -import static org.testng.AssertJUnit.*; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.fail; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import org.testng.annotations.Test; +import ch.systemsx.cisd.base.BuildAndEnvironmentInfo; import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked; @@ -93,4 +100,45 @@ public class IOExceptionUncheckedTests } } + public static void main(String[] args) throws Throwable + { + System.out.println(BuildAndEnvironmentInfo.INSTANCE); + System.out.println("Test class: " + IOExceptionUncheckedTests.class.getSimpleName()); + System.out.println(); + final IOExceptionUncheckedTests test = new IOExceptionUncheckedTests(); + for (Method m : IOExceptionUncheckedTests.class.getMethods()) + { + final Test testAnnotation = m.getAnnotation(Test.class); + if (testAnnotation == null) + { + continue; + } + if (m.getParameterTypes().length == 0) + { + System.out.println("Running " + m.getName()); + try + { + m.invoke(test); + } catch (InvocationTargetException wrapperThrowable) + { + final Throwable th = wrapperThrowable.getCause(); + boolean exceptionFound = false; + for (Class<?> expectedExClazz : testAnnotation.expectedExceptions()) + { + if (expectedExClazz == th.getClass()) + { + exceptionFound = true; + break; + } + } + if (exceptionFound == false) + { + throw th; + } + } + } + } + System.out.println("Tests OK!"); + } + } diff --git a/base/sourceTest/java/ch/systemsx/cisd/base/io/ByteBufferRandomAccessFileTests.java b/base/sourceTest/java/ch/systemsx/cisd/base/io/ByteBufferRandomAccessFileTests.java index cd8f0f16aa8..0987c3474fa 100644 --- a/base/sourceTest/java/ch/systemsx/cisd/base/io/ByteBufferRandomAccessFileTests.java +++ b/base/sourceTest/java/ch/systemsx/cisd/base/io/ByteBufferRandomAccessFileTests.java @@ -16,6 +16,13 @@ package ch.systemsx.cisd.base.io; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.testng.annotations.Test; + +import ch.systemsx.cisd.base.BuildAndEnvironmentInfo; + /** * Test cases for {@link RandomAccessFileImpl}. * @@ -36,4 +43,52 @@ public class ByteBufferRandomAccessFileTests extends IRandomAccessFileTests return new ByteBufferRandomAccessFile(content); } + public static void main(String[] args) throws Throwable + { + System.out.println(BuildAndEnvironmentInfo.INSTANCE); + System.out.println("Test class: " + ByteBufferRandomAccessFileTests.class.getSimpleName()); + System.out.println(); + final ByteBufferRandomAccessFileTests test = new ByteBufferRandomAccessFileTests(); + try + { + for (Method m : ByteBufferRandomAccessFileTests.class.getMethods()) + { + final Test testAnnotation = m.getAnnotation(Test.class); + if (testAnnotation == null) + { + continue; + } + if (m.getParameterTypes().length == 0) + { + System.out.println("Running " + m.getName()); + test.setUp(); + try + { + m.invoke(test); + } catch (InvocationTargetException wrapperThrowable) + { + final Throwable th = wrapperThrowable.getCause(); + boolean exceptionFound = false; + for (Class<?> expectedExClazz : testAnnotation.expectedExceptions()) + { + if (expectedExClazz == th.getClass()) + { + exceptionFound = true; + break; + } + } + if (exceptionFound == false) + { + throw th; + } + } + } + } + System.out.println("Tests OK!"); + } finally + { + test.afterClass(); + } + } + } diff --git a/base/sourceTest/java/ch/systemsx/cisd/base/io/RandomAccessFileImplTests.java b/base/sourceTest/java/ch/systemsx/cisd/base/io/RandomAccessFileImplTests.java index e725bad6b7d..2bc200b3d2c 100644 --- a/base/sourceTest/java/ch/systemsx/cisd/base/io/RandomAccessFileImplTests.java +++ b/base/sourceTest/java/ch/systemsx/cisd/base/io/RandomAccessFileImplTests.java @@ -16,6 +16,13 @@ package ch.systemsx.cisd.base.io; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.testng.annotations.Test; + +import ch.systemsx.cisd.base.BuildAndEnvironmentInfo; + /** * Test cases for {@link RandomAccessFileImpl}. * @@ -39,4 +46,52 @@ public class RandomAccessFileImplTests extends IRandomAccessFileTests return f; } + public static void main(String[] args) throws Throwable + { + System.out.println(BuildAndEnvironmentInfo.INSTANCE); + System.out.println("Test class: " + RandomAccessFileImplTests.class.getSimpleName()); + System.out.println(); + final RandomAccessFileImplTests test = new RandomAccessFileImplTests(); + try + { + for (Method m : RandomAccessFileImplTests.class.getMethods()) + { + final Test testAnnotation = m.getAnnotation(Test.class); + if (testAnnotation == null) + { + continue; + } + if (m.getParameterTypes().length == 0) + { + System.out.println("Running " + m.getName()); + test.setUp(); + try + { + m.invoke(test); + } catch (InvocationTargetException wrapperThrowable) + { + final Throwable th = wrapperThrowable.getCause(); + boolean exceptionFound = false; + for (Class<?> expectedExClazz : testAnnotation.expectedExceptions()) + { + if (expectedExClazz == th.getClass()) + { + exceptionFound = true; + break; + } + } + if (exceptionFound == false) + { + throw th; + } + } + } + } + System.out.println("Tests OK!"); + } finally + { + test.afterClass(); + } + } + } diff --git a/base/sourceTest/java/ch/systemsx/cisd/base/mdarray/MDArraytest.java b/base/sourceTest/java/ch/systemsx/cisd/base/mdarray/MDArraytest.java index af780c26d77..82325310990 100644 --- a/base/sourceTest/java/ch/systemsx/cisd/base/mdarray/MDArraytest.java +++ b/base/sourceTest/java/ch/systemsx/cisd/base/mdarray/MDArraytest.java @@ -16,14 +16,16 @@ package ch.systemsx.cisd.base.mdarray; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Arrays; import org.testng.annotations.Test; -import ch.systemsx.cisd.base.mdarray.MDAbstractArray; -import ch.systemsx.cisd.base.mdarray.MDFloatArray; - -import static org.testng.AssertJUnit.*; +import ch.systemsx.cisd.base.BuildAndEnvironmentInfo; /** * Test cases for {@link MDAbstractArray}. @@ -175,4 +177,46 @@ public class MDArraytest assertTrue(Arrays.equals(matrix1[i], matrix2[i])); } } + + public static void main(String[] args) throws Throwable + { + System.out.println(BuildAndEnvironmentInfo.INSTANCE); + System.out.println("Test class: " + MDArraytest.class.getSimpleName()); + System.out.println(); + final MDArraytest test = new MDArraytest(); + for (Method m : MDArraytest.class.getMethods()) + { + final Test testAnnotation = m.getAnnotation(Test.class); + if (testAnnotation == null) + { + continue; + } + if (m.getParameterTypes().length == 0) + { + System.out.println("Running " + m.getName()); + try + { + m.invoke(test); + } catch (InvocationTargetException wrapperThrowable) + { + final Throwable th = wrapperThrowable.getCause(); + boolean exceptionFound = false; + for (Class<?> expectedExClazz : testAnnotation.expectedExceptions()) + { + if (expectedExClazz == th.getClass()) + { + exceptionFound = true; + break; + } + } + if (exceptionFound == false) + { + throw th; + } + } + } + } + System.out.println("Tests OK!"); + } + } diff --git a/base/sourceTest/java/ch/systemsx/cisd/base/unix/UnixTests.java b/base/sourceTest/java/ch/systemsx/cisd/base/unix/UnixTests.java index 8dc10b86263..d1a20c5634e 100644 --- a/base/sourceTest/java/ch/systemsx/cisd/base/unix/UnixTests.java +++ b/base/sourceTest/java/ch/systemsx/cisd/base/unix/UnixTests.java @@ -272,6 +272,7 @@ public class UnixTests extends AbstractFileSystemTestCase public static void main(String[] args) throws Throwable { System.out.println(BuildAndEnvironmentInfo.INSTANCE); + System.out.println("Test class: " + UnixTests.class.getSimpleName()); System.out.println(); if (Unix.isOperational() == false) { -- GitLab