Author: alexsmirnov
Date: 2008-11-13 20:20:09 -0500 (Thu, 13 Nov 2008)
New Revision: 11160
Added:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
Modified:
trunk/framework/jsf-test/pom.xml
trunk/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
trunk/framework/pom.xml
trunk/samples/seamIntegration/pom.xml
Log:
jsf-test merged from the jsf 2.0 branch.
Modified: trunk/framework/jsf-test/pom.xml
===================================================================
--- trunk/framework/jsf-test/pom.xml 2008-11-14 00:42:12 UTC (rev 11159)
+++ trunk/framework/jsf-test/pom.xml 2008-11-14 01:20:09 UTC (rev 11160)
@@ -25,6 +25,7 @@
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2_10</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>el-impl</groupId>
@@ -90,6 +91,7 @@
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>1.2_10</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2008-11-14
00:42:12 UTC (rev 11159)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2008-11-14
01:20:09 UTC (rev 11160)
@@ -37,16 +37,15 @@
private ClassLoader contextClassLoader;
protected StagingServer facesServer;
-
+
protected StagingConnection connection;
-
+
protected FacesContext facesContext;
protected Lifecycle lifecycle;
protected Application application;
-
/**
* @throws java.lang.Exception
*/
@@ -55,8 +54,8 @@
contextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader());
- InputStream stream = this.getClass()
- .getResourceAsStream("logging.properties");
+ InputStream stream = this.getClass().getResourceAsStream(
+ "logging.properties");
if (null != stream) {
try {
LogManager.getLogManager().readConfiguration(stream);
@@ -75,6 +74,13 @@
setupFacesListener();
setupWebContent();
facesServer.init();
+ ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
+ application = applicationFactory.getApplication();
+ LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ lifecycle = lifecycleFactory
+ .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
}
/**
@@ -101,7 +107,8 @@
} catch (ClassNotFoundException e1) {
throw new TestException("No JSF listeners have been found", e1);
} catch (Exception e2) {
- throw new TestException("Error instantiate MyFaces listener", e2);
+ throw new TestException("Error instantiate MyFaces listener",
+ e2);
}
} catch (Exception e) {
throw new TestException("Error instantiate JSF RI listener", e);
@@ -113,24 +120,25 @@
* @throws InstantiationException
* @throws IllegalAccessException
*/
- protected void setupFacesServlet() {
- ServletContainer facesServletContainer = new ServletContainer("*.jsf", new
FacesServlet());
+ protected void setupFacesServlet() {
+ ServletContainer facesServletContainer = new ServletContainer("*.jsf",
+ new FacesServlet());
facesServletContainer.setName("Faces Servlet");
try {
// Check for an ajax4jsf filter.
Class<? extends Filter> ajaxFilterClass = contextClassLoader
- .loadClass("org.ajax4jsf.Filter")
- .asSubclass(Filter.class);
+ .loadClass("org.ajax4jsf.Filter").asSubclass(Filter.class);
Filter ajaxFilter = ajaxFilterClass.newInstance();
- FilterContainer filterContainer = new
FilterContainer(ajaxFilter,facesServletContainer);
+ FilterContainer filterContainer = new FilterContainer(ajaxFilter,
+ facesServletContainer);
filterContainer.setName("ajax4jsf");
facesServer.addResource("/WEB-INF/web.xml",
- "org/richfaces/test/ajax-web.xml");
+ "org/richfaces/test/ajax-web.xml");
facesServer.addServlet(filterContainer);
} catch (ClassNotFoundException e) {
// No Richfaces filter, uses servlet directly.
facesServer.addResource("/WEB-INF/web.xml",
- "org/richfaces/test/web.xml");
+ "org/richfaces/test/web.xml");
facesServer.addServlet(facesServletContainer);
} catch (Exception e) {
throw new TestException(e);
@@ -143,7 +151,7 @@
}
protected void setupMyFaces() {
- // Do nothing by default.
+ // Do nothing by default.
}
protected void setupSunFaces() {
@@ -151,31 +159,34 @@
facesServer.addInitParameter("com.sun.faces.verifyObjects",
"true");
}
- protected void setupWebContent(){
-
+ protected void setupWebContent() {
+
}
-
-
protected void setupFacesRequest() throws Exception {
- connection = facesServer.getConnection(new
URL("http://localhost/index.jsf"));
+ connection = facesServer.getConnection(new URL(
+ "http://localhost/test.jsf"));
setupConnection(connection);
connection.start();
- ApplicationFactory applicationFactory = (ApplicationFactory)
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- application = applicationFactory.getApplication();
- LifecycleFactory lifecycleFactory = (LifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
- FacesContextFactory facesContextFactory = (FacesContextFactory)
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- facesContext = facesContextFactory.getFacesContext(facesServer.getContext(),
connection.getRequest(), connection.getResponse(), lifecycle);
- facesContext.setViewRoot(setupView());
+ FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ facesContext = facesContextFactory.getFacesContext(facesServer
+ .getContext(), connection.getRequest(), connection
+ .getResponse(), lifecycle);
+ UIViewRoot viewRoot = setupView();
+ if (null != viewRoot) {
+ facesContext.setViewRoot(viewRoot);
+ }
}
-
+
protected UIViewRoot setupView() {
- return null;
+ UIViewRoot viewRoot = (UIViewRoot)
application.createComponent(UIViewRoot.COMPONENT_TYPE);
+ viewRoot.setViewId("/test.xhtml");
+ return viewRoot;
}
protected void setupConnection(StagingConnection connection) {
-
+
}
/**
@@ -183,12 +194,12 @@
*/
@After
public void tearDownServer() throws Exception {
- if(null != facesContext){
+ if (null != facesContext) {
facesContext.release();
facesContext = null;
}
- if(null != connection){
- if(!connection.isFinished()){
+ if (null != connection) {
+ if (!connection.isFinished()) {
connection.finish();
}
connection = null;
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-14
00:42:12 UTC (rev 11159)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-14
01:20:09 UTC (rev 11160)
@@ -25,6 +25,7 @@
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
+import javax.servlet.jsp.JspFactory;
import org.richfaces.test.staging.ClasspathServerResource;
import org.richfaces.test.staging.RequestChain;
@@ -32,9 +33,11 @@
import org.richfaces.test.staging.ServerResourcePath;
import org.richfaces.test.staging.ServerResourcesDirectory;
import org.richfaces.test.staging.ServletContainer;
+import org.richfaces.test.staging.StaggingJspFactory;
import org.richfaces.test.staging.StagingHttpSession;
import org.richfaces.test.staging.StagingServletContext;
import org.richfaces.test.staging.StaticServlet;
+import org.richfaces.test.staging.UrlServerResource;
/**
@@ -191,6 +194,10 @@
serverRoot.addResource(new ServerResourcePath(path), new
ClasspathServerResource(resource));
}
+ public void addResource(String path, URL resource){
+ serverRoot.addResource(new ServerResourcePath(path), new UrlServerResource(resource));
+ }
+
public void addWebListener(EventListener listener) {
contextListeners.add(listener);
}
@@ -228,6 +235,8 @@
public void init() {
// Create context.
this.context = new LocalContext();
+ // Create Jsp factory
+ JspFactory.setDefaultFactory(new StaggingJspFactory());
// Create init parameters
context.addInitParameters(initParameters);
// Inform listeners
@@ -274,7 +283,10 @@
for (RequestChain servlet : servlets) {
servlet.destroy();
}
- defaultServlet.destroy();
+ defaultServlet.destroy();
+ // Create Jsp factory
+ JspFactory.setDefaultFactory(null);
+
}
public StagingConnection getConnection(URL url) {
Copied:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
(from rev 11159,
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java)
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
(rev 0)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java 2008-11-14
01:20:09 UTC (rev 11160)
@@ -0,0 +1,53 @@
+package org.richfaces.test.staging;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Collections;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.richfaces.test.ServerLogger;
+
+public abstract class AbstractServerResource implements ServerResource {
+
+ private static final Logger log = ServerLogger.RESOURCE.getLogger();
+
+ public AbstractServerResource() {
+ }
+
+ public InputStream getAsStream() throws IOException {
+ URL url = getURL();
+ if (url != null) {
+ URLConnection connection = url.openConnection();
+ try {
+ connection.setUseCaches(false);
+ } catch (IllegalArgumentException e) {
+ log.info("RESOURCE_NOT_CACHEABLE");
+ }
+ return connection.getInputStream();
+ } else {
+ return null;
+ }
+ }
+
+ public void addResource(ServerResourcePath path, ServerResource resource) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServerResource getResource(ServerResourcePath path) {
+ if(null == path){
+ throw new NullPointerException();
+ }
+ if(path.isFile()){
+ return this;
+ }
+ return null;
+ }
+
+ public Set<String> getPaths() {
+ return Collections.emptySet();
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java 2008-11-14
00:42:12 UTC (rev 11159)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java 2008-11-14
01:20:09 UTC (rev 11160)
@@ -20,7 +20,7 @@
* @author asmirnov
*
*/
-public class ClasspathServerResource implements ServerResource {
+public class ClasspathServerResource extends AbstractServerResource {
private final String classpath;
@@ -36,53 +36,6 @@
}
/* (non-Javadoc)
- * @see
org.richfaces.test.staging.ServerResource#addResource(org.richfaces.test.staging.ServerResource)
- */
- public void addResource(ServerResourcePath path, ServerResource resource) {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.ServerResource#getResource(org.richfaces.test.staging.ServerResourcePath)
- */
- public ServerResource getResource(ServerResourcePath path) {
- if(null == path){
- throw new NullPointerException();
- }
- if(path.isFile()){
- return this;
- }
- return null;
- }
- /* (non-Javadoc)
- * @see org.richfaces.test.staging.ServerResource#getPaths()
- */
- public Set<String> getPaths() {
- return Collections.emptySet();
- }
-
-
-
- /* (non-Javadoc)
- * @see org.richfaces.test.staging.ServerResource#getAsStream()
- */
- public InputStream getAsStream() throws IOException {
- URL url = getURL();
- if (url != null) {
- URLConnection connection = url.openConnection();
- try {
- connection.setUseCaches(false);
- } catch (IllegalArgumentException e) {
- log.info("RESOURCE_NOT_CACHEABLE");
- }
- return connection.getInputStream();
- } else {
- return null;
- }
- }
-
-
- /* (non-Javadoc)
* @see org.richfaces.test.staging.ServerResource#getURL()
*/
public URL getURL() {
Copied:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
(from rev 11159,
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java)
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
(rev 0)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java 2008-11-14
01:20:09 UTC (rev 11160)
@@ -0,0 +1,47 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import javax.el.ELContextListener;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.servlet.jsp.JspApplicationContext;
+
+import com.sun.el.ExpressionFactoryImpl;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class StaggingJspApplicationContext implements JspApplicationContext {
+
+ private final ExpressionFactory expressionFactory ;
+
+ public StaggingJspApplicationContext() {
+ expressionFactory = ExpressionFactory.newInstance();
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.servlet.jsp.JspApplicationContext#addELContextListener(javax.el.ELContextListener)
+ */
+ public void addELContextListener(ELContextListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.JspApplicationContext#addELResolver(javax.el.ELResolver)
+ */
+ public void addELResolver(ELResolver resolver) {
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.JspApplicationContext#getExpressionFactory()
+ */
+ public ExpressionFactory getExpressionFactory() {
+ return expressionFactory;
+ }
+
+}
Property changes on:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
(from rev 11159,
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java)
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
(rev 0)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java 2008-11-14
01:20:09 UTC (rev 11160)
@@ -0,0 +1,73 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspApplicationContext;
+import javax.servlet.jsp.JspEngineInfo;
+import javax.servlet.jsp.JspFactory;
+import javax.servlet.jsp.PageContext;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class StaggingJspFactory extends JspFactory {
+
+ private static final JspEngineInfo engineInfo = new JspEngineInfo(){
+
+
+ @Override
+ public String getSpecificationVersion() {
+ return "2.1";
+ }
+
+ };
+
+ private final JspApplicationContext context;
+
+ public StaggingJspFactory() {
+ this.context = new StaggingJspApplicationContext();
+ }
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.JspFactory#getEngineInfo()
+ */
+ @Override
+ public JspEngineInfo getEngineInfo() {
+ // TODO Auto-generated method stub
+ return engineInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.servlet.jsp.JspFactory#getJspApplicationContext(javax.servlet.ServletContext)
+ */
+ @Override
+ public JspApplicationContext getJspApplicationContext(ServletContext context) {
+ return this.context;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.JspFactory#getPageContext(javax.servlet.Servlet,
javax.servlet.ServletRequest, javax.servlet.ServletResponse, java.lang.String, boolean,
int, boolean)
+ */
+ @Override
+ public PageContext getPageContext(Servlet servlet, ServletRequest request,
+ ServletResponse response, String errorPageURL,
+ boolean needsSession, int buffer, boolean autoflush) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.JspFactory#releasePageContext(javax.servlet.jsp.PageContext)
+ */
+ @Override
+ public void releasePageContext(PageContext pc) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
(from rev 11159,
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java)
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
(rev 0)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java 2008-11-14
01:20:09 UTC (rev 11160)
@@ -0,0 +1,12 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class URLScanner {
+
+}
Property changes on:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
(from rev 11159,
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java)
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
(rev 0)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java 2008-11-14
01:20:09 UTC (rev 11160)
@@ -0,0 +1,32 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import java.net.URL;
+import java.util.logging.Logger;
+
+import org.richfaces.test.ServerLogger;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class UrlServerResource extends AbstractServerResource {
+
+ private final URL resource;
+
+ static final Logger log = ServerLogger.RESOURCE.getLogger();
+
+ public UrlServerResource(URL resource) {
+ this.resource = resource;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.ServerResource#getURL()
+ */
+ public URL getURL() {
+ return resource;
+ }
+
+}
Property changes on:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/framework/pom.xml
===================================================================
--- trunk/framework/pom.xml 2008-11-14 00:42:12 UTC (rev 11159)
+++ trunk/framework/pom.xml 2008-11-14 01:20:09 UTC (rev 11160)
@@ -118,5 +118,6 @@
<module>api</module>
<module>impl</module>
<module>test</module>
+ <module>jsf-test</module>
</modules>
</project>
\ No newline at end of file
Modified: trunk/samples/seamIntegration/pom.xml
===================================================================
--- trunk/samples/seamIntegration/pom.xml 2008-11-14 00:42:12 UTC (rev 11159)
+++ trunk/samples/seamIntegration/pom.xml 2008-11-14 01:20:09 UTC (rev 11160)
@@ -13,7 +13,7 @@
<packaging>war</packaging>
<name>seamIntegration Maven Webapp</name>
<properties>
- <seam.version>2.1.0-SNAPSHOT</seam.version>
+ <seam.version>2.1.1-SNAPSHOT</seam.version>
</properties>
<build>
<finalName>seamIntegration</finalName>