Index: trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java
===================================================================
--- trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java	(revision 7101)
+++ trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java	(revision 7109)
@@ -4,19 +4,18 @@
 import java.awt.Graphics2D;
 import java.awt.image.BufferedImage;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
-import java.io.File;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.JOSMFixture;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.osm.DataSet;
-import org.openstreetmap.josm.data.projection.Projections;
 import org.openstreetmap.josm.gui.NavigatableComponent;
 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
+import org.openstreetmap.josm.io.Compression;
 import org.openstreetmap.josm.io.OsmReader;
-import org.openstreetmap.josm.io.Compression;
 
 public class StyledMapRendererPerformanceTest {
@@ -34,6 +33,5 @@
     @BeforeClass
     public static void load() throws Exception {
-        Main.initApplicationPreferences();
-        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
+        JOSMFixture.createPerformanceTestFixture().init();
         img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_3BYTE_BGR);
         g = (Graphics2D)img.getGraphics();
@@ -53,8 +51,4 @@
             dsCity = OsmReader.parseDataSet(fisC, NullProgressMonitor.INSTANCE);
         }
-
-        // Warm up
-        new StyledMapRendererPerformanceTest().testRestrictionSmall();
-        new StyledMapRendererPerformanceTest().testCity();
     }
 
Index: trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy
===================================================================
--- trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy	(revision 7101)
+++ trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy	(revision 7109)
@@ -111,5 +111,5 @@
         def mv = Main.map.mapView
 
-        BufferedImage img = mv.createImage(mv.getWidth(), mv.getHeight())
+        BufferedImage img = new BufferedImage(mv.getWidth(), mv.getHeight(), BufferedImage.TYPE_3BYTE_BGR)
         Graphics2D g = img.createGraphics()
         g.setClip(0,0, mv.getWidth(), mv.getHeight())
Index: trunk/test/unit/org/openstreetmap/josm/TestUtils.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 7101)
+++ trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 7109)
@@ -5,9 +5,11 @@
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
+import java.util.Arrays;
+import java.util.Comparator;
 import java.util.Map;
 
 import org.junit.Test;
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -65,3 +67,62 @@
     }
 
+    /**
+     * Checks that the given Comparator respects its contract on the given table.
+     * @param comparator The comparator to test
+     * @param array The array sorted for test purpose
+     */
+    public static <T> void checkComparableContract(Comparator<T> comparator, T[] array) {
+        System.out.println("Validating Comparable contract on array of "+array.length+" elements");
+        // Check each compare possibility
+        for (int i=0; i<array.length; i++) {
+            T r1 = array[i];
+            for (int j=i; j<array.length; j++) {
+                T r2 = array[j];
+                int a = comparator.compare(r1, r2);
+                int b = comparator.compare(r2, r1);
+                if (i==j || a==b) {
+                    if (a != 0 || b != 0) {
+                        fail(getFailMessage(r1, r2, a, b));
+                    }
+                } else {
+                    if (a != -b) {
+                        fail(getFailMessage(r1, r2, a, b));
+                    }
+                }
+                for (int k=j; k<array.length; k++) {
+                    T r3 = array[k];
+                    int c = comparator.compare(r1, r3);
+                    int d = comparator.compare(r2, r3);
+                    if (a > 0 && d > 0) {
+                        if (c <= 0) {
+                           fail(getFailMessage(r1, r2, r3, a, b, c, d));
+                        }
+                    } else if (a == 0 && d == 0) {
+                        if (c != 0) {
+                            fail(getFailMessage(r1, r2, r3, a, b, c, d));
+                        }
+                    } else if (a < 0 && d < 0) {
+                        if (c >= 0) {
+                            fail(getFailMessage(r1, r2, r3, a, b, c, d));
+                        }
+                    }
+                }
+            }
+        }
+        // Sort relation array
+        Arrays.sort(array, comparator);
+    }
+
+    private static <T> String getFailMessage(T o1, T o2, int a, int b) {
+        return new StringBuilder("Compared\no1: ").append(o1).append("\no2: ")
+        .append(o2).append("\ngave: ").append(a).append("/").append(b)
+        .toString();
+    }
+
+    private static <T> String getFailMessage(T o1, T o2, T o3, int a, int b, int c, int d) {
+        return new StringBuilder(getFailMessage(o1, o2, a, b))
+        .append("\nCompared\no1: ").append(o1).append("\no3: ").append(o3).append("\ngave: ").append(c)
+        .append("\nCompared\no2: ").append(o2).append("\no3: ").append(o3).append("\ngave: ").append(d)
+        .toString();
+    }
 }
Index: trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java	(revision 7101)
+++ trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java	(revision 7109)
@@ -3,5 +3,4 @@
 
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.io.FileInputStream;
@@ -9,5 +8,4 @@
 import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Comparator;
 
@@ -75,56 +73,6 @@
             Relation[] relations = new ArrayList<>(ds.getRelations()).toArray(new Relation[0]);
 
-            // Check each compare possibility
-            for (int i=0; i<relations.length; i++) {
-                Relation r1 = relations[i];
-                for (int j=i; j<relations.length; j++) {
-                    Relation r2 = relations[j];
-                    int a = comparator.compare(r1, r2);
-                    int b = comparator.compare(r2, r1);
-                    if (i==j || a==b) {
-                        if (a != 0 || b != 0) {
-                            fail(getFailMessage(r1, r2, a, b));
-                        }
-                    } else {
-                        if (a != -b) {
-                            fail(getFailMessage(r1, r2, a, b));
-                        }
-                    }
-                    for (int k=j; k<relations.length; k++) {
-                        Relation r3 = relations[k];
-                        int c = comparator.compare(r1, r3);
-                        int d = comparator.compare(r2, r3);
-                        if (a > 0 && d > 0) {
-                            if (c <= 0) {
-                               fail(getFailMessage(r1, r2, r3, a, b, c, d));
-                            }
-                        } else if (a == 0 && d == 0) {
-                            if (c != 0) {
-                                fail(getFailMessage(r1, r2, r3, a, b, c, d));
-                            }
-                        } else if (a < 0 && d < 0) {
-                            if (c >= 0) {
-                                fail(getFailMessage(r1, r2, r3, a, b, c, d));
-                            }
-                        }
-                    }
-                }
-            }
-            // Sort relation array
-            Arrays.sort(relations, comparator);
+            TestUtils.checkComparableContract(comparator, relations);
         }
     }
-
-    private static String getFailMessage(Relation r1, Relation r2, int a, int b) {
-        return new StringBuilder("Compared\nr1: ").append(r1).append("\nr2: ")
-        .append(r2).append("\ngave: ").append(a).append("/").append(b)
-        .toString();
-    }
-
-    private static String getFailMessage(Relation r1, Relation r2, Relation r3, int a, int b, int c, int d) {
-        return new StringBuilder(getFailMessage(r1, r2, a, b))
-        .append("\nCompared\nr1: ").append(r1).append("\nr3: ").append(r3).append("\ngave: ").append(c)
-        .append("\nCompared\nr2: ").append(r2).append("\nr3: ").append(r3).append("\ngave: ").append(d)
-        .toString();
-    }
 }
