struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r427538 - /struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestTilesServlet.java
Date Tue, 01 Aug 2006 11:33:23 GMT
Author: apetrelli
Date: Tue Aug  1 04:33:23 2006
New Revision: 427538

URL: http://svn.apache.org/viewvc?rev=427538&view=rev
Log:
SB-24
Added method testCustomizedInitTilesServlet to test TilesServlet with customized parameters.
Corrected typo in testInitTilesServlet

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

Modified: struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestTilesServlet.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestTilesServlet.java?rev=427538&r1=427537&r2=427538&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestTilesServlet.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/TestTilesServlet.java
Tue Aug  1 04:33:23 2006
@@ -24,6 +24,9 @@
 import junit.framework.TestSuite;
 import servletunit.ServletConfigSimulator;
 import servletunit.ServletContextSimulator;
+
+import org.apache.tiles.mock.MockComponentDefinitions;
+import org.apache.tiles.mock.MockDefinitionsReader;
 import org.apache.tiles.servlets.TilesServlet;
 
 /**
@@ -68,7 +71,40 @@
             TilesServlet servlet = new TilesServlet();
             servlet.init(servletConfig);
         } catch (Exception e) {
-            fail("Eception initializing servlet: " + e);
+            fail("Exception initializing servlet: " + e);
+        }
+    }
+
+    /**
+     * Executes the servlet init() method with a custom definitions reader and
+     * a custom component definitions.
+     */
+    public void testCustomizedInitTilesServlet() {
+        int readerInstanceCount = MockDefinitionsReader.getInstanceCount();
+        int defsInstanceCount = MockComponentDefinitions.getInstanceCount();
+        
+        try {
+            ServletConfigSimulator servletConfig = new ServletConfigSimulator();
+            servletConfig.setInitParameter("definitions-config", 
+                    "org/apache/tiles/config/tiles-defs.xml");
+            servletConfig.setInitParameter(
+                    DefinitionsFactory.READER_IMPL_PROPERTY,
+                    "org.apache.tiles.mock.MockDefinitionsReader");
+            servletConfig.setInitParameter(
+                    DefinitionsFactory.DEFINITIONS_IMPL_PROPERTY,
+                    "org.apache.tiles.mock.MockComponentDefinitions");
+            
+            TilesServlet servlet = new TilesServlet();
+            servlet.init(servletConfig);
+            
+            assertEquals("MockDefinitionsReader not used.",  
+                    readerInstanceCount + 1,
+                    MockDefinitionsReader.getInstanceCount());
+            assertEquals("MockComponentDefinitions not used.",  
+                    defsInstanceCount + 1,
+                    MockDefinitionsReader.getInstanceCount());
+        } catch (Exception e) {
+            fail("Exception initializing servlet: " + e);
         }
     }
 }



Mime
View raw message