Index: /trunk/test/functional/org/openstreetmap/josm/fixtures/JOSMFixture.java
===================================================================
--- /trunk/test/functional/org/openstreetmap/josm/fixtures/JOSMFixture.java	(revision 3987)
+++ /trunk/test/functional/org/openstreetmap/josm/fixtures/JOSMFixture.java	(revision 3988)
@@ -11,5 +11,5 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.DataSetMergerTest;
+import org.openstreetmap.josm.data.Preferences;
 import org.openstreetmap.josm.data.projection.Mercator;
 import org.openstreetmap.josm.io.OsmApi;
@@ -40,5 +40,5 @@
         //
         try {
-            testProperties.load(DataSetMergerTest.class.getResourceAsStream(testPropertiesResourceName));
+            testProperties.load(JOSMFixture.class.getResourceAsStream(testPropertiesResourceName));
         } catch(Exception e){
             logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", testPropertiesResourceName));
@@ -58,4 +58,5 @@
         }
         System.setProperty("josm.home", josmHome);
+        Main.pref = new Preferences();
         I18n.init();
         // initialize the plaform hook, and
Index: /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/AllMappaintTests.groovy
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/AllMappaintTests.groovy	(revision 3988)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/AllMappaintTests.groovy	(revision 3988)
@@ -0,0 +1,30 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.mappaint
+
+import junit.framework.TestCase;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses([
+    LabelCompositionStrategyTest.class,
+    MapCSSWithExtendedTextDirectivesTest.class
+])
+public class AllMappaintTests extends TestCase{}
+
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.mappaint
+
+import junit.framework.TestCase;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses([
+    LabelCompositionStrategyTest.class,
+    MapCSSWithExtendedTextDirectivesTest.class
+])
+public class AllMappaintTests extends TestCase{}
+
Index: /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategyTest.groovy
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategyTest.groovy	(revision 3988)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategyTest.groovy	(revision 3988)
@@ -0,0 +1,132 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.mappaint
+
+import org.junit.*
+import org.openstreetmap.josm.fixtures.JOSMFixture;
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy 
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy;
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy 
+import org.openstreetmap.josm.data.osm.Node;
+
+class LabelCompositionStrategyTest {
+    
+    @BeforeClass
+    public static void createJOSMFixture(){
+        JOSMFixture.createUnitTestFixture().init()
+    }
+
+    @Test
+    public void createStaticLabelCompositionStrategy() {
+        def n = new Node()
+        
+        def strat = new StaticLabelCompositionStrategy(null)
+        assert strat.compose(n) == null
+        
+        strat = new StaticLabelCompositionStrategy("a label")
+        assert strat.compose(n) == "a label"        
+    }
+    
+    @Test
+    public void createTagLookupCompositionStrategy() {
+        def n = new Node()
+        n.put("my-tag", "my-value")
+        
+        def strat = new TagLookupCompositionStrategy(null)
+        assert strat.compose(n) == null
+        
+        strat = new TagLookupCompositionStrategy("name")
+        assert strat.compose(n) == null
+        
+        strat = new TagLookupCompositionStrategy("my-tag")
+        assert strat.compose(n) == "my-value"
+    }
+    
+    @Test
+    public void createDeriveLabelFromNameTagsCompositionStrategy() {
+        def n 
+        def strat
+        
+        strat = new DeriveLabelFromNameTagsCompositionStrategy()
+        strat.setNameTags(null)
+        assert strat.getNameTags() == []
+        
+        strat = new DeriveLabelFromNameTagsCompositionStrategy()
+        strat.setNameTags(["name", "brand"])
+        assert strat.getNameTags() == ["name", "brand"]
+        
+        n = new Node()
+        n.put("brand", "my brand")        
+        assert strat.compose(n) == "my brand"
+        
+        n = new Node()
+        n.put("name", "my name")
+        n.put("brand", "my brand")
+        assert strat.compose(n) == "my name"        
+    }
+}
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.mappaint
+
+import org.junit.*
+import org.openstreetmap.josm.fixtures.JOSMFixture;
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy 
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy;
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy 
+import org.openstreetmap.josm.data.osm.Node;
+
+class LabelCompositionStrategyTest {
+    
+    @BeforeClass
+    public static void createJOSMFixture(){
+        JOSMFixture.createUnitTestFixture().init()
+    }
+
+    @Test
+    public void createStaticLabelCompositionStrategy() {
+        def n = new Node()
+        
+        def strat = new StaticLabelCompositionStrategy(null)
+        assert strat.compose(n) == null
+        
+        strat = new StaticLabelCompositionStrategy("a label")
+        assert strat.compose(n) == "a label"        
+    }
+    
+    @Test
+    public void createTagLookupCompositionStrategy() {
+        def n = new Node()
+        n.put("my-tag", "my-value")
+        
+        def strat = new TagLookupCompositionStrategy(null)
+        assert strat.compose(n) == null
+        
+        strat = new TagLookupCompositionStrategy("name")
+        assert strat.compose(n) == null
+        
+        strat = new TagLookupCompositionStrategy("my-tag")
+        assert strat.compose(n) == "my-value"
+    }
+    
+    @Test
+    public void createDeriveLabelFromNameTagsCompositionStrategy() {
+        def n 
+        def strat
+        
+        strat = new DeriveLabelFromNameTagsCompositionStrategy()
+        strat.setNameTags(null)
+        assert strat.getNameTags() == []
+        
+        strat = new DeriveLabelFromNameTagsCompositionStrategy()
+        strat.setNameTags(["name", "brand"])
+        assert strat.getNameTags() == ["name", "brand"]
+        
+        n = new Node()
+        n.put("brand", "my brand")        
+        assert strat.compose(n) == "my brand"
+        
+        n = new Node()
+        n.put("name", "my name")
+        n.put("brand", "my brand")
+        assert strat.compose(n) == "my name"        
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy	(revision 3988)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy	(revision 3988)
@@ -0,0 +1,116 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.mappaint
+
+import java.awt.Color;
+
+import org.junit.*;
+import org.openstreetmap.josm.fixtures.JOSMFixture 
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy 
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy 
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy 
+class MapCSSWithExtendedTextDirectivesTest {
+    
+
+    @BeforeClass
+    public static void createJOSMFixture(){
+        JOSMFixture.createUnitTestFixture().init()
+    }
+
+    @Test
+    public void createAutoTextElement() {
+        Cascade c = new Cascade()
+        c.put("text", new Keyword("auto"))
+        
+        TextElement te = TextElement.create(c, Color.WHITE)
+        assert te.labelCompositionStrategy != null
+        assert te.labelCompositionStrategy instanceof DeriveLabelFromNameTagsCompositionStrategy
+    }
+    
+    @Test
+    public void createTextElementComposingTextFromTag() {
+        Cascade c = new Cascade()
+        c.put("text", "my_name")
+        
+        TextElement te = TextElement.create(c, Color.WHITE)
+        assert te.labelCompositionStrategy != null
+        assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy
+        assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name"
+    }
+    
+    @Test
+    public void createTextElementComposingTextFromTag_2() {
+        Cascade c = new Cascade()
+        c.put("text", new Keyword("my_name"))
+        
+        TextElement te = TextElement.create(c, Color.WHITE)
+        assert te.labelCompositionStrategy != null
+        assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy
+        assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name"
+    }
+        
+    @Test
+    public void createNullStrategy() {
+        Cascade c = new Cascade()
+        
+        TextElement te = TextElement.create(c, Color.WHITE)
+        assert te.labelCompositionStrategy == null
+    }
+}
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.mappaint
+
+import java.awt.Color;
+
+import org.junit.*;
+import org.openstreetmap.josm.fixtures.JOSMFixture 
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy 
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy 
+import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy 
+class MapCSSWithExtendedTextDirectivesTest {
+    
+
+    @BeforeClass
+    public static void createJOSMFixture(){
+        JOSMFixture.createUnitTestFixture().init()
+    }
+
+    @Test
+    public void createAutoTextElement() {
+        Cascade c = new Cascade()
+        c.put("text", new Keyword("auto"))
+        
+        TextElement te = TextElement.create(c, Color.WHITE)
+        assert te.labelCompositionStrategy != null
+        assert te.labelCompositionStrategy instanceof DeriveLabelFromNameTagsCompositionStrategy
+    }
+    
+    @Test
+    public void createTextElementComposingTextFromTag() {
+        Cascade c = new Cascade()
+        c.put("text", "my_name")
+        
+        TextElement te = TextElement.create(c, Color.WHITE)
+        assert te.labelCompositionStrategy != null
+        assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy
+        assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name"
+    }
+    
+    @Test
+    public void createTextElementComposingTextFromTag_2() {
+        Cascade c = new Cascade()
+        c.put("text", new Keyword("my_name"))
+        
+        TextElement te = TextElement.create(c, Color.WHITE)
+        assert te.labelCompositionStrategy != null
+        assert te.labelCompositionStrategy instanceof TagLookupCompositionStrategy
+        assert te.labelCompositionStrategy.getDefaultLabelTag() == "my_name"
+    }
+        
+    @Test
+    public void createNullStrategy() {
+        Cascade c = new Cascade()
+        
+        TextElement te = TextElement.create(c, Color.WHITE)
+        assert te.labelCompositionStrategy == null
+    }
+}
