[jboss-cvs] JBossAS SVN: r59998 - branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 25 09:06:44 EST 2007
Author: stan.silvert at jboss.com
Date: 2007-01-25 09:06:44 -0500 (Thu, 25 Jan 2007)
New Revision: 59998
Modified:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java
Log:
Update JUnit test for JSF 1.2
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java 2007-01-25 13:50:59 UTC (rev 59997)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/web/test/JSFIntegrationUnitTestCase.java 2007-01-25 14:06:44 UTC (rev 59998)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
package org.jboss.test.web.test;
//import java.net.HttpURLConnection;
@@ -31,8 +31,9 @@
import org.jboss.test.JBossTestCase;
import org.jboss.test.JBossTestSetup;
import org.jboss.test.util.web.HttpUtils;
-//import org.apache.commons.httpclient.HttpMethodBase;
-//import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.methods.GetMethod;
/** Tests of JSF integration into the JBoss server. This test
requires than a web container and JSF implementation be integrated
@@ -47,24 +48,51 @@
*/
public class JSFIntegrationUnitTestCase extends JBossTestCase
{
- private static String REALM = "JBossTest Servlets";
private String baseURL = HttpUtils.getBaseURL();
- private String baseURLNoAuth = HttpUtils.getBaseURLNoAuth();
+ private HttpClient client = new HttpClient();
public JSFIntegrationUnitTestCase(String name)
{
super(name);
}
- /** Access the http://localhost/jbosstest/index.faces to make
- * sure that JSF and its tag libraries are integrated.
+ /** Access the http://localhost/jbosstest-jsf/index.jsf.
*/
public void testJSFIntegrated() throws Exception
{
- URL url = new URL(baseURL+"jbosstest-jsf/index.faces");
- HttpUtils.accessURL(url);
+ client.executeMethod(makeRequest());
+
+ HttpMethodBase result = makeRequest();
+
+ // need to hit it twice with the same session for test to pass
+ client.executeMethod(result);
+
+ String responseBody = result.getResponseBodyAsString();
+ if (responseBody == null) {
+ throw new Exception("Unable to get response from server.");
+ }
+
+ assertTrue(contains(responseBody, "@PostConstruct was called."));
+ assertTrue(contains(responseBody, "@PreDestroy was called."));
+ assertTrue(contains(responseBody, "Datasource was injected."));
+
+ // Tests JSF/JSTL integration
+ assertTrue(contains(responseBody, "number one"));
+ assertTrue(contains(responseBody, "number two"));
+ assertTrue(contains(responseBody, "number three"));
+
+ // Tests enum support
+ assertTrue(contains(responseBody, "JBoss Color selection is PURPLE"));
}
+ private boolean contains(String base, String target) {
+ return base.indexOf(target) != -1;
+ }
+
+ private GetMethod makeRequest() {
+ return new GetMethod(baseURL+"jbosstest-jsf/index.jsf");
+ }
+
public static Test suite() throws Exception
{
TestSuite suite = new TestSuite();
More information about the jboss-cvs-commits
mailing list