modules/graphics/src/test/java/test/javafx/css/CssMetaDataTest.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:

@@ -21,11 +21,11 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-package javafx.css;
+package test.javafx.css;
 
 import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;

@@ -38,12 +38,12 @@
 
 import com.sun.javafx.css.CascadingStyle;
 import com.sun.javafx.css.ParsedValueImpl;
 import com.sun.javafx.css.PseudoClassState;
 import com.sun.javafx.css.StyleManager;
-import com.sun.javafx.css.TestNode;
-import com.sun.javafx.css.TestNodeBase;
+import test.com.sun.javafx.css.TestNode;
+import test.com.sun.javafx.css.TestNodeBase;
 import com.sun.javafx.sg.prism.NGNode;
 import javafx.beans.value.WritableValue;
 import javafx.scene.Group;
 import javafx.scene.Node;
 import javafx.scene.Scene;

@@ -55,10 +55,31 @@
 import javafx.css.converter.BooleanConverter;
 import com.sun.javafx.geom.BaseBounds;
 import com.sun.javafx.geom.transform.BaseTransform;
 import com.sun.javafx.jmx.MXNodeAlgorithm;
 import com.sun.javafx.jmx.MXNodeAlgorithmContext;
+import javafx.css.CompoundSelector;
+import javafx.css.CssMetaData;
+import javafx.css.CssParser;
+import javafx.css.Declaration;
+import javafx.css.DeclarationShim;
+import javafx.css.FontCssMetaData;
+import javafx.css.ParsedValue;
+import javafx.css.PseudoClass;
+import javafx.css.Rule;
+import javafx.css.RuleShim;
+import javafx.css.Selector;
+import javafx.css.SelectorShim;
+import javafx.css.SimpleSelector;
+import javafx.css.SimpleSelectorShim;
+import javafx.css.Style;
+import javafx.css.StyleConverter;
+import javafx.css.StyleOrigin;
+import javafx.css.Styleable;
+import javafx.css.StyleableProperty;
+import javafx.css.Stylesheet;
+import javafx.css.StylesheetShim;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
 
 

@@ -230,17 +251,18 @@
     static CascadingStyle createCascadingStyle(Selector selector, Declaration declaration) {
 
         Set<PseudoClass> pseudoClasses = null;
         if (selector instanceof SimpleSelector) {
 
-            pseudoClasses = ((SimpleSelector)selector).getPseudoClassStates();
+            pseudoClasses = 
+                    SimpleSelectorShim.getPseudoClassStates((SimpleSelector)selector);
         } else {
 
             pseudoClasses = new PseudoClassState();
             for (SimpleSelector sel : ((CompoundSelector)selector).getSelectors()) {
 
-                Set<PseudoClass> selectorPseudoClasses = sel.getPseudoClassStates();
+                Set<PseudoClass> selectorPseudoClasses = SimpleSelectorShim.getPseudoClassStates(sel);
                 pseudoClasses.addAll(selectorPseudoClasses);
             }
         }
 
         return new CascadingStyle(

@@ -253,11 +275,11 @@
 
     @Test @org.junit.Ignore
     public void testGetMatchingStyles() {
 
 
-        final Stylesheet stylesheet = new Stylesheet();
+        final Stylesheet stylesheet = StylesheetShim.getStylesheet();
         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         final List<Rule> rules = stylesheet.getRules();
 

@@ -265,63 +287,63 @@
         // .root { -fx-base: red; -fx-color: -fx-base; }
         //
         List<String> rootStyleClass = new ArrayList<String>();
         rootStyleClass.add("root");
 
-        Selector root = new SimpleSelector("*", rootStyleClass, null, null);
+        Selector root = SimpleSelectorShim.getSimpleSelector("*", rootStyleClass, null, null);
 
         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
-        Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
+        Declaration fxBase = DeclarationShim.getDeclaration("-fx-base", fxBaseValue, false);
 
         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
-        Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
+        Declaration fxColor = DeclarationShim.getDeclaration("-fx-color", fxColorValue, false);
 
         List<Selector> selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, root);
 
         List<Declaration> declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxBase, fxColor);
 
-        Rule baseRule = new Rule(selectors, declarations);
+        Rule baseRule = RuleShim.getRule(selectors, declarations);
         rules.add(baseRule);
 
         //
         // .rect { -fx-fill: -fx-color; }
         //
         List<String> rectStyleClass = new ArrayList<String>();
         rectStyleClass.add("rect");
 
-        Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
+        Selector rect = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, null, null);
 
         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
-        Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
+        Declaration fxFill = DeclarationShim.getDeclaration("-fx-fill", fxFillValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rect);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFill);
 
-        Rule rectRule = new Rule(selectors, declarations);
+        Rule rectRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectRule);
 
         // .rect:hover { -fx-fill: yellow; }
         List<String> pseudoclasses = new ArrayList<String>();
         pseudoclasses.add("hover");
 
-        Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
+        Selector rectHover = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, pseudoclasses, null);
 
         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
-        Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
+        Declaration fxFillHover = DeclarationShim.getDeclaration("-fx-fill", fxFillHoverValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rectHover);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFillHover);
 
-        Rule rectHoverRule = new Rule(selectors, declarations);
+        Rule rectHoverRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectHoverRule);
 
         List<Style> expecteds = new ArrayList<Style>();
         Collections.addAll(expecteds,
                            new Style(root, fxBase),

@@ -358,11 +380,11 @@
 
     @Test @org.junit.Ignore
     public void testGetMatchingStylesWithInlineStyleOnParent() {
 
 
-        final Stylesheet stylesheet = new Stylesheet();
+        final Stylesheet stylesheet = StylesheetShim.getStylesheet();
         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         final List<Rule> rules = stylesheet.getRules();
 

@@ -370,81 +392,81 @@
         // .root { -fx-base: red; -fx-color: -fx-base; }
         //
         List<String> rootStyleClass = new ArrayList<String>();
         rootStyleClass.add("root");
 
-        Selector root = new SimpleSelector("*", rootStyleClass, null, null);
+        Selector root = SimpleSelectorShim.getSimpleSelector("*", rootStyleClass, null, null);
 
         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
-        Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
+        Declaration fxBase = DeclarationShim.getDeclaration("-fx-base", fxBaseValue, false);
 
         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
-        Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
+        Declaration fxColor = DeclarationShim.getDeclaration("-fx-color", fxColorValue, false);
 
         List<Selector> selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, root);
 
         List<Declaration> declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxBase, fxColor);
 
-        Rule baseRule = new Rule(selectors, declarations);
+        Rule baseRule = RuleShim.getRule(selectors, declarations);
         rules.add(baseRule);
 
         //
         // .rect { -fx-fill: -fx-color; }
         //
         List<String> rectStyleClass = new ArrayList<String>();
         rectStyleClass.add("rect");
 
-        Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
+        Selector rect = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, null, null);
 
         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
-        Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
+        Declaration fxFill = DeclarationShim.getDeclaration("-fx-fill", fxFillValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rect);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFill);
 
-        Rule rectRule = new Rule(selectors, declarations);
+        Rule rectRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectRule);
 
         // .rect:hover { -fx-fill: yellow; }
         List<String> pseudoclasses = new ArrayList<String>();
         pseudoclasses.add("hover");
 
-        Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
+        Selector rectHover = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, pseudoclasses, null);
 
         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
-        Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
+        Declaration fxFillHover = DeclarationShim.getDeclaration("-fx-fill", fxFillHoverValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rectHover);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFillHover);
 
-        Rule rectHoverRule = new Rule(selectors, declarations);
+        Rule rectHoverRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectHoverRule);
 
         // Declaration now checks origin, so we need to make this expected
         // value look like it came from an inline
-        final Declaration decl = new Declaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
+        final Declaration decl = DeclarationShim.getDeclaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
 
-        Stylesheet ss = new Stylesheet() {
+        Stylesheet ss = new StylesheetShim(null) {
             {
                 setOrigin(StyleOrigin.INLINE);
                 getRules().add(
-                        new Rule(Arrays.asList(SimpleSelector.getUniversalSelector()), Arrays.asList(decl))
+                        RuleShim.getRule(Arrays.asList(SelectorShim.getUniversalSelector()), Arrays.asList(decl))
                 );
             }
         };
 
         List<Style> expecteds = new ArrayList<Style>();
         Collections.addAll(expecteds,
-                           new Style(SimpleSelector.getUniversalSelector(), decl),
+                           new Style(SelectorShim.getUniversalSelector(), decl),
                            new Style(root, fxBase),
                            new Style(root, fxColor),
                            new Style(rect, fxFill),
                            new Style(rectHover, fxFillHover)
         );

@@ -481,11 +503,11 @@
 
     @Test @org.junit.Ignore
     public void testGetMatchingStylesWithInlineStyleOnLeaf() {
 
 
-        final Stylesheet stylesheet = new Stylesheet();
+        final Stylesheet stylesheet = StylesheetShim.getStylesheet();
         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         final List<Rule> rules = stylesheet.getRules();
 

@@ -493,81 +515,81 @@
         // .root { -fx-base: red; -fx-color: -fx-base; }
         //
         List<String> rootStyleClass = new ArrayList<String>();
         rootStyleClass.add("root");
 
-        Selector root = new SimpleSelector("*", rootStyleClass, null, null);
+        Selector root = SimpleSelectorShim.getSimpleSelector("*", rootStyleClass, null, null);
 
         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
-        Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
+        Declaration fxBase = DeclarationShim.getDeclaration("-fx-base", fxBaseValue, false);
 
         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
-        Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
+        Declaration fxColor = DeclarationShim.getDeclaration("-fx-color", fxColorValue, false);
 
         List<Selector> selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, root);
 
         List<Declaration> declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxBase, fxColor);
 
-        Rule baseRule = new Rule(selectors, declarations);
+        Rule baseRule = RuleShim.getRule(selectors, declarations);
         rules.add(baseRule);
 
         //
         // .rect { -fx-fill: -fx-color; }
         //
         List<String> rectStyleClass = new ArrayList<String>();
         rectStyleClass.add("rect");
 
-        Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
+        Selector rect = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, null, null);
 
         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
-        Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
+        Declaration fxFill = DeclarationShim.getDeclaration("-fx-fill", fxFillValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rect);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFill);
 
-        Rule rectRule = new Rule(selectors, declarations);
+        Rule rectRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectRule);
 
         // .rect:hover { -fx-fill: yellow; }
         List<String> pseudoclasses = new ArrayList<String>();
         pseudoclasses.add("hover");
 
-        Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
+        Selector rectHover = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, pseudoclasses, null);
 
         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
-        Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
+        Declaration fxFillHover = DeclarationShim.getDeclaration("-fx-fill", fxFillHoverValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rectHover);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFillHover);
 
-        Rule rectHoverRule = new Rule(selectors, declarations);
+        Rule rectHoverRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectHoverRule);
 
         // Declaration now checks origin, so we need to make this expected
         // value look like it came from an inline
-        final Declaration decl = new Declaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
+        final Declaration decl = DeclarationShim.getDeclaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
 
-        Stylesheet ss = new Stylesheet() {
+        Stylesheet ss = new StylesheetShim(null) {
             {
                 setOrigin(StyleOrigin.INLINE);
                 getRules().add(
-                        new Rule(Arrays.asList(SimpleSelector.getUniversalSelector()), Arrays.asList(decl))
+                        RuleShim.getRule(Arrays.asList(SelectorShim.getUniversalSelector()), Arrays.asList(decl))
                 );
             }
         };
 
         List<Style> expecteds = new ArrayList<Style>();
         Collections.addAll(expecteds,
-                           new Style(SimpleSelector.getUniversalSelector(), decl),
+                           new Style(SelectorShim.getUniversalSelector(), decl),
                            new Style(root, fxBase),
                            new Style(root, fxColor),
                            new Style(rect, fxFill),
                            new Style(rectHover, fxFillHover)
         );

@@ -604,11 +626,11 @@
 
     @Test @org.junit.Ignore
     public void testGetMatchingStylesWithInlineStyleOnRootAndLeaf() {
 
 
-        final Stylesheet stylesheet = new Stylesheet();
+        final Stylesheet stylesheet = StylesheetShim.getStylesheet();
         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         final List<Rule> rules = stylesheet.getRules();
 

@@ -616,84 +638,84 @@
         // .root { -fx-base: red; -fx-color: -fx-base; }
         //
         List<String> rootStyleClass = new ArrayList<String>();
         rootStyleClass.add("root");
 
-        Selector root = new SimpleSelector("*", rootStyleClass, null, null);
+        Selector root = SimpleSelectorShim.getSimpleSelector("*", rootStyleClass, null, null);
 
         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
-        Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
+        Declaration fxBase = DeclarationShim.getDeclaration("-fx-base", fxBaseValue, false);
 
         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
-        Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
+        Declaration fxColor = DeclarationShim.getDeclaration("-fx-color", fxColorValue, false);
 
         List<Selector> selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, root);
 
         List<Declaration> declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxBase, fxColor);
 
-        Rule baseRule = new Rule(selectors, declarations);
+        Rule baseRule = RuleShim.getRule(selectors, declarations);
         rules.add(baseRule);
 
         //
         // .rect { -fx-fill: -fx-color; }
         //
         List<String> rectStyleClass = new ArrayList<String>();
         rectStyleClass.add("rect");
 
-        Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
+        Selector rect = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, null, null);
 
         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
-        Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
+        Declaration fxFill = DeclarationShim.getDeclaration("-fx-fill", fxFillValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rect);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFill);
 
-        Rule rectRule = new Rule(selectors, declarations);
+        Rule rectRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectRule);
 
         // .rect:hover { -fx-fill: yellow; }
         List<String> pseudoclasses = new ArrayList<String>();
         pseudoclasses.add("hover");
 
-        Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
+        Selector rectHover = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, pseudoclasses, null);
 
         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
-        Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
+        Declaration fxFillHover = DeclarationShim.getDeclaration("-fx-fill", fxFillHoverValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rectHover);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFillHover);
 
-        Rule rectHoverRule = new Rule(selectors, declarations);
+        Rule rectHoverRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectHoverRule);
 
         // Declaration now checks origin, so we need to make this expected
         // value look like it came from an inline
-        final Declaration gdecl = new Declaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
-        final Declaration ydecl = new Declaration("-fx-color", new ParsedValueImpl<Color,Color>(Color.YELLOW, null), false);
+        final Declaration gdecl = DeclarationShim.getDeclaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
+        final Declaration ydecl = DeclarationShim.getDeclaration("-fx-color", new ParsedValueImpl<Color,Color>(Color.YELLOW, null), false);
 
-        Stylesheet ss = new Stylesheet() {
+        Stylesheet ss = new StylesheetShim(null) {
             {
                 setOrigin(StyleOrigin.INLINE);
                 Collections.addAll(getRules(),
-                                   new Rule(Arrays.asList(SimpleSelector.getUniversalSelector()), Arrays.asList(gdecl)),
-                                   new Rule(Arrays.asList(SimpleSelector.getUniversalSelector()), Arrays.asList(ydecl))
+                                   RuleShim.getRule(Arrays.asList(SelectorShim.getUniversalSelector()), Arrays.asList(gdecl)),
+                                   RuleShim.getRule(Arrays.asList(SelectorShim.getUniversalSelector()), Arrays.asList(ydecl))
                 );
             }
         };
 
         List<Style> expecteds = new ArrayList<Style>();
         Collections.addAll(expecteds,
-                           new Style(SimpleSelector.getUniversalSelector(), ydecl),
-                           new Style(SimpleSelector.getUniversalSelector(), gdecl),
+                           new Style(SelectorShim.getUniversalSelector(), ydecl),
+                           new Style(SelectorShim.getUniversalSelector(), gdecl),
                            new Style(root, fxBase),
                            new Style(root, fxColor),
                            new Style(rect, fxFill),
                            new Style(rectHover, fxFillHover)
         );

@@ -731,11 +753,11 @@
 
     @Test @org.junit.Ignore
     public void testGetMatchingStylesShouldNotReturnAncestorPropertyIfNotInherited() {
 
 
-        final Stylesheet stylesheet = new Stylesheet();
+        final Stylesheet stylesheet = StylesheetShim.getStylesheet();
         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         final List<Rule> rules = stylesheet.getRules();
 

@@ -743,66 +765,66 @@
         // .root { -fx-base: red; -fx-color: -fx-base; }
         //
         List<String> rootStyleClass = new ArrayList<String>();
         rootStyleClass.add("root");
 
-        Selector root = new SimpleSelector("*", rootStyleClass, null, null);
+        Selector root = SimpleSelectorShim.getSimpleSelector("*", rootStyleClass, null, null);
 
         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
-        Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
+        Declaration fxBase = DeclarationShim.getDeclaration("-fx-base", fxBaseValue, false);
 
         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
-        Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
+        Declaration fxColor = DeclarationShim.getDeclaration("-fx-color", fxColorValue, false);
 
         ParsedValueImpl<Color,Color> fxFillShouldNotMatchValue = new ParsedValueImpl<Color,Color>(Color.RED, null);
-        Declaration fxFillShouldNotMatch = new Declaration("-fx-fill", fxFillShouldNotMatchValue, false);
+        Declaration fxFillShouldNotMatch = DeclarationShim.getDeclaration("-fx-fill", fxFillShouldNotMatchValue, false);
 
         List<Selector> selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, root);
 
         List<Declaration> declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxBase, fxColor, fxFillShouldNotMatch);
 
-        Rule baseRule = new Rule(selectors, declarations);
+        Rule baseRule = RuleShim.getRule(selectors, declarations);
         rules.add(baseRule);
 
         //
         // .rect { -fx-fill: -fx-color; }
         //
         List<String> rectStyleClass = new ArrayList<String>();
         rectStyleClass.add("rect");
 
-        Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
+        Selector rect = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, null, null);
 
         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
-        Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
+        Declaration fxFill = DeclarationShim.getDeclaration("-fx-fill", fxFillValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rect);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFill);
 
-        Rule rectRule = new Rule(selectors, declarations);
+        Rule rectRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectRule);
 
         // .rect:hover { -fx-fill: yellow; }
         List<String> pseudoclasses = new ArrayList<String>();
         pseudoclasses.add("hover");
 
-        Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
+        Selector rectHover = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, pseudoclasses, null);
 
         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
-        Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
+        Declaration fxFillHover = DeclarationShim.getDeclaration("-fx-fill", fxFillHoverValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rectHover);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFillHover);
 
-        Rule rectHoverRule = new Rule(selectors, declarations);
+        Rule rectHoverRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectHoverRule);
 
         List<Style> expecteds = new ArrayList<Style>();
         Collections.addAll(expecteds,
                            new Style(root, fxBase),

@@ -839,11 +861,11 @@
 
 
     @Test @org.junit.Ignore
     public void testGetMatchingStylesShouldNotReturnInlineAncestorPropertyIfNotInherited() {
 
-        final Stylesheet stylesheet = new Stylesheet();
+        final Stylesheet stylesheet = StylesheetShim.getStylesheet();
         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         final List<Rule> rules = stylesheet.getRules();
 

@@ -854,63 +876,63 @@
         rectStyleClass.add("rect");
 
         //
         // .root { -fx-base: red; -fx-color: -fx-base; }
         //
-        Selector root = new SimpleSelector("*", rootStyleClass, null, null);
+        Selector root = SimpleSelectorShim.getSimpleSelector("*", rootStyleClass, null, null);
 
         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
-        Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
+        Declaration fxBase = DeclarationShim.getDeclaration("-fx-base", fxBaseValue, false);
 
         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
-        Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
+        Declaration fxColor = DeclarationShim.getDeclaration("-fx-color", fxColorValue, false);
 
         ParsedValueImpl<Color,Color> fxFillShouldNotMatchValue = new ParsedValueImpl<Color,Color>(Color.RED, null);
-        Declaration fxFillShouldNotMatch = new Declaration("-fx-fill", fxFillShouldNotMatchValue, false);
+        Declaration fxFillShouldNotMatch = DeclarationShim.getDeclaration("-fx-fill", fxFillShouldNotMatchValue, false);
 
         List<Selector> selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, root);
 
         List<Declaration> declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxBase, fxColor, fxFillShouldNotMatch);
 
-        Rule baseRule = new Rule(selectors, declarations);
+        Rule baseRule = RuleShim.getRule(selectors, declarations);
         rules.add(baseRule);
 
         //
         // .rect { -fx-fill: -fx-color; }
         //
-        Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
+        Selector rect = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, null, null);
 
         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
-        Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
+        Declaration fxFill = DeclarationShim.getDeclaration("-fx-fill", fxFillValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rect);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFill);
 
-        Rule rectRule = new Rule(selectors, declarations);
+        Rule rectRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectRule);
 
         // .rect:hover { -fx-fill: yellow; }
         List<String> pseudoclasses = new ArrayList<String>();
         pseudoclasses.add("hover");
 
-        Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
+        Selector rectHover = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, pseudoclasses, null);
 
         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
-        Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
+        Declaration fxFillHover = DeclarationShim.getDeclaration("-fx-fill", fxFillHoverValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, rectHover);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFillHover);
 
-        Rule rectHoverRule = new Rule(selectors, declarations);
+        Rule rectHoverRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectHoverRule);
 
         List<Style> expecteds = new ArrayList<Style>();
         Collections.addAll(expecteds,
                            new Style(root, fxBase),

@@ -945,11 +967,11 @@
 
     @Test @org.junit.Ignore
     public void testGetMatchingStylesReturnsInheritedProperty() {
 
 
-        final Stylesheet stylesheet = new Stylesheet();
+        final Stylesheet stylesheet = StylesheetShim.getStylesheet();
         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         final List<Rule> rules = stylesheet.getRules();
 

@@ -957,42 +979,42 @@
         // .root { -fx-base: red; -fx-color: -fx-base; }
         //
         List<String> rootStyleClass = new ArrayList<String>();
         rootStyleClass.add("root");
 
-        Selector root = new SimpleSelector("*", rootStyleClass, null, null);
+        Selector root = SimpleSelectorShim.getSimpleSelector("*", rootStyleClass, null, null);
 
         ParsedValue<Color,Color> fxFontShouldInheritValue = new CssParser().parseExpr("-fx-font", "12px system");
-        Declaration fxFontShouldInherit = new Declaration("-fx-font", fxFontShouldInheritValue, false);
+        Declaration fxFontShouldInherit = DeclarationShim.getDeclaration("-fx-font", fxFontShouldInheritValue, false);
 
         List<Selector> selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, root);
 
         List<Declaration> declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFontShouldInherit);
 
-        Rule baseRule = new Rule(selectors, declarations);
+        Rule baseRule = RuleShim.getRule(selectors, declarations);
         rules.add(baseRule);
 
         //
         // .text { -fx-fill: -fx-color; }
         //
         List<String> textStyleClass = new ArrayList<String>();
         textStyleClass.add("text");
 
-        Selector textSelector = new SimpleSelector("*", textStyleClass, null, null);
+        Selector textSelector = SimpleSelectorShim.getSimpleSelector("*", textStyleClass, null, null);
 
         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "red");
-        Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
+        Declaration fxFill = DeclarationShim.getDeclaration("-fx-fill", fxFillValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, textSelector);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFill);
 
-        Rule rectRule = new Rule(selectors, declarations);
+        Rule rectRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectRule);
 
         List<Style> expecteds = new ArrayList<Style>();
         Collections.addAll(expecteds,
                            new Style(root, fxFontShouldInherit)

@@ -1025,11 +1047,11 @@
     }
 
     @Test @org.junit.Ignore
     public void testGetMatchingStylesReturnsSubProperty() {
 
-        final Stylesheet stylesheet = new Stylesheet();
+        final Stylesheet stylesheet = StylesheetShim.getStylesheet();
         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         final List<Rule> rules = stylesheet.getRules();
 

@@ -1037,45 +1059,45 @@
         // .root { -fx-base: red; -fx-color: -fx-base; }
         //
         List<String> rootStyleClass = new ArrayList<String>();
         rootStyleClass.add("root");
 
-        Selector root = new SimpleSelector("*", rootStyleClass, null, null);
+        Selector root = SimpleSelectorShim.getSimpleSelector("*", rootStyleClass, null, null);
 
         ParsedValue<Color,Color> fxFontShouldInheritValue = new CssParser().parseExpr("-fx-font", "12px system");
-        Declaration fxFontShouldInherit = new Declaration("-fx-font", fxFontShouldInheritValue, false);
+        Declaration fxFontShouldInherit = DeclarationShim.getDeclaration("-fx-font", fxFontShouldInheritValue, false);
 
         List<Selector> selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, root);
 
         List<Declaration> declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFontShouldInherit);
 
-        Rule baseRule = new Rule(selectors, declarations);
+        Rule baseRule = RuleShim.getRule(selectors, declarations);
         rules.add(baseRule);
 
         //
         // .text { -fx-fill: -fx-color; }
         //
         List<String> rectStyleClass = new ArrayList<String>();
         rectStyleClass.add("text");
 
-        Selector textSelector = new SimpleSelector("*", rectStyleClass, null, null);
+        Selector textSelector = SimpleSelectorShim.getSimpleSelector("*", rectStyleClass, null, null);
 
         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "red");
-        Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
+        Declaration fxFill = DeclarationShim.getDeclaration("-fx-fill", fxFillValue, false);
 
         ParsedValue fxFontFamilyValue = new CssParser().parseExpr("-fx-font-family", "arial");
-        Declaration fxFontFamily = new Declaration("-fx-font-family", fxFontFamilyValue, false);
+        Declaration fxFontFamily = DeclarationShim.getDeclaration("-fx-font-family", fxFontFamilyValue, false);
 
         selectors = new ArrayList<Selector>();
         Collections.addAll(selectors, textSelector);
 
         declarations = new ArrayList<Declaration>();
         Collections.addAll(declarations, fxFill, fxFontFamily);
 
-        Rule rectRule = new Rule(selectors, declarations);
+        Rule rectRule = RuleShim.getRule(selectors, declarations);
         rules.add(rectRule);
 
         List<Style> expecteds = new ArrayList<Style>();
         Collections.addAll(expecteds,
                            new Style(textSelector, fxFontFamily),