You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2005/09/18 03:49:23 UTC
svn commit: r289879 - in
/struts/shale/trunk/core-library/src/test/org/apache/shale/view: ./ impl/
impl/DefaultViewControllerMapperTestCase.java
Author: craigmcc
Date: Sat Sep 17 18:49:19 2005
New Revision: 289879
URL: http://svn.apache.org/viewcvs?rev=289879&view=rev
Log:
Unit tests for DefaultViewControllerMapper.
Added:
struts/shale/trunk/core-library/src/test/org/apache/shale/view/
struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/
struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java
Added: struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java?rev=289879&view=auto
==============================================================================
--- struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java (added)
+++ struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java Sat Sep 17 18:49:19 2005
@@ -0,0 +1,126 @@
+/*
+ * 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.view.impl;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * <p>Test case for <code>DefaultViewControllerMapper</code>.</p>
+ */
+public class DefaultViewControllerMapperTestCase extends TestCase {
+
+
+ // ------------------------------------------------------------ Constructors
+
+
+ // Construct a new instance of this test case.
+ public DefaultViewControllerMapperTestCase(String name) {
+ super(name);
+ }
+
+
+ // ---------------------------------------------------- Overall Test Methods
+
+
+ // Set up instance variables required by this test case.
+ public void setUp() throws Exception {
+
+ super.setUp();
+
+ // Set up the instance we will be testing
+ dvcm = new DefaultViewControllerMapper();
+
+ }
+
+
+ // Return the tests included in this test case.
+ public static Test suite() {
+
+ return (new TestSuite(DefaultViewControllerMapperTestCase.class));
+
+ }
+
+
+ // Tear down instance variables required by this test case.
+ public void tearDown() throws Exception {
+
+ dvcm = null;
+ super.tearDown();
+
+ }
+
+
+ // ------------------------------------------------------ Instance Variables
+
+
+ // The instance to be tested
+ DefaultViewControllerMapper dvcm = null;
+
+ // The set of reserved managed bean names that should be treated specially
+ String reserved[] = {
+ "applicationScope", "cookies", "facesContext", "header", "headerValues",
+ "initParam", "param", "paramValues", "requestScope", "sessionScope", "view",
+ };
+
+ // ------------------------------------------------------------ Test Methods
+
+
+ // Test multiple directory level mappings
+ public void testMultiple() {
+
+ assertEquals("foo$bar", dvcm.mapViewId("/foo/bar.jsp"));
+ assertEquals("foo$bar", dvcm.mapViewId("/foo/bar.xxx"));
+ assertEquals("foo$bar", dvcm.mapViewId("foo/bar.jsp"));
+ assertEquals("foo$bar", dvcm.mapViewId("foo/bar.xxx"));
+
+ }
+
+
+ // Test a pristine instance
+ public void testPristine() {
+
+ ;
+
+ }
+
+
+ // Test mapping of reserved managed bean names
+ public void testReserved() {
+
+ for (int i = 0; i < reserved.length; i++) {
+ assertEquals(reserved[i],
+ "_" + reserved[i],
+ dvcm.mapViewId("/" + reserved[i] + ".jsp"));
+ }
+
+ }
+
+
+ // Test single directory level mappings
+ public void testSingle() {
+
+ assertEquals("foo", dvcm.mapViewId("/foo.jsp"));
+ assertEquals("foo", dvcm.mapViewId("/foo.xxx"));
+ assertEquals("foo", dvcm.mapViewId("foo.jsp"));
+ assertEquals("foo", dvcm.mapViewId("foo.xxx"));
+
+ }
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org