struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject svn commit: r151631 - in struts/shale/trunk/test-framework: build.xml src/java/org/apache/shale/test/base/AbstractViewControllerTestCase.java src/java/org/apache/shale/test/mock/MockApplication.java
Date Sun, 06 Feb 2005 22:57:52 GMT
Author: craigmcc
Date: Sun Feb  6 14:57:50 2005
New Revision: 151631

URL: http://svn.apache.org/viewcvs?view=rev&rev=151631
Log:
Add a convenience base class for unit tests of ViewController implementations.

Added:
    struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractViewControllerTestCase.java
Modified:
    struts/shale/trunk/test-framework/build.xml
    struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockApplication.java

Modified: struts/shale/trunk/test-framework/build.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/test-framework/build.xml?view=diff&r1=151630&r2=151631
==============================================================================
--- struts/shale/trunk/test-framework/build.xml (original)
+++ struts/shale/trunk/test-framework/build.xml Sun Feb  6 14:57:50 2005
@@ -37,7 +37,7 @@
   <property name="jstl.home"        value="/usr/local/standard-1.0.3"/>
   <property name="junit.home"       value="/usr/local/junit-3.8.1"/>
   <property name="server.home"      value="/usr/local/jakarta-tomcat-5.0.25"/>
-  <property name="shale.home"       value="${basedir}/../struts-shale/target"/>
+  <property name="shale.home"       value="${basedir}/../core-library/target"/>
 
 
   <!-- Dependency library defaults -->

Added: struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractViewControllerTestCase.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractViewControllerTestCase.java?view=auto&rev=151631
==============================================================================
--- struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractViewControllerTestCase.java
(added)
+++ struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractViewControllerTestCase.java
Sun Feb  6 14:57:50 2005
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale.test.base;
+
+import java.util.Iterator;
+
+/**
+ * <p>Abstract base class for testing <code>ViewController</code>
+ * implementations.</p>
+ *
+ * $Id$
+ */
+public abstract class AbstractViewControllerTestCase extends AbstractJsfTestCase {
+    
+    // ------------------------------------------------------------ Constructors
+
+
+    // Construct a new instance of this test case.
+    public AbstractViewControllerTestCase(String name) {
+        super(name);
+    }
+
+
+    // ---------------------------------------------------- Overall Test Methods
+
+
+    // ------------------------------------------------------ Instance Variables
+
+
+    // ------------------------------------------------------- Protected Methods
+
+
+    /**
+     * <p>Test that the specified number of messages have been queued on the
+     * <code>FacesContext</code> instance, without regard to matching a
+     * particular client identifier.</p>
+     *
+     * @param expected The expected number of messages
+     */
+    protected void checkMessageCount(int expected) {
+
+        int actual = 0;
+        Iterator messages = facesContext.getMessages();
+        while (messages.hasNext()) {
+            messages.next();
+            actual++;
+        }
+        assertEquals("Complete message count", expected, actual);
+
+    }
+
+
+    /**
+     * <p>Test that the specified number of messages have been queued on the
+     * <code>FacesContext</code> instance, for the specified client id.</p>
+     *
+     * @param clientId Client identifier of the component for which to
+     *  count queued messages
+     * @param expected The expected number of messages
+     */
+    protected void checkMessageCount(String clientId, int expected) {
+
+        int actual = 0;
+        Iterator messages = facesContext.getMessages(clientId);
+        while (messages.hasNext()) {
+            messages.next();
+            actual++;
+        }
+        assertEquals("Complete message count", expected, actual);
+
+    }
+
+
+}

Modified: struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockApplication.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockApplication.java?view=diff&r1=151630&r2=151631
==============================================================================
--- struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockApplication.java
(original)
+++ struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockApplication.java
Sun Feb  6 14:57:50 2005
@@ -201,7 +201,7 @@
     }
 
 
-    public void setSupportedLocales(Collection newLocales) {
+    public void setSupportedLocales(Collection supportedLocales) {
 
         this.supportedLocales = supportedLocales;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message