Author: alexsmirnov
Date: 2008-11-25 20:16:00 -0500 (Tue, 25 Nov 2008)
New Revision: 11386
Removed:
trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/classes/
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/StagingConnection.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java
trunk/test-applications/ajaxTest/pom.xml
trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml
trunk/test-applications/ajaxTest/src/test/java/org/richfaces/RepeaterTest.java
Log:
Minor test framework improvements.
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-25
23:44:58 UTC (rev 11385)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java 2008-11-26
01:16:00 UTC (rev 11386)
@@ -7,7 +7,9 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.richfaces.test.TestException;
+
/**
* This class represents file from classpath in the virtual web application
* content.
@@ -51,8 +53,11 @@
.getContextClassLoader();
if (null == classLoader) {
classLoader = this.getClass().getClassLoader();
+ }
+ url = classLoader.getResource(classpath);
+ if(null == url){
+ throw new TestException("Virtual server resource can't be loaded from
"+classpath);
}
- url = classLoader.getResource(classpath);
}
}
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java 2008-11-25
23:44:58 UTC (rev 11385)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java 2008-11-26
01:16:00 UTC (rev 11386)
@@ -150,17 +150,17 @@
return started;
}
- private void checkStarted() {
- if (!isFinished()) {
- throw new TestException("request have not been started");
- }
- }
+// private void checkStarted() {
+// if (!isFinished()) {
+// throw new TestException("request have not been started");
+// }
+// }
- private void checkNotStarted() {
- if (isStarted()) {
- throw new TestException("request was started, no parameters changes
allowed");
- }
- }
+// private void checkNotStarted() {
+// if (isStarted()) {
+// throw new TestException("request was started, no parameters changes
allowed");
+// }
+// }
/**
* Execute this connection request on the associated servlet or filter chain.
@@ -215,11 +215,9 @@
* Set request HTTP methos ( GET, POST etc ).
* @param method
* the method to set
- * @throws TestException
- * if connection have already been started.
*/
public void setRequestMethod(HttpMethod method) {
- checkNotStarted();
+// checkNotStarted();
this.method = method;
}
@@ -235,11 +233,9 @@
* Append additional request parameter.
* @param name
* @param value
- * @throws TestException
- * if connection have already been started.
*/
public void addRequestParameter(String name, String value) {
- checkNotStarted();
+// checkNotStarted();
String[] values = requestParameters.get(name);
if (null == values) {
values = new String[1];
@@ -256,10 +252,10 @@
* Get content of the response as String.
* @return content of the response writer or String created from the ServletOutputStream
with current response encoding.
* @throws TestException
- * if connection have not been started or response has an unsupported
encoding.
+ * if has an unsupported encoding.
*/
public String getContentAsString() {
- checkStarted();
+// checkStarted();
String content = response.getWriterContent();
if (null == content) {
byte[] streamContent = response.getStreamContent();
@@ -283,10 +279,10 @@
* Get content of the response as byte array.
* @return content of the ServletOutputStream or convert String, collected by response
writer, with current response encoding.
* @throws TestException
- * if connection have not been started or response has unsupported encoding.
+ * if response has unsupported encoding.
*/
public byte[] getResponseBody() {
- checkStarted();
+// checkStarted();
byte[] content = response.getStreamContent();
if (null == content) {
String writerContent = response.getWriterContent();
@@ -330,41 +326,33 @@
/**
* @return encoding used to write response.
- * @throws TestException
- * if connection have not been started .
*/
public String getResponseCharacterEncoding() {
- checkStarted();
+// checkStarted();
return response.getCharacterEncoding();
}
/**
* @return content type ( eg 'text/html' ) of the response.
- * @throws TestException
- * if connection have not been started .
*/
public String getResponseContentType() {
- checkStarted();
+// checkStarted();
return response.getContentType();
}
/**
* @return HTTP status code of the response.
- * @throws TestException
- * if connection have not been started .
*/
public int getResponseStatus() {
- checkStarted();
+// checkStarted();
return response.getStatus();
}
/**
* @return HTTP error message.
- * @throws TestException
- * if connection have not been started .
*/
public String getErrorMessage() {
- checkStarted();
+// checkStarted();
return response.getErrorMessage();
}
@@ -372,11 +360,9 @@
* Set request Query string. This method does not parse query string, {@link
#parseFormParameters(String)} should be used.
* @param queryString
* the queryString to set
- * @throws TestException
- * if connection have already been started .
*/
public void setQueryString(String queryString) {
- checkNotStarted();
+// checkNotStarted();
this.queryString = queryString;
}
@@ -390,11 +376,9 @@
/**
* Get HTTP response headers.
* @return headers name-values map.
- * @throws TestException
- * if connection have not been started .
*/
public Map<String, String[]> getResponseHeaders() {
- checkStarted();
+// checkStarted();
return response.getHeaders();
}
@@ -404,7 +388,7 @@
* @throws UnsupportedEncodingException
*/
public void setRequestCharacterEncoding(String charset) throws
UnsupportedEncodingException {
- checkNotStarted();
+// checkNotStarted();
request.setCharacterEncoding(charset);
}
@@ -413,7 +397,7 @@
* @param body
*/
public void setRequestBody(String body) {
- checkNotStarted();
+// checkNotStarted();
request.setRequestBody(body);
}
@@ -422,7 +406,7 @@
* @param contentType
*/
public void setRequestContentType(String contentType) {
- checkNotStarted();
+// checkNotStarted();
request.setContentType(contentType);
}
@@ -432,7 +416,7 @@
* @param headers
*/
public void addRequestHeaders(Map<String, String> headers) {
- checkNotStarted();
+// checkNotStarted();
request.addHeaders(headers);
}
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java
===================================================================
---
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java 2008-11-25
23:44:58 UTC (rev 11385)
+++
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java 2008-11-26
01:16:00 UTC (rev 11386)
@@ -44,17 +44,19 @@
import org.richfaces.test.TestException;
/**
- * This class implements limited Http servlet container 2.5 functionality. It is designed
for a test purposes only ,so that has a limitations:
+ * This class implements limited Http servlet container 2.5 functionality. It is
+ * designed for a test purposes only ,so that has a limitations:
* <ul>
* <li>supports local calls only.</li>
* <li>java code only configuration ( no xml files processed ).</li>
* <li>just one web application, 'deployed' in the root
context.</li>
* <li>only one client session</li>
* <li>communicates by the local java calls only, no network connection</li>
- * <li>no JSP compilator support ( but it is possible to register pre-compiled
pages as servlets)</li>
+ * <li>no JSP compilator support ( but it is possible to register pre-compiled
+ * pages as servlets)</li>
* <li>...</li>
* </ul>
- * It is main part of the test framework.
+ * It is main part of the test framework.
*
*/
public class StagingServer {
@@ -73,7 +75,8 @@
private final List<RequestChain> servlets = new ArrayList<RequestChain>();
- private RequestChain defaultServlet= new ServletContainer(null, new StaticServlet());
+ private RequestChain defaultServlet = new ServletContainer(null,
+ new StaticServlet());
private final List<EventListener> contextListeners = new
ArrayList<EventListener>();
@@ -89,16 +92,17 @@
private ServletContext contextProxy;
- private ServerHttpSession session=null;
+ private ServerHttpSession session = null;
- private HttpSession sessionProxy=null;
+ private HttpSession sessionProxy = null;
- private boolean initialised=false;
+ private boolean initialised = false;
/**
* This inner class links ServletContext calls to the server instance.
+ *
* @author asmirnov
- *
+ *
*/
private class LocalContext extends StagingServletContext {
@@ -116,8 +120,12 @@
return mimeTypes.get(file);
}
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.StagingServletContext#valueBound(javax.servlet.ServletContextAttributeEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.test.staging.StagingServletContext#valueBound(javax
+ * .servlet.ServletContextAttributeEvent)
*/
@Override
protected void valueBound(ServletContextAttributeEvent event) {
@@ -130,8 +138,12 @@
}
}
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.StagingServletContext#valueReplaced(javax.servlet.ServletContextAttributeEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.test.staging.StagingServletContext#valueReplaced(javax
+ * .servlet.ServletContextAttributeEvent)
*/
@Override
protected void valueReplaced(ServletContextAttributeEvent event) {
@@ -144,8 +156,12 @@
}
}
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.StagingServletContext#valueUnbound(javax.servlet.ServletContextAttributeEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.test.staging.StagingServletContext#valueUnbound(javax
+ * .servlet.ServletContextAttributeEvent)
*/
@Override
protected void valueUnbound(ServletContextAttributeEvent event) {
@@ -158,8 +174,12 @@
}
}
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.StagingServletContext#getServerResource(java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.test.staging.StagingServletContext#getServerResource
+ * (java.lang.String)
*/
@Override
protected ServerResource getServerResource(String path) {
@@ -170,20 +190,27 @@
/**
* This inner class links session object calls to the server instance.
+ *
* @author asmirnov
- *
+ *
*/
private class ServerHttpSession extends StagingHttpSession {
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see javax.servlet.http.HttpSession#getServletContext()
*/
public ServletContext getServletContext() {
return context;
}
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.StagingHttpSession#valueBound(javax.servlet.http.HttpSessionBindingEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.test.staging.StagingHttpSession#valueBound(javax.servlet
+ * .http.HttpSessionBindingEvent)
*/
@Override
protected void valueBound(
@@ -197,8 +224,12 @@
});
}
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.StagingHttpSession#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.test.staging.StagingHttpSession#valueUnbound(javax.
+ * servlet.http.HttpSessionBindingEvent)
*/
@Override
protected void valueUnbound(
@@ -212,8 +243,12 @@
});
}
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.StagingHttpSession#valueReplaced(javax.servlet.http.HttpSessionBindingEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.test.staging.StagingHttpSession#valueReplaced(javax
+ * .servlet.http.HttpSessionBindingEvent)
*/
@Override
protected void valueReplaced(
@@ -242,8 +277,8 @@
}
/**
- * Append executable server object ( {@link Filter} or {@link Servlet}
- * to the server.
+ * Append executable server object ( {@link Filter} or {@link Servlet} to
+ * the server.
*
* @param servlet
*/
@@ -268,8 +303,9 @@
*
* @param path
* request path relative to web application context.
- * @return Appropriate Filter or Servlet executable object to serve given request. If no
servlet was registered for the given path,
- * try to send requested object directly.
+ * @return Appropriate Filter or Servlet executable object to serve given
+ * request. If no servlet was registered for the given path, try to
+ * send requested object directly.
*/
public RequestChain getServlet(String path) {
RequestChain result = null;
@@ -288,7 +324,7 @@
result = defaultServlet;
}
} catch (MalformedURLException e) {
- log.warning("Mailformed request URL "+e.getMessage());
+ log.warning("Mailformed request URL " + e.getMessage());
}
}
return result;
@@ -296,6 +332,7 @@
/**
* Add web application init parameter.
+ *
* @param name
* @param value
*/
@@ -304,7 +341,8 @@
}
/**
- * Add default mime type for serve files with given extension.
+ * Add default mime type for serve files with given extension.
+ *
* @param extension
* @param mimeType
*/
@@ -313,9 +351,14 @@
}
/**
- * Add java resource to the virtual web application content. This method makes all
parent directories as needed.
- * @param path path to the file in the virtual web server.
- * @param resource path to the resource in the classpath, as required by the {@link
ClassLoader#getResource(String)}.
+ * Add java resource to the virtual web application content. This method
+ * makes all parent directories as needed.
+ *
+ * @param path
+ * path to the file in the virtual web server.
+ * @param resource
+ * path to the resource in the classpath, as required by the
+ * {@link ClassLoader#getResource(String)}.
*/
public void addResource(String path, String resource) {
ServerResourcePath resourcePath = new ServerResourcePath(path);
@@ -324,9 +367,13 @@
}
/**
- * Add resource to the virtual veb application content. This method makes all parent
directories as needed.
- * @param path path to the file in the virtual web server.
- * @param resource {@code URL} to the file content.
+ * Add resource to the virtual veb application content. This method makes
+ * all parent directories as needed.
+ *
+ * @param path
+ * path to the file in the virtual web server.
+ * @param resource
+ * {@code URL} to the file content.
*/
public void addResource(String path, URL resource) {
serverRoot.addResource(new ServerResourcePath(path),
@@ -334,9 +381,18 @@
}
/**
- * Add all resources from the directory to the virtual web application content.
- * @param path name of the target directory in the virtual web application. If no such
directory exists, it will be created, as well as all parent directories as needed.
- * @param resource {@code URL} to the source directory or any file in the source
directory. Only 'file' or 'jar' protocols are supported. If this parameter
points to a file, it will be converted to a enclosing directory.
+ * Add all resources from the directory to the virtual web application
+ * content.
+ *
+ * @param path
+ * name of the target directory in the virtual web application.
+ * If no such directory exists, it will be created, as well as
+ * all parent directories as needed.
+ * @param resource
+ * {@code URL} to the source directory or any file in the source
+ * directory. Only 'file' or 'jar' protocols are supported.
If
+ * this parameter points to a file, it will be converted to a
+ * enclosing directory.
*/
public void addResourcesFromDirectory(String path, URL resource) {
ServerResourcePath resourcePath = new ServerResourcePath(path);
@@ -357,10 +413,46 @@
}
/**
- * Internal method used by the {@link #addResourcesFromDirectory(String, URL)} to
process 'file' protocol.
- * @param resource source directory.
- * @param baseDirectory target virtual directory.
+ * Add all files from the directory to the virtual web application
+ * content.
+ *
+ * @param path
+ * name of the target directory in the virtual web application.
+ * If no such directory exists, it will be created, as well as
+ * all parent directories as needed.
+ * @param resource
+ * {@code File} of the source directory or any file in the source
+ * directory. If this parameter points to a file, it will be converted to a
+ * enclosing directory.
*/
+ public void addResourcesFromDirectory(String path, File directory) {
+ ServerResourcePath resourcePath = new ServerResourcePath(path);
+ ServerResource baseDirectory = serverRoot.getResource(resourcePath);
+ if (null == baseDirectory) {
+ // Create target directory.
+ baseDirectory = new ServerResourcesDirectory();
+ serverRoot.addResource(resourcePath, baseDirectory);
+ }
+ if (!directory.isDirectory()) {
+ directory = directory.getParentFile();
+ }
+ try {
+ addFiles(baseDirectory, directory);
+ } catch (MalformedURLException e) {
+ throw new TestException(e);
+ }
+ }
+
+ /**
+ * Internal method used by the
+ * {@link #addResourcesFromDirectory(String, URL)} to process 'file'
+ * protocol.
+ *
+ * @param resource
+ * source directory.
+ * @param baseDirectory
+ * target virtual directory.
+ */
protected void addResourcesFromFile(URL resource,
ServerResource baseDirectory) {
File file = new File(resource.getPath());
@@ -375,9 +467,14 @@
}
/**
- * Internal method used by the {@link #addResourcesFromDirectory(String, URL)} to
process 'jar' protocol.
- * @param resource URL to the any object in the source directory.
- * @param baseDirectory target virtual directory.
+ * Internal method used by the
+ * {@link #addResourcesFromDirectory(String, URL)} to process 'jar'
+ * protocol.
+ *
+ * @param resource
+ * URL to the any object in the source directory.
+ * @param baseDirectory
+ * target virtual directory.
*/
protected void addResourcesFromJar(URL resource,
ServerResource baseDirectory) {
@@ -402,14 +499,16 @@
}
} catch (IOException e) {
- throw new TestException("Error read Jar content",e);
+ throw new TestException("Error read Jar content", e);
} catch (URISyntaxException e) {
throw new TestException(e);
}
}
/**
- * Internal reccursive method process directory content and all subdirectories.
+ * Internal reccursive method process directory content and all
+ * subdirectories.
+ *
* @param baseDirectory
* @param file
* @throws MalformedURLException
@@ -435,8 +534,8 @@
/**
* Add web-application wide listenes, same as it is defined by the
- * <listener> element in the web.xml file for a real server.
- * Supported listener types:
+ * <listener> element in the web.xml file for a real server. Supported
+ * listener types:
* <ul>
* <li>{@link ServletContextListener}</li>
* <li>{@link ServletContextAttributeListener}</li>
@@ -445,7 +544,9 @@
* <li>{@link ServletRequestListener}</li>
* <li>{@link ServletRequestAttributeListener}</li>
* </ul>
- * @param listener web listener instance.
+ *
+ * @param listener
+ * web listener instance.
*/
public void addWebListener(EventListener listener) {
contextListeners.add(listener);
@@ -453,6 +554,7 @@
/**
* Getter method for 'interceptor' events listener.
+ *
* @return the invocationListener
*/
public InvocationListener getInvocationListener() {
@@ -460,8 +562,11 @@
}
/**
- * Set listener which gets events on all calls to any methods of the {@link
ServletContext}, {@link HttpSession}, {@link HttpServletRequest}, {@link
HttpServletResponse} instances
- * in the virtual server. this interceptor can be used to check internal calls in the
tests .
+ * Set listener which gets events on all calls to any methods of the
+ * {@link ServletContext}, {@link HttpSession}, {@link HttpServletRequest},
+ * {@link HttpServletResponse} instances in the virtual server. this
+ * interceptor can be used to check internal calls in the tests .
+ *
* @param invocationListener
* the invocationListener to set
*/
@@ -470,8 +575,10 @@
}
/**
- * Create instance of the {@link InvocationHandler} for the proxy objects. This handler
fire events to the
- * registered {@link InvocationListener} ( if present ) after target object method
call.
+ * Create instance of the {@link InvocationHandler} for the proxy objects.
+ * This handler fire events to the registered {@link InvocationListener} (
+ * if present ) after target object method call.
+ *
* @return the invocationHandler
*/
InvocationHandler getInvocationHandler(final Object target) {
@@ -502,6 +609,7 @@
/**
* Get virtual server session object. Create new one if necessary.
+ *
* @return instance of the virtual server session.
*/
public HttpSession getSession() {
@@ -509,32 +617,31 @@
}
/**
- *
- * Returns the current <code>HttpSession</code>
- * associated with this server or, if there is no
- * current session and <code>create</code> is true, returns
- * a new session. Staging server supports only one session per instance,
- * different clients for the same server instance does not supported.
- *
- * <p>If <code>create</code> is <code>false</code>
- * and the request has no valid <code>HttpSession</code>,
- * this method returns <code>null</code>.
- *
- *
- * @param create <code>true</code> to create
- * a new session for this request if necessary;
- * <code>false</code> to return <code>null</code>
- * if there's no current session
- *
- *
- * @return the <code>HttpSession</code> associated
- * with this server instance or <code>null</code> if
- * <code>create</code> is <code>false</code>
- * and the server has no session
- *
+ *
+ * Returns the current <code>HttpSession</code> associated with this server
+ * or, if there is no current session and <code>create</code> is true,
+ * returns a new session. Staging server supports only one session per
+ * instance, different clients for the same server instance does not
+ * supported.
+ *
+ * <p>
+ * If <code>create</code> is <code>false</code> and the request
has no valid
+ * <code>HttpSession</code>, this method returns
<code>null</code>.
+ *
+ *
+ * @param create
+ * <code>true</code> to create a new session for this request if
+ * necessary; <code>false</code> to return
<code>null</code> if
+ * there's no current session
+ *
+ *
+ * @return the <code>HttpSession</code> associated with this server
instance
+ * or <code>null</code> if <code>create</code> is
<code>false</code>
+ * and the server has no session
+ *
*/
public synchronized HttpSession getSession(boolean create) {
- if(!initialised){
+ if (!initialised) {
throw new TestException("Staging server have not been initialised");
}
if (null == this.session && create) {
@@ -560,9 +667,11 @@
}
/**
- * Virtual server initialization. This method creates instances of the {@link
ServletContext}, {@link JspFactory},
- * informs {@link ServletContextListener} ind inits all {@link Filter} and {@link
Servlet} instances.
- * It should be called from test setUp method to prepare testing environment.
+ * Virtual server initialization. This method creates instances of the
+ * {@link ServletContext}, {@link JspFactory}, informs
+ * {@link ServletContextListener} ind inits all {@link Filter} and
+ * {@link Servlet} instances. It should be called from test setUp method to
+ * prepare testing environment.
*/
public void init() {
log.info("Init staging server");
@@ -595,18 +704,20 @@
}
defaultServlet.init(context);
} catch (ServletException e) {
- throw new TestException("Servlet initialisation error ",e);
+ throw new TestException("Servlet initialisation error ", e);
}
this.initialised = true;
}
/**
- * Stop wirtual server. This method informs {@link ServletContextListener} ind inits all
{@link Filter} and {@link Servlet} instances, as well remove all internal objects.
- * It should be called from the testt thearDown method to clean up testing environment.
- *
+ * Stop wirtual server. This method informs {@link ServletContextListener}
+ * ind inits all {@link Filter} and {@link Servlet} instances, as well
+ * remove all internal objects. It should be called from the testt thearDown
+ * method to clean up testing environment.
+ *
*/
public void destroy() {
- if(!initialised){
+ if (!initialised) {
throw new TestException("Staging server have not been initialised");
}
this.initialised = false;
@@ -643,14 +754,18 @@
}
/**
- * Get virtual connection to the given URL. Even thought for an http request to the
- * external servers, only local connection to the virtual server will be created.
- * @param url request url.
- * @return local connection to the appropriate servlet in the virtual server.
+ * Get virtual connection to the given URL. Even thought for an http request
+ * to the external servers, only local connection to the virtual server will
+ * be created.
+ *
+ * @param url
+ * request url.
+ * @return local connection to the appropriate servlet in the virtual
+ * server.
* @throws {@link TestException} if no servlet found to process given URL.
*/
public StagingConnection getConnection(URL url) {
- if(!initialised){
+ if (!initialised) {
throw new TestException("Staging server have not been initialised");
}
return new StagingConnection(this, url);
@@ -658,10 +773,11 @@
/**
* Get instance of virtual web application context.
+ *
* @return context instance.
*/
public ServletContext getContext() {
- if(!initialised){
+ if (!initialised) {
throw new TestException("Staging server have not been initialised");
}
return contextProxy;
@@ -669,7 +785,9 @@
/**
* Inform {@link ServletRequestListener} instances. For internal use only.
- * @param request started request.
+ *
+ * @param request
+ * started request.
*/
void requestStarted(ServletRequest request) {
final ServletRequestEvent event = new ServletRequestEvent(context,
@@ -685,7 +803,9 @@
/**
* Inform {@link ServletRequestListener} instances. For internal use only.
- * @param request finished request.
+ *
+ * @param request
+ * finished request.
*/
void requestFinished(ServletRequest request) {
final ServletRequestEvent event = new ServletRequestEvent(context,
@@ -698,8 +818,7 @@
});
}
- void requestAttributeAdded(ServletRequest request, String name,
- Object o) {
+ void requestAttributeAdded(ServletRequest request, String name, Object o) {
final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(
context, request, name, o);
fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS,
Modified: trunk/test-applications/ajaxTest/pom.xml
===================================================================
--- trunk/test-applications/ajaxTest/pom.xml 2008-11-25 23:44:58 UTC (rev 11385)
+++ trunk/test-applications/ajaxTest/pom.xml 2008-11-26 01:16:00 UTC (rev 11386)
@@ -7,15 +7,13 @@
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
- <testResources>
- <testResource>
- <directory>src/main/webapp</directory>
- </testResource>
- <testResource>
- <directory>src/test/resources</directory>
- </testResource>
- </testResources>
- <finalName>ajaxTest</finalName>
+ <!--
+ <testResources> <testResource>
<directory>src/main/webapp</directory>
+ </testResource> <testResource>
+ <directory>src/test/resources</directory> </testResource>
+ </testResources>
+ -->
+ <finalName>ajaxTest</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
@@ -25,6 +23,32 @@
<target>1.5</target>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <!--
http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin -->
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <connectors>
+ <connector
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8080</port>
+ <maxIdleTime>60000</maxIdleTime>
+ </connector>
+ </connectors>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>webapp</name>
+ <value>${basedir}/src/main/webapp</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified: trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml
===================================================================
--- trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml 2008-11-25 23:44:58
UTC (rev 11385)
+++ trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml 2008-11-26 01:16:00
UTC (rev 11386)
@@ -7,7 +7,7 @@
<body>
<h:form id="ajaxForm">
<h:inputText id="text" value="#{bean.text}">
- <a4j:support reRender="out"
event="onclick"></a4j:support>
+ <a4j:support reRender="out"
event="onkeyup"></a4j:support>
</h:inputText>
<h:outputText id="out"
value="#{bean.text}"></h:outputText>
</h:form>
Modified: trunk/test-applications/ajaxTest/src/test/java/org/richfaces/RepeaterTest.java
===================================================================
---
trunk/test-applications/ajaxTest/src/test/java/org/richfaces/RepeaterTest.java 2008-11-25
23:44:58 UTC (rev 11385)
+++
trunk/test-applications/ajaxTest/src/test/java/org/richfaces/RepeaterTest.java 2008-11-26
01:16:00 UTC (rev 11386)
@@ -5,17 +5,15 @@
import static org.junit.Assert.*;
-import org.junit.After;
-import org.junit.Before;
+import java.io.File;
+
import org.junit.Test;
import org.richfaces.test.AbstractFacesTest;
import org.richfaces.test.LocalWebClient;
+import org.richfaces.test.TestException;
import org.w3c.dom.Element;
-import com.gargoylesoftware.htmlunit.BrowserVersion;
-import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
@@ -27,30 +25,31 @@
@Override
protected void setupWebContent() {
- facesServer.addResourcesFromDirectory("/",
this.getClass().getResource("/repeater.xhtml"));
+ String webappDirectory = System.getProperty("webapp");
+ if (null == webappDirectory) {
+ throw new TestException("The 'webapp' system property does not
set");
+ }
+ File webFile = new File(webappDirectory);
+ facesServer.addResourcesFromDirectory("/", webFile);
+ facesServer.addResource("/WEB-INF/faces-config.xml",
"test-faces-config.xml");
}
-// @Override
-// protected void setupSunFaces() {
-// }
+ // @Override
+ // protected void setupSunFaces() {
+ // }
/**
* @throws java.lang.Exception
*/
@Test
public void testHelloFacelets() throws Exception {
- WebClient webClient = new LocalWebClient(facesServer,BrowserVersion.FIREFOX_3);
- webClient.setThrowExceptionOnScriptError(true);
- webClient.setAjaxController(new NicelyResynchronizingAjaxController());
+ WebClient webClient = new LocalWebClient(facesServer);
HtmlPage page = webClient.getPage("http://localhost/repeater.jsf");
page.getEnclosingWindow().getThreadManager().joinAll(10000);
-// System.out.println(page.asXml());
- HtmlForm htmlForm = page.getFormByName("ajaxForm");
- HtmlInput htmlInput = htmlForm.getInputByName("ajaxForm:text");
- assertNotNull(htmlForm);
- htmlInput.setValueAttribute("foo");
- htmlInput.click();
-// System.out.println(page.asXml());
+ HtmlInput htmlInput = (HtmlInput) page.getElementById("ajaxForm:text");
+ assertNotNull(htmlInput);
+ htmlInput.type("foo");
+ // System.out.println(page.asXml());
Element element = page.getElementById("ajaxForm:out");
assertEquals("foo", element.getTextContent().trim());
}