Author: alexsmirnov
Date: 2008-10-31 14:28:55 -0400 (Fri, 31 Oct 2008)
New Revision: 10995
Added:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/stub/NotImplementedException.java
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/faces-config.xml
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/hello.xhtml
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/logging.properties
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/LocalServer.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/ServerConnection.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/stub/ServletContainer.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/web.xml
Log:
set logging leval to all
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/LocalServer.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/LocalServer.java 2008-10-31
17:20:55 UTC (rev 10994)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/LocalServer.java 2008-10-31
18:28:55 UTC (rev 10995)
@@ -29,6 +29,7 @@
*/
public class LocalServer {
+
private List<ServletContainer> servlets = new
ArrayList<ServletContainer>();
private ServletContainer defaultServlet;
@@ -93,7 +94,11 @@
for (ServletContextListener listener : contextListeners) {
listener.contextDestroyed(new ServletContextEvent(context));
}
-
+ // Destroy servlets
+ for (ServletContainer servlet : servlets) {
+ servlet.destroy();
+ }
+ defaultServlet.destroy();
}
public ServerConnection getConnection(URL url) {
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/ServerConnection.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/ServerConnection.java 2008-10-31
17:20:55 UTC (rev 10994)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/ServerConnection.java 2008-10-31
18:28:55 UTC (rev 10995)
@@ -4,6 +4,7 @@
package org.richfaces.test;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
@@ -102,6 +103,27 @@
requestParameters.put(name, values);
}
+ public String getRenderedContent() {
+ String content = response.getWriterContent();
+ if(null == content){
+ byte[] streamContent = response.getStreamContent();
+ if(null!= streamContent){
+ String encoding = response.getCharacterEncoding();
+ if(null != encoding){
+ try {
+ content = new String(streamContent,encoding);
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ }
+ } else {
+ content = new String(streamContent);
+ }
+ }
+ }
+ return content;
+ }
+
+
/**
* @return the cookies
*/
Added:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/stub/NotImplementedException.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/stub/NotImplementedException.java
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/stub/NotImplementedException.java 2008-10-31
18:28:55 UTC (rev 10995)
@@ -0,0 +1,44 @@
+/**
+ *
+ */
+package org.richfaces.test.stub;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class NotImplementedException extends RuntimeException {
+
+ /**
+ *
+ */
+ public NotImplementedException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public NotImplementedException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public NotImplementedException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public NotImplementedException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/stub/ServletContainer.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/stub/ServletContainer.java 2008-10-31
17:20:55 UTC (rev 10994)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/stub/ServletContainer.java 2008-10-31
18:28:55 UTC (rev 10995)
@@ -6,19 +6,24 @@
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
+import java.util.logging.Logger;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import org.richfaces.test.ServerLogger;
+
/**
* @author asmirnov
*
*/
public class ServletContainer {
+ private static final Logger log = ServerLogger.SERVER.getLogger();
+
private final Servlet servlet;
private final boolean prefixMapped;
@@ -94,4 +99,8 @@
this.servlet.service(request, response);
}
+
+ public void destroy() {
+ this.servlet.destroy();
+ }
}
Modified:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java 2008-10-31
17:20:55 UTC (rev 10994)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java 2008-10-31
18:28:55 UTC (rev 10995)
@@ -5,9 +5,15 @@
import static org.junit.Assert.*;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
import javax.faces.webapp.FacesServlet;
import org.junit.After;
@@ -17,26 +23,46 @@
import org.junit.Test;
import com.sun.faces.config.ConfigureListener;
+import com.sun.faces.util.FacesLogger;
/**
* @author asmirnov
- *
+ *
*/
public class FacesServerTest {
private static ClassLoader contextClassLoader;
-
+
private static LocalServer facesServer;
+
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
contextClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(LocalServer.class.getClassLoader());
+ Thread.currentThread().setContextClassLoader(
+ LocalServer.class.getClassLoader());
+ InputStream stream = FacesServerTest.class
+ .getResourceAsStream("logging.properties");
+ if (null != stream) {
+ try {
+ LogManager.getLogManager().readConfiguration(stream);
+ } finally {
+ stream.close();
+ }
+ }
facesServer = new LocalServer();
facesServer.addServlet("*.jsf", new FacesServlet());
- facesServer.addResource("/WEB-INF/web.xml",
"org/richfaces/test/web.xml");
+ facesServer.addResource("/WEB-INF/web.xml",
+ "org/richfaces/test/web.xml");
+ facesServer.addResource("/WEB-INF/faces-config.xml",
+ "org/richfaces/test/faces-config.xml");
+ facesServer.addResource("/hello.xhml",
"org/richfaces/test/hello.xhml");
+ facesServer.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME,
StateManager.STATE_SAVING_METHOD_SERVER);
+ facesServer.addInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME,
".xhtml");
+ facesServer.addInitParameter("com.sun.faces.validateXml", "true");
+ facesServer.addInitParameter("com.sun.faces.verifyObjects",
"true");
facesServer.addContextListener(new ConfigureListener());
facesServer.init();
}
@@ -65,13 +91,17 @@
}
/**
- * Test method for {@link org.richfaces.test.LocalServer#getConnection(java.net.URL)}.
- * @throws Exception
+ * Test method for
+ * {@link org.richfaces.test.LocalServer#getConnection(java.net.URL)}.
+ *
+ * @throws Exception
*/
@Test
public void testGetConnection() throws Exception {
- ServerConnection connection = facesServer.getConnection(new
URL("http://localhost/index.jsf"));
+ ServerConnection connection = facesServer.getConnection(new URL(
+ "http://localhost/hello.jsf"));
connection.execute();
+ System.out.println(connection.getRenderedContent());
}
}
Added:
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/faces-config.xml
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/faces-config.xml
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/faces-config.xml 2008-10-31
18:28:55 UTC (rev 10995)
@@ -0,0 +1,69 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+ Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+
+ The contents of this file are subject to the terms of either the GNU
+ General Public License Version 2 only ("GPL") or the Common Development
+ and Distribution License("CDDL") (collectively, the "License").
You
+ may not use this file except in compliance with the License. You can obtain
+ a copy of the License at
https://glassfish.dev.java.net/public/CDDL+GPL.html
+ or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ When distributing the software, include this License Header Notice in each
+ file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ Sun designates this particular file as subject to the "Classpath" exception
+ as provided by Sun in the GPL Version 2 section of the License file that
+ accompanied this code. If applicable, add the following below the License
+ Header, with the fields enclosed by brackets [] replaced by your own
+ identifying information: "Portions Copyrighted [year]
+ [name of copyright owner]"
+
+ Contributor(s):
+
+ If you wish your version of this file to be governed by only the CDDL or
+ only the GPL Version 2, indicate your decision by adding "[Contributor]
+ elects to include this software in this distribution under the [CDDL or GPL
+ Version 2] license." If you don't indicate a single choice of license, a
+ recipient has the option to distribute your version of this file under
+ either the CDDL, the GPL Version 2 or to extend the choice of license to
+ its licensees as provided above. However, if you add GPL Version 2 code
+ and therefore, elected the GPL Version 2 license, then the option applies
+ only if the new code is made subject to such option by the copyright
+ holder.
+-->
+
+<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <!-- our NumberBean we created before -->
+ <managed-bean>
+ <managed-bean-name>HelloBean</managed-bean-name>
+ <managed-bean-class>helloFacelet.HelloBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
+ <!-- going from guess.xhtml to response.xhtml -->
+ <navigation-rule>
+ <from-view-id>/hello.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/response.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <!-- going from response.xhtml to guess.xhtml -->
+ <navigation-rule>
+ <from-view-id>/response.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/hello.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+</faces-config>
Added:
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/hello.xhtml
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/hello.xhtml
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/hello.xhtml 2008-10-31
18:28:55 UTC (rev 10995)
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html">
+
+ <body bgcolor="white">
+ <h2>My name is Duke. What is yours?</h2>
+ <h:form id="helloForm" >
+ <h:graphicImage id="waveImg" url="/wave.med.gif"
/>
+ <h:inputText id="username"
+ value="#{HelloBean.name}"/>
+ <h:commandButton id="submit" action="success"
value="Submit"
+ type="submit" />
+ </h:form>
+ </body>
+</html>
\ No newline at end of file
Added:
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/logging.properties
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/logging.properties
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/logging.properties 2008-10-31
18:28:55 UTC (rev 10995)
@@ -0,0 +1,21 @@
+handlers java.util.logging.ConsoleHandler
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+java.util.logging.ConsoleHandler.level ALL
+java.util.logging.ConsoleHandler.formatter java.util.logging.SimpleFormatter
+
+facelets.level=ALL
+com.sun.faces.level=ALL
+javax.faces.level=ALL
+org.apache.myfaces.level=INFO
+org.ajax4jsf.io.level=ERROR
+org.ajax4jsf.webapp.level=ALL
+org.ajax4jsf.application.level=ALL
+org.ajax4jsf.context.level=ALL
+javax.enterprise.resource.webcontainer.jsf.level=ALL
+org.richfaces.level=ALL
+
\ No newline at end of file
Modified:
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/web.xml
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/web.xml 2008-10-31
17:20:55 UTC (rev 10994)
+++
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/web.xml 2008-10-31
18:28:55 UTC (rev 10995)
@@ -13,6 +13,31 @@
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>com.sun.faces.validateXml</param-name>
+ <param-value>true</param-value>
+ <description>
+ Set this flag to true if you want the JavaServer Faces
+ Reference Implementation to validate the XML in your
+ faces-config.xml resources against the DTD. Default
+ value is false.
+ </description>
+ </context-param>
+ <context-param>
+ <param-name>com.sun.faces.verifyObjects</param-name>
+ <param-value>true</param-value>
+ <description>
+ Set this flag to true if you want the JavaServer Faces
+ Reference Implementation to verify that all of the application
+ objects you have configured (components, converters,
+ renderers, and validators) can be successfully created.
+ Default value is false.
+ </description>
+ </context-param>
<!-- Faces Servlet -->
<servlet>