JBoss Rich Faces SVN: r11160 - in trunk: framework/jsf-test and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
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>
16 years, 10 months
JBoss Rich Faces SVN: r11159 - in branches/jsf2.0: framework/jsf-test/src/main/java/org/richfaces/test/staging and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-11-13 19:42:12 -0500 (Thu, 13 Nov 2008)
New Revision: 11159
Added:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
Removed:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
branches/jsf2.0/tests/ajax/pom.xml
Log:
rename stub package to staging.
Test resources search.
Modified: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-13 23:58:13 UTC (rev 11158)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -37,6 +37,7 @@
import org.richfaces.test.staging.StagingHttpSession;
import org.richfaces.test.staging.StagingServletContext;
import org.richfaces.test.staging.StaticServlet;
+import org.richfaces.test.staging.UrlServerResource;
/**
@@ -193,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);
}
Added: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -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: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java 2008-11-13 23:58:13 UTC (rev 11158)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -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() {
Added: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -0,0 +1,12 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class URLScanner {
+
+}
Property changes on: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -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: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging (from rev 11094, branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub)
Deleted: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServerResourcePathTest.java 2008-11-11 20:12:38 UTC (rev 11094)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -1,87 +0,0 @@
-/**
- *
- */
-package org.richfaces.test.stub;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-/**
- * @author asmirnov
- *
- */
-public class ServerResourcePathTest {
-
- /**
- * Test method for {@link org.richfaces.test.stub.ServerResourcePath#ServerResourcePath(java.lang.String)}.
- */
- @Test
- public void testRootPath() {
- ServerResourcePath path = new ServerResourcePath("/");
- assertNull(path.getNextPath());
- assertNull(path.getNextElementName());
- assertTrue(path.isFile());
- assertEquals("/", path.toString());
- }
-
- /**
- * Test method for {@link org.richfaces.test.stub.ServerResourcePath#ServerResourcePath(java.lang.String)}.
- */
- @Test
- public void testWebInfPath() {
- ServerResourcePath path = ServerResourcePath.WEB_INF;
- assertNotNull(path.getNextPath());
- assertNotNull(path.getNextElementName());
- assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
- assertEquals("/WEB-INF", path.toString());
- path = path.getNextPath();
- assertNotNull(path);
- assertTrue(path.isFile());
- path = path.getNextPath();
- assertNull(path);
- }
-
- /**
- * Test method for {@link org.richfaces.test.stub.ServerResourcePath#ServerResourcePath(java.lang.String)}.
- */
- @Test
- public void testWebInfTrainingSlashPath() {
- ServerResourcePath path = new ServerResourcePath("/WEB-INF/");
- assertNotNull(path.getNextPath());
- assertNotNull(path.getNextElementName());
- assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
- assertEquals("/WEB-INF", path.toString());
- path = path.getNextPath();
- assertNotNull(path);
- assertTrue(path.isFile());
- path = path.getNextPath();
- assertNull(path);
- }
-
-
- /**
- * Test method for {@link org.richfaces.test.stub.ServerResourcePath#ServerResourcePath(java.lang.String)}.
- */
- @Test
- public void testWebXmlPath() {
- ServerResourcePath path = ServerResourcePath.WEB_XML;
- assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
- assertEquals("/WEB-INF/web.xml", path.toString());
- path = path.getNextPath();
- assertNotNull(path.getNextElementName());
- assertFalse(path.isFile());
- assertEquals("web.xml", path.getNextElementName());
- assertEquals("/web.xml", path.toString());
- path = path.getNextPath();
- assertNotNull(path);
- assertTrue(path.isFile());
- path = path.getNextPath();
- assertNull(path);
- }
-
-
-}
Copied: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java (from rev 11158, branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServerResourcePathTest.java)
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.richfaces.test.staging.ServerResourcePath;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ServerResourcePathTest {
+
+ /**
+ * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+ */
+ @Test
+ public void testRootPath() {
+ ServerResourcePath path = new ServerResourcePath("/");
+ assertNull(path.getNextPath());
+ assertNull(path.getNextElementName());
+ assertTrue(path.isFile());
+ assertEquals("/", path.toString());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+ */
+ @Test
+ public void testWebInfPath() {
+ ServerResourcePath path = ServerResourcePath.WEB_INF;
+ assertNotNull(path.getNextPath());
+ assertNotNull(path.getNextElementName());
+ assertFalse(path.isFile());
+ assertEquals("WEB-INF", path.getNextElementName());
+ assertEquals("/WEB-INF", path.toString());
+ path = path.getNextPath();
+ assertNotNull(path);
+ assertTrue(path.isFile());
+ path = path.getNextPath();
+ assertNull(path);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+ */
+ @Test
+ public void testWebInfTrainingSlashPath() {
+ ServerResourcePath path = new ServerResourcePath("/WEB-INF/");
+ assertNotNull(path.getNextPath());
+ assertNotNull(path.getNextElementName());
+ assertFalse(path.isFile());
+ assertEquals("WEB-INF", path.getNextElementName());
+ assertEquals("/WEB-INF", path.toString());
+ path = path.getNextPath();
+ assertNotNull(path);
+ assertTrue(path.isFile());
+ path = path.getNextPath();
+ assertNull(path);
+ }
+
+
+ /**
+ * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+ */
+ @Test
+ public void testWebXmlPath() {
+ ServerResourcePath path = ServerResourcePath.WEB_XML;
+ assertFalse(path.isFile());
+ assertEquals("WEB-INF", path.getNextElementName());
+ assertEquals("/WEB-INF/web.xml", path.toString());
+ path = path.getNextPath();
+ assertNotNull(path.getNextElementName());
+ assertFalse(path.isFile());
+ assertEquals("web.xml", path.getNextElementName());
+ assertEquals("/web.xml", path.toString());
+ path = path.getNextPath();
+ assertNotNull(path);
+ assertTrue(path.isFile());
+ path = path.getNextPath();
+ assertNull(path);
+ }
+
+
+}
Deleted: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServerResourceTest.java 2008-11-11 20:12:38 UTC (rev 11094)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -1,141 +0,0 @@
-/**
- *
- */
-package org.richfaces.test.stub;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Set;
-
-import org.junit.Test;
-
-/**
- * @author asmirnov
- *
- */
-public class ServerResourceTest {
-
- private class MockResource implements ServerResource {
-
- public void addResource(ServerResourcePath path, ServerResource resource) {
- }
-
- public InputStream getAsStream() throws IOException {
- return null;
- }
-
- public Set<String> getPaths() {
- return null;
- }
-
- public ServerResource getResource(ServerResourcePath path) {
- if (null != path && path.isFile()) {
- return this;
- }
- return null;
- }
-
- public URL getURL() {
- return null;
- }
-
- }
-
- /**
- * Test method for
- * {@link org.richfaces.test.stub.ServerResourcesDirectory#addResource(org.richfaces.test.stub.ServerResourcePath, org.richfaces.test.stub.ServerResource)}
- * .
- */
- @Test
- public void testAddResource() {
- ServerResourcesDirectory root = new ServerResourcesDirectory();
- MockResource webXml = new MockResource();
- root.addResource(ServerResourcePath.WEB_XML, webXml);
- assertEquals(1, root.getPaths().size());
- MockResource facesConfig = new MockResource();
- root.addResource(ServerResourcePath.FACES_CONFIG, facesConfig);
- assertEquals(1, root.getPaths().size());
- ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
- assertNotNull(webInf);
- assertEquals(2, webInf.getPaths().size());
- assertSame(webXml, webInf
- .getResource(new ServerResourcePath("/web.xml")));
- assertSame(facesConfig, webInf.getResource(new ServerResourcePath(
- "/faces-config.xml")));
- }
-
- /**
- * Test method for
- * {@link org.richfaces.test.stub.ServerResourcesDirectory#getResource(org.richfaces.test.stub.ServerResourcePath)}
- * .
- */
- @Test
- public void testGetResource() {
- ServerResourcesDirectory root = new ServerResourcesDirectory();
- MockResource webXml = new MockResource();
- root.addResource(ServerResourcePath.WEB_XML, webXml);
- ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
- assertNotNull(webInf);
- assertNull(root.getResource(new ServerResourcePath("/foo")));
- assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
- assertEquals(1, root.getPaths().size());
- assertNull(root.getResource(new ServerResourcePath(
- "/WEB-INF/web.xml/foo")));
- assertSame(webXml, webInf.getResource(new ServerResourcePath(
- "/web.xml")));
- }
-
- /**
- * Test method for
- * {@link org.richfaces.test.stub.ServerResourcesDirectory#getResource(org.richfaces.test.stub.ServerResourcePath)}
- * .
- */
- @Test
- public void testGetResourceRoot() {
- ServerResourcesDirectory root = new ServerResourcesDirectory();
- MockResource indexXhtml = new MockResource();
- root.addResource(new ServerResourcePath("/index.xhtml"), indexXhtml);
- ServerResource index = root.getResource(new ServerResourcePath("/index.xhtml"));
- assertNotNull(index);
- assertNull(root.getResource(new ServerResourcePath("/foo")));
- assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
- assertEquals(1, root.getPaths().size());
- }
-
- /**
- * Test method for
- * {@link org.richfaces.test.stub.ServerResourcesDirectory#getAsStream()}.
- *
- * @throws IOException
- */
- @Test
- public void testGetAsStream() throws IOException {
- ClasspathServerResource resource = new ClasspathServerResource(
- "org/richfaces/test/resource.txt");
- InputStream inputStream = resource.getAsStream();
- assertNotNull(inputStream);
- try {
- byte[] buff = new byte[20];
- assertEquals(3, inputStream.read(buff));
-
- } finally {
- inputStream.close();
- }
- }
-
-
- /**
- * Test method for
- * {@link org.richfaces.test.stub.ServerResourcesDirectory#getURL()}.
- */
- @Test
- public void testGetURL() {
- ClasspathServerResource resource = new ClasspathServerResource(
- "org/richfaces/test/resource.txt");
- assertNotNull(resource.getURL());
- }
-
-}
Copied: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java (from rev 11158, branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServerResourceTest.java)
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -0,0 +1,145 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Set;
+
+import org.junit.Test;
+import org.richfaces.test.staging.ClasspathServerResource;
+import org.richfaces.test.staging.ServerResource;
+import org.richfaces.test.staging.ServerResourcePath;
+import org.richfaces.test.staging.ServerResourcesDirectory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ServerResourceTest {
+
+ private class MockResource implements ServerResource {
+
+ public void addResource(ServerResourcePath path, ServerResource resource) {
+ }
+
+ public InputStream getAsStream() throws IOException {
+ return null;
+ }
+
+ public Set<String> getPaths() {
+ return null;
+ }
+
+ public ServerResource getResource(ServerResourcePath path) {
+ if (null != path && path.isFile()) {
+ return this;
+ }
+ return null;
+ }
+
+ public URL getURL() {
+ return null;
+ }
+
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.test.staging.ServerResourcesDirectory#addResource(org.richfaces.test.staging.ServerResourcePath, org.richfaces.test.staging.ServerResource)}
+ * .
+ */
+ @Test
+ public void testAddResource() {
+ ServerResourcesDirectory root = new ServerResourcesDirectory();
+ MockResource webXml = new MockResource();
+ root.addResource(ServerResourcePath.WEB_XML, webXml);
+ assertEquals(1, root.getPaths().size());
+ MockResource facesConfig = new MockResource();
+ root.addResource(ServerResourcePath.FACES_CONFIG, facesConfig);
+ assertEquals(1, root.getPaths().size());
+ ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
+ assertNotNull(webInf);
+ assertEquals(2, webInf.getPaths().size());
+ assertSame(webXml, webInf
+ .getResource(new ServerResourcePath("/web.xml")));
+ assertSame(facesConfig, webInf.getResource(new ServerResourcePath(
+ "/faces-config.xml")));
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.test.staging.ServerResourcesDirectory#getResource(org.richfaces.test.staging.ServerResourcePath)}
+ * .
+ */
+ @Test
+ public void testGetResource() {
+ ServerResourcesDirectory root = new ServerResourcesDirectory();
+ MockResource webXml = new MockResource();
+ root.addResource(ServerResourcePath.WEB_XML, webXml);
+ ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
+ assertNotNull(webInf);
+ assertNull(root.getResource(new ServerResourcePath("/foo")));
+ assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
+ assertEquals(1, root.getPaths().size());
+ assertNull(root.getResource(new ServerResourcePath(
+ "/WEB-INF/web.xml/foo")));
+ assertSame(webXml, webInf.getResource(new ServerResourcePath(
+ "/web.xml")));
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.test.staging.ServerResourcesDirectory#getResource(org.richfaces.test.staging.ServerResourcePath)}
+ * .
+ */
+ @Test
+ public void testGetResourceRoot() {
+ ServerResourcesDirectory root = new ServerResourcesDirectory();
+ MockResource indexXhtml = new MockResource();
+ root.addResource(new ServerResourcePath("/index.xhtml"), indexXhtml);
+ ServerResource index = root.getResource(new ServerResourcePath("/index.xhtml"));
+ assertNotNull(index);
+ assertNull(root.getResource(new ServerResourcePath("/foo")));
+ assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
+ assertEquals(1, root.getPaths().size());
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.test.staging.ServerResourcesDirectory#getAsStream()}.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testGetAsStream() throws IOException {
+ ClasspathServerResource resource = new ClasspathServerResource(
+ "org/richfaces/test/resource.txt");
+ InputStream inputStream = resource.getAsStream();
+ assertNotNull(inputStream);
+ try {
+ byte[] buff = new byte[20];
+ assertEquals(3, inputStream.read(buff));
+
+ } finally {
+ inputStream.close();
+ }
+ }
+
+
+ /**
+ * Test method for
+ * {@link org.richfaces.test.staging.ServerResourcesDirectory#getURL()}.
+ */
+ @Test
+ public void testGetURL() {
+ ClasspathServerResource resource = new ClasspathServerResource(
+ "org/richfaces/test/resource.txt");
+ assertNotNull(resource.getURL());
+ }
+
+}
Deleted: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServletTest.java 2008-11-11 20:12:38 UTC (rev 11094)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -1,87 +0,0 @@
-package org.richfaces.test.stub;
-
-import static org.junit.Assert.*;
-
-import javax.servlet.ServletContextAttributeEvent;
-import javax.servlet.ServletException;
-
-import org.junit.Test;
-
-public class ServletTest {
-
- @Test
- public void testIsApplicable() {
- StaticServlet staticServlet = new StaticServlet();
- ServletContainer servlet = new ServletContainer("/foo/*",staticServlet);
- assertTrue(servlet.isApplicable("/foo/bar.jsf"));
- assertFalse(servlet.isApplicable("/foz/bar.jsf"));
- assertFalse(servlet.isApplicable("bar"));
- servlet = new ServletContainer("*.jsf",staticServlet);
- assertTrue(servlet.isApplicable("/foo/bar.jsf"));
- assertFalse(servlet.isApplicable("bar"));
- try {
- servlet = new ServletContainer(".jsf",staticServlet);
- } catch (IllegalArgumentException e) {
- return;
- }
- assertFalse(true);
- }
-
- @Test
- public void testGetServletPath() {
- StaticServlet staticServlet = new StaticServlet();
- ServletContainer servlet = new ServletContainer("/foo/*",staticServlet);
- assertEquals("/foo/", servlet.getServletPath("/foo/bar.jsf"));
- assertNull(servlet.getServletPath("/foz/bar.jsf"));
- servlet = new ServletContainer("*.jsf",staticServlet);
- assertEquals("/foo/bar.jsf", servlet.getServletPath("/foo/bar.jsf"));
- }
-
- @Test
- public void testGetPathInfo() {
- StaticServlet staticServlet = new StaticServlet();
- ServletContainer servlet = new ServletContainer("/foo/*",staticServlet);
- assertEquals("bar.jsf", servlet.getPathInfo("/foo/bar.jsf"));
- assertNull(servlet.getPathInfo("/foz/bar.jsf"));
- servlet = new ServletContainer("*.jsf",staticServlet);
- assertNull(servlet.getPathInfo("/foo/bar.jsf"));
-
- }
-
- @Test
- public void testInit() throws ServletException {
- StaticServlet staticServlet = new StaticServlet();
- ServletContainer servlet = new ServletContainer("/foo/*",staticServlet);
- StubServletContext context = new StubServletContext(){
-
- @Override
- protected ServerResource getServerResource(String path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected void valueBound(ServletContextAttributeEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void valueReplaced(ServletContextAttributeEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void valueUnbound(
- ServletContextAttributeEvent servletContextAttributeEvent) {
- // TODO Auto-generated method stub
-
- }
-
- };
- servlet.init(context);
- assertSame(context,staticServlet.getServletContext());
- }
-
-}
Copied: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java (from rev 11158, branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServletTest.java)
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -0,0 +1,92 @@
+package org.richfaces.test.staging;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletException;
+
+import org.junit.Test;
+import org.richfaces.test.staging.RequestChain;
+import org.richfaces.test.staging.ServerResource;
+import org.richfaces.test.staging.ServletContainer;
+import org.richfaces.test.staging.StaticServlet;
+import org.richfaces.test.staging.StagingServletContext;
+
+public class ServletTest {
+
+ @Test
+ public void testIsApplicable() {
+ StaticServlet staticServlet = new StaticServlet();
+ RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
+ assertTrue(servlet.isApplicable("/foo/bar.jsf"));
+ assertFalse(servlet.isApplicable("/foz/bar.jsf"));
+ assertFalse(servlet.isApplicable("bar"));
+ servlet = new ServletContainer("*.jsf",staticServlet);
+ assertTrue(servlet.isApplicable("/foo/bar.jsf"));
+ assertFalse(servlet.isApplicable("bar"));
+ try {
+ servlet = new ServletContainer(".jsf",staticServlet);
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+ assertFalse(true);
+ }
+
+ @Test
+ public void testGetServletPath() {
+ StaticServlet staticServlet = new StaticServlet();
+ RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
+ assertEquals("/foo/", servlet.getServletPath("/foo/bar.jsf"));
+ assertNull(servlet.getServletPath("/foz/bar.jsf"));
+ servlet = new ServletContainer("*.jsf",staticServlet);
+ assertEquals("/foo/bar.jsf", servlet.getServletPath("/foo/bar.jsf"));
+ }
+
+ @Test
+ public void testGetPathInfo() {
+ StaticServlet staticServlet = new StaticServlet();
+ RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
+ assertEquals("bar.jsf", servlet.getPathInfo("/foo/bar.jsf"));
+ assertNull(servlet.getPathInfo("/foz/bar.jsf"));
+ servlet = new ServletContainer("*.jsf",staticServlet);
+ assertNull(servlet.getPathInfo("/foo/bar.jsf"));
+
+ }
+
+ @Test
+ public void testInit() throws ServletException {
+ StaticServlet staticServlet = new StaticServlet();
+ RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
+ StagingServletContext context = new StagingServletContext(){
+
+ @Override
+ protected ServerResource getServerResource(String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void valueBound(ServletContextAttributeEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void valueReplaced(ServletContextAttributeEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void valueUnbound(
+ ServletContextAttributeEvent servletContextAttributeEvent) {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+ servlet.init(context);
+ assertSame(context,staticServlet.getServletContext());
+ }
+
+}
Added: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java 2008-11-14 00:42:12 UTC (rev 11159)
@@ -0,0 +1,76 @@
+package org.richfaces.test.staging;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.junit.Test;
+
+public class UrlResourceLoadingTest {
+
+ @Test
+ public void testGetURL() throws Exception {
+ URL resource = this.getClass().getClassLoader().getResource("java/util/Set.class");
+ assertNotNull(resource);
+ System.out.println(resource.toExternalForm());
+ System.out.println(resource.getProtocol());
+ String path = resource.getPath();
+ System.out.println(path);
+ String entry = path.substring(path.indexOf('!')+2);
+ path = path.substring(0,path.indexOf('!'));
+ System.out.println(path+" entry: "+entry);
+ File file = new File(new URI(path));
+ ZipFile zip = new ZipFile(file);
+ ZipEntry zipEntry = zip.getEntry(entry);
+ assertNotNull(zipEntry);
+ Enumeration<? extends ZipEntry> entries = zip.entries();
+ entry = entry.substring(0, entry.lastIndexOf('/')+1);
+ while (entries.hasMoreElements()) {
+ ZipEntry zzz = (ZipEntry) entries.nextElement();
+ if(zzz.getName().startsWith(entry) && !zzz.isDirectory()){
+ String relativePath = zzz.getName().substring(entry.length());
+ System.out.println(" entry: "+relativePath);
+ URL relativeResource = new URL(resource,relativePath);
+ System.out.println(relativeResource.toExternalForm());
+
+ }
+ }
+ resource = this.getClass().getClassLoader().getResource("org/richfaces/test/HelloBean.class");
+ assertNotNull(resource);
+ System.out.println(resource.toExternalForm());
+ System.out.println(resource.getProtocol());
+ System.out.println(resource.getPath());
+ System.out.println(resource.toExternalForm());
+ file = new File(resource.getPath());
+ if(!file.isDirectory()){
+ file = file.getParentFile();
+ }
+ listFiles("/",file);
+ resource = this.getClass().getClassLoader().getResource("org/richfaces/test/");
+ assertNotNull(resource);
+ System.out.println(resource.toExternalForm());
+ }
+
+ private void listFiles(String path,File file) {
+ File[] files = file.listFiles();
+ for (File subfile : files) {
+ if(subfile.isDirectory()){
+ listFiles(path+subfile.getName()+"/",subfile);
+ } else {
+ System.out.println(path+subfile.getName());
+
+ }
+ }
+ }
+
+ @Test
+ public void testGetDirectory() {
+ }
+
+}
Property changes on: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jsf2.0/tests/ajax/pom.xml
===================================================================
--- branches/jsf2.0/tests/ajax/pom.xml 2008-11-13 23:58:13 UTC (rev 11158)
+++ branches/jsf2.0/tests/ajax/pom.xml 2008-11-14 00:42:12 UTC (rev 11159)
@@ -79,5 +79,11 @@
<version>2.0.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>jstl</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
16 years, 10 months
JBoss Rich Faces SVN: r11158 - trunk/framework/test/src/main/java/org/ajax4jsf/tests.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-13 18:58:13 -0500 (Thu, 13 Nov 2008)
New Revision: 11158
Modified:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
Log:
Changes from previous revision reverted
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2008-11-13 22:34:03 UTC (rev 11157)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2008-11-13 23:58:13 UTC (rev 11158)
@@ -24,7 +24,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
@@ -388,9 +387,8 @@
webConnection = new MockWebConnection(webClient) {
public WebResponse getResponse(WebRequestSettings settings)
throws IOException {
- String resourcePath = settings.getURL().getFile().substring(
- request.getContextPath().length());
- String resourceKey = WebXml.getInstance(facesContext).getFacesResourceKey(resourcePath);
+ String resourceKey = WebXml.getInstance(facesContext).getFacesResourceKey(settings.getURL().getFile().substring(
+ request.getContextPath().length()));
if (resourceKey != null) {
InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
@@ -422,54 +420,7 @@
};
} else {
- WebResponse webResponse = super.getResponse(settings);
- if (webResponse == null || webResponse.getStatusCode() == HttpServletResponse.SC_NOT_FOUND) {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- if (resourcePath.length() != 0) {
- URL url = classLoader.getResource(resourcePath);
- if (url == null) {
- char charAt = resourcePath.charAt(0);
- String alternatePath = charAt == '/' ? resourcePath.substring(1) : "/" + resourcePath;
-
- url = classLoader.getResource(alternatePath);
- }
-
- if (url != null) {
- final String extension;
- int extensionIndex = resourcePath.lastIndexOf('.');
-
- if (extensionIndex != -1) {
- extension = resourcePath.substring(extensionIndex + 1);
- } else {
- extension = null;
- }
-
- return new WebResponseImpl(
- new WebResponseData(
- url.openStream(),
- HttpServletResponse.SC_OK,
- "OK",
- Collections.EMPTY_LIST),
- settings.getURL(),
- settings.getSubmitMethod(),
- 0) {
-
- public String getContentType() {
- if ("js".equals(extension)) {
- return "text/javascript";
- } else if ("css".equals(extension)) {
- return "text/css";
- } else {
- //TODO return text/plain for unknown types?
- return "text/html";
- }
- }
- };
- }
- }
- }
-
- return webResponse;
+ return super.getResponse(settings);
}
}
};
16 years, 10 months
JBoss Rich Faces SVN: r11157 - in branches/jsf2.0: framework/jsf-test/src/main/java/org/richfaces/test/staging and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-11-13 17:34:03 -0500 (Thu, 13 Nov 2008)
New Revision: 11157
Added:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/WEB-INF/
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/WEB-INF/faces-config.xml
branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/
branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/SimpleAjaxTest.java
branches/jsf2.0/tests/ajax/src/test/resources/org/
branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/
branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/
branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/
branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties
Removed:
branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/faces-config.xml
branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/SimpleAjaxTest.java
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.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/logging.properties
branches/jsf2.0/tests/ajax/pom.xml
branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/faces-config.xml
branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/web.xml
Log:
JSF 2.0 ajax test started.
Modified: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2008-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2008-11-13 22:34:03 UTC (rev 11157)
@@ -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: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-13 22:34:03 UTC (rev 11157)
@@ -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,6 +33,7 @@
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;
@@ -228,6 +230,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 +278,10 @@
for (RequestChain servlet : servlets) {
servlet.destroy();
}
- defaultServlet.destroy();
+ defaultServlet.destroy();
+ // Create Jsp factory
+ JspFactory.setDefaultFactory(null);
+
}
public StagingConnection getConnection(URL url) {
Added: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java 2008-11-13 22:34:03 UTC (rev 11157)
@@ -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: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java 2008-11-13 22:34:03 UTC (rev 11157)
@@ -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: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java 2008-11-13 22:34:03 UTC (rev 11157)
@@ -49,7 +49,7 @@
@Override
protected void setupWebContent() {
- facesServer.addResource("/WEB-INF/faces-config.xml", "org/richfaces/test/faces-config.xml");
+ facesServer.addResource("/WEB-INF/faces-config.xml", "org/richfaces/test/WEB-INF/faces-config.xml");
facesServer.addResource("/hello.xhtml", "org/richfaces/test/hello.xhtml");
facesServer.addResource("/response.xhtml", "org/richfaces/test/response.xhtml");
facesServer.addResource("/wave.med.gif", "org/richfaces/test/wave.med.gif");
Copied: branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/WEB-INF/faces-config.xml (from rev 11126, 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/WEB-INF/faces-config.xml (rev 0)
+++ branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/WEB-INF/faces-config.xml 2008-11-13 22:34:03 UTC (rev 11157)
@@ -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>org.richfaces.test.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>
Property changes on: branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/WEB-INF/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: 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 2008-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/faces-config.xml 2008-11-13 22:34:03 UTC (rev 11157)
@@ -1,69 +0,0 @@
-<?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>org.richfaces.test.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>
Modified: 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 2008-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/framework/jsf-test/src/test/resources/org/richfaces/test/logging.properties 2008-11-13 22:34:03 UTC (rev 11157)
@@ -18,4 +18,6 @@
org.ajax4jsf.context.level=ALL
javax.enterprise.resource.webcontainer.jsf.level=ALL
org.richfaces.level=ALL
+com.gargoylesoftware.htmlunit.level=ALL
+
\ No newline at end of file
Modified: branches/jsf2.0/tests/ajax/pom.xml
===================================================================
--- branches/jsf2.0/tests/ajax/pom.xml 2008-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/tests/ajax/pom.xml 2008-11-13 22:34:03 UTC (rev 11157)
@@ -17,6 +17,9 @@
<testResource>
<directory>src/main/webapp</directory>
</testResource>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
</testResources>
<finalName>ajax</finalName>
<plugins>
@@ -59,5 +62,22 @@
</plugins>
</build>
<dependencies>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.0-b05</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jvnet.wagon-svn</groupId>
+ <artifactId>wagon-svn</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>mojarra-jsf-impl</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/faces-config.xml 2008-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/faces-config.xml 2008-11-13 22:34:03 UTC (rev 11157)
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<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_1_2.xsd"
- version="1.2">
-
+<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">
+<managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>declarativeajax.Bean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+</managed-bean>
</faces-config>
Modified: branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/web.xml 2008-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/tests/ajax/src/main/webapp/WEB-INF/web.xml 2008-11-13 22:34:03 UTC (rev 11157)
@@ -1,7 +1,95 @@
<?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.
+-->
+
<web-app version="2.5"
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-app_2_5.xsd" >
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name></display-name>
+ <description></description>
+
+ <context-param>
+ <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>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <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>
+ <param-name>com.sun.faces.validateXml</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+
+ <!-- Faces Servlet Mapping -->
+ <!--
+
+ This mapping identifies a jsp page as having JSF content. If a
+ request comes to the server for foo.faces, the container will
+ send the request to the FacesServlet, which will expect a
+ corresponding foo.jsp page to exist containing the content.
+
+ -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
</web-app>
Deleted: branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/SimpleAjaxTest.java
===================================================================
--- branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/SimpleAjaxTest.java 2008-11-13 20:09:50 UTC (rev 11156)
+++ branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/SimpleAjaxTest.java 2008-11-13 22:34:03 UTC (rev 11157)
@@ -1,50 +0,0 @@
-/**
- *
- */
-package org.richfaces.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-/**
- * @author asmirnov
- *
- */
-public class SimpleAjaxTest extends AbstractFacesTest {
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
-
- @Override
- protected void setupWebContent() {
- facesServer.addResource("/WEB-INF/faces-config.xml", "/WEB-INF/faces-config.xml");
- facesServer.addResource("/index.jsp", "/index.jsp");
- facesServer.addResource("/home.xhtml", "/home.xhtml");
- facesServer.addResource("/resources/stylesheet.css", "/resources/stylesheet.css");
- facesServer.addResource("/resources/anim-star-bkgrnd.gif", "/resources/anim-star-bkgrnd.gif");
- }
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testRequest() throws Exception {
- WebClient webClient = new LocalWebClient(facesServer);
- HtmlPage page = webClient.getPage("http://localhost/hello.jsf");
- System.out.println(page.asXml());
-
- }
-}
Copied: branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/SimpleAjaxTest.java (from rev 11126, branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/SimpleAjaxTest.java)
===================================================================
--- branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/SimpleAjaxTest.java (rev 0)
+++ branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/SimpleAjaxTest.java 2008-11-13 22:34:03 UTC (rev 11157)
@@ -0,0 +1,62 @@
+/**
+ *
+ */
+package org.richfaces.test.ajax;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.test.AbstractFacesTest;
+import org.richfaces.test.LocalWebClient;
+
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+import declarativeajax.Bean;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class SimpleAjaxTest extends AbstractFacesTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Override
+ protected void setupWebContent() {
+ facesServer.addResource("/WEB-INF/faces-config.xml", "WEB-INF/faces-config.xml");
+ facesServer.addResource("/home.xhtml", "home.xhtml");
+ facesServer.addResource("/resources/stylesheet.css", "resources/stylesheet.css");
+ facesServer.addResource("/resources/anim-star-bkgrnd.gif", "resources/anim-star-bkgrnd.gif");
+ }
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testRequest() throws Exception {
+ WebClient webClient = new LocalWebClient(facesServer,BrowserVersion.FIREFOX_3);
+ webClient.setThrowExceptionOnScriptError(false);
+ HtmlPage page = webClient.getPage("http://localhost/home.jsf");
+ System.out.println(page.asXml());
+
+ }
+
+ @Test
+ public void BeanTest() throws Exception {
+ setupFacesRequest();
+ Bean bean = application.evaluateExpressionGet(facesContext, "#{bean}", Bean.class);
+ assertNotNull(bean);
+ }
+}
Property changes on: branches/jsf2.0/tests/ajax/src/test/java/org/richfaces/test/ajax/SimpleAjaxTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties
===================================================================
--- branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties (rev 0)
+++ branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties 2008-11-13 22:34:03 UTC (rev 11157)
@@ -0,0 +1,22 @@
+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
+com.gargoylesoftware.htmlunit.level=ALL
+
\ No newline at end of file
Property changes on: branches/jsf2.0/tests/ajax/src/test/resources/org/richfaces/test/ajax/logging.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 10 months
JBoss Rich Faces SVN: r11156 - trunk/framework/impl/src/main/javascript/ajaxjsf.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-13 15:09:50 -0500 (Thu, 13 Nov 2008)
New Revision: 11156
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
Cleaned legacy queue code
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-13 19:51:28 UTC (rev 11155)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-13 20:09:50 UTC (rev 11156)
@@ -359,7 +359,6 @@
* }
*/
-
var EventQueueData = function(queue, query, options) {
this.queue = queue;
this.query = query;
@@ -397,51 +396,16 @@
});
-// EventQueueData.prototype.setEventData = function(query, options) {
-// this.query = query;
-// this.options = options;
-// };
-//
-// EventQueueData.prototype.increaseEventCounter = function() {
-// this.eventsCount++;
-// };
-//
-// EventQueueData.prototype.executeDelay = function() {
-// var delay = this.options.requestDelay;
-// LOG.debug("Queue will wait " + (delay || 0) + "ms before submit");
-//
-// if (delay) {
-// var _this = this;
-//
-// this.timerId = setTimeout(function() {
-// try {
-// _this.delayPassed = true;
-// _this.queue.submit();
-// } finally {
-// _this = undefined;
-// }
-// }, delay);
-// } else {
-// this.delayPassed = true;
-// this.queue.submit();
-// }
-// };
-//
-// EventQueueData.prototype.abortDelay = function() {
-// if (this.timerId) {
-// clearTimeout(this.timerId);
-//
-// this.timerId = undefined;
-// }
-//
-// this.delayPassed = false;
-// };
-//
-// EventQueueData.prototype.submit = function() {
-// this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
-//
-// return A4J.AJAX.SubmitQuery(this.query, this.options)
-// };
+// LOG.debug("Queue will wait " + (delay || 0) + "ms before submit");
+// LOG.debug("Similar request already in queue '" + this.name + "'");
+// LOG.debug("After request: queue '" + this.name + "' is empty now");
+// LOG.debug("Deleting transient queue '" + this.name + "' from queues registry");
+// LOG.debug("After request: queue not empty, processing next event in queue '" + this.name + "'");
+// LOG.debug("Queue '" + this.name + "' will submit request NOW");
+// LOG.debug("Delay for request not passed yet, have to wait");
+// LOG.debug("Queue '" + this.name + "' is empty, nothing to submit");
+// LOG.debug("Request in queue '" + this.name + "' is active now, wait until its completion");
+// LOG.debug("New event added to queue '" + this.name + "'. Queue requestId changed to " + requestId);
var extendOptions = function(options) {
var opts = {};
@@ -475,124 +439,15 @@
return policy;
},
- submit: function() {
- if (!this.request) {
- var queueData = this.queue[0];
-
- if (queueData) {
- if (queueData.delayPassed) {
- this.queue.shift();
- LOG.debug("Queue '" + this.name + "' will submit request NOW");
-
- this.request = queueData.submit();
- this.request.queue = this;
- } else {
- LOG.debug("Delay for request not passed yet, have to wait");
- }
- } else {
- LOG.debug("Queue '" + this.name + "' is empty, nothing to submit");
- }
- } else {
- LOG.debug("Request in queue '" + this.name + "' is active now, wait until its completion");
- }
+ push: function(query, opts) {
+ var options = extendOptions.call(this, opts);
+ var queueData = new EventQueueData(this, query, options);
+
+ this.gate.push(queueData);
},
-
- push: function() {
- var dropNew = function() {
- this._requestId = undefined;
- };
- var fireNew = function(queueData) {
- this._requestId = undefined;
- queueData.submit();
- };
-
- var addToQueue = function(queueData, requestId) {
- this.queue.push(queueData);
- this._requestId = requestId;
- queueData.executeDelay();
-
- LOG.debug("New event added to queue '" + this.name + "'. Queue requestId changed to " + requestId);
- };
-
- var removeFirst = function() {
- var nextQueueData = this.queue.shift();
- if (nextQueueData) {
- nextQueueData.abortDelay();
- }
-
- //barrier element could be removed
- //next element can be ready for submit
- this.submit();
-
- return nextQueueData;
- };
-
- return function(query, opts) {
- var options = extendOptions.call(this, opts);
- var queueData = new EventQueueData(this, query, options);
-
- this.gate.push(queueData);
-
-// var options = extendOptions.call(this, opts);
-//
-// //TODO add processing for ignoreDupResponse
-//
-// var queueData;
-//
-// var requestId = options.requestId;
-//
-// if (this.queue.length == 0 || requestId != this._requestId) {
-// queueData = new EventQueueData(this, query, options);
-//
-// if (this.getQueueSize() == this.queue.length) {
-// var oversizeBehavior = this.getSizeExceededBehavior();
-// if ('dropNext' == oversizeBehavior) {
-// removeFirst.call(this);
-// addToQueue.call(this, queueData, requestId);
-// } else if ('fireNext' == oversizeBehavior) {
-// var firstQueueData = removeFirst.call(this);
-// if (firstQueueData) {
-// firstQueueData.submit();
-// }
-// addToQueue.call(this, queueData, requestId);
-// } else if ('dropNew' == oversizeBehavior) {
-// dropNew.call(this);
-// } else if ('fireNew' == oversizeBehavior) {
-// fireNew.call(this, queueData);
-// }
-// } else {
-// addToQueue.call(this, queueData, requestId);
-// }
-// } else {
-// queueData = this.queue[this.queue.length - 1];
-// queueData.setEventData(query, options);
-// queueData.increaseEventCounter();
-//
-// queueData.abortDelay();
-// queueData.executeDelay();
-//
-// LOG.debug("Similar request already in queue '" + this.name + "'");
-// }
- }
- }(),
-
pop: function() {
this.pipeline.submitNext()
-
-// this.request = undefined;
-//
-// if (this.queue.length == 0) {
-// LOG.debug("After request: queue '" + this.name + "' is empty now");
-//
-// if (this._transient) {
-// LOG.debug("Deleting transient queue '" + this.name + "' from queues registry");
-// A4J.AJAX.EventQueue.removeQueue(this.name);
-// }
-// } else {
-// LOG.debug("After request: queue not empty, processing next event in queue '" + this.name + "'");
-// this.submit();
-// }
}
}
}();
16 years, 10 months
JBoss Rich Faces SVN: r11155 - in trunk/sandbox/samples/queue-sample/src/main: webapp/pages and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-13 14:51:28 -0500 (Thu, 13 Nov 2008)
New Revision: 11155
Modified:
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml
Log:
Queue sample updated
Modified: trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/Bean.java 2008-11-13 19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/Bean.java 2008-11-13 19:51:28 UTC (rev 11155)
@@ -23,12 +23,17 @@
import java.util.Map;
+import javax.faces.component.UIComponent;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.ajax4jsf.event.AjaxEvent;
import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptString;
+import org.ajax4jsf.taglib.html.jsp.AjaxFunction;
/**
* @author $Autor$
@@ -40,6 +45,8 @@
private long clientRequestDelay = 300;
+ private long queueRequestDelay = 0;
+
private boolean pollEnabled;
private static final String AJAX_REQUESTS_COUNT_ATTRIBUTE = "ajaxRequestsCount";
@@ -60,6 +67,14 @@
this.clientRequestDelay = clientRequestDelay;
}
+ public long getQueueRequestDelay() {
+ return queueRequestDelay;
+ }
+
+ public void setQueueRequestDelay(long queueRequestDelay) {
+ this.queueRequestDelay = queueRequestDelay;
+ }
+
public boolean isPollEnabled() {
return pollEnabled;
}
@@ -107,4 +122,5 @@
sessionMap.put(AJAX_REQUESTS_COUNT_ATTRIBUTE, ++count);
}
+
}
\ No newline at end of file
Modified: trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java 2008-11-13 19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java 2008-11-13 19:51:28 UTC (rev 11155)
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.Map;
+import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
@@ -44,6 +45,14 @@
this.queueData = new HashMap<String, String>();
}
+ public void fireDelay() {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ throw new FacesException(e);
+ }
+ }
+
public void action() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml 2008-11-13 19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml 2008-11-13 19:51:28 UTC (rev 11155)
@@ -31,7 +31,7 @@
</ui:define>
<ui:define name="formQueue">
- <q:queue requestDelay="1000" />
+ <q:queue requestDelay="#{bean.queueRequestDelay}" />
</ui:define>
<ui:define name="title">Global form queue</ui:define>
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml 2008-11-13 19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml 2008-11-13 19:51:28 UTC (rev 11155)
@@ -28,11 +28,11 @@
<ui:decorate template="/templates/index.xhtml">
<ui:define name="viewQueue">
- <q:queue name="queue" requestDelay="1000" oncomplete="window.status = 'queue handler'"/>
+ <q:queue name="queue" requestDelay="#{bean.queueRequestDelay}" oncomplete="window.status = 'queue handler'"/>
</ui:define>
<ui:define name="formQueue">
- <q:queue name="formQueue" requestDelay="1000" />
+ <q:queue name="formQueue" requestDelay="#{bean.queueRequestDelay}" />
</ui:define>
<ui:define name="title">No global queues</ui:define>
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml 2008-11-13 19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml 2008-11-13 19:51:28 UTC (rev 11155)
@@ -27,8 +27,8 @@
<a4j:status startText="...running..." stopText="stopped" startStyle="color: green" />
- <c:set var="size" value="1" />
- <c:set var="requestDelay" value="1500" />
+ <c:set var="size" value="2" />
+ <c:set var="requestDelay" value="#{bean.queueRequestDelay}" />
<c:forEach items="#{oversizeBean.queueNames}" var="queueName">
<q:queue requestDelay="#{requestDelay}" size="#{size}" name="#{queueName}"
@@ -69,9 +69,13 @@
<h:form>
<c:forEach items="#{oversizeBean.queueNames}" var="queueName">
- <button onclick="#{queueName}Fire1();#{queueName}Fire2(); return false;">
+ <button onclick="#{queueName}FireDelay();#{queueName}Fire1();#{queueName}Fire2(); return false;">
#{queueName}
</button>
+ <a4j:jsFunction action="#{oversizeBean.fireDelay}"
+ name="#{queueName}FireDelay"
+ reRender="queueStatus" eventsQueue="#{queueName}">
+ </a4j:jsFunction>
<c:forEach begin="1" end="2" var="index">
<a4j:jsFunction action="#{oversizeBean.action}"
name="#{queueName}Fire#{index}"
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml 2008-11-13 19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml 2008-11-13 19:51:28 UTC (rev 11155)
@@ -28,7 +28,7 @@
<ui:decorate template="/templates/index.xhtml">
<ui:define name="viewQueue">
- <q:queue requestDelay="1000" oncomplete="window.status = 'queue handler'"/>
+ <q:queue requestDelay="#{bean.queueRequestDelay}" oncomplete="window.status = 'queue handler'"/>
</ui:define>
<ui:define name="formQueue">
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml 2008-11-13 19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml 2008-11-13 19:51:28 UTC (rev 11155)
@@ -6,7 +6,6 @@
xmlns:q="http://labs.jboss.com/jbossrichfaces/ui/ui/queue">
<ui:composition>
-
<h2><ui:insert name="title" /></h2>
<ui:insert name="viewQueue" />
@@ -20,11 +19,18 @@
 
- <a4j:commandLink value="Reset ajax counter" action="#{bean.resetAjaxCounter}" onclick="hideLog()" oncomplete="LOG.clear();showLog();"/>
+ <a4j:commandLink eventsQueue="resetCounterQueue" value="Reset ajax counter" action="#{bean.resetAjaxCounter}" onclick="hideLog()" oncomplete="LOG.clear();showLog();"/>
<br /><br />
<fieldset>
+ <h:outputLabel for="queueRequestDelay" value="Queue request delay " />
+ <h:inputText id="queueRequestDelay" value="#{bean.queueRequestDelay}">
+ <f:convertNumber />
+ </h:inputText>
+
+ <br />
+
<h:outputLabel for="clientRequestDelay" value="Client request delay " />
<h:inputText id="clientRequestDelay" value="#{bean.clientRequestDelay}">
<f:convertNumber />
16 years, 10 months
JBoss Rich Faces SVN: r11154 - in trunk/sandbox/ui/queue/src/test: java/org/richfaces and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2008-11-13 14:50:57 -0500 (Thu, 13 Nov 2008)
New Revision: 11154
Added:
trunk/sandbox/ui/queue/src/test/java/org/richfaces/AbstractQueueComponentTest.java
trunk/sandbox/ui/queue/src/test/resources/
trunk/sandbox/ui/queue/src/test/resources/META-INF/
trunk/sandbox/ui/queue/src/test/resources/META-INF/resources-config.xml
trunk/sandbox/ui/queue/src/test/resources/org/
trunk/sandbox/ui/queue/src/test/resources/org/richfaces/
trunk/sandbox/ui/queue/src/test/resources/org/richfaces/root
trunk/sandbox/ui/queue/src/test/resources/org/richfaces/script.xhtml
trunk/sandbox/ui/queue/src/test/resources/org/richfaces/simulation.js
Modified:
trunk/sandbox/ui/queue/src/test/java/org/richfaces/ScriptTest.java
Log:
Queue simulation test implemented in draft
Added: trunk/sandbox/ui/queue/src/test/java/org/richfaces/AbstractQueueComponentTest.java
===================================================================
--- trunk/sandbox/ui/queue/src/test/java/org/richfaces/AbstractQueueComponentTest.java (rev 0)
+++ trunk/sandbox/ui/queue/src/test/java/org/richfaces/AbstractQueueComponentTest.java 2008-11-13 19:50:57 UTC (rev 11154)
@@ -0,0 +1,369 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+package org.richfaces;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.component.UIAjaxCommandButton;
+import org.ajax4jsf.component.UIResource;
+import org.ajax4jsf.component.html.HtmlLoadScript;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.UserResourceRenderer2;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.mozilla.javascript.NativeArray;
+import org.mozilla.javascript.NativeObject;
+
+import com.gargoylesoftware.htmlunit.AlertHandler;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.ScriptResult;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
+import com.sun.facelets.Facelet;
+import com.sun.facelets.FaceletFactory;
+import com.sun.facelets.compiler.SAXCompiler;
+import com.sun.facelets.impl.DefaultFaceletFactory;
+import com.sun.facelets.impl.ResourceResolver;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public abstract class AbstractQueueComponentTest extends AbstractAjax4JsfTestCase implements ResourceResolver {
+
+ private static final String COMPONENT_TYPE = AjaxSubmitFunctionComponent.class.getName();
+
+ public final static class AjaxSubmitFunctionComponent extends UIComponentBase {
+
+ @Override
+ public String getRendererType() {
+ return COMPONENT_TYPE;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_TYPE;
+ }
+
+ }
+
+ private final static class AjaxSubmitFunctionResourceRenderer extends
+ Renderer implements UserResourceRenderer2 {
+
+ public void encodeToHead(FacesContext facesContext, UIComponent component)
+ throws IOException {
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(component, facesContext);
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(facesContext, component);
+ options.put("requestDelay", new JSReference("parameters.requestDelay"));
+ options.put("requestId", new JSReference("parameters.requestId || '" + component.getClientId(facesContext) + "'"));
+ options.put("data", new JSReference("data"));
+ options.put("requestTime", new JSReference("parameters.requestTime || 1000"));
+ options.put("timeout", new JSReference("parameters.timeout"));
+ options.put("eventsQueue", new JSReference("parameters.eventsQueue || 'testQueue'"));
+
+ ajaxFunction.addParameter(options);
+
+ ResponseWriter responseWriter = facesContext.getResponseWriter();
+ responseWriter.startElement(HTML.SCRIPT_ELEM, component);
+ responseWriter.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ responseWriter.writeText("var ajaxSubmit = function(data, parameters) {" + ajaxFunction.toScript() + "};", null);
+ responseWriter.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ ResponseWriter responseWriter = context.getResponseWriter();
+ responseWriter.startElement(HTML.SPAN_ELEM, component);
+ responseWriter.writeAttribute(HTML.id_ATTRIBUTE, component.getClientId(context), null);
+ responseWriter.writeText("hi", null);
+ responseWriter.endElement(HTML.SPAN_ELEM);
+ }
+ }
+
+ public AbstractQueueComponentTest(String name) {
+ super(name);
+ }
+
+ public URL resolveUrl(String path) {
+ return Thread.currentThread().getContextClassLoader().getResource("org/richfaces" + path);
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ UIResource resource;
+
+ UIComponent form = application.createComponent(UIForm.COMPONENT_TYPE);
+ viewRoot.getChildren().add(form);
+ final UIComponent commandButton = application.createComponent(UIAjaxCommandButton.COMPONENT_TYPE);
+ form.getChildren().add(commandButton);
+
+ facesContext.getRenderKit().addRenderer(COMPONENT_TYPE, COMPONENT_TYPE, new AjaxSubmitFunctionResourceRenderer());
+ form.getChildren().add(new AjaxSubmitFunctionComponent());
+
+ resource = (UIResource) application.createComponent(HtmlLoadScript.COMPONENT_TYPE);
+ resource.setSrc("resource:///org/richfaces/simulation.js");
+ viewRoot.getChildren().add(resource);
+
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private List<ScriptCommand> scriptCommands = new ArrayList<ScriptCommand>();
+
+ private abstract interface ScriptCommand {
+ public void append(StringBuilder builder);
+ }
+
+ private static final class DelayCommand implements ScriptCommand {
+ private int delayValue;
+
+ public DelayCommand(int value) {
+ super();
+ this.delayValue = value;
+ }
+
+ public void append(StringBuilder builder) {
+ builder.append("wait(" + delayValue + ");");
+ }
+ }
+
+ private static final class AjaxCommand implements ScriptCommand {
+ private String data;
+ private String parameters;
+
+ public AjaxCommand(String data, String parameters) {
+ super();
+ this.data = data;
+ this.parameters = parameters;
+ }
+
+ public void append(StringBuilder builder) {
+ builder.append("ajax('" + data + "', " + parameters + ");");
+ }
+ }
+
+ protected static final class TestsResult {
+ private List<RequestData> dataList = new ArrayList<RequestData>();
+
+ private Number currentTime;
+
+ public void addData(RequestData data) {
+ this.dataList.add(data);
+ }
+
+ public List<RequestData> getDataList() {
+ return dataList;
+ }
+
+ public void setCurrentTime(Number number) {
+ this.currentTime = number;
+ }
+
+ public Number getCurrentTime() {
+ return currentTime;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("[\n");
+ for (RequestData data : dataList) {
+ builder.append(" ");
+ builder.append(data);
+ builder.append("\n");
+ }
+ builder.append("]\n");
+ builder.append("Current time: " + this.currentTime);
+
+ return builder.toString();
+ }
+ }
+
+ protected static final class RequestData {
+ private boolean timedOut;
+
+ private Number startTime;
+
+ private Number endTime;
+
+ private String data;
+
+ public RequestData(String data, Number startTime, Number endTime,
+ boolean timedOut) {
+ super();
+ this.data = data;
+ this.startTime = startTime;
+ this.endTime = endTime;
+ this.timedOut = timedOut;
+ }
+
+ public boolean isTimedOut() {
+ return timedOut;
+ }
+
+ public Number getStartTime() {
+ return startTime;
+ }
+
+ public Number getEndTime() {
+ return endTime;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("data: ");
+ builder.append(data);
+ builder.append(", ");
+
+ builder.append("startTime: ");
+ builder.append(startTime);
+ builder.append(", ");
+
+ builder.append("endTime: ");
+ builder.append(endTime);
+ builder.append(", ");
+
+ if (isTimedOut()) {
+ builder.append("timeout: ");
+ builder.append(true);
+ }
+
+ return builder.toString();
+ }
+ };
+
+ protected void ajax(String data, String parameters) {
+ scriptCommands.add(new AjaxCommand(data, parameters));
+ }
+
+ protected void delay(int delayValue) {
+ scriptCommands.add(new DelayCommand(delayValue));
+ }
+
+ protected void buildView(String viewId) throws IOException {
+ com.sun.facelets.compiler.Compiler c = new SAXCompiler();
+ FaceletFactory factory = new DefaultFaceletFactory(c, this);
+ FaceletFactory.setInstance(factory);
+
+ FaceletFactory f = FaceletFactory.getInstance();
+ Facelet at = f.getFacelet(viewId);
+
+ UIViewRoot root = facesContext.getViewRoot();
+ root.setViewId(viewId);
+ at.apply(facesContext, root);
+ }
+
+ @Override
+ protected HtmlPage renderView() throws Exception {
+ StringBuilder builder = new StringBuilder("<script type='text/javascript'>do { with (simulationContext) {");
+ for (ScriptCommand command : scriptCommands) {
+ command.append(builder);
+ }
+ builder.append("}; Timer.execute(); } while (!Timer.isEmpty());</script>");
+
+ HtmlOutputText text = new HtmlOutputText();
+ text.setEscape(false);
+ text.setValue(builder.toString());
+
+ List<UIComponent> childList = facesContext.getViewRoot().getChildren();
+ childList.add(childList.size(), text);
+
+ return super.renderView();
+ }
+
+ protected TestsResult getTestsResult(HtmlPage page) {
+ TestsResult result = new TestsResult();
+
+ ScriptResult scriptResult = page.executeJavaScript("window.simulationContext.results");
+ NativeArray array = (NativeArray) scriptResult.getJavaScriptResult();
+
+ for (int i = 0; i < array.getLength(); i++) {
+ NativeObject object = (NativeObject) array.get(i, array);
+
+ String data = (String) object.get("data", object);
+ Number startTime = (Number) object.get("startTime", object);
+ Number endTime = (Number) object.get("endTime", object);
+
+ Object timedOut = object.get("timedOut", object);
+ boolean timedOutBoolean = timedOut instanceof Boolean && (Boolean) timedOut;
+
+ result.addData(new RequestData(data, startTime, endTime, timedOutBoolean));
+ }
+
+ scriptResult = page.executeJavaScript("Timer.currentTime");
+ result.setCurrentTime((Number) scriptResult.getJavaScriptResult());
+
+ return result;
+ }
+
+ @Override
+ protected WebClient createWebClient() {
+ WebClient webClient = super.createWebClient();
+ webClient.setJavaScriptEngine(new JavaScriptEngine(webClient));
+ webClient.setAlertHandler(new AlertHandler() {
+
+ public void handleAlert(Page page, String message) {
+ fail(message);
+ }
+
+ });
+
+ return webClient;
+ }
+
+}
Modified: trunk/sandbox/ui/queue/src/test/java/org/richfaces/ScriptTest.java
===================================================================
--- trunk/sandbox/ui/queue/src/test/java/org/richfaces/ScriptTest.java 2008-11-13 19:49:04 UTC (rev 11153)
+++ trunk/sandbox/ui/queue/src/test/java/org/richfaces/ScriptTest.java 2008-11-13 19:50:57 UTC (rev 11154)
@@ -22,68 +22,30 @@
package org.richfaces;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-
-import org.ajax4jsf.component.UIAjaxFunction;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.component.UIQueue;
-
-import com.gargoylesoftware.htmlunit.ScriptResult;
-import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
/**
* @author mikalaj
*
*/
-public class ScriptTest extends AbstractAjax4JsfTestCase {
+public class ScriptTest extends AbstractQueueComponentTest {
public ScriptTest(String name) {
super(name);
}
- @Override
- protected WebClient createWebClient() {
- WebClient webClient = super.createWebClient();
- webClient.setJavaScriptEngine(new JavaScriptEngine(webClient));
+ public void testScript() throws Exception {
+ buildView("/script.xhtml");
- return webClient;
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ delay(500);
+ ajax("a", "{requestDelay: 1000, requestId: '12', requestTime: 1500}");
+ delay(4100);
+ ajax("b", "{requestDelay: 4100, requestId: '12', requestTime: 101, timeout: 10}");
- List<UIComponent> viewRootChildren = facesContext.getViewRoot().getChildren();
-
- viewRootChildren.add(application.createComponent(UIQueue.COMPONENT_TYPE));
-
- UIComponent form = application.createComponent(UIForm.COMPONENT_TYPE);
- viewRootChildren.add(form);
- UIAjaxFunction function = (UIAjaxFunction) application.createComponent(UIAjaxFunction.COMPONENT_TYPE);
- function.setName("ajaxSubmit");
- form.getChildren().add(function);
-
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testScript() throws Exception {
HtmlPage page = this.renderView();
assertNotNull(page);
- ScriptResult scriptResult = page.executeJavaScript("setTimeout(function(){A4J.AJAX.EventQueue.getOrCreateQueue('" +
- UIQueue.GLOBAL_QUEUE_NAME + "')}, 2000000)");
- System.out.println(scriptResult.getJavaScriptResult());
-
-
+ System.out.println(getTestsResult(page));
}
}
Added: trunk/sandbox/ui/queue/src/test/resources/META-INF/resources-config.xml
===================================================================
--- trunk/sandbox/ui/queue/src/test/resources/META-INF/resources-config.xml (rev 0)
+++ trunk/sandbox/ui/queue/src/test/resources/META-INF/resources-config.xml 2008-11-13 19:50:57 UTC (rev 11154)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resource-config>
+
+ <resource>
+ <name>org/richfaces/simulation.js</name>
+ <path>org/richfaces/simulation.js</path>
+ </resource>
+
+ <resource>
+ <name>org.richfaces.AbstractQueueComponentTest</name>
+ <path>org.richfaces.AbstractQueueComponentTest</path>
+ </resource>
+
+</resource-config>
Added: trunk/sandbox/ui/queue/src/test/resources/org/richfaces/root
===================================================================
Added: trunk/sandbox/ui/queue/src/test/resources/org/richfaces/script.xhtml
===================================================================
--- trunk/sandbox/ui/queue/src/test/resources/org/richfaces/script.xhtml (rev 0)
+++ trunk/sandbox/ui/queue/src/test/resources/org/richfaces/script.xhtml 2008-11-13 19:50:57 UTC (rev 11154)
@@ -0,0 +1,19 @@
+<html
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:q="http://labs.jboss.com/jbossrichfaces/ui/ui/queue">
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <a4j:status startText="...running..." stopText="stopped" startStyle="color: green" />
+
+ <q:queue size="2" sizeExceededBehavior="fireNext" name="testQueue" />
+
+ </f:view>
+ </body>
+</html>
Added: trunk/sandbox/ui/queue/src/test/resources/org/richfaces/simulation.js
===================================================================
--- trunk/sandbox/ui/queue/src/test/resources/org/richfaces/simulation.js (rev 0)
+++ trunk/sandbox/ui/queue/src/test/resources/org/richfaces/simulation.js 2008-11-13 19:50:57 UTC (rev 11154)
@@ -0,0 +1,120 @@
+var Timer = {
+
+ _eventCounter: 0,
+
+ currentTime: 0,
+
+ maxTime: 100000,
+
+ events: new Array(),
+
+ addEventToTimer: function(callback, delay) {
+ var eventTime = this.currentTime + delay;
+
+ var i = 0;
+
+ while (this.events[i] && (this.events[i].eventTime <= eventTime)) {
+ i++;
+ }
+
+ var eventId = this._eventCounter++;
+
+ this.events.splice(i, 0, {eventTime: eventTime, callback: callback, eventId: eventId});
+
+ return eventId;
+ },
+
+ removeEventFromTimer: function(eventId) {
+ for ( var i = 0; i < this.events.length; i++) {
+ if (this.events[i].eventId == eventId) {
+ this.events.splice(i, 1);
+
+ break;
+ }
+ }
+ },
+
+ execute: function() {
+ while (this.events.length > 0) {
+ var eventData = this.events.shift();
+
+ this.currentTime = eventData.eventTime;
+ if (this.currentTime > this.maxTime) {
+ throw "Maximum execution time reached, aborting timer";
+ }
+
+ try {
+
+ eventData.callback();
+ } catch (e) {
+ alert(e.message);
+ }
+ }
+ },
+
+ isEmpty: function() {
+ return this.events.length == 0;
+ }
+};
+
+window.setTimeout = function(callback, delay) {
+ return Timer.addEventToTimer(callback, delay);
+}
+
+window.clearTimeout = function(timerId) {
+ Timer.removeEventFromTimer(timerId);
+}
+
+window.simulationContext = {
+
+ results: new Array(),
+
+ delay: 0,
+
+ wait: function(delay) {
+ this.delay += delay;
+ },
+
+ ajax: function() {
+ var args = arguments;
+ ajaxSubmit(args[0], args[1]);
+
+ Timer.addEventToTimer(function() {
+ ajaxSubmit(args[0], args[1]);
+ }, this.delay);
+ }
+ };
+
+A4J.AJAX.SubmitQuery = function(query, options) {
+ var request = {};
+
+ var length = window.simulationContext.results.push({data: options.data, startTime: Timer.currentTime});
+
+ var timer = Timer.addEventToTimer(function() {
+ if (request.timeoutTimer) {
+ Timer.removeEventFromTimer(request.timeoutTimer);
+ }
+
+ if (request.queue) {
+ request.queue.pop();
+ }
+
+ window.simulationContext.results[length - 1].endTime = Timer.currentTime;
+
+ }, options.requestTime);
+
+ if (options.timeout) {
+ request.timeoutTimer = Timer.addEventToTimer(function() {
+ Timer.removeEventFromTimer(timer);
+ if (request.queue) {
+ request.queue.pop();
+ }
+
+ window.simulationContext.results[length - 1].timedOut = true;
+ window.simulationContext.results[length - 1].endTime = Timer.currentTime;
+ }, options.timeout);
+ }
+
+ return request;
+}
+
16 years, 10 months
JBoss Rich Faces SVN: r11153 - trunk/framework/impl/src/main/javascript/ajaxjsf.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-13 14:49:04 -0500 (Thu, 13 Nov 2008)
New Revision: 11153
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
queue.js script updated for the latest change request
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-13 19:47:56 UTC (rev 11152)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-13 19:49:04 UTC (rev 11153)
@@ -3,12 +3,194 @@
A4J.AJAX._eventQueues = {};
+var extend = function(target, source) {
+ for (var property in source) {
+ target[property] = source[property];
+ }
+};
+
+var Pipeline = function(size, gate) {
+ this.size = size || -1;
+
+ this.gate = gate;
+ this.items = new Array();
+};
+
+extend(Pipeline.prototype, function() {
+
+ return {
+ submit: function() {
+ var data = this.items.shift();
+ if (data) {
+ this.request = data.submitWithCallback();
+ }
+ },
+
+ getSize: function() {
+ var size = this.items.length;
+
+ if (this.request) {
+ size++;
+ }
+
+ return size;
+ },
+
+ dropFirst: function() {
+ this.items.shift();
+ },
+
+ fireFirst: function() {
+ var data = this.items.shift();
+ if (data) {
+ data.submitWithoutCallback()
+ }
+ },
+
+ addEvent: function(data) {
+ if (!this.isFull()) {
+ this.items.push(data);
+
+ if (!this.request) {
+ this.submit();
+ }
+ } else {
+ //log error
+ }
+ },
+
+ submitNext: function() {
+ this.request = undefined;
+
+ if (this.getSize() > 0) {
+ this.submit();
+ } else {
+ this.gate.transferIfReady();
+ }
+ },
+
+ isFull: function() {
+ return this.getSize() == this.size;
+ },
+
+ isEmpty: function() {
+ return this.getSize() == 0;
+ }
+ }
+}());
+
+var Gate = function() {
+ this.eventsCounter = 0;
+};
+
+extend(Gate.prototype, {
+
+ stopRequestDelay: function () {
+ if (this.timer) {
+ clearTimeout(this.timer);
+ this.timer = undefined;
+ }
+ },
+
+ resetRequestDelay: function() {
+ this.delayPassed = false;
+
+ this.stopRequestDelay();
+ this.startRequestDelay();
+ },
+
+ startRequestDelay: function() {
+ var delay = this.data.getRequestDelay();
+ if (delay) {
+ var _this = this;
+ this.timer = setTimeout(function() {
+ try {
+ _this.transferIfPipelineEmpty();
+ _this.timer = undefined;
+ } finally {
+ _this = undefined;
+ }
+ }, delay);
+ } else {
+ this.transferIfPipelineEmpty();
+ }
+ },
+
+ transferIfPipelineEmpty: function() {
+ if (this.pipeline.isEmpty()) {
+ this.pipeline.addEvent(this.pop());
+ } else {
+ this.delayPassed = true;
+ }
+ },
+
+ transferIfReady: function() {
+ if (this.delayPassed) {
+ this.pipeline.addEvent(this.pop());
+ }
+ },
+
+ pop: function() {
+ var data = this.data;
+ this.data = undefined;
+
+ this.eventsCounter = 0;
+ this.requestId = undefined;
+ this.delayPassed = false;
+
+ return data;
+ },
+
+ push: function(data) {
+ var requestId = data.getRequestId();
+
+ if (this.requestId == requestId) {
+ this.data = data;
+ data.setEventsCounter(++this.eventsCounter);
+
+ this.resetRequestDelay();
+ } else {
+ if (this.data) {
+ this.stopRequestDelay();
+ this.pipeline.addEvent(this.pop());
+ }
+
+ if (this.pipeline.isFull()) {
+ //special handling for size = 1 queue
+
+ var behavior = data.queue.getSizeExceededBehavior();
+ if (behavior == 'dropNew') {
+ return;
+ } else if (behavior == 'fireNew') {
+ data.submitWithoutCallback();
+ return;
+ } else if (behavior == 'fireNext') {
+ this.pipeline.fireFirst();
+ } else if (behavior == 'dropNext') {
+ this.pipeline.dropFirst();
+ }
+
+ }
+
+ this.data = data;
+ this.requestId = requestId;
+ this.startRequestDelay();
+ }
+
+ },
+});
+
+
//queue constructor
A4J.AJAX.EventQueue = function(name, queueOptions, requestOptions) {
this.name = name;
this.queueOptions = queueOptions || {};
this.requestOptions = requestOptions || {};
+ this.gate = new Gate();
+ this.pipeline = new Pipeline(this.queueOptions.size, this.gate);
+ this.gate.pipeline = this.pipeline;
+
this.queue = new Array();
};
@@ -80,6 +262,104 @@
A4J.AJAX.EventQueue.prototype = function() {
+
+ /*
+ * Queue: {
+ * pop: {
+ * pop();
+ * barrier.unlock();
+ *
+ * if (!empty) {
+ * submit();
+ * } else {
+ * barrier.transferIfReady();
+ * }
+ * },
+ *
+ * push: {
+ * if (full) {
+ * throw e;
+ * }
+ *
+ * push();
+ *
+ * if (full) {
+ * barrier.lock();
+ * }
+ *
+ * if (!submitted) {
+ * submit();
+ * }
+ * }
+ *
+ * submit: {
+ * submit();
+ * }
+ *
+ * }
+ *
+ * Barrier: {
+ * match: {
+ * //not matches if empty
+ * }
+ *
+ * push: {
+ * if (match()) {
+ * //queue size stays the same
+ *
+ * assign();
+ * increaseCounter();
+ *
+ * //reset can do immediate transfer
+ * clearTimeout();
+ * setTimeout(transferIfQueueEmpty())
+ * } else {
+ * //queue size increased by one
+ *
+ * if (!empty) {
+ * clearTimeout();
+ * delayPassed = true;
+ * transfer();
+ * }
+ *
+ * if (locked) {
+ * //special unlock case when size = 1
+ * unlock();
+ * }
+ *
+ * assign();
+ * setTimeout(transferIfQueueEmpty())
+ * }
+ * }
+ *
+ * pop: {
+ * applyCounter();
+ * resetCounter();
+ * delayPassed = false;
+ * empty = true;
+ * }
+ *
+ * transfer: {
+ * queue.push(pop());
+ * }
+ *
+ * transferIfQueueEmpty: {
+ * if (queue.isEmpty()) {
+ * transfer();
+ * } else {
+ * delayPassed = true;
+ * }
+ * }
+ *
+ * transferIfReady: {
+ * if (delayPassed) {
+ * transfer();
+ * }
+ * }
+ * }
+ */
+
+
var EventQueueData = function(queue, query, options) {
this.queue = queue;
this.query = query;
@@ -88,51 +368,80 @@
this.eventsCount = 1;
};
- EventQueueData.prototype.setEventData = function(query, options) {
- this.query = query;
- this.options = options;
- };
-
- EventQueueData.prototype.increaseEventCounter = function() {
- this.eventsCount++;
- };
-
- EventQueueData.prototype.executeDelay = function() {
- var delay = this.options.requestDelay;
- LOG.debug("Queue will wait " + (delay || 0) + "ms before submit");
-
- if (delay) {
- var _this = this;
+ extend(EventQueueData.prototype, {
+ submitWithCallback: function() {
+ this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
- this.timerId = setTimeout(function() {
- try {
- _this.delayPassed = true;
- _this.queue.submit();
- } finally {
- _this = undefined;
- }
- }, delay);
- } else {
- this.delayPassed = true;
- this.queue.submit();
+ var request = A4J.AJAX.SubmitQuery(this.query, this.options)
+ request.queue = this.queue;
+
+ return request;
+ },
+
+ submitWithoutCallback: function() {
+ this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
+ return A4J.AJAX.SubmitQuery(this.query, this.options)
+ },
+
+ getRequestId: function() {
+ return this.options.requestId;
+ },
+
+ getRequestDelay: function() {
+ return this.options.requestDelay;
+ },
+
+ setEventsCounter: function(count) {
+ this.eventsCount = count;
}
- };
+ });
- EventQueueData.prototype.abortDelay = function() {
- if (this.timerId) {
- clearTimeout(this.timerId);
- this.timerId = undefined;
- }
-
- this.delayPassed = false;
- };
-
- EventQueueData.prototype.submit = function() {
- this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
-
- return A4J.AJAX.SubmitQuery(this.query, this.options)
- };
+// EventQueueData.prototype.setEventData = function(query, options) {
+// this.query = query;
+// this.options = options;
+// };
+//
+// EventQueueData.prototype.increaseEventCounter = function() {
+// this.eventsCount++;
+// };
+//
+// EventQueueData.prototype.executeDelay = function() {
+// var delay = this.options.requestDelay;
+// LOG.debug("Queue will wait " + (delay || 0) + "ms before submit");
+//
+// if (delay) {
+// var _this = this;
+//
+// this.timerId = setTimeout(function() {
+// try {
+// _this.delayPassed = true;
+// _this.queue.submit();
+// } finally {
+// _this = undefined;
+// }
+// }, delay);
+// } else {
+// this.delayPassed = true;
+// this.queue.submit();
+// }
+// };
+//
+// EventQueueData.prototype.abortDelay = function() {
+// if (this.timerId) {
+// clearTimeout(this.timerId);
+//
+// this.timerId = undefined;
+// }
+//
+// this.delayPassed = false;
+// };
+//
+// EventQueueData.prototype.submit = function() {
+// this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
+//
+// return A4J.AJAX.SubmitQuery(this.query, this.options)
+// };
var extendOptions = function(options) {
var opts = {};
@@ -221,62 +530,69 @@
return function(query, opts) {
var options = extendOptions.call(this, opts);
+ var queueData = new EventQueueData(this, query, options);
- //TODO add processing for ignoreDupResponse
-
- var queueData;
-
- var requestId = options.requestId;
+ this.gate.push(queueData);
- if (this.queue.length == 0 || requestId != this._requestId) {
- queueData = new EventQueueData(this, query, options);
-
- if (this.getQueueSize() == this.queue.length) {
- var oversizeBehavior = this.getSizeExceededBehavior();
- if ('dropNext' == oversizeBehavior) {
- removeFirst.call(this);
- addToQueue.call(this, queueData, requestId);
- } else if ('fireNext' == oversizeBehavior) {
- var firstQueueData = removeFirst.call(this);
- if (firstQueueData) {
- firstQueueData.submit();
- }
- addToQueue.call(this, queueData, requestId);
- } else if ('dropNew' == oversizeBehavior) {
- dropNew.call(this);
- } else if ('fireNew' == oversizeBehavior) {
- fireNew.call(this, queueData);
- }
- } else {
- addToQueue.call(this, queueData, requestId);
- }
- } else {
- queueData = this.queue[this.queue.length - 1];
- queueData.setEventData(query, options);
- queueData.increaseEventCounter();
-
- queueData.abortDelay();
- queueData.executeDelay();
-
- LOG.debug("Similar request already in queue '" + this.name + "'");
- }
+// var options = extendOptions.call(this, opts);
+//
+// //TODO add processing for ignoreDupResponse
+//
+// var queueData;
+//
+// var requestId = options.requestId;
+//
+// if (this.queue.length == 0 || requestId != this._requestId) {
+// queueData = new EventQueueData(this, query, options);
+//
+// if (this.getQueueSize() == this.queue.length) {
+// var oversizeBehavior = this.getSizeExceededBehavior();
+// if ('dropNext' == oversizeBehavior) {
+// removeFirst.call(this);
+// addToQueue.call(this, queueData, requestId);
+// } else if ('fireNext' == oversizeBehavior) {
+// var firstQueueData = removeFirst.call(this);
+// if (firstQueueData) {
+// firstQueueData.submit();
+// }
+// addToQueue.call(this, queueData, requestId);
+// } else if ('dropNew' == oversizeBehavior) {
+// dropNew.call(this);
+// } else if ('fireNew' == oversizeBehavior) {
+// fireNew.call(this, queueData);
+// }
+// } else {
+// addToQueue.call(this, queueData, requestId);
+// }
+// } else {
+// queueData = this.queue[this.queue.length - 1];
+// queueData.setEventData(query, options);
+// queueData.increaseEventCounter();
+//
+// queueData.abortDelay();
+// queueData.executeDelay();
+//
+// LOG.debug("Similar request already in queue '" + this.name + "'");
+// }
}
}(),
pop: function() {
- this.request = undefined;
+ this.pipeline.submitNext()
- if (this.queue.length == 0) {
- LOG.debug("After request: queue '" + this.name + "' is empty now");
-
- if (this._transient) {
- LOG.debug("Deleting transient queue '" + this.name + "' from queues registry");
- A4J.AJAX.EventQueue.removeQueue(this.name);
- }
- } else {
- LOG.debug("After request: queue not empty, processing next event in queue '" + this.name + "'");
- this.submit();
- }
+// this.request = undefined;
+//
+// if (this.queue.length == 0) {
+// LOG.debug("After request: queue '" + this.name + "' is empty now");
+//
+// if (this._transient) {
+// LOG.debug("Deleting transient queue '" + this.name + "' from queues registry");
+// A4J.AJAX.EventQueue.removeQueue(this.name);
+// }
+// } else {
+// LOG.debug("After request: queue not empty, processing next event in queue '" + this.name + "'");
+// this.submit();
+// }
}
}
}();
16 years, 10 months
JBoss Rich Faces SVN: r11152 - trunk/framework/test/src/main/java/org/ajax4jsf/tests.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-13 14:47:56 -0500 (Thu, 13 Nov 2008)
New Revision: 11152
Modified:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
Log:
AbstractAjax4JsfTestCase: implemented possibility to return web resources from context CL
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2008-11-13 16:39:24 UTC (rev 11151)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2008-11-13 19:47:56 UTC (rev 11152)
@@ -24,6 +24,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
@@ -387,8 +388,9 @@
webConnection = new MockWebConnection(webClient) {
public WebResponse getResponse(WebRequestSettings settings)
throws IOException {
- String resourceKey = WebXml.getInstance(facesContext).getFacesResourceKey(settings.getURL().getFile().substring(
- request.getContextPath().length()));
+ String resourcePath = settings.getURL().getFile().substring(
+ request.getContextPath().length());
+ String resourceKey = WebXml.getInstance(facesContext).getFacesResourceKey(resourcePath);
if (resourceKey != null) {
InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
@@ -420,7 +422,54 @@
};
} else {
- return super.getResponse(settings);
+ WebResponse webResponse = super.getResponse(settings);
+ if (webResponse == null || webResponse.getStatusCode() == HttpServletResponse.SC_NOT_FOUND) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ if (resourcePath.length() != 0) {
+ URL url = classLoader.getResource(resourcePath);
+ if (url == null) {
+ char charAt = resourcePath.charAt(0);
+ String alternatePath = charAt == '/' ? resourcePath.substring(1) : "/" + resourcePath;
+
+ url = classLoader.getResource(alternatePath);
+ }
+
+ if (url != null) {
+ final String extension;
+ int extensionIndex = resourcePath.lastIndexOf('.');
+
+ if (extensionIndex != -1) {
+ extension = resourcePath.substring(extensionIndex + 1);
+ } else {
+ extension = null;
+ }
+
+ return new WebResponseImpl(
+ new WebResponseData(
+ url.openStream(),
+ HttpServletResponse.SC_OK,
+ "OK",
+ Collections.EMPTY_LIST),
+ settings.getURL(),
+ settings.getSubmitMethod(),
+ 0) {
+
+ public String getContentType() {
+ if ("js".equals(extension)) {
+ return "text/javascript";
+ } else if ("css".equals(extension)) {
+ return "text/css";
+ } else {
+ //TODO return text/plain for unknown types?
+ return "text/html";
+ }
+ }
+ };
+ }
+ }
+ }
+
+ return webResponse;
}
}
};
16 years, 10 months
JBoss Rich Faces SVN: r11151 - in trunk/sandbox/ui/editor/src/main: java/org/richfaces/component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-11-13 11:39:24 -0500 (Thu, 13 Nov 2008)
New Revision: 11151
Modified:
trunk/sandbox/ui/editor/src/main/config/component/editor.xml
trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
trunk/sandbox/ui/editor/src/main/templates/editor.jspx
Log:
Editor: implement view mode attribute
Modified: trunk/sandbox/ui/editor/src/main/config/component/editor.xml
===================================================================
--- trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-11-13 16:20:27 UTC (rev 11150)
+++ trunk/sandbox/ui/editor/src/main/config/component/editor.xml 2008-11-13 16:39:24 UTC (rev 11151)
@@ -50,14 +50,14 @@
</property>
<property>
<name>width</name>
- <classname>int</classname>
+ <classname>java.lang.Integer</classname>
<description>
Attribute defines width of component.
</description>
</property>
<property>
<name>height</name>
- <classname>int</classname>
+ <classname>java.lang.Integer</classname>
<description>
Attribute defines height of component.
</description>
@@ -165,5 +165,13 @@
Attribute defines Editor skin
</description>
</property>
+ <property>
+ <name>viewMode</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Attribute defines if tinyMCE WYSIWYG should be disabled
+ </description>
+ <defaultvalue>"visual"</defaultvalue>
+ </property>
</component>
</components>
Modified: trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java 2008-11-13 16:20:27 UTC (rev 11150)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/component/UIEditor.java 2008-11-13 16:39:24 UTC (rev 11151)
@@ -49,13 +49,13 @@
public abstract String getType();
- public abstract int getWidth();
+ public abstract Integer getWidth();
- public abstract void setWidth(int width);
+ public abstract void setWidth(Integer width);
- public abstract int getHeight();
+ public abstract Integer getHeight();
- public abstract void setHeight(int height);
+ public abstract void setHeight(Integer height);
public abstract void setTheme(String theme);
@@ -108,7 +108,11 @@
public abstract void setSkin(String skin);
public abstract String getSkin();
+
+ public abstract void setViewMode(String viewMode);
+ public abstract String getViewMode();
+
public boolean getRendersChildren() {
return true;
}
Modified: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-11-13 16:20:27 UTC (rev 11150)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/EditorRendererBase.java 2008-11-13 16:39:24 UTC (rev 11151)
@@ -48,7 +48,9 @@
private final static String SPECIFIC_SCRIPT_RESOURCE_NAME = "org/richfaces/renderkit/html/1$1.js";
private final static String SPECIFIC_XCSS_RESOURCE_NAME = "org/richfaces/renderkit/html/1$1.xcss";
-
+
+ private final static String TINY_MCE_DISABLED_MODE = "source";
+
@Override
protected Class<? extends UIComponent> getComponentClass() {
return UIEditor.class;
@@ -185,11 +187,11 @@
+ ScriptUtils.toScript(component.getPlugins()) + ";\n",
null);
}
- if (component.getWidth() != 0) {
+ if (component.getWidth() != null) {
writer.writeText("tinyMceParams.width = "
+ ScriptUtils.toScript(component.getWidth()) + ";\n", null);
}
- if (component.getHeight() != 0) {
+ if (component.getHeight() != null) {
writer
.writeText("tinyMceParams.height = "
+ ScriptUtils.toScript(component.getHeight())
@@ -245,4 +247,27 @@
}
}
}
+
+ public boolean shouldRenderTinyMCE(UIEditor component) {
+ if (component.getViewMode() != null
+ && component.getViewMode().equalsIgnoreCase(
+ TINY_MCE_DISABLED_MODE)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ public String getTextAreaStyle(UIEditor component) {
+ StringBuilder b = new StringBuilder();
+ if (component.getWidth() != null) {
+ b.append("width: " + component.getWidth() + "px;");
+ }
+ if (component.getHeight() != null) {
+ b.append("height: " + component.getHeight() + "px;");
+ }
+ return b.toString();
+ }
+
+
}
Modified: trunk/sandbox/ui/editor/src/main/templates/editor.jspx
===================================================================
--- trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-11-13 16:20:27 UTC (rev 11150)
+++ trunk/sandbox/ui/editor/src/main/templates/editor.jspx 2008-11-13 16:39:24 UTC (rev 11151)
@@ -13,22 +13,18 @@
<f:clientid var="clientId"/>
<h:styles>css/editor.xcss</h:styles>
<h:scripts>new org.ajax4jsf.javascript.AjaxScript(), new org.ajax4jsf.javascript.PrototypeScript(), scripts/tiny_mce/tiny_mce_src.js, scripts/editor.js</h:scripts>
+ <jsp:scriptlet>
+ <![CDATA[
+ if(shouldRenderTinyMCE(component)) {
+ ]]>
+ </jsp:scriptlet>
<div id="#{clientId}" x:passThruWithExclusions="id,value,styleClass,class"
class="rich-editor #{component.attributes['styleClass']}" style="#{component.attributes['style']}">
- <textarea id="#{clientId}TextArea" name='#{clientId}TextArea'
+ <textarea id="#{clientId}TextArea" name="#{clientId}TextArea"
style="visibility: hidden">
#{this:getFormattedComponentStringValue(context, component)}
</textarea>
- <jsp:scriptlet>
- <![CDATA[
- String onsetup = null;
- if (component.getAttributes().get("onsetup") != null) {
- onsetup = (String) component.getAttributes().get("onsetup");
- }
- variables.setVariable("onsetup", onsetup);
- ]]>
- </jsp:scriptlet>
<script type="text/javascript">
<f:call name="writeEditorConfigurationParameters" />
@@ -41,4 +37,20 @@
new RichEditor('#{clientId}', richParams, tinyMceParams);
</script>
</div>
+ <jsp:scriptlet>
+ <![CDATA[
+ } else {
+ ]]>
+ </jsp:scriptlet>
+ <div id="#{clientId}" x:passThruWithExclusions="id,value,styleClass,class"
+ class="rich-editor #{component.attributes['styleClass']}" style="#{component.attributes['style']}">
+ <textarea id="#{clientId}TextArea" name="#{clientId}TextArea" style="#{this:getTextAreaStyle(component)}">
+ #{this:getFormattedComponentStringValue(context, component)}
+ </textarea>
+ </div>
+ <jsp:scriptlet>
+ <![CDATA[
+ }
+ ]]>
+ </jsp:scriptlet>
</f:root>
16 years, 10 months