From 888156b24158b4750dbbd2e64a6bf4842ab0279c Mon Sep 17 00:00:00 2001
From: ribeaudc <ribeaudc>
Date: Fri, 18 Apr 2008 11:10:21 +0000
Subject: [PATCH] change: - 'fail' did not work as they should.

SVN: 5686
---
 .../java/ch/systemsx/cisd/bds/DataSet.java    |  4 +-
 .../cisd/bds/SampleFileSystemTestCase.java    | 11 ++---
 .../ch/systemsx/cisd/bds/UtilitiesTest.java   | 15 ++++---
 .../bds/handler/MappingFileHandlerTest.java   |  5 ++-
 .../systemsx/cisd/bds/hcs/GeometryTest.java   | 26 +++++++----
 .../bds/hcs/HCSImageFormattedDataTest.java    |  7 +--
 .../systemsx/cisd/bds/hcs/LocationTest.java   | 45 ++++++++++---------
 .../cisd/bds/hcs/PlateGeometryTest.java       |  7 +--
 .../cisd/bds/storage/NodeFiltersTest.java     | 10 +++--
 9 files changed, 75 insertions(+), 55 deletions(-)

diff --git a/bds/source/java/ch/systemsx/cisd/bds/DataSet.java b/bds/source/java/ch/systemsx/cisd/bds/DataSet.java
index c9110ebbcfc..bd2b7710f82 100644
--- a/bds/source/java/ch/systemsx/cisd/bds/DataSet.java
+++ b/bds/source/java/ch/systemsx/cisd/bds/DataSet.java
@@ -117,7 +117,7 @@ public final class DataSet implements IStorable
         this.productionTimestamp = productionTimestampOrNull;
     }
 
-    public final void setCode(String code)
+    public final void setCode(final String code)
     {
         this.code = code;
     }
@@ -152,7 +152,7 @@ public final class DataSet implements IStorable
         return parentCodes;
     }
     
-    public final void setComplete(boolean complete)
+    public final void setComplete(final boolean complete)
     {
         isComplete = BooleanOrUnknown.resolve(complete);
     }
diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/SampleFileSystemTestCase.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/SampleFileSystemTestCase.java
index 9ab28d39467..2293f778501 100644
--- a/bds/sourceTest/java/ch/systemsx/cisd/bds/SampleFileSystemTestCase.java
+++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/SampleFileSystemTestCase.java
@@ -17,7 +17,6 @@
 package ch.systemsx.cisd.bds;
 
 import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.fail;
 
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
@@ -52,22 +51,24 @@ public final class SampleFileSystemTestCase extends AbstractFileSystemTestCase
     @Test
     public final void testConstructor()
     {
+        boolean fail = true;
         try
         {
             new Sample(null, null, null);
-            fail("Null values not allowed.");
         } catch (final AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
+        fail = true;
         try
         {
             new Sample("", "", "");
-            fail("Empty values not allowed.");
         } catch (final AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         new Sample(" ", " ", " ");
     }
 
diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/UtilitiesTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/UtilitiesTest.java
index e49e4d3a84a..b38d9ea97f3 100644
--- a/bds/sourceTest/java/ch/systemsx/cisd/bds/UtilitiesTest.java
+++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/UtilitiesTest.java
@@ -61,14 +61,15 @@ public class UtilitiesTest extends AbstractFileSystemTestCase
         assertEquals(1, listFiles.length);
         assertEquals(key, listFiles[0].getName());
         assertEquals(value, file.getStringContent().trim());
+        boolean fail = true;
         try
         {
             Utilities.getNumber(null, null);
-            fail("Directory and name can not be null.");
         } catch (AssertionError ex)
         {
-            // Nothing to do here
+            fail = false;
         }
+        assertEquals(false, fail);
         try
         {
             Utilities.getNumber(directory, "doesNotExist");
@@ -83,14 +84,15 @@ public class UtilitiesTest extends AbstractFileSystemTestCase
     @Test
     public final void testListNodes() throws IOException
     {
+        boolean fail = true;
         try
         {
             Utilities.listNodes(null, null);
-            fail("Given directory can not be null.");
         } catch (AssertionError e)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         createFile(workingDirectory, "file1");
         final File dir1 = new File(workingDirectory, "dir1");
         dir1.mkdir();
@@ -110,14 +112,15 @@ public class UtilitiesTest extends AbstractFileSystemTestCase
     @Test
     public final void testGetBoolean()
     {
+        boolean fail = true;
         try
         {
             Utilities.getBoolean(null, null);
-            fail("Directory and name can not be null.");
         } catch (final AssertionError e)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         final IDirectory directory = (IDirectory) NodeFactory.createNode(workingDirectory);
         try
         {
diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/handler/MappingFileHandlerTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/handler/MappingFileHandlerTest.java
index d43a3bf36e6..e687ed89a2e 100644
--- a/bds/sourceTest/java/ch/systemsx/cisd/bds/handler/MappingFileHandlerTest.java
+++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/handler/MappingFileHandlerTest.java
@@ -95,14 +95,15 @@ public final class MappingFileHandlerTest extends AbstractFileSystemTestCase
     @Test
     public final void testAddReference()
     {
+        boolean fail = true;
         try
         {
             handler.addReference(null);
-            fail("Null value not allowed.");
         } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         handler.addReference(new Reference("1", "2", ReferenceType.IDENTICAL));
         try
         {
diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/GeometryTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/GeometryTest.java
index 18f4c6e70fd..570d644826a 100644
--- a/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/GeometryTest.java
+++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/GeometryTest.java
@@ -16,8 +16,13 @@
 
 package ch.systemsx.cisd.bds.hcs;
 
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertTrue;
+
 import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.*;
 
 /**
  * Test cases for corresponding {@link Geometry} class.
@@ -31,14 +36,15 @@ public final class GeometryTest
     public final void testContainsLocation()
     {
         final Geometry geometry = new Geometry(2, 3);
+        boolean fail = true;
         try
         {
             geometry.contains(null);
-            fail("Location can not be null.");
-        } catch (AssertionError e)
+        } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         assertTrue(geometry.contains(new Location(1, 2)));
         assertFalse(geometry.contains(new Location(1, 3)));
         assertTrue(geometry.contains(new Location(3, 1)));
@@ -48,27 +54,29 @@ public final class GeometryTest
     @Test
     public final void testCreateFromString()
     {
+        boolean fail = true;
         try
         {
             Geometry.createFromString(null);
-            fail("Null value not allowed here.");
-        } catch (AssertionError e)
+        } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         assertNull(Geometry.createFromString("a"));
         assertNull(Geometry.createFromString("x4"));
         final Geometry geometry = Geometry.createFromString("1x4");
         assertNotNull(geometry);
         assertEquals(1, geometry.getRows());
         assertEquals(4, geometry.getColumns());
+        fail = true;
         try
         {
             Geometry.createFromString("0x4");
-            fail("0 row not possible.");
         } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
     }
 }
\ No newline at end of file
diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/HCSImageFormattedDataTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/HCSImageFormattedDataTest.java
index 9f65885fb73..2ad1ff093cf 100644
--- a/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/HCSImageFormattedDataTest.java
+++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/HCSImageFormattedDataTest.java
@@ -158,14 +158,15 @@ public class HCSImageFormattedDataTest extends AbstractFileSystemTestCase
     @Test
     public final void testCreateWellFileName()
     {
+        boolean fail = true;
         try
         {
             HCSImageFormattedData.createWellFileName(null);
-            fail("Location can not be null.");
-        } catch (final AssertionError ex)
+        } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         final Location location = WELL_LOCATION;
         final String expected = "row2_column1.tiff";
         assertEquals(expected, HCSImageFormattedData.createWellFileName(location));
diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/LocationTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/LocationTest.java
index 7854fb14ce0..a95002aad9c 100644
--- a/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/LocationTest.java
+++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/LocationTest.java
@@ -16,8 +16,11 @@
 
 package ch.systemsx.cisd.bds.hcs;
 
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+
 import org.testng.annotations.Test;
-import static org.testng.AssertJUnit.*;
 
 /**
  * Test cases for corresponding {@link Location} class.
@@ -30,30 +33,33 @@ public final class LocationTest
     @Test
     public final void testConstructor()
     {
+        boolean fail = true;
         try
         {
             new Location(-1, 0);
-            fail("Wrong parameters.");
-        } catch (AssertionError e)
+        } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
+        fail = true;
         try
         {
             new Location(1, 0);
-            fail("Wrong parameters.");
-        } catch (AssertionError e)
+        } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
+        fail = true;
         try
         {
             new Location(0, 1);
-            fail("Wrong parameters.");
-        } catch (AssertionError e)
+        } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
     }
 
     @Test
@@ -69,39 +75,34 @@ public final class LocationTest
     public final void testCreateLocationFromPosition()
     {
         final Geometry geometry = new Geometry(4, 5);
+        boolean fail = true;
         try
         {
             Location.tryCreateLocationFromPosition(1, null);
-            fail("Null geometry not allowed.");
         } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         assertEquals(new Location(2, 3), Location.tryCreateLocationFromPosition(12, geometry));
         assertEquals(new Location(5, 3), Location.tryCreateLocationFromPosition(15, geometry));
         assertEquals(new Location(2, 1), Location.tryCreateLocationFromPosition(2, geometry));
         assertEquals(new Location(1, 2), Location.tryCreateLocationFromPosition(6, geometry));
-        try
-        {
-            Location.tryCreateLocationFromPosition(100, geometry);
-            fail("Position is out of range.");
-        } catch (AssertionError ex)
-        {
-            // Nothing to do here.
-        }
+        assertNull(Location.tryCreateLocationFromPosition(100, geometry));
     }
 
     @Test
     public final void testCreateLocationFromMatrixCoordinate()
     {
+        boolean fail = true;
         try
         {
             Location.tryCreateLocationFromMatrixCoordinate(null);
-            fail("Coordinate can not be null.");
         } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
         assertNull(Location.tryCreateLocationFromMatrixCoordinate(""));
         assertNull(Location.tryCreateLocationFromMatrixCoordinate("8"));
         assertNull(Location.tryCreateLocationFromMatrixCoordinate("M"));
diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/PlateGeometryTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/PlateGeometryTest.java
index 4bd1ee2702e..7bddddf15cd 100644
--- a/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/PlateGeometryTest.java
+++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/hcs/PlateGeometryTest.java
@@ -18,8 +18,8 @@ package ch.systemsx.cisd.bds.hcs;
 
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNotNull;
 import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.*;
 
 import java.io.File;
 
@@ -43,14 +43,15 @@ public final class PlateGeometryTest extends AbstractFileSystemTestCase
     @Test
     public final void testConstructor()
     {
+        boolean fail = true;
         try
         {
             new PlateGeometry(-1, 0);
-            fail("Rows and columns must be > 0.");
         } catch (AssertionError ex)
         {
-            // Nothing to do here.
+            fail = false;
         }
+        assertEquals(false, fail);
     }
 
     @Test
diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/NodeFiltersTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/NodeFiltersTest.java
index 5fd57433060..032e5a865f3 100644
--- a/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/NodeFiltersTest.java
+++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/NodeFiltersTest.java
@@ -16,7 +16,9 @@
 
 package ch.systemsx.cisd.bds.storage;
 
-import static org.testng.AssertJUnit.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
@@ -45,13 +47,15 @@ public class NodeFiltersTest extends AbstractFileSystemTestCase
     @Test
     public final void testExtensionNodeFilterWithNull()
     {
+        boolean fail = true;
         try
         {
-            NodeFilters.createExtensionNodeFilter(true, (String) null);
-            fail("Null extension not accepted.");
+            NodeFilters.createExtensionNodeFilter(true, (String[]) null);
         } catch (AssertionError ex)
         {
+            fail = false;
         }
+        assertEquals(false, fail);
     }
 
     @Test
-- 
GitLab