You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by cr...@apache.org on 2006/08/08 08:02:37 UTC

svn commit: r429594 - /shale/framework/trunk/shale-apps/shale-usecases/src/test/java/org/apache/shale/usecases/systest/ExceptionTestCase.java

Author: craigmcc
Date: Mon Aug  7 23:02:37 2006
New Revision: 429594

URL: http://svn.apache.org/viewvc?rev=429594&view=rev
Log:
Add a system integration test for the new exception handling
functionality.

SHALE-125

Added:
    shale/framework/trunk/shale-apps/shale-usecases/src/test/java/org/apache/shale/usecases/systest/ExceptionTestCase.java

Added: shale/framework/trunk/shale-apps/shale-usecases/src/test/java/org/apache/shale/usecases/systest/ExceptionTestCase.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-usecases/src/test/java/org/apache/shale/usecases/systest/ExceptionTestCase.java?rev=429594&view=auto
==============================================================================
--- shale/framework/trunk/shale-apps/shale-usecases/src/test/java/org/apache/shale/usecases/systest/ExceptionTestCase.java (added)
+++ shale/framework/trunk/shale-apps/shale-usecases/src/test/java/org/apache/shale/usecases/systest/ExceptionTestCase.java Mon Aug  7 23:02:37 2006
@@ -0,0 +1,130 @@
+/*
+ * 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.usecases.systest;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlHiddenInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSpan;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.shale.test.cargo.CargoTestSetup;
+
+/**
+ * <p>Test case for the exception handling use case.</p>
+ */
+public class ExceptionTestCase extends AbstractTestCase {
+
+
+    // ------------------------------------------------------------ Constructors
+
+
+    // Construct a new instance of this test case.
+    public ExceptionTestCase(String name) {
+        super(name);
+    }
+
+
+    // ---------------------------------------------------- Overall Test Methods
+
+
+    // Set up instance variables required by this test case.
+    public void setUp() throws Exception {
+
+        super.setUp();
+        page("/exception/test.faces");
+
+    }
+
+    // Return the tests included in this test case.
+    public static Test suite() {
+
+        return new CargoTestSetup(new TestSuite(ExceptionTestCase.class));
+
+    }
+
+
+    // Tear down instance variables required by this test case.
+    public void tearDown() {
+
+        super.tearDown();
+
+    }
+
+
+    // ------------------------------------------------------------ Test Methods
+
+
+    /**
+     * <p>Test the "normal" flow of submitting a correctly entered form.</p>
+     */
+    public void testNormal() throws Exception {
+
+        HtmlElement element = null;
+
+        // setUp() should have put us on the page
+        assertEquals("Exception Handling Test", title());
+
+        // Submit the form
+        HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");
+        submit(submit);
+
+        // Validate that we have transferred to the exception handling page
+        assertEquals("Exception Handling - Correct Result", title());
+
+        // Validate the contents of selected fields
+        element = element("form:status_code");
+        assertNotNull(element);
+        assertEquals("200", element.asText());
+        element = element("form:exception_type");
+        assertNotNull(element);
+        assertEquals("org.apache.shale.view.ApplicationException", element.asText());
+
+    }
+
+
+    /**
+     * <p>Validate pristine instance of the "Token" test page.</p>
+     */
+    public void testPristine() throws Exception {
+
+        HtmlForm form = null;
+        HtmlElement messages = null;
+        HtmlSubmitInput submit = null;
+
+        // setUp() should have put us on the page
+        assertEquals("Exception Handling Test", title());
+        form = (HtmlForm) element("form");
+        assertNotNull(form);
+        messages = element("form:messages");
+        // MyFaces 1.1 and the JSF RI 1.1 are inconsistent about whether the
+        // "messages" element is actually created when there are no messages
+//        assertNull(messages);
+        submit = (HtmlSubmitInput) element("form:submit");
+        assertNotNull(submit);
+
+    }
+
+
+}