Author: apetrelli
Date: Mon Jul 31 04:30:28 2006
New Revision: 427076

URL: http://svn.apache.org/viewvc?rev=427076&view=rev
Log:
[SB-26]
Updated testResolveAttributeDependencies for the use with a specified locale.

Modified:
    
struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestComponentDefinitions.java

Modified: 
struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestComponentDefinitions.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestComponentDefinitions.java?rev=427076&r1=427075&r2=427076&view=diff
==============================================================================
--- 
struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestComponentDefinitions.java
 (original)
+++ 
struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestComponentDefinitions.java
 Mon Jul 31 04:30:28 2006
@@ -232,12 +232,23 @@
         defs.put(def.getName(), def);
         
         def = new ComponentDefinition();
+        def.setName("parent.notype.def1");
+        def.setPath("/test1.jsp");
+        attr = new ComponentAttribute();
+        attr.setName("attr1");
+        attr.setValue("tiles.def2");
+        // Don't set the type
+        def.addAttribute(attr);
+        defs.put(def.getName(), def);
+        
+        def = new ComponentDefinition();
         def.setName("tiles.def2");
         defs.put(def.getName(), def);
         
         ComponentDefinitions definitions = new ComponentDefinitionsImpl();
         try {
             definitions.addDefinitions(defs);
+            definitions.addDefinitions(defs, Locale.ITALIAN);
         } catch (NoSuchDefinitionException e) {
             fail("Test failure: " + e);
         }
@@ -246,6 +257,35 @@
         assertNotNull("Parent definition not found.", newDef);
         
         Object newAttr = newDef.getAttribute("attr1");
+        assertNotNull("Dependent attribute not found.", newAttr);
+        assertTrue("Dependent attribute incorrect type.", 
+                newAttr instanceof ComponentDefinition);
+        
+        newDef = definitions.getDefinition("parent.notype.def1");
+        assertNotNull("Parent definition not found.", newDef);
+        
+        newAttr = newDef.getAttribute("attr1");
+        assertNotNull("Dependent attribute not found.", newAttr);
+        assertTrue("Dependent attribute incorrect type.", 
+                newAttr instanceof ComponentDefinition);
+        
+        assertEquals("Incorrect dependent attribute name.", "tiles.def2",
+                ((ComponentDefinition) newAttr).getName());
+        
+        // Part of the test for locale-specific definitions.
+        newDef = definitions.getDefinition("parent.def1", Locale.ITALIAN);
+        assertNotNull("Parent definition not found.", newDef);
+        
+        newAttr = newDef.getAttribute("attr1");
+        assertNotNull("Dependent attribute not found.", newAttr);
+        assertTrue("Dependent attribute incorrect type.", 
+                newAttr instanceof ComponentDefinition);
+        
+        newDef = definitions.getDefinition("parent.notype.def1",
+                       Locale.ITALIAN);
+        assertNotNull("Parent definition not found.", newDef);
+        
+        newAttr = newDef.getAttribute("attr1");
         assertNotNull("Dependent attribute not found.", newAttr);
         assertTrue("Dependent attribute incorrect type.", 
                 newAttr instanceof ComponentDefinition);


Reply via email to