JBoss Rich Faces SVN: r11230 - trunk/docs/common-resources/en.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2008-11-19 05:07:23 -0500 (Wed, 19 Nov 2008)
New Revision: 11230
Added:
trunk/docs/common-resources/en/pom.xml
Log:
https://jira.jboss.org/jira/browse/RF-4107 - one resources folder was added
Added: trunk/docs/common-resources/en/pom.xml
===================================================================
--- trunk/docs/common-resources/en/pom.xml (rev 0)
+++ trunk/docs/common-resources/en/pom.xml 2008-11-19 10:07:23 UTC (rev 11230)
@@ -0,0 +1,51 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>common-resources</artifactId>
+ <groupId>org.richfaces.docs</groupId>
+ <version>3.3.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.docs.common-resources</groupId>
+ <artifactId>en</artifactId>
+ <version>3.3.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Documentation common resources (en)</name>
+ <description>
+ Documentation common resources for En-Us translation
+ </description>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.docs</groupId>
+ <artifactId>highlight</artifactId>
+ <version>3.3.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/xslt</directory>
+ <targetPath>common-resources/xslt</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/css</directory>
+ <targetPath>common-resources/css</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/script</directory>
+ <targetPath>common-resources/script</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/images</directory>
+ <targetPath>common-resources/images</targetPath>
+ </resource>
+ </resources>
+ <!--plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-style-plugin</artifactId>
+ <version>1.0.0</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins-->
+ </build>
+</project>
\ No newline at end of file
Property changes on: trunk/docs/common-resources/en/pom.xml
___________________________________________________________________
Name: svn:executable
+ *
17 years, 6 months
JBoss Rich Faces SVN: r11229 - in trunk: docs/xslt and 23 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-11-18 20:04:10 -0500 (Tue, 18 Nov 2008)
New Revision: 11229
Added:
trunk/docs/xslt/
trunk/docs/xslt/en/
trunk/framework/jsf-test/src/main/javadoc/
trunk/framework/jsf-test/src/main/javadoc/org/
trunk/framework/jsf-test/src/main/javadoc/org/richfaces/
trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/
trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html
trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/staging/
trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/staging/package.html
trunk/test-applications/ajaxTest/.metadata/
trunk/test-applications/ajaxTest/.metadata/src/
trunk/test-applications/ajaxTest/.metadata/src/main/
trunk/test-applications/ajaxTest/.metadata/src/main/webapp/
trunk/test-applications/ajaxTest/.metadata/src/main/webapp/WEB-INF/
trunk/test-applications/ajaxTest/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow
trunk/test-applications/ajaxTest/src/main/java/org/
trunk/test-applications/ajaxTest/src/main/java/org/richfaces/
trunk/test-applications/ajaxTest/src/main/java/org/richfaces/Bean.java
trunk/test-applications/ajaxTest/src/main/webapp/
trunk/test-applications/ajaxTest/src/main/webapp/META-INF/
trunk/test-applications/ajaxTest/src/main/webapp/META-INF/MANIFEST.MF
trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/
trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/classes/
trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/lib/
trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/web.xml
trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml
Removed:
trunk/test-applications/ajaxTest/src/main/java/Bean.java
trunk/test-applications/ajaxTest/src/test/resources/faces-config.xml
trunk/test-applications/ajaxTest/src/test/resources/repeater.xhtml
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebClient.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebResponse.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/TestException.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/test/java/org/richfaces/RepeaterTest.java
Log:
Edit Javadoc comments in the public classes
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-18 22:44:40 UTC (rev 11228)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -22,37 +22,64 @@
import javax.faces.webapp.FacesServlet;
import javax.servlet.Filter;
+import junit.framework.TestCase;
+
import org.junit.After;
import org.junit.Before;
import org.richfaces.test.staging.FilterContainer;
-import org.richfaces.test.staging.RequestChain;
import org.richfaces.test.staging.ServletContainer;
import org.richfaces.test.staging.StagingConnection;
import org.richfaces.test.staging.StagingServer;
/**
+ * Base class for all JSF test cases.
* @author asmirnov
*
*/
-public abstract class AbstractFacesTest {
+public abstract class AbstractFacesTest extends TestCase {
private ClassLoader contextClassLoader;
+ /**
+ * Prepared test server instance. Populated by the default {@link #setUp()} method.
+ */
protected StagingServer facesServer;
+ /**
+ * Current virtual connection. This field populated by the {@link #setupWebContent()} method only.
+ */
protected StagingConnection connection;
+ /**
+ * Current {@link FacesContext} instance. This field populated by the {@link #setupWebContent()} method only.
+ */
protected FacesContext facesContext;
+ /**
+ * JSF {@link Lifecycle} instance. Populated by the default {@link #setUp()} method.
+ */
protected Lifecycle lifecycle;
+ /**
+ * JSF {@link Application} instance. Populated by the default {@link #setUp()} method.
+ */
protected Application application;
/**
+ * Setup staging server instance with JSF implementation. First, this method creates a local test instance
+ * and calls the other template method in the next sequence:
+ * <ol>
+ * <li>{@link #setupFacesServlet()}</li>
+ * <li>{@link #setupFacesListener()}</li>
+ * <li>{@link #setupJsfInitParameters()}</li>
+ * <li>{@link #setupWebContent()}</li>
+ * </ol>
+ * After them, test server is initialized as well as fields {@link #lifecycle} and {@link #application} populated.
+ * Also, if the resource "logging.properties" is exist in the test class package, The Java {@link LogManager} will be configured with its content.
* @throws java.lang.Exception
*/
@Before
- public void setUpServer() throws Exception {
+ public void setUp() throws Exception {
contextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader());
@@ -74,6 +101,7 @@
facesServer = new StagingServer();
setupFacesServlet();
setupFacesListener();
+ setupJsfInitParameters();
setupWebContent();
facesServer.init();
ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
@@ -86,18 +114,22 @@
}
/**
- *
+ * This hook method called from the {@link #setUp()} should append JSF implementation
+ * listener to the test server. Default version applends "com.sun.faces.config.ConfigureListener"
+ * or "org.apache.myfaces.webapp.StartupServletContextListener" for the existed SUN RI or MyFaces implementation.
+ * This metod also calls appropriate {@link #setupSunFaces()} or {@link #setupMyFaces()} methods.
*/
protected void setupFacesListener() {
EventListener listener = null;
try {
+ // Check Sun RI configuration listener class.
Class<? extends EventListener> listenerClass = contextClassLoader
.loadClass("com.sun.faces.config.ConfigureListener")
.asSubclass(EventListener.class);
listener = listenerClass.newInstance();
setupSunFaces();
} catch (ClassNotFoundException e) {
- // No JSF RI listener
+ // No JSF RI listener, check MyFaces.
Class<? extends EventListener> listenerClass;
try {
listenerClass = contextClassLoader
@@ -119,8 +151,10 @@
}
/**
- * @throws InstantiationException
- * @throws IllegalAccessException
+ * This template method called from {@link #setUp()} to create {@link FacesServlet} instance.
+ * The default implementation also tests presense of the "org.ajax4jsf.Filter" class.
+ * If this class is avalable, these instance appended to the Faces Servlet call chain.
+ * Default mapping to the FacesServlet instance is "*.jsf"
*/
protected void setupFacesServlet() {
ServletContainer facesServletContainer = new ServletContainer("*.jsf",
@@ -145,6 +179,13 @@
} catch (Exception e) {
throw new TestException(e);
}
+ }
+
+ /**
+ * This template method called from {@link #setUp()} to append appropriate init parameters to the test server.
+ * The default implementation sets state saving method to the "server" and default jsf page suffix to the ".xhtml"
+ */
+ protected void setupJsfInitParameters() {
facesServer.addInitParameter(
StateManager.STATE_SAVING_METHOD_PARAM_NAME,
StateManager.STATE_SAVING_METHOD_SERVER);
@@ -152,23 +193,45 @@
".xhtml");
}
+ /**
+ * This template method called from the {@link #setupFacesListener()} if MyFaces implementation presents.
+ * The default implementation does nothing.
+ */
protected void setupMyFaces() {
// Do nothing by default.
}
+ /**
+ * This template method called from the {@link #setupFacesListener()} if Sun JSF reference implementation presents.
+ * The default implementation sets the "com.sun.faces.validateXml" "com.sun.faces.verifyObjects" init parameters to the "true"
+ */
protected void setupSunFaces() {
facesServer.addInitParameter("com.sun.faces.validateXml", "true");
facesServer.addInitParameter("com.sun.faces.verifyObjects", "true");
}
+ /**
+ * This template method called from the {@link #setUp()} to populate virtual server content.
+ * The default implementation do nothing.
+ */
protected void setupWebContent() {
}
+ /**
+ * Setup virtual server connection to run tests inside JSF lifecycle.
+ * The default implementation setups virtual request to the "http://localhost/test.jsf" URL and creates {@link FacesContext} instance.
+ * Two template methods are called :
+ * <ol>
+ * <li>{@link #setupConnection()} to prepare request method, parameters, headers and so</li>
+ * <li>{@link #setupView()} to create default view.</li>
+ * </ol>
+ * @throws Exception
+ */
protected void setupFacesRequest() throws Exception {
connection = facesServer.getConnection(new URL(
"http://localhost/test.jsf"));
- setupConnection(connection);
+ setupConnection();
connection.start();
FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
@@ -181,21 +244,31 @@
}
}
+ /**
+ * This template method called from the {@link #setupFacesRequest()} to create components view tree in the virtual request.
+ * The default implementation is only creates {@link UIViewRoot} instance for view ID "/test.xhtml".
+ * @return
+ */
protected UIViewRoot setupView() {
UIViewRoot viewRoot = (UIViewRoot) application.createComponent(UIViewRoot.COMPONENT_TYPE);
viewRoot.setViewId("/test.xhtml");
return viewRoot;
}
- protected void setupConnection(StagingConnection connection) {
+ /**
+ * This template method called from the {@link #setupFacesRequest()} to setup additional virtual connection parameters.
+ * The default implementation does nothing.
+ */
+ protected void setupConnection() {
}
/**
+ * Virtual server instance cleanup.
* @throws java.lang.Exception
*/
@After
- public void tearDownServer() throws Exception {
+ public void tearDown() throws Exception {
if (null != facesContext) {
facesContext.release();
facesContext = null;
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebClient.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebClient.java 2008-11-18 22:44:40 UTC (rev 11228)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebClient.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -11,6 +11,10 @@
import com.gargoylesoftware.htmlunit.WebConnection;
/**
+ * Modified version of the HtmlUnit {@link WebClient}. This subclass uses {@link LocalWebConnection} by default,
+ * to perform requests to the local saging server {@link StagingServer} instead of real network request.
+ * It is also setup synchonous ajax controller {@link WebClient#setAjaxController(com.gargoylesoftware.htmlunit.AjaxController)},
+ * to avoid thread syncronisation problem.
* @author asmirnov
*
*/
@@ -22,7 +26,8 @@
private transient WebConnection webConnection;
/**
- *
+ * Create WebConnection instance for the given {@link StagingServer}
+ * @param server test server instance.
*/
public LocalWebClient(StagingServer server) {
super();
@@ -31,6 +36,8 @@
}
/**
+ * Create WebConnection instance for the given {@link StagingServer} and browser version.
+ * @param server test server instance.
* @param browserVersion
*/
public LocalWebClient(StagingServer server,BrowserVersion browserVersion) {
@@ -40,8 +47,10 @@
}
/**
+ * Overwride default webConnection.
* @return the webConnection
*/
+ @Override
public WebConnection getWebConnection() {
if (this.webConnection == null) {
this.webConnection = new LocalWebConnection(server);
@@ -53,6 +62,7 @@
/**
* @param webConnection the webConnection to set
*/
+ @Override
public void setWebConnection(WebConnection webConnection) {
this.webConnection = webConnection;
}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java 2008-11-18 22:44:40 UTC (rev 11228)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -17,7 +17,16 @@
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.WebResponse;
+/**
+ * This implementation of the HtmlUnit {@link WebConnection} execute http requests on the local
+ * staging server instead of the real network connection.
+ * @author asmirnov
+ *
+ */
public final class LocalWebConnection implements WebConnection {
+ /**
+ * test server instance
+ */
private final StagingServer localServer;
/**
@@ -27,9 +36,13 @@
this.localServer = localServer;
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebConnection#getResponse(com.gargoylesoftware.htmlunit.WebRequestSettings)
+ */
public WebResponse getResponse(WebRequestSettings settings)
throws IOException {
StagingConnection connection = localServer.getConnection(settings.getUrl());
+ // Propagate web request settings to the local connection.
for (NameValuePair param : settings.getRequestParameters()) {
connection.addRequestParameter(param.getName(), param.getValue());
}
@@ -41,6 +54,8 @@
connection.setRequestBody(body);
connection.setRequestContentType(contentType);
connection.addRequestHeaders(settings.getAdditionalHeaders());
+ // HtmlUnit uses request parameters map for the form submit, but does not parse
+ // XMLHttpRequest content.
if(null != body && FormEncodingType.URL_ENCODED.getName().equals(contentType)){
connection.parseFormParameters(body);
}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebResponse.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebResponse.java 2008-11-18 22:44:40 UTC (rev 11228)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebResponse.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -6,10 +6,8 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
@@ -19,7 +17,13 @@
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.WebResponse;
-public final class LocalWebResponse implements WebResponse {
+/**
+ * This implementation realise WebResponse wrapper for a staging server connection.
+ * This class for an internal use only.
+ * @author asmirnov
+ *
+ */
+final class LocalWebResponse implements WebResponse {
private final WebRequestSettings settings;
private final StagingConnection serverConnection;
@@ -28,14 +32,23 @@
this.serverConnection = serverConnection;
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsStream()
+ */
public InputStream getContentAsStream() throws IOException {
return new ByteArrayInputStream(getResponseBody());
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsString()
+ */
public String getContentAsString() {
return serverConnection.getContentAsString();
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getContentCharSet()
+ */
public String getContentCharSet() {
return serverConnection.getCharacterEncoding();
}
@@ -44,39 +57,66 @@
return serverConnection.getContentType();
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getLoadTimeInMilliSeconds()
+ */
public long getLoadTimeInMilliSeconds() {
return 0;
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getRequestMethod()
+ */
public com.gargoylesoftware.htmlunit.HttpMethod getRequestMethod() {
return com.gargoylesoftware.htmlunit.HttpMethod.valueOf(serverConnection.getMethod().toString());
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getRequestSettings()
+ */
public WebRequestSettings getRequestSettings() {
return settings;
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getResponseBody()
+ */
public byte[] getResponseBody() {
return serverConnection.getResponseBody();
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getResponseHeaderValue(java.lang.String)
+ */
public String getResponseHeaderValue(String headerName) {
// TODO Auto-generated method stub
return null;
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getStatusCode()
+ */
public int getStatusCode() {
return serverConnection.getStatus();
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getStatusMessage()
+ */
public String getStatusMessage() {
return serverConnection.getErrorMessage();
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getUrl()
+ */
public URL getUrl() {
return serverConnection.getUrl();
}
+ /* (non-Javadoc)
+ * @see com.gargoylesoftware.htmlunit.WebResponse#getResponseHeaders()
+ */
public List<NameValuePair> getResponseHeaders() {
ArrayList<NameValuePair> headers = new ArrayList<NameValuePair>(10);
for (Entry<String, String[]> entry : serverConnection.getResponseHeaders().entrySet()) {
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/TestException.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/TestException.java 2008-11-18 22:44:40 UTC (rev 11228)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/TestException.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -3,17 +3,21 @@
*/
package org.richfaces.test;
+import org.richfaces.test.staging.StagingServer;
+
/**
+ * Internal runtame exception for the {@link StagingServer} engine.
* @author asmirnov
*
*/
+@SuppressWarnings("serial")
public class TestException extends RuntimeException {
/**
*
*/
public TestException() {
- // TODO Auto-generated constructor stub
+ super();
}
/**
@@ -21,7 +25,6 @@
*/
public TestException(String message) {
super(message);
- // TODO Auto-generated constructor stub
}
/**
@@ -29,7 +32,6 @@
*/
public TestException(Throwable cause) {
super(cause);
- // TODO Auto-generated constructor stub
}
/**
@@ -38,7 +40,6 @@
*/
public TestException(String message, Throwable cause) {
super(message, cause);
- // TODO Auto-generated constructor stub
}
}
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-18 22:44:40 UTC (rev 11228)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -70,20 +70,16 @@
private final Map<String, String> mimeTypes = new HashMap<String, String>();
-
private InvocationListener invocationListener;
-
private StagingServletContext context;
-
+
private ServletContext contextProxy;
-
private ServerHttpSession session;
private HttpSession sessionProxy;
-
private class LocalContext extends StagingServletContext {
/*
@@ -365,7 +361,8 @@
}
/**
- * @param invocationListener the invocationListener to set
+ * @param invocationListener
+ * the invocationListener to set
*/
public void setInvocationListener(InvocationListener invocationListener) {
this.invocationListener = invocationListener;
@@ -376,26 +373,28 @@
*/
public InvocationHandler getInvocationHandler(final Object target) {
return new InvocationHandler() {
-
+
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
InvocationListener listener = getInvocationListener();
try {
Object result = method.invoke(target, args);
- if(null != listener){
- listener.afterInvoke(new InvocationEvent(target,method,args,result));
+ if (null != listener) {
+ listener.afterInvoke(new InvocationEvent(target,
+ method, args, result));
}
return result;
} catch (Throwable e) {
- if(null != listener){
- listener.processException(new InvocationErrorEvent(target,method,args,e));
+ if (null != listener) {
+ listener.processException(new InvocationErrorEvent(
+ target, method, args, e));
}
throw e;
}
}
-
+
};
-
+
}
public HttpSession getSession() {
@@ -407,10 +406,12 @@
this.session = new ServerHttpSession();
// Create proxy objects.
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if(null == loader){
+ if (null == loader) {
loader = this.getClass().getClassLoader();
}
- this.sessionProxy = (HttpSession) Proxy.newProxyInstance(loader, new Class[]{HttpSession.class}, getInvocationHandler(session));
+ this.sessionProxy = (HttpSession) Proxy.newProxyInstance(loader,
+ new Class[] { HttpSession.class },
+ getInvocationHandler(session));
// inform session listeners.
final HttpSessionEvent event = new HttpSessionEvent(session);
fireEvent(SESSION_LISTENER_CLASS,
@@ -433,10 +434,14 @@
// Inform listeners
// Create proxy objects.
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if(null == loader){
+ if (null == loader) {
loader = this.getClass().getClassLoader();
}
- this.contextProxy = (ServletContext) Proxy.newProxyInstance(loader, new Class[]{ServletContext.class}, getInvocationHandler(context));
+ this.contextProxy = (ServletContext) Proxy.newProxyInstance(loader,
+ new Class[] { ServletContext.class },
+ getInvocationHandler(context));
+ // Create default servlet
+ defaultServlet = new ServletContainer(null, new StaticServlet());
final ServletContextEvent event = new ServletContextEvent(context);
fireEvent(CONTEXT_LISTENER_CLASS,
new EventInvoker<ServletContextListener>() {
@@ -450,7 +455,6 @@
// init servlet
servlet.init(this.context);
}
- defaultServlet = new ServletContainer(null, new StaticServlet());
defaultServlet.init(getContext());
} catch (ServletException e) {
throw new TestException(e);
Added: trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html
===================================================================
--- trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html (rev 0)
+++ trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html 2008-11-19 01:04:10 UTC (rev 11229)
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+
+</body>
+</html>
\ No newline at end of file
Property changes on: trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/package.html
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/staging/package.html
===================================================================
--- trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/staging/package.html (rev 0)
+++ trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/staging/package.html 2008-11-19 01:04:10 UTC (rev 11229)
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+
+</body>
+</html>
\ No newline at end of file
Property changes on: trunk/framework/jsf-test/src/main/javadoc/org/richfaces/test/staging/package.html
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-applications/ajaxTest/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow
===================================================================
--- trunk/test-applications/ajaxTest/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow (rev 0)
+++ trunk/test-applications/ajaxTest/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow 2008-11-19 01:04:10 UTC (rev 11229)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pageflow:Pageflow xmlns:pageflow="http://www.sybase.com/suade/pageflow" id="pf12270500671790" configfile="/ajaxTest/src/main/webapp/WEB-INF/faces-config.xml"/>
Modified: trunk/test-applications/ajaxTest/pom.xml
===================================================================
--- trunk/test-applications/ajaxTest/pom.xml 2008-11-18 22:44:40 UTC (rev 11228)
+++ trunk/test-applications/ajaxTest/pom.xml 2008-11-19 01:04:10 UTC (rev 11229)
@@ -5,7 +5,17 @@
<artifactId>ajaxTest</artifactId>
<name>ajax test</name>
<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>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
@@ -28,12 +38,44 @@
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.14</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>core</artifactId>
<version>3.3.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>jstl</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.2_10</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_10</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Deleted: trunk/test-applications/ajaxTest/src/main/java/Bean.java
===================================================================
--- trunk/test-applications/ajaxTest/src/main/java/Bean.java 2008-11-18 22:44:40 UTC (rev 11228)
+++ trunk/test-applications/ajaxTest/src/main/java/Bean.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -1,15 +0,0 @@
-
-
-import java.io.Serializable;
-
-public class Bean implements Serializable {
-
- private String text;
-
- public Bean() {}
-
- public String getText() { return text;}
-
- public void setText(String name) { this.text = name; }
-
-}
Copied: trunk/test-applications/ajaxTest/src/main/java/org/richfaces/Bean.java (from rev 11227, trunk/test-applications/ajaxTest/src/main/java/Bean.java)
===================================================================
--- trunk/test-applications/ajaxTest/src/main/java/org/richfaces/Bean.java (rev 0)
+++ trunk/test-applications/ajaxTest/src/main/java/org/richfaces/Bean.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -0,0 +1,16 @@
+package org.richfaces;
+
+
+import java.io.Serializable;
+
+public class Bean implements Serializable {
+
+ private String text;
+
+ public Bean() {}
+
+ public String getText() { return text;}
+
+ public void setText(String name) { this.text = name; }
+
+}
Property changes on: trunk/test-applications/ajaxTest/src/main/java/org/richfaces/Bean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/test-applications/ajaxTest/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- trunk/test-applications/ajaxTest/src/main/webapp/META-INF/MANIFEST.MF (rev 0)
+++ trunk/test-applications/ajaxTest/src/main/webapp/META-INF/MANIFEST.MF 2008-11-19 01:04:10 UTC (rev 11229)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/test-applications/ajaxTest/src/main/webapp/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/faces-config.xml (from rev 11227, trunk/test-applications/ajaxTest/src/test/resources/faces-config.xml)
===================================================================
--- trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/faces-config.xml 2008-11-19 01:04:10 UTC (rev 11229)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="1.2" 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">
+
+ <application>
+ <!--
+ <message-bundle>messages</message-bundle>
+ -->
+ <locale-config>
+ <default-locale>en</default-locale>
+ </locale-config>
+ <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
+ </application>
+ <managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>org.richfaces.Bean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+</faces-config>
Property changes on: trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/web.xml 2008-11-19 01:04:10 UTC (rev 11229)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="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"
+ version="2.5">
+ <display-name>ajaxTest</display-name>
+ <description>ajax simple repeater test</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.VIEW_MAPPINGS</param-name>
+ <param-value>*.xhtml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ <dispatcher>ERROR</dispatcher>
+ </filter-mapping>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Property changes on: trunk/test-applications/ajaxTest/src/main/webapp/WEB-INF/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml (from rev 11227, trunk/test-applications/ajaxTest/src/test/resources/repeater.xhtml)
===================================================================
--- trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml (rev 0)
+++ trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml 2008-11-19 01:04:10 UTC (rev 11229)
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+ <head><title>Simple repeater in seam</title></head>
+ <body>
+ <h:form id="ajaxForm">
+ <h:inputText id="text" value="#{bean.text}">
+ <a4j:support reRender="out" event="onclick"></a4j:support>
+ </h:inputText>
+ <h:outputText id="out" value="#{bean.text}"></h:outputText>
+ </h:form>
+ </body>
+</html>
Property changes on: trunk/test-applications/ajaxTest/src/main/webapp/repeater.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-18 22:44:40 UTC (rev 11228)
+++ trunk/test-applications/ajaxTest/src/test/java/org/richfaces/RepeaterTest.java 2008-11-19 01:04:10 UTC (rev 11229)
@@ -27,11 +27,12 @@
@Override
protected void setupWebContent() {
- facesServer
- .addResource("/WEB-INF/faces-config.xml", "faces-config.xml");
- facesServer.addResource("/repeater.xhtml", "repeater.xhtml");
+ facesServer.addResourcesFromDirectory("/", this.getClass().getResource("/repeater.xhtml"));
}
+// @Override
+// protected void setupSunFaces() {
+// }
/**
* @throws java.lang.Exception
*/
Deleted: trunk/test-applications/ajaxTest/src/test/resources/faces-config.xml
===================================================================
--- trunk/test-applications/ajaxTest/src/test/resources/faces-config.xml 2008-11-18 22:44:40 UTC (rev 11228)
+++ trunk/test-applications/ajaxTest/src/test/resources/faces-config.xml 2008-11-19 01:04:10 UTC (rev 11229)
@@ -1,20 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<faces-config version="1.2" 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">
-
- <application>
- <!--
- <message-bundle>messages</message-bundle>
- -->
- <locale-config>
- <default-locale>en</default-locale>
- </locale-config>
- <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
- </application>
- <managed-bean>
- <managed-bean-name>bean</managed-bean-name>
- <managed-bean-class>Bean</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- </managed-bean>
-</faces-config>
Deleted: trunk/test-applications/ajaxTest/src/test/resources/repeater.xhtml
===================================================================
--- trunk/test-applications/ajaxTest/src/test/resources/repeater.xhtml 2008-11-18 22:44:40 UTC (rev 11228)
+++ trunk/test-applications/ajaxTest/src/test/resources/repeater.xhtml 2008-11-19 01:04:10 UTC (rev 11229)
@@ -1,15 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html">
- <head><title>Simple repeater in seam</title></head>
- <body>
- <h:form id="ajaxForm">
- <h:inputText id="text" value="#{bean.text}">
- <a4j:support reRender="out" event="onclick"></a4j:support>
- </h:inputText>
- <h:outputText id="out" value="#{bean.text}"></h:outputText>
- </h:form>
- </body>
-</html>
17 years, 6 months
JBoss Rich Faces SVN: r11228 - in trunk/framework/jsf-test/src: main/java/org/richfaces/test/staging and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-11-18 17:44:40 -0500 (Tue, 18 Nov 2008)
New Revision: 11228
Added:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/EventInvoker.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/HttpMethod.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationEvent.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationListener.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/PageContextExtension.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerLogger.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
Removed:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/EventInvoker.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/HttpMethod.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/ServerLogger.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingConnection.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java
Modified:
trunk/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebClient.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebResponse.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/FilterContainer.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/RequestChain.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServletContainer.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/StagingHttpRequest.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpSession.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
trunk/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
Log:
Merge test project from JSF2.0 branch.
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-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -27,6 +27,8 @@
import org.richfaces.test.staging.FilterContainer;
import org.richfaces.test.staging.RequestChain;
import org.richfaces.test.staging.ServletContainer;
+import org.richfaces.test.staging.StagingConnection;
+import org.richfaces.test.staging.StagingServer;
/**
* @author asmirnov
Deleted: trunk/framework/jsf-test/src/main/java/org/richfaces/test/EventInvoker.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/EventInvoker.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/EventInvoker.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -1,10 +0,0 @@
-/**
- *
- */
-package org.richfaces.test;
-
-import java.util.EventListener;
-
-public interface EventInvoker<T extends EventListener> {
- public void invoke(T listener);
-}
\ No newline at end of file
Deleted: trunk/framework/jsf-test/src/main/java/org/richfaces/test/HttpMethod.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/HttpMethod.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/HttpMethod.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -1,33 +0,0 @@
-/**
- *
- */
-package org.richfaces.test;
-
-/**
- * @author asmirnov
- *
- */
-public enum HttpMethod {
-
- GET("GET"),
- POST("POST"),
- HEAD("HEAD"),
- PUT("PUT"),
- OPTIONS("OPTIONS"),
- TRACE("TRACE"),
- DELETE("DELETE");
-
- /**
- * @param name
- */
- private HttpMethod(String name) {
- this.name = name;
- }
-
- private String name;
-
- @Override
- public String toString() {
- return name;
- }
-}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebClient.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebClient.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebClient.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -3,6 +3,8 @@
*/
package org.richfaces.test;
+import org.richfaces.test.staging.StagingServer;
+
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebConnection.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -8,7 +8,9 @@
import javax.servlet.ServletException;
import org.apache.commons.httpclient.NameValuePair;
-import org.richfaces.test.staging.StagingHttpRequest;
+import org.richfaces.test.staging.HttpMethod;
+import org.richfaces.test.staging.StagingConnection;
+import org.richfaces.test.staging.StagingServer;
import com.gargoylesoftware.htmlunit.FormEncodingType;
import com.gargoylesoftware.htmlunit.WebConnection;
@@ -32,14 +34,13 @@
connection.addRequestParameter(param.getName(), param.getValue());
}
HttpMethod httpMethod = HttpMethod.valueOf(settings.getHttpMethod().toString());
- connection.setMethod(httpMethod);
- StagingHttpRequest request = connection.getRequest();
- request.setCharacterEncoding(settings.getCharset());
+ connection.setRequestMethod(httpMethod);
+ connection.setRequestCharacterEncoding(settings.getCharset());
String body = settings.getRequestBody();
String contentType = settings.getEncodingType().getName();
- request.setRequestBody(body);
- request.setContentType(contentType);
- request.addHeaders(settings.getAdditionalHeaders());
+ connection.setRequestBody(body);
+ connection.setRequestContentType(contentType);
+ connection.addRequestHeaders(settings.getAdditionalHeaders());
if(null != body && FormEncodingType.URL_ENCODED.getName().equals(contentType)){
connection.parseFormParameters(body);
}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebResponse.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebResponse.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/LocalWebResponse.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -14,6 +14,7 @@
import java.util.Map.Entry;
import org.apache.commons.httpclient.NameValuePair;
+import org.richfaces.test.staging.StagingConnection;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.WebResponse;
@@ -78,7 +79,7 @@
public List<NameValuePair> getResponseHeaders() {
ArrayList<NameValuePair> headers = new ArrayList<NameValuePair>(10);
- for (Entry<String, String[]> entry : serverConnection.getResponse().getHeaders().entrySet()) {
+ for (Entry<String, String[]> entry : serverConnection.getResponseHeaders().entrySet()) {
for (String value : entry.getValue()) {
headers.add(new NameValuePair(entry.getKey(),value));
}
Deleted: trunk/framework/jsf-test/src/main/java/org/richfaces/test/ServerLogger.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/ServerLogger.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/ServerLogger.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -1,41 +0,0 @@
-/**
- *
- */
-package org.richfaces.test;
-
-import java.util.logging.Logger;
-
-/**
- * @author asmirnov
- *
- */
-public enum ServerLogger {
-
- RESOURCE("resource"),
- CONNECTION("connection"),
- SERVER("server");
-
- private static final String PREFIX="org.richfaces.test.";
-
- private static final String LOGGING_BUNDLE="org.richfaces.test.LogMessages";
- private final String name;
-
- /**
- * @param name
- */
- private ServerLogger(String name) {
- this.name = PREFIX+name;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- public Logger getLogger(){
- return Logger.getLogger(name, LOGGING_BUNDLE);
- }
-
-}
Deleted: trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingConnection.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingConnection.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingConnection.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -1,477 +0,0 @@
-/**
- *
- */
-package org.richfaces.test;
-
-import java.io.IOException;
-import java.io.InvalidClassException;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.richfaces.test.staging.RequestChain;
-import org.richfaces.test.staging.StagingHttpRequest;
-import org.richfaces.test.staging.StagingHttpResponse;
-import org.richfaces.test.staging.StagingServletContext;
-
-import com.gargoylesoftware.htmlunit.WebRequestSettings;
-import com.gargoylesoftware.htmlunit.WebResponse;
-
-/**
- * This class represent single connection to the server.
- *
- * @author asmirnov
- *
- */
-public class StagingConnection {
-
- private static final Logger log = ServerLogger.SERVER.getLogger();
-
- private final StagingServer server;
-
- final URL url;
-
- private ConnectionRequest request;
-
- ConnectionResponse response;
-
- private final RequestChain servlet;
-
- private HttpMethod method = HttpMethod.GET;
-
- private static final Cookie[] COOKIE = new Cookie[] {};
-
- private List<Cookie> cookies = new ArrayList<Cookie>();
-
- private Map<String, String[]> requestParameters = new HashMap<String, String[]>();
-
- private final String pathInfo;
-
- private final String servletPath;
-
- private boolean finished = false;
-
- private boolean started = false;
-
- private String queryString;
-
- public StagingConnection(StagingServer localServer, URL url) {
- this.server = localServer;
- this.url = url;
- String path = url.getPath();
- servlet = localServer.getServlet(path);
- if (null == servlet) {
- throw new IllegalArgumentException();
- }
- this.pathInfo = servlet.getPathInfo(path);
- this.servletPath = servlet.getServletPath(path);
- this.request = new ConnectionRequest();
- this.response = new ConnectionResponse();
- this.request.setAttribute("javax.servlet.include.path_info",
- this.pathInfo);
- this.request.setAttribute("javax.servlet.include.servlet_path",
- this.servletPath);
- setQueryString(url.getQuery());
- if (null != getQueryString()) {
- parseFormParameters(queryString);
- }
-
- }
-
- public void parseFormParameters(String queryString) {
- String[] queryParams = queryString.split("&");
- for (int i = 0; i < queryParams.length; i++) {
- try {
- String par = queryParams[i];
- int eqIndex = par.indexOf('=');
- if (eqIndex >= 0) {
- // TODO - decode url-decoded values.
- String name = URLDecoder.decode(par.substring(0, eqIndex),
- request.getCharacterEncoding());
- String value = URLDecoder.decode(
- par.substring(eqIndex + 1), request
- .getCharacterEncoding());
- addRequestParameter(name, value);
- } else {
- addRequestParameter(URLDecoder.decode(par, request
- .getCharacterEncoding()), null);
- }
- } catch (UnsupportedEncodingException e) {
- throw new TestException(e);
- }
- }
- }
-
- /**
- * @return the finished
- */
- public boolean isFinished() {
- return finished;
- }
-
- /**
- * @return the started
- */
- public boolean isStarted() {
- return started;
- }
-
- private void checkStarted() {
- if (!isFinished()) {
- throw new IllegalStateException("request have not been started");
- }
- }
-
- public void execute() throws ServletException, IOException {
- if (isStarted() || isFinished()) {
- throw new IllegalStateException(
- "request have already been executed");
- }
- start();
- this.servlet.execute(request, response);
- finish();
- }
-
- public void finish() {
- server.requestFinished(request);
- finished = true;
- }
-
- public void start() {
- log.fine("start " + getMethod() + " request processing for file "
- + url.getFile());
- log.fine("request parameters: " + requestParameters);
- server.requestStarted(request);
- started = true;
- }
-
- /**
- * @return the method
- */
- public HttpMethod getMethod() {
- return method;
- }
-
- /**
- * @param method
- * the method to set
- */
- public void setMethod(HttpMethod method) {
- this.method = method;
- }
-
- /**
- * @return the url
- */
- public URL getUrl() {
- return url;
- }
-
- public void addRequestParameter(String name, String value) {
- String[] values = requestParameters.get(name);
- if (null == values) {
- values = new String[1];
- } else {
- String[] newValues = new String[values.length + 1];
- System.arraycopy(values, 0, newValues, 0, values.length);
- values = newValues;
- }
- values[values.length - 1] = value;
- requestParameters.put(name, values);
- }
-
- public String getContentAsString() {
- checkStarted();
- String content = response.getWriterContent();
- if (null == content) {
- byte[] streamContent = response.getStreamContent();
- if (null != streamContent) {
- String encoding = response.getCharacterEncoding();
- if (null != encoding) {
- try {
- content = new String(streamContent, encoding);
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- }
- } else {
- content = new String(streamContent);
- }
- }
- }
- return content;
- }
-
- public byte[] getResponseBody() {
- checkStarted();
- byte[] content = response.getStreamContent();
- if (null == content) {
- String writerContent = response.getWriterContent();
- if (null != writerContent) {
- try {
- content = writerContent.getBytes(response
- .getCharacterEncoding());
- } catch (UnsupportedEncodingException e) {
- content = writerContent.getBytes();
- }
- } else {
- content = new byte[0];
- }
- }
- return content;
- }
-
- /**
- * @return the cookies
- */
- public List<Cookie> getCookies() {
- return cookies;
- }
-
- /**
- * @return the request
- */
- public StagingHttpRequest getRequest() {
- return request;
- }
-
- /**
- * @return the response
- */
- public StagingHttpResponse getResponse() {
- return response;
- }
-
- private class ConnectionRequest extends StagingHttpRequest {
-
- public Cookie[] getCookies() {
- return cookies.toArray(COOKIE);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.http.HttpServletRequest#getMethod()
- */
- public String getMethod() {
- return method.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.http.HttpServletRequest#getServletPath()
- */
- public String getServletPath() {
- return servletPath;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.http.HttpServletRequest#getPathInfo()
- */
- public String getPathInfo() {
- return pathInfo;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.http.HttpServletRequest#getQueryString()
- */
- public String getQueryString() {
- return queryString;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.http.HttpServletRequest#getRequestURI()
- */
- public String getRequestURI() {
- return url.getPath();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
- */
- public String getParameter(String name) {
- String[] values = requestParameters.get(name);
- if (null != values && values.length > 0) {
- return values[0];
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.ServletRequest#getParameterMap()
- */
- @SuppressWarnings("unchecked")
- public Map getParameterMap() {
- return Collections.unmodifiableMap(requestParameters);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.ServletRequest#getParameterNames()
- */
- @SuppressWarnings("unchecked")
- public Enumeration getParameterNames() {
- return Collections.enumeration(requestParameters.keySet());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.servlet.ServletRequest#getParameterValues(java.lang.String)
- */
- public String[] getParameterValues(String name) {
- return requestParameters.get(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.http.HttpServletRequest#getSession()
- */
- public HttpSession getSession() {
- return server.getSession();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
- */
- public HttpSession getSession(boolean create) {
- return server.getSession(create);
- }
-
- @Override
- public RequestDispatcher getRequestDispatcher(String path) {
- RequestDispatcher dispatcher = null;
- if (!path.startsWith("/")) {
- try {
- URL absoluteUrl = new URL(url, path);
- path = absoluteUrl.getFile();
- } catch (MalformedURLException e) {
- return null;
- }
- }
- final RequestChain dispatchedServlet = server.getServlet(path);
- if (null != dispatchedServlet) {
- dispatcher = new RequestDispatcher() {
-
- public void forward(ServletRequest request,
- ServletResponse response) throws ServletException,
- IOException {
- response.reset();
- dispatchedServlet.execute(request, response);
- }
-
- public void include(ServletRequest request,
- ServletResponse response) throws ServletException,
- IOException {
- dispatchedServlet.execute(request, response);
- }
-
- };
- }
- return dispatcher;
- }
-
- @Override
- protected void attributeAdded(String name, Object o) {
- server.requestAttributeAdded(this, name, o);
-
- }
-
- @Override
- protected void attributeRemoved(String name, Object removed) {
- server.requestAttributeRemoved(this, name, removed);
-
- }
-
- @Override
- protected void attributeReplaced(String name, Object o) {
- server.requestAttributeReplaced(this, name, o);
-
- }
-
- }
-
- private class ConnectionResponse extends StagingHttpResponse {
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http
- * .Cookie )
- */
- public void addCookie(Cookie cookie) {
- cookies.add(cookie);
-
- }
-
- }
-
- public String getCharacterEncoding() {
- checkStarted();
- return response.getCharacterEncoding();
- }
-
- public String getContentType() {
- checkStarted();
- return response.getContentType();
- }
-
- public int getStatus() {
- checkStarted();
- return response.getStatus();
- }
-
- public String getErrorMessage() {
- checkStarted();
- return response.getErrorMessage();
- }
-
- /**
- * @param queryString
- * the queryString to set
- */
- public void setQueryString(String queryString) {
- this.queryString = queryString;
- }
-
- /**
- * @return the queryString
- */
- public String getQueryString() {
- return queryString;
- }
-
-}
Deleted: 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-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -1,348 +0,0 @@
-package org.richfaces.test;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.EventListener;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextAttributeEvent;
-import javax.servlet.ServletContextAttributeListener;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletRequestAttributeEvent;
-import javax.servlet.ServletRequestAttributeListener;
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.ServletRequestListener;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionAttributeListener;
-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;
-import org.richfaces.test.staging.ServerResource;
-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;
-
-
-/**
- * Hello world!
- *
- */
-public class StagingServer {
-
-
- private static final Class<ServletRequestListener> REQUEST_LISTENER_CLASS = ServletRequestListener.class;
-
- private static final Class<ServletRequestAttributeListener> REQUEST_ATTRIBUTE_LISTENER_CLASS = ServletRequestAttributeListener.class;
-
- private static final Class<ServletContextListener> CONTEXT_LISTENER_CLASS = ServletContextListener.class;
-
- private static final Class<HttpSessionListener> SESSION_LISTENER_CLASS = HttpSessionListener.class;
-
- private static final Class<HttpSessionAttributeListener> SESSION_ATTRIBUTE_LISTENER_CLASS = HttpSessionAttributeListener.class;
-
- private List<RequestChain> servlets = new ArrayList<RequestChain>();
-
- private RequestChain defaultServlet;
-
- private List<EventListener> contextListeners = new ArrayList<EventListener>();
-
- private Map<String,String> initParameters=new HashMap<String, String>();
-
- private ServerResource serverRoot = new ServerResourcesDirectory();
-
- private class LocalContext extends StagingServletContext{
-
- @Override
- protected void valueBound(ServletContextAttributeEvent event) {
- // inform listeners.
- for (EventListener listener : contextListeners) {
- if (listener instanceof ServletContextAttributeListener) {
- ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
- contextListener.attributeAdded(event);
- }
- }
- }
-
- @Override
- protected void valueReplaced(ServletContextAttributeEvent event) {
- // inform listeners.
- for (EventListener listener : contextListeners) {
- if (listener instanceof ServletContextAttributeListener) {
- ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
- contextListener.attributeReplaced(event);
- }
- }
- }
-
- @Override
- protected void valueUnbound(
- ServletContextAttributeEvent event) {
- // inform listeners.
- for (EventListener listener : contextListeners) {
- if (listener instanceof ServletContextAttributeListener) {
- ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
- contextListener.attributeRemoved(event);
- }
- }
- }
-
- @Override
- /**
- * @param path
- * @return
- */
- protected ServerResource getServerResource(String path) {
- return serverRoot.getResource(new ServerResourcePath(path));
- }
-
- }
-
- private StagingServletContext context;
-
- private class ServerHttpSession extends StagingHttpSession {
-
-
- public ServletContext getServletContext() {
- return context;
- }
-
- @Override
- protected void valueBound(final HttpSessionBindingEvent sessionBindingEvent) {
- // inform session listeners.
- fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,new EventInvoker<HttpSessionAttributeListener>(){
- public void invoke(HttpSessionAttributeListener listener) {
- listener.attributeAdded(sessionBindingEvent);
- }
- });
- }
-
- @Override
- protected void valueUnbound(final HttpSessionBindingEvent sessionBindingEvent) {
- // inform session listeners.
- fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,new EventInvoker<HttpSessionAttributeListener>(){
- public void invoke(HttpSessionAttributeListener listener) {
- listener.attributeRemoved(sessionBindingEvent);
- }
- });
- }
-
- @Override
- protected void valueReplaced(final HttpSessionBindingEvent sessionBindingEvent) {
- // inform session listeners.
- fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,new EventInvoker<HttpSessionAttributeListener>(){
- public void invoke(HttpSessionAttributeListener listener) {
- listener.attributeReplaced(sessionBindingEvent);
- }
- });
- }
- }
-
- private ServerHttpSession session;
-
-
- public void addServlet(RequestChain servlet) {
- servlets.add(servlet);
- }
-
- public void addServlet(String mapping,Servlet servlet){
- servlets.add(new ServletContainer(mapping,servlet));
- }
-
- public RequestChain getServlet(String path) {
- RequestChain result = null;
- for (RequestChain servlet : servlets) {
- if(servlet.isApplicable(path)){
- result = servlet;
- break;
- }
- }
- if(null == result){
- try {
- URL resource = context.getResource(path);
- if(null != resource){
- result = defaultServlet;
- }
- } catch (MalformedURLException e) {
- // do nothing, just return no servlet.
- }
- }
- return result;
- }
-
- public void addInitParameter(String name, String value) {
- initParameters.put(name, value);
- }
-
- public void addResource(String path, String resource){
- 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);
- }
-
- public HttpSession getSession(){
- return getSession(true);
- }
-
- public synchronized HttpSession getSession(boolean create){
- if(null == this.session && create){
- this.session = new ServerHttpSession();
- // inform session listeners.
- final HttpSessionEvent event = new HttpSessionEvent(session);
- fireEvent(SESSION_LISTENER_CLASS,new EventInvoker<HttpSessionListener>(){
- public void invoke(HttpSessionListener listener) {
- listener.sessionCreated(event);
- }
- });
- }
- return session;
- }
-
- /**
- *
- */
- @SuppressWarnings("unchecked")
- private <T extends EventListener> void fireEvent(Class<T> listenerClass,EventInvoker<T> invoker) {
- for (EventListener listener : contextListeners) {
- if (listenerClass.isInstance(listener)) {
- invoker.invoke((T) listener);
- }
- }
- }
-
- public void init() {
- // Create context.
- this.context = new LocalContext();
- // Create Jsp factory
- JspFactory.setDefaultFactory(new StaggingJspFactory());
- // Create init parameters
- context.addInitParameters(initParameters);
- // Inform listeners
- final ServletContextEvent event = new ServletContextEvent(context);
- fireEvent(CONTEXT_LISTENER_CLASS,new EventInvoker<ServletContextListener>(){
- public void invoke(ServletContextListener listener) {
- listener.contextInitialized(event);
- }
- });
- // Init servlets
- try {
- for (RequestChain servlet : servlets) {
- // init servlet
- servlet.init(this.context);
- }
- defaultServlet = new ServletContainer(null,new StaticServlet());
- defaultServlet.init(getContext());
- } catch(ServletException e){
- throw new TestException(e);
- }
- }
-
- public void destroy(){
- // Destroy session
- if (null != this.session) {
- // inform session listeners.
- final HttpSessionEvent event = new HttpSessionEvent(session);
- fireEvent(SESSION_LISTENER_CLASS,new EventInvoker<HttpSessionListener>(){
- public void invoke(HttpSessionListener listener) {
- listener.sessionDestroyed(event);
- }
- });
- session.destroy();
- session = null;
- }
- // Inform listeners
- final ServletContextEvent event = new ServletContextEvent(context);
- fireEvent(CONTEXT_LISTENER_CLASS,new EventInvoker<ServletContextListener>(){
- public void invoke(ServletContextListener listener) {
- listener.contextDestroyed(event);
- }
- });
- // Destroy servlets
- for (RequestChain servlet : servlets) {
- servlet.destroy();
- }
- defaultServlet.destroy();
- // Create Jsp factory
- JspFactory.setDefaultFactory(null);
-
- }
-
- public StagingConnection getConnection(URL url) {
- return new StagingConnection(this,url);
- }
-
- public StagingServletContext getContext() {
- return context;
- }
-
- public void requestStarted(ServletRequest request) {
- final ServletRequestEvent event = new ServletRequestEvent(context,request);
- fireEvent(REQUEST_LISTENER_CLASS, new EventInvoker<ServletRequestListener>(){
- public void invoke(ServletRequestListener listener) {
- listener.requestInitialized(event);
-
- }
- });
- }
-
- public void requestFinished(ServletRequest request) {
- final ServletRequestEvent event = new ServletRequestEvent(context,request);
- fireEvent(REQUEST_LISTENER_CLASS, new EventInvoker<ServletRequestListener>(){
- public void invoke(ServletRequestListener listener) {
- listener.requestDestroyed(event);
- }
- });
- }
-
- public void requestAttributeAdded(ServletRequest request,
- String name, Object o) {
- final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context,request,name,o);
- fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<ServletRequestAttributeListener>(){
- public void invoke(ServletRequestAttributeListener listener) {
- listener.attributeAdded(event);
- }
- });
- }
-
- public void requestAttributeRemoved(ServletRequest request,
- String name, Object removed) {
- final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context,request,name,removed);
- fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<ServletRequestAttributeListener>(){
- public void invoke(ServletRequestAttributeListener listener) {
- listener.attributeRemoved(event);
- }
- });
- }
-
- public void requestAttributeReplaced(ServletRequest request,
- String name, Object value) {
- final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context,request,name,value);
- fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<ServletRequestAttributeListener>(){
- public void invoke(ServletRequestAttributeListener listener) {
- listener.attributeReplaced(event);
- }
- });
- }
-}
Modified: trunk/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 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -8,8 +8,12 @@
import java.util.Set;
import java.util.logging.Logger;
-import org.richfaces.test.ServerLogger;
+/**
+ * Base abstract class for an all file references in the 'virtual' staging server directory.
+ * @author asmirnov
+ *
+ */
public abstract class AbstractServerResource implements ServerResource {
private static final Logger log = ServerLogger.RESOURCE.getLogger();
@@ -17,6 +21,10 @@
public AbstractServerResource() {
}
+ /** This implementation creates stream from the resource URL. I also tries to disable
+ * url connection cache, to prevent jar file locking in the windows environment.
+ * @see org.richfaces.test.staging.ServerResource#getAsStream()
+ */
public InputStream getAsStream() throws IOException {
URL url = getURL();
if (url != null) {
@@ -32,22 +40,34 @@
}
}
+ /**
+ * File-like resources do not allows resources additions.
+ * @throws UnsupportedOperationException
+ * @see org.richfaces.test.staging.ServerResource#addResource(org.richfaces.test.staging.ServerResourcePath, 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 points to the resource itself, returns this instance.
if(path.isFile()){
return this;
}
return null;
}
+ /** File-like resources does not contain any other, so this method always returns null.
+ * @see org.richfaces.test.staging.ServerResource#getPaths()
+ */
public Set<String> getPaths() {
- return Collections.emptySet();
+ return null;//Collections.emptySet();
}
}
\ No newline at end of file
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-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -3,29 +3,28 @@
*/
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.Level;
import java.util.logging.Logger;
-import javax.servlet.ServletResponse;
-import org.richfaces.test.ServerLogger;
-
/**
+ * This class represents file from classpath in the virtual web application
+ * content.
+ *
* @author asmirnov
- *
+ *
*/
public class ClasspathServerResource extends AbstractServerResource {
-
+
+ /**
+ *
+ */
private final String classpath;
-
+
+ private volatile URL url = null;
+
private static final Logger log = ServerLogger.RESOURCE.getLogger();
-
/**
* @param name
@@ -35,16 +34,29 @@
this.classpath = classpath;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.richfaces.test.staging.ServerResource#getURL()
*/
public URL getURL() {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- if(null == classLoader){
- classLoader = this.getClass().getClassLoader();
+ if (url == null) {
+ // JDK-5 singleton-like synchronization.
+ // @see http://jeremymanson.blogspot.com/2008/05/double-checked-locking.html
+ synchronized (this) {
+ if(log.isLoggable(Level.FINEST)){
+ log.finest("get classpath resource from "+this.classpath);
+ }
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ if (null == classLoader) {
+ classLoader = this.getClass().getClassLoader();
+ }
+ url = classLoader.getResource(classpath);
+ }
}
- return classLoader.getResource(classpath);
+
+ return url;
}
-
}
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/EventInvoker.java (from rev 11221, branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/EventInvoker.java)
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/EventInvoker.java (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/EventInvoker.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,10 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import java.util.EventListener;
+
+interface EventInvoker<T extends EventListener> {
+ public void invoke(T listener);
+}
\ No newline at end of file
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/FilterContainer.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/FilterContainer.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/FilterContainer.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -5,6 +5,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
+import java.util.logging.Logger;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -14,40 +15,94 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+
+/**
+ * Holds a filter instance and reference to the next executable server object (
+ * filter or servlet ) in the chain.
+ *
+ * @author asmirnov
+ *
+ */
public class FilterContainer implements RequestChain {
+ private static final Logger log = ServerLogger.SERVER.getLogger();
+
+ /**
+ * Servlet filter instance.
+ */
private final Filter filter;
+ /**
+ * Next object in the chain.
+ */
private final RequestChain next;
+ /**
+ * Filter name.
+ */
private String name = "Default";
+ /**
+ * Filter initialization parameters.
+ */
private final Map<String, String> initParameters;
+ /**
+ * Initialization flag to avoid double calls.
+ */
private boolean initialized = false;
/**
* @param filter
+ * instance of the web application filter.
* @param next
+ * next executable object in the filter chain.
+ * @throws NullPointerException if any of parameter is null.
*/
public FilterContainer(Filter filter, RequestChain next) {
+ if(null == filter || null == next){
+ throw new NullPointerException();
+ }
this.filter = filter;
this.next = next;
this.initParameters = new HashMap<String, String>();
}
+ /**
+ * @return filter name.
+ */
public String getName() {
return name;
}
+ /**
+ * @param name
+ * new filter name.
+ */
public void setName(String name) {
+ if (initialized) {
+ throw new IllegalStateException(
+ "Filter have already been initialized, name can't be changed");
+ }
this.name = name;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.test.staging.RequestChain#execute(javax.servlet.ServletRequest
+ * , javax.servlet.ServletResponse)
+ */
public void execute(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
+ if (!initialized) {
+ throw new IllegalStateException(
+ "Filter "+getName()+" have not been initialized, could'n execute request");
+ }
+ log.finest("Request '"+request+"' executes by the '"+getName()+"' filter");
FilterChain chain = new FilterChain() {
-
+ // Execute next object in the chain.
public void doFilter(ServletRequest request,
ServletResponse response) throws IOException,
ServletException {
@@ -60,14 +115,41 @@
}
+ /**
+ * Append filter initialization parameter. Name and value are same as
+ * defined in the web.xml
+ *
+ * <code>
+ * <init-param>
+ * <param-name>foo</param-name>
+ * <param-value>bar</param-value>
+ * </init-param>
+ * </code>
+ *
+ * @param name
+ * name of the parameter
+ * @param value
+ * its value
+ */
public void addInitParameter(String name, String value) {
+ if (initialized) {
+ throw new IllegalStateException(
+ "Filter have already been initialized, init parameters can't be changed");
+ }
initParameters.put(name, value);
}
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#isApplicable(java.lang.String)
+ */
public boolean isApplicable(String path) {
+ // Delegate to the next object. Filter has a same mapping as target servlet.
return next.isApplicable(path);
}
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#destroy()
+ */
public void destroy() {
if (initialized) {
next.destroy();
@@ -76,7 +158,10 @@
}
}
- public void init(final StagingServletContext context)
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#init(org.richfaces.test.staging.StagingServletContext)
+ */
+ public void init(final ServletContext context)
throws ServletException {
if (!initialized) {
filter.init(new FilterConfig() {
@@ -104,11 +189,19 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#getPathInfo(java.lang.String)
+ */
public String getPathInfo(String path) {
+ // Delegate to the next object. Filter has a same mapping as target servlet.
return next.getPathInfo(path);
}
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#getServletPath(java.lang.String)
+ */
public String getServletPath(String path) {
+ // Delegate to the next object. Filter has a same mapping as target servlet.
return next.getServletPath(path);
}
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/HttpMethod.java (from rev 11221, branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/HttpMethod.java)
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/HttpMethod.java (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/HttpMethod.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+/**
+ * @author asmirnov
+ *
+ */
+public enum HttpMethod {
+
+ GET("GET"),
+ POST("POST"),
+ HEAD("HEAD"),
+ PUT("PUT"),
+ OPTIONS("OPTIONS"),
+ TRACE("TRACE"),
+ DELETE("DELETE");
+
+ /**
+ * @param name
+ */
+ private HttpMethod(String name) {
+ this.name = name;
+ }
+
+ private String name;
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java (from rev 11221, branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java)
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,36 @@
+package org.richfaces.test.staging;
+
+import java.lang.reflect.Method;
+import java.util.EventObject;
+
+public class InvocationErrorEvent extends EventObject {
+ private Object target;
+ private Method method;
+ private Object[] args;
+ private Throwable e;
+
+ public InvocationErrorEvent(Object target, Method method, Object[] args,
+ Throwable e) {
+ super(target);
+ this.target = target;
+ this.method = method;
+ this.args = args;
+ this.e = e;
+ }
+
+ public Object getTarget() {
+ return target;
+ }
+
+ public Method getMethod() {
+ return method;
+ }
+
+ public Object[] getArgs() {
+ return args;
+ }
+
+ public Throwable getE() {
+ return e;
+ }
+}
\ No newline at end of file
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationEvent.java (from rev 11221, branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationEvent.java)
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationEvent.java (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationEvent.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,36 @@
+package org.richfaces.test.staging;
+
+import java.lang.reflect.Method;
+import java.util.EventObject;
+
+public class InvocationEvent extends EventObject {
+ private Object target;
+ private Method method;
+ private Object[] args;
+ private Object result;
+
+ public InvocationEvent(Object target, Method method, Object[] args,
+ Object result) {
+ super(target);
+ this.target = target;
+ this.method = method;
+ this.args = args;
+ this.result = result;
+ }
+
+ public Object getTarget() {
+ return target;
+ }
+
+ public Method getMethod() {
+ return method;
+ }
+
+ public Object[] getArgs() {
+ return args;
+ }
+
+ public Object getResult() {
+ return result;
+ }
+}
\ No newline at end of file
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationListener.java (from rev 11221, branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationListener.java)
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationListener.java (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/InvocationListener.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,32 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import java.util.EventListener;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+
+/**
+ * Listener interface to inspect all calls to {@link HttpServletRequest} , {@link HttpServletResponse}, {@link HttpSession} and {@link ServletContext} objects.
+ * @author asmirnov
+ *
+ */
+public interface InvocationListener extends EventListener{
+
+ /**
+ * This metod called after successful invocation on the target object.
+ * @param invocationEvent
+ */
+ public void afterInvoke(InvocationEvent invocationEvent);
+
+ /**
+ * This method called after any {@link Throwable} thrown during method invocation.
+ * @param invocationErrorEvent
+ */
+ public void processException(InvocationErrorEvent invocationErrorEvent);
+
+}
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/PageContextExtension.java (from rev 11221, branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/PageContextExtension.java)
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/PageContextExtension.java (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/PageContextExtension.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,201 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.el.ELContext;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.el.ExpressionEvaluator;
+import javax.servlet.jsp.el.VariableResolver;
+
+final class PageContextExtension extends PageContext {
+ private ServletResponse response;
+ private Servlet servlet;
+ private ServletRequest request;
+ private boolean needsSession;
+ private int bufferSize;
+ private boolean autoFlush;
+
+
+ @Override
+ public void forward(String relativeUrlPath)
+ throws ServletException, IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Exception getException() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getPage() {
+ return servlet;
+ }
+
+ @Override
+ public ServletRequest getRequest() {
+ return request;
+ }
+
+ @Override
+ public ServletResponse getResponse() {
+ return response;
+ }
+
+ @Override
+ public ServletConfig getServletConfig() {
+ return servlet.getServletConfig();
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ return servlet.getServletConfig().getServletContext();
+ }
+
+ @Override
+ public HttpSession getSession() {
+ HttpServletRequest httpRequest = (HttpServletRequest) request;
+ return httpRequest.getSession(needsSession);
+ }
+
+ @Override
+ public void handlePageException(Exception e)
+ throws ServletException, IOException {
+ throw new ServletException(e);
+
+ }
+
+ @Override
+ public void handlePageException(Throwable t)
+ throws ServletException, IOException {
+ throw new ServletException(t);
+
+ }
+
+ @Override
+ public void include(String relativeUrlPath)
+ throws ServletException, IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void include(String relativeUrlPath, boolean flush)
+ throws ServletException, IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void initialize(Servlet servlet, ServletRequest request,
+ ServletResponse response, String errorPageURL,
+ boolean needsSession, int bufferSize, boolean autoFlush)
+ throws IOException, IllegalStateException,
+ IllegalArgumentException {
+ this.response = response;
+ this.servlet = servlet;
+ this.request = request;
+ this.needsSession = needsSession;
+ this.bufferSize = bufferSize;
+ this.autoFlush = autoFlush;
+ }
+
+ @Override
+ public void release() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object findAttribute(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getAttribute(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getAttribute(String name, int scope) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getAttributeNamesInScope(int scope) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getAttributesScope(String name) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public ELContext getELContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ExpressionEvaluator getExpressionEvaluator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public JspWriter getOut() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VariableResolver getVariableResolver() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void removeAttribute(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeAttribute(String name, int scope) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setAttribute(String name, Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setAttribute(String name, Object value, int scope) {
+ // TODO Auto-generated method stub
+
+ }
+}
\ No newline at end of file
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/RequestChain.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/RequestChain.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/RequestChain.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -2,23 +2,60 @@
import java.io.IOException;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+/**
+ * Implementations of the this interface represent any executable request object ( filter or servlet ) in the virtual server.
+ * Filter implementation also hold a reference to the next server object in the chain.
+ * @author asmirnov
+ *
+ */
public interface RequestChain {
+ /**
+ * Is this object applicable to process given path ?
+ * @param path request path relative to web application context.
+ * @return true if this object was configured to process given path.
+ */
public abstract boolean isApplicable(String path);
+ /**
+ * Execute request with current object. Filter objects also delegate doFilter calls to the next object in the chain.
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
public abstract void execute(ServletRequest request,
ServletResponse response) throws ServletException, IOException;
+ /**
+ * Destroy containing web server objects.
+ */
public abstract void destroy();
- public abstract void init(StagingServletContext context) throws ServletException;
+ /**
+ * Init containing objects ( filters or servlet ).
+ * @param servletContext
+ * @throws ServletException
+ */
+ public abstract void init(ServletContext servletContext) throws ServletException;
+ /**
+ * Calculate path info for a request path.
+ * @param path request path relative to the web application context.
+ * @return part of the path after servlet path or null for a suffix-based mapping.
+ */
public abstract String getPathInfo(String path);
+ /**
+ * Calculate servlet path for a given request.
+ * @param path request path relative to the web application context.
+ * @return prefix part from servlet mapping or {@code path} for a suffix-based mapping.
+ */
public abstract String getServletPath(String path);
}
\ No newline at end of file
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerLogger.java (from rev 11221, branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerLogger.java)
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerLogger.java (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerLogger.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,41 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import java.util.logging.Logger;
+
+/**
+ * @author asmirnov
+ *
+ */
+public enum ServerLogger {
+
+ RESOURCE("resource"),
+ CONNECTION("connection"),
+ SERVER("server");
+
+ private static final String PREFIX="org.richfaces.test.";
+
+ private static final String LOGGING_BUNDLE="org.richfaces.test.LogMessages";
+ private final String name;
+
+ /**
+ * @param name
+ */
+ private ServerLogger(String name) {
+ this.name = PREFIX+name;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ public Logger getLogger(){
+ return Logger.getLogger(name, LOGGING_BUNDLE);
+ }
+
+}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -11,6 +11,7 @@
import java.util.Set;
/**
+ * Directory-like resource for a virtual web application content.
* @author asmirnov
*
*/
@@ -18,6 +19,9 @@
+ /**
+ * Directory content.
+ */
private final Map<String,ServerResource> children = new HashMap<String,ServerResource>();
/* (non-Javadoc)
@@ -28,8 +32,10 @@
if(null == path || path.isFile()){
throw new IllegalArgumentException();
} else if(path.getNextPath().isFile()) {
+ // This is a last part in the path - append resource to the directory content.
children.put(path.getNextElementName(), resource);
} else {
+ // Create a next directory entry.
ServerResource nextDirectory = children.get(path.getNextElementName());
if(null == nextDirectory){
nextDirectory = new ServerResourcesDirectory();
@@ -48,10 +54,12 @@
}
ServerResource resource = null; //children.get(path.getName());
if(path.isFile()){
+ // Path points to the resource itself.
resource=this;
} else {
resource = children.get(path.getNextElementName());
if(!path.getNextPath().isFile() && null!=resource){
+ // Get next resource in the tree, if exists.
resource = resource.getResource(path.getNextPath());
}
}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServletContainer.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServletContainer.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/ServletContainer.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -17,9 +17,9 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
-import org.richfaces.test.ServerLogger;
/**
+ * This class represens Servlet in the web application.
* @author asmirnov
*
*/
@@ -40,10 +40,14 @@
private boolean initialized = false;
/**
- * @param mapping
- * @param servlet
+ * @param mapping Servlet mapping pattern, as defined in the <servlet-mapping> element.
+ * @param servlet servlet instance. Can't be null.
+ * @throws NullPointerException if servlet parameter is null.
*/
public ServletContainer(String mapping, Servlet servlet) {
+ if(null == servlet){
+ throw new NullPointerException();
+ }
if (null == mapping) {
this.prefixMapped = true;
this.mapping = "";
@@ -60,12 +64,31 @@
this.initParameters = new HashMap<String, String>();
}
+ /**
+ * Append filter initialization parameter. Name and value are same as
+ * defined in the web.xml
+ *
+ * <code>
+ * <init-param>
+ * <param-name>foo</param-name>
+ * <param-value>bar</param-value>
+ * </init-param>
+ * </code>
+ *
+ * @param name
+ * @param value
+ * @throws IllegalStateException if servlet was already initialized.
+ */
public void addInitParameter(String name, String value) {
+ if (initialized) {
+ throw new IllegalStateException(
+ "Servlet have already been initialized, init parameters can't be changed");
+ }
initParameters.put(name, value);
}
/**
- * @return the name
+ * @return the name of servlet
*/
public String getName() {
return name;
@@ -74,8 +97,13 @@
/**
* @param name
* the name to set
+ * @throws IllegalStateException if servlet was already initialized.
*/
public void setName(String name) {
+ if (initialized) {
+ throw new IllegalStateException(
+ "Servlet have already been initialized, name can't be changed");
+ }
this.name = name;
}
@@ -95,6 +123,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#getServletPath(java.lang.String)
+ */
public String getServletPath(String path) {
if (!isApplicable(path)) {
return null;
@@ -106,6 +137,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#getPathInfo(java.lang.String)
+ */
public String getPathInfo(String path) {
if (!isApplicable(path)) {
return null;
@@ -118,9 +152,13 @@
}
- public void init(final StagingServletContext context)
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#init(org.richfaces.test.staging.StagingServletContext)
+ */
+ public void init(final ServletContext context)
throws ServletException {
if (!initialized) {
+ log.finest("Initialize servlet "+getName());
servlet.init(new ServletConfig() {
public String getInitParameter(String name) {
@@ -154,10 +192,18 @@
*/
public void execute(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
+ if (!initialized) {
+ throw new IllegalStateException(
+ "Servlet "+getName()+" have not been initialized, could'n execute request");
+ }
+ log.finest("Request '"+request+"' executes by the '"+getName()+"' servlet");
this.servlet.service(request, response);
}
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.RequestChain#destroy()
+ */
public void destroy() {
if (initialized) {
this.servlet.destroy();
Modified: trunk/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 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -6,6 +6,7 @@
import javax.el.ELContextListener;
import javax.el.ELResolver;
import javax.el.ExpressionFactory;
+import javax.servlet.ServletContext;
import javax.servlet.jsp.JspApplicationContext;
import com.sun.el.ExpressionFactoryImpl;
@@ -17,8 +18,11 @@
public class StaggingJspApplicationContext implements JspApplicationContext {
private final ExpressionFactory expressionFactory ;
+ private final ServletContext servletContext;
- public StaggingJspApplicationContext() {
+
+ public StaggingJspApplicationContext(ServletContext servletContext) {
+ this.servletContext = servletContext;
expressionFactory = ExpressionFactory.newInstance();
}
@@ -26,7 +30,6 @@
* @see javax.servlet.jsp.JspApplicationContext#addELContextListener(javax.el.ELContextListener)
*/
public void addELContextListener(ELContextListener listener) {
- // TODO Auto-generated method stub
}
Modified: trunk/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 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -3,6 +3,8 @@
*/
package org.richfaces.test.staging;
+import java.io.IOException;
+
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
@@ -13,27 +15,31 @@
import javax.servlet.jsp.PageContext;
/**
+ * Stagging implementation of the {@link JspFactory} to simulate JSP processing in the stagging server.
+ * TODO - implement JSP functionality.
* @author asmirnov
- *
+ *
*/
public class StaggingJspFactory extends JspFactory {
-
- private static final JspEngineInfo engineInfo = new JspEngineInfo(){
-
+ private static final JspEngineInfo engineInfo = new JspEngineInfo() {
+
@Override
public String getSpecificationVersion() {
return "2.1";
}
-
+
};
- private final JspApplicationContext context;
+ private final JspApplicationContext context;
- public StaggingJspFactory() {
- this.context = new StaggingJspApplicationContext();
+ public StaggingJspFactory(ServletContext servletContext) {
+ this.context = new StaggingJspApplicationContext(servletContext);
}
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see javax.servlet.jsp.JspFactory#getEngineInfo()
*/
@Override
@@ -42,31 +48,47 @@
return engineInfo;
}
- /* (non-Javadoc)
- * @see javax.servlet.jsp.JspFactory#getJspApplicationContext(javax.servlet.ServletContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @seejavax.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)
+ /*
+ * (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;
+ public PageContext getPageContext(final Servlet servlet, final ServletRequest request,
+ final ServletResponse response, String errorPageURL,
+ final boolean needsSession, int buffer, boolean autoflush) {
+ PageContextExtension pageContextExtension = new PageContextExtension();
+ try {
+ pageContextExtension.initialize(servlet, request, response, errorPageURL, needsSession, buffer, autoflush);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ return pageContextExtension;
}
- /* (non-Javadoc)
- * @see javax.servlet.jsp.JspFactory#releasePageContext(javax.servlet.jsp.PageContext)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.servlet.jsp.JspFactory#releasePageContext(javax.servlet.jsp.PageContext
+ * )
*/
@Override
public void releasePageContext(PageContext pc) {
- // TODO Auto-generated method stub
+ pc.release();
}
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java (from rev 11221, branches/jsf2.0/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 (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingConnection.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,521 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.richfaces.test.TestException;
+
+/**
+ * This class represent single connection to the server.
+ *
+ * @author asmirnov
+ *
+ */
+public class StagingConnection {
+
+ private static final Logger log = ServerLogger.SERVER.getLogger();
+
+ private final StagingServer server;
+
+ final URL url;
+
+ private ConnectionRequest request;
+
+ private ConnectionResponse response;
+
+ private final RequestChain servlet;
+
+ private HttpMethod method = HttpMethod.GET;
+
+ private static final Cookie[] COOKIE = new Cookie[] {};
+
+ private List<Cookie> cookies = new ArrayList<Cookie>();
+
+ private Map<String, String[]> requestParameters = new HashMap<String, String[]>();
+
+ private final String pathInfo;
+
+ private final String servletPath;
+
+ private boolean finished = false;
+
+ private boolean started = false;
+
+ private String queryString;
+
+ private HttpServletRequest requestProxy;
+
+ private HttpServletResponse responseProxy;
+
+ public StagingConnection(StagingServer localServer, URL url) {
+ this.server = localServer;
+ this.url = url;
+ String path = url.getPath();
+ servlet = localServer.getServlet(path);
+ if (null == servlet) {
+ throw new IllegalArgumentException();
+ }
+ this.pathInfo = servlet.getPathInfo(path);
+ this.servletPath = servlet.getServletPath(path);
+ this.request = new ConnectionRequest();
+ this.response = new ConnectionResponse();
+ this.request.setAttribute("javax.servlet.include.path_info",
+ this.pathInfo);
+ this.request.setAttribute("javax.servlet.include.servlet_path",
+ this.servletPath);
+ setQueryString(url.getQuery());
+ if (null != getQueryString()) {
+ parseFormParameters(queryString);
+ }
+
+ // Create proxy objects.
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if(null == loader){
+ loader = this.getClass().getClassLoader();
+ }
+ requestProxy = (HttpServletRequest) Proxy.newProxyInstance(loader, new Class[]{HttpServletRequest.class}, server.getInvocationHandler(request));
+ responseProxy = (HttpServletResponse) Proxy.newProxyInstance(loader, new Class[]{HttpServletResponse.class}, server.getInvocationHandler(response));
+ }
+
+ public void parseFormParameters(String queryString) {
+ String[] queryParams = queryString.split("&");
+ for (int i = 0; i < queryParams.length; i++) {
+ try {
+ String par = queryParams[i];
+ int eqIndex = par.indexOf('=');
+ if (eqIndex >= 0) {
+ // decode url-decoded values.
+ String name = URLDecoder.decode(par.substring(0, eqIndex),
+ request.getCharacterEncoding());
+ String value = URLDecoder.decode(
+ par.substring(eqIndex + 1), request
+ .getCharacterEncoding());
+ addRequestParameter(name, value);
+ } else {
+ addRequestParameter(URLDecoder.decode(par, request
+ .getCharacterEncoding()), null);
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw new TestException(e);
+ }
+ }
+ }
+
+ /**
+ * @return the finished
+ */
+ public boolean isFinished() {
+ return finished;
+ }
+
+ /**
+ * @return the started
+ */
+ public boolean isStarted() {
+ return started;
+ }
+
+ private void checkStarted() {
+ if (!isFinished()) {
+ throw new IllegalStateException("request have not been started");
+ }
+ }
+
+ private void checkNotStarted() {
+ if (isStarted()) {
+ throw new IllegalStateException("request was started, no parameters changes allowed");
+ }
+ }
+
+ public void execute() throws ServletException, IOException {
+ if (isStarted() || isFinished()) {
+ throw new IllegalStateException(
+ "request have already been executed");
+ }
+ start();
+ this.servlet.execute(request, response);
+ finish();
+ }
+
+ public void finish() {
+ server.requestFinished(request);
+ finished = true;
+ }
+
+ public void start() {
+ log.fine("start " + getMethod() + " request processing for file "
+ + url.getFile());
+ log.fine("request parameters: " + requestParameters);
+ server.requestStarted(request);
+ started = true;
+ }
+
+ /**
+ * @return the method
+ */
+ public HttpMethod getMethod() {
+ return method;
+ }
+
+ /**
+ * @param method
+ * the method to set
+ */
+ public void setRequestMethod(HttpMethod method) {
+ checkNotStarted();
+ this.method = method;
+ }
+
+ /**
+ * @return the url
+ */
+ public URL getUrl() {
+ return url;
+ }
+
+ public void addRequestParameter(String name, String value) {
+ checkNotStarted();
+ String[] values = requestParameters.get(name);
+ if (null == values) {
+ values = new String[1];
+ } else {
+ String[] newValues = new String[values.length + 1];
+ System.arraycopy(values, 0, newValues, 0, values.length);
+ values = newValues;
+ }
+ values[values.length - 1] = value;
+ requestParameters.put(name, values);
+ }
+
+ /**
+ * @return
+ */
+ public String getContentAsString() {
+ checkStarted();
+ String content = response.getWriterContent();
+ if (null == content) {
+ byte[] streamContent = response.getStreamContent();
+ if (null != streamContent) {
+ String encoding = response.getCharacterEncoding();
+ if (null != encoding) {
+ try {
+ content = new String(streamContent, encoding);
+ } catch (UnsupportedEncodingException e) {
+ throw new TestException(e);
+ }
+ } else {
+ content = new String(streamContent);
+ }
+ }
+ }
+ return content;
+ }
+
+ public byte[] getResponseBody() {
+ checkStarted();
+ byte[] content = response.getStreamContent();
+ if (null == content) {
+ String writerContent = response.getWriterContent();
+ if (null != writerContent) {
+ try {
+ content = writerContent.getBytes(response
+ .getCharacterEncoding());
+ } catch (UnsupportedEncodingException e) {
+ content = writerContent.getBytes();
+ }
+ } else {
+ content = new byte[0];
+ }
+ }
+ return content;
+ }
+
+ /**
+ * @return the cookies
+ */
+ public List<Cookie> getCookies() {
+ return cookies;
+ }
+
+ /**
+ * @return the request
+ */
+ public HttpServletRequest getRequest() {
+ return requestProxy;
+ }
+
+ /**
+ * @return the response
+ */
+ public HttpServletResponse getResponse() {
+ return responseProxy;
+ }
+
+ private class ConnectionRequest extends StagingHttpRequest {
+
+ public Cookie[] getCookies() {
+ return cookies.toArray(COOKIE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServletRequest#getMethod()
+ */
+ public String getMethod() {
+ return method.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServletRequest#getServletPath()
+ */
+ public String getServletPath() {
+ return servletPath;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServletRequest#getPathInfo()
+ */
+ public String getPathInfo() {
+ return pathInfo;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServletRequest#getQueryString()
+ */
+ public String getQueryString() {
+ return queryString;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServletRequest#getRequestURI()
+ */
+ public String getRequestURI() {
+ return url.getPath();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
+ */
+ public String getParameter(String name) {
+ String[] values = requestParameters.get(name);
+ if (null != values && values.length > 0) {
+ return values[0];
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletRequest#getParameterMap()
+ */
+ @SuppressWarnings("unchecked")
+ public Map getParameterMap() {
+ return Collections.unmodifiableMap(requestParameters);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletRequest#getParameterNames()
+ */
+ @SuppressWarnings("unchecked")
+ public Enumeration getParameterNames() {
+ return Collections.enumeration(requestParameters.keySet());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.servlet.ServletRequest#getParameterValues(java.lang.String)
+ */
+ public String[] getParameterValues(String name) {
+ return requestParameters.get(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServletRequest#getSession()
+ */
+ public HttpSession getSession() {
+ return server.getSession();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
+ */
+ public HttpSession getSession(boolean create) {
+ return server.getSession(create);
+ }
+
+ @Override
+ public RequestDispatcher getRequestDispatcher(String path) {
+ RequestDispatcher dispatcher = null;
+ if (!path.startsWith("/")) {
+ try {
+ URL absoluteUrl = new URL(url, path);
+ path = absoluteUrl.getFile();
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ }
+ final RequestChain dispatchedServlet = server.getServlet(path);
+ if (null != dispatchedServlet) {
+ dispatcher = new RequestDispatcher() {
+
+ public void forward(ServletRequest request,
+ ServletResponse response) throws ServletException,
+ IOException {
+ response.reset();
+ dispatchedServlet.execute(request, response);
+ }
+
+ public void include(ServletRequest request,
+ ServletResponse response) throws ServletException,
+ IOException {
+ dispatchedServlet.execute(request, response);
+ }
+
+ };
+ }
+ return dispatcher;
+ }
+
+ @Override
+ protected void attributeAdded(String name, Object o) {
+ server.requestAttributeAdded(this, name, o);
+
+ }
+
+ @Override
+ protected void attributeRemoved(String name, Object removed) {
+ server.requestAttributeRemoved(this, name, removed);
+
+ }
+
+ @Override
+ protected void attributeReplaced(String name, Object o) {
+ server.requestAttributeReplaced(this, name, o);
+
+ }
+
+ }
+
+ private class ConnectionResponse extends StagingHttpResponse {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http
+ * .Cookie )
+ */
+ public void addCookie(Cookie cookie) {
+ cookies.add(cookie);
+
+ }
+
+ }
+
+ public String getCharacterEncoding() {
+ checkStarted();
+ return response.getCharacterEncoding();
+ }
+
+ public String getContentType() {
+ checkStarted();
+ return response.getContentType();
+ }
+
+ public int getStatus() {
+ checkStarted();
+ return response.getStatus();
+ }
+
+ public String getErrorMessage() {
+ checkStarted();
+ return response.getErrorMessage();
+ }
+
+ /**
+ * @param queryString
+ * the queryString to set
+ */
+ public void setQueryString(String queryString) {
+ checkNotStarted();
+ this.queryString = queryString;
+ }
+
+ /**
+ * @return the queryString
+ */
+ public String getQueryString() {
+ return queryString;
+ }
+
+ /**
+ * @return
+ */
+ public Map<String, String[]> getResponseHeaders() {
+ checkStarted();
+ return response.getHeaders();
+ }
+
+ public void setRequestCharacterEncoding(String charset) throws UnsupportedEncodingException {
+ checkNotStarted();
+ request.setCharacterEncoding(charset);
+ }
+
+ public void setRequestBody(String body) {
+ checkNotStarted();
+ request.setRequestBody(body);
+ }
+
+ public void setRequestContentType(String contentType) {
+ checkNotStarted();
+ request.setContentType(contentType);
+
+ }
+
+ public void addRequestHeaders(Map<String, String> headers) {
+ request.addHeaders(headers);
+ }
+
+}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -8,6 +8,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
import java.security.Principal;
import java.text.DateFormat;
import java.text.ParseException;
@@ -26,13 +27,12 @@
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
-import org.richfaces.test.ServerLogger;
/**
* @author asmirnov
*
*/
-public abstract class StagingHttpRequest implements HttpServletRequest {
+abstract class StagingHttpRequest implements HttpServletRequest {
private static final Logger log = ServerLogger.CONNECTION.getLogger();
@@ -57,7 +57,7 @@
/**
* @return the requestBody
*/
- public String getRequestBody() {
+ String getRequestBody() {
return requestBody;
}
@@ -65,7 +65,7 @@
* @param requestBody
* the requestBody to set
*/
- public void setRequestBody(String requestBody) {
+ void setRequestBody(String requestBody) {
this.requestBody = requestBody;
}
@@ -157,11 +157,11 @@
return -1;
}
- public void addHeader(String name, String value) {
+ void addHeader(String name, String value) {
headers.put(name, value);
}
- public void addHeaders(Map<String, String> headers) {
+ void addHeaders(Map<String, String> headers) {
this.headers.putAll(headers);
}
@@ -541,6 +541,9 @@
*/
public void setCharacterEncoding(String env)
throws UnsupportedEncodingException {
+ if (!Charset.isSupported(env)) {
+ throw new UnsupportedEncodingException("Unknown charset "+env);
+ }
this.characterEncoding = env;
}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -22,13 +22,12 @@
import org.apache.commons.httpclient.HttpStatus;
import org.junit.internal.matchers.SubstringMatcher;
-import org.richfaces.test.ServerLogger;
/**
* @author asmirnov
*
*/
-public abstract class StagingHttpResponse implements HttpServletResponse {
+abstract class StagingHttpResponse implements HttpServletResponse {
private static final Logger log = ServerLogger.CONNECTION.getLogger();
@@ -63,7 +62,7 @@
/**
* @return the headers
*/
- public Map<String, String[]> getHeaders() {
+ Map<String, String[]> getHeaders() {
return headers;
}
@@ -445,21 +444,21 @@
/**
* @return the status
*/
- public int getStatus() {
+ int getStatus() {
return status;
}
/**
* @return the redirectLocation
*/
- public String getRedirectLocation() {
+ String getRedirectLocation() {
return redirectLocation;
}
/**
* @return the errorMessage
*/
- public String getErrorMessage() {
+ String getErrorMessage() {
return errorMessage;
}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpSession.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpSession.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingHttpSession.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -21,7 +21,7 @@
* @author asmirnov
*
*/
-public abstract class StagingHttpSession implements HttpSession {
+abstract class StagingHttpSession implements HttpSession {
private static final int DEFAULT_INACTIVE_TIME = 30;
@@ -43,7 +43,7 @@
/**
*
*/
- public void destroy() {
+ void destroy() {
// Destroy all session attributes.
unboundAttributes();
}
Copied: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java (from rev 11221, branches/jsf2.0/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 (rev 0)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServer.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -0,0 +1,558 @@
+package org.richfaces.test.staging;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextAttributeListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.ServletRequestAttributeListener;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+import javax.servlet.jsp.JspFactory;
+
+import org.richfaces.test.TestException;
+
+/**
+ * This class implements limited Http servlet container 2.5 functionality. It
+ * supports only calls only, java code configuration, just one web application
+ * etc...
+ *
+ */
+public class StagingServer {
+
+ private static final Class<ServletRequestListener> REQUEST_LISTENER_CLASS = ServletRequestListener.class;
+
+ private static final Class<ServletRequestAttributeListener> REQUEST_ATTRIBUTE_LISTENER_CLASS = ServletRequestAttributeListener.class;
+
+ private static final Class<ServletContextListener> CONTEXT_LISTENER_CLASS = ServletContextListener.class;
+
+ private static final Class<HttpSessionListener> SESSION_LISTENER_CLASS = HttpSessionListener.class;
+
+ private static final Class<HttpSessionAttributeListener> SESSION_ATTRIBUTE_LISTENER_CLASS = HttpSessionAttributeListener.class;
+
+ private List<RequestChain> servlets = new ArrayList<RequestChain>();
+
+ private RequestChain defaultServlet;
+
+ private List<EventListener> contextListeners = new ArrayList<EventListener>();
+
+ private Map<String, String> initParameters = new HashMap<String, String>();
+
+ private ServerResource serverRoot = new ServerResourcesDirectory();
+
+ private final Map<String, String> mimeTypes = new HashMap<String, String>();
+
+
+ private InvocationListener invocationListener;
+
+
+ private StagingServletContext context;
+
+ private ServletContext contextProxy;
+
+
+ private ServerHttpSession session;
+
+ private HttpSession sessionProxy;
+
+
+ private class LocalContext extends StagingServletContext {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
+ */
+ public String getMimeType(String file) {
+ int indexOfDot = file.lastIndexOf('.');
+ // get extension.
+ if (indexOfDot >= 0) {
+ file = file.substring(indexOfDot);
+ }
+ return mimeTypes.get(file);
+ }
+
+ @Override
+ protected void valueBound(ServletContextAttributeEvent event) {
+ // inform listeners.
+ for (EventListener listener : contextListeners) {
+ if (listener instanceof ServletContextAttributeListener) {
+ ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
+ contextListener.attributeAdded(event);
+ }
+ }
+ }
+
+ @Override
+ protected void valueReplaced(ServletContextAttributeEvent event) {
+ // inform listeners.
+ for (EventListener listener : contextListeners) {
+ if (listener instanceof ServletContextAttributeListener) {
+ ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
+ contextListener.attributeReplaced(event);
+ }
+ }
+ }
+
+ @Override
+ protected void valueUnbound(ServletContextAttributeEvent event) {
+ // inform listeners.
+ for (EventListener listener : contextListeners) {
+ if (listener instanceof ServletContextAttributeListener) {
+ ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
+ contextListener.attributeRemoved(event);
+ }
+ }
+ }
+
+ @Override
+ /*
+ * @param path
+ *
+ * @return
+ */
+ protected ServerResource getServerResource(String path) {
+ return serverRoot.getResource(new ServerResourcePath(path));
+ }
+
+ }
+
+ private class ServerHttpSession extends StagingHttpSession {
+
+ public ServletContext getServletContext() {
+ return context;
+ }
+
+ @Override
+ protected void valueBound(
+ final HttpSessionBindingEvent sessionBindingEvent) {
+ // inform session listeners.
+ fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,
+ new EventInvoker<HttpSessionAttributeListener>() {
+ public void invoke(HttpSessionAttributeListener listener) {
+ listener.attributeAdded(sessionBindingEvent);
+ }
+ });
+ }
+
+ @Override
+ protected void valueUnbound(
+ final HttpSessionBindingEvent sessionBindingEvent) {
+ // inform session listeners.
+ fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,
+ new EventInvoker<HttpSessionAttributeListener>() {
+ public void invoke(HttpSessionAttributeListener listener) {
+ listener.attributeRemoved(sessionBindingEvent);
+ }
+ });
+ }
+
+ @Override
+ protected void valueReplaced(
+ final HttpSessionBindingEvent sessionBindingEvent) {
+ // inform session listeners.
+ fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,
+ new EventInvoker<HttpSessionAttributeListener>() {
+ public void invoke(HttpSessionAttributeListener listener) {
+ listener.attributeReplaced(sessionBindingEvent);
+ }
+ });
+ }
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("unchecked")
+ private <T extends EventListener> void fireEvent(Class<T> listenerClass,
+ EventInvoker<T> invoker) {
+ for (EventListener listener : contextListeners) {
+ if (listenerClass.isInstance(listener)) {
+ invoker.invoke((T) listener);
+ }
+ }
+ }
+
+ /**
+ * Append executable server object ( {@link Filter} or {@link Servlet}
+ * container.
+ *
+ * @param servlet
+ */
+ public void addServlet(RequestChain servlet) {
+ servlets.add(servlet);
+ }
+
+ /**
+ * Add servlet to the server.
+ *
+ * @param mapping
+ * servlet mapping
+ * @param servlet
+ * {@link Servlet} instance.
+ */
+ public void addServlet(String mapping, Servlet servlet) {
+ servlets.add(new ServletContainer(mapping, servlet));
+ }
+
+ /**
+ * Get appropriate object ( Filter or Servlet ) for a given path.
+ *
+ * @param path
+ * request path relative to web application context.
+ * @return
+ */
+ public RequestChain getServlet(String path) {
+ RequestChain result = null;
+ for (RequestChain servlet : servlets) {
+ if (servlet.isApplicable(path)) {
+ result = servlet;
+ break;
+ }
+ }
+ if (null == result) {
+ try {
+ URL resource = context.getResource(path);
+ if (null != resource) {
+ result = defaultServlet;
+ }
+ } catch (MalformedURLException e) {
+ // do nothing, just return no servlet.
+ }
+ }
+ return result;
+ }
+
+ public void addInitParameter(String name, String value) {
+ initParameters.put(name, value);
+ }
+
+ void addMimeType(String extension, String mimeType) {
+ mimeTypes.put(extension, mimeType);
+ }
+
+ public void addResource(String path, String resource) {
+ ServerResourcePath resourcePath = new ServerResourcePath(path);
+ serverRoot.addResource(resourcePath, new ClasspathServerResource(
+ resource));
+ }
+
+ public void addResource(String path, URL resource) {
+ serverRoot.addResource(new ServerResourcePath(path),
+ new UrlServerResource(resource));
+ }
+
+ public void addResourcesFromDirectory(String path, URL resource) {
+ ServerResourcePath resourcePath = new ServerResourcePath(path);
+ ServerResource baseDirectory = serverRoot.getResource(resourcePath);
+ if (null == baseDirectory) {
+ baseDirectory = new ServerResourcesDirectory();
+ serverRoot.addResource(resourcePath, baseDirectory);
+ }
+ String protocol = resource.getProtocol();
+ if ("jar".equals(protocol)) {
+ addResourcesFromJar(resource, baseDirectory);
+ } else if ("file".equals(protocol)) {
+ addResourcesFromFile(resource, baseDirectory);
+ } else {
+ throw new TestException("Unsupported protocol " + protocol);
+ }
+ }
+
+ protected void addResourcesFromFile(URL resource,
+ ServerResource baseDirectory) {
+ File file = new File(resource.getPath());
+ if (!file.isDirectory()) {
+ file = file.getParentFile();
+ }
+ try {
+ addFiles(baseDirectory, file);
+ } catch (MalformedURLException e) {
+ throw new TestException(e);
+ }
+ }
+
+ protected void addResourcesFromJar(URL resource,
+ ServerResource baseDirectory) {
+ try {
+ String jarPath = resource.getPath();
+ String entry = jarPath.substring(jarPath.indexOf('!') + 2);
+ jarPath = jarPath.substring(0, jarPath.indexOf('!'));
+ File file = new File(new URI(jarPath));
+ ZipFile zip = new ZipFile(file);
+ 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());
+ URL relativeResource = new URL(resource, relativePath);
+ baseDirectory.addResource(new ServerResourcePath("/"
+ + relativePath), new UrlServerResource(
+ relativeResource));
+ }
+ }
+
+ } catch (IOException e) {
+ throw new TestException(e);
+ } catch (URISyntaxException e) {
+ throw new TestException(e);
+ }
+ }
+
+ /**
+ * @param baseDirectory
+ * @param file
+ * @throws MalformedURLException
+ */
+ protected void addFiles(ServerResource baseDirectory, File file)
+ throws MalformedURLException {
+ File[] files = file.listFiles();
+ for (File subfile : files) {
+ ServerResourcePath serverResourcePath = new ServerResourcePath("/"
+ + subfile.getName());
+ if (subfile.isDirectory()) {
+ ServerResourcesDirectory subDir = new ServerResourcesDirectory();
+ baseDirectory.addResource(serverResourcePath, subDir);
+ addFiles(subDir, subfile);
+ } else {
+ UrlServerResource resource = new UrlServerResource(subfile
+ .toURL());
+ baseDirectory.addResource(serverResourcePath, resource);
+
+ }
+ }
+ }
+
+ public void addWebListener(EventListener listener) {
+ contextListeners.add(listener);
+ }
+
+ /**
+ * @return the invocationListener
+ */
+ public InvocationListener getInvocationListener() {
+ return invocationListener;
+ }
+
+ /**
+ * @param invocationListener the invocationListener to set
+ */
+ public void setInvocationListener(InvocationListener invocationListener) {
+ this.invocationListener = invocationListener;
+ }
+
+ /**
+ * @return the invocationHandler
+ */
+ public InvocationHandler getInvocationHandler(final Object target) {
+ return new InvocationHandler() {
+
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ InvocationListener listener = getInvocationListener();
+ try {
+ Object result = method.invoke(target, args);
+ if(null != listener){
+ listener.afterInvoke(new InvocationEvent(target,method,args,result));
+ }
+ return result;
+ } catch (Throwable e) {
+ if(null != listener){
+ listener.processException(new InvocationErrorEvent(target,method,args,e));
+ }
+ throw e;
+ }
+ }
+
+ };
+
+ }
+
+ public HttpSession getSession() {
+ return getSession(true);
+ }
+
+ public synchronized HttpSession getSession(boolean create) {
+ if (null == this.session && create) {
+ this.session = new ServerHttpSession();
+ // Create proxy objects.
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if(null == loader){
+ loader = this.getClass().getClassLoader();
+ }
+ this.sessionProxy = (HttpSession) Proxy.newProxyInstance(loader, new Class[]{HttpSession.class}, getInvocationHandler(session));
+ // inform session listeners.
+ final HttpSessionEvent event = new HttpSessionEvent(session);
+ fireEvent(SESSION_LISTENER_CLASS,
+ new EventInvoker<HttpSessionListener>() {
+ public void invoke(HttpSessionListener listener) {
+ listener.sessionCreated(event);
+ }
+ });
+ }
+ return sessionProxy;
+ }
+
+ public void init() {
+ // Create context.
+ this.context = new LocalContext();
+ // Create Jsp factory
+ JspFactory.setDefaultFactory(new StaggingJspFactory(this.context));
+ // Create init parameters
+ context.addInitParameters(initParameters);
+ // Inform listeners
+ // Create proxy objects.
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if(null == loader){
+ loader = this.getClass().getClassLoader();
+ }
+ this.contextProxy = (ServletContext) Proxy.newProxyInstance(loader, new Class[]{ServletContext.class}, getInvocationHandler(context));
+ final ServletContextEvent event = new ServletContextEvent(context);
+ fireEvent(CONTEXT_LISTENER_CLASS,
+ new EventInvoker<ServletContextListener>() {
+ public void invoke(ServletContextListener listener) {
+ listener.contextInitialized(event);
+ }
+ });
+ // Init servlets
+ try {
+ for (RequestChain servlet : servlets) {
+ // init servlet
+ servlet.init(this.context);
+ }
+ defaultServlet = new ServletContainer(null, new StaticServlet());
+ defaultServlet.init(getContext());
+ } catch (ServletException e) {
+ throw new TestException(e);
+ }
+ }
+
+ public void destroy() {
+ // Destroy session
+ if (null != this.session) {
+ // inform session listeners.
+ final HttpSessionEvent event = new HttpSessionEvent(session);
+ fireEvent(SESSION_LISTENER_CLASS,
+ new EventInvoker<HttpSessionListener>() {
+ public void invoke(HttpSessionListener listener) {
+ listener.sessionDestroyed(event);
+ }
+ });
+ session.destroy();
+ session = null;
+ }
+ // Inform listeners
+ final ServletContextEvent event = new ServletContextEvent(context);
+ fireEvent(CONTEXT_LISTENER_CLASS,
+ new EventInvoker<ServletContextListener>() {
+ public void invoke(ServletContextListener listener) {
+ listener.contextDestroyed(event);
+ }
+ });
+ // Destroy servlets
+ for (RequestChain servlet : servlets) {
+ servlet.destroy();
+ }
+ defaultServlet.destroy();
+ // Create Jsp factory
+ JspFactory.setDefaultFactory(null);
+
+ }
+
+ public StagingConnection getConnection(URL url) {
+ return new StagingConnection(this, url);
+ }
+
+ public ServletContext getContext() {
+ return contextProxy;
+ }
+
+ public void requestStarted(ServletRequest request) {
+ final ServletRequestEvent event = new ServletRequestEvent(context,
+ request);
+ fireEvent(REQUEST_LISTENER_CLASS,
+ new EventInvoker<ServletRequestListener>() {
+ public void invoke(ServletRequestListener listener) {
+ listener.requestInitialized(event);
+
+ }
+ });
+ }
+
+ public void requestFinished(ServletRequest request) {
+ final ServletRequestEvent event = new ServletRequestEvent(context,
+ request);
+ fireEvent(REQUEST_LISTENER_CLASS,
+ new EventInvoker<ServletRequestListener>() {
+ public void invoke(ServletRequestListener listener) {
+ listener.requestDestroyed(event);
+ }
+ });
+ }
+
+ public void requestAttributeAdded(ServletRequest request, String name,
+ Object o) {
+ final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(
+ context, request, name, o);
+ fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS,
+ new EventInvoker<ServletRequestAttributeListener>() {
+ public void invoke(ServletRequestAttributeListener listener) {
+ listener.attributeAdded(event);
+ }
+ });
+ }
+
+ public void requestAttributeRemoved(ServletRequest request, String name,
+ Object removed) {
+ final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(
+ context, request, name, removed);
+ fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS,
+ new EventInvoker<ServletRequestAttributeListener>() {
+ public void invoke(ServletRequestAttributeListener listener) {
+ listener.attributeRemoved(event);
+ }
+ });
+ }
+
+ public void requestAttributeReplaced(ServletRequest request, String name,
+ Object value) {
+ final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(
+ context, request, name, value);
+ fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS,
+ new EventInvoker<ServletRequestAttributeListener>() {
+ public void invoke(ServletRequestAttributeListener listener) {
+ listener.attributeReplaced(event);
+ }
+ });
+ }
+}
Modified: trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
===================================================================
--- trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -24,13 +24,12 @@
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletException;
-import org.richfaces.test.ServerLogger;
/**
* @author asmirnov
*
*/
-public abstract class StagingServletContext implements ServletContext {
+abstract class StagingServletContext implements ServletContext {
private static final Logger log = ServerLogger.SERVER.getLogger();
@@ -38,7 +37,7 @@
private static final String APPLICATION_NAME = "stub";
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
- private Map<String,String> initParameters = new HashMap<String, String>();
+ private final Map<String,String> initParameters = new HashMap<String, String>();
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getAttribute(java.lang.String)
@@ -106,14 +105,6 @@
return 2;
}
- /* (non-Javadoc)
- * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
- */
- public String getMimeType(String file) {
- // TODO create mime-types table.
- log.info("unimplemented servlet context method getMimeType");
- return null;
- }
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getMinorVersion()
Modified: trunk/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 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -6,18 +6,24 @@
import java.net.URL;
import java.util.logging.Logger;
-import org.richfaces.test.ServerLogger;
/**
+ * This class represent file-like virtual web application object, loaded from the any URL.
* @author asmirnov
*
*/
public class UrlServerResource extends AbstractServerResource {
+ /**
+ * Resource target URL
+ */
private final URL resource;
static final Logger log = ServerLogger.RESOURCE.getLogger();
+ /**
+ * @param resource url to the resource content.
+ */
public UrlServerResource(URL resource) {
this.resource = resource;
}
Modified: trunk/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
===================================================================
--- trunk/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java 2008-11-18 17:55:45 UTC (rev 11227)
+++ trunk/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java 2008-11-18 22:44:40 UTC (rev 11228)
@@ -59,6 +59,10 @@
RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
StagingServletContext context = new StagingServletContext(){
+ public String getMimeType(String file){
+ return null;
+ }
+
@Override
protected ServerResource getServerResource(String path) {
// TODO Auto-generated method stub
17 years, 6 months
JBoss Rich Faces SVN: r11227 - in trunk/sandbox/ui/editor/src/main: java/org/richfaces/renderkit/html/images and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-11-18 12:55:45 -0500 (Tue, 18 Nov 2008)
New Revision: 11227
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorAdvancedThemeIcons.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorSimpleThemeIcons.java
Removed:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java
Modified:
trunk/sandbox/ui/editor/src/main/config/resources/resources-config.xml
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss
Log:
Editor: Rename icons classes
Modified: trunk/sandbox/ui/editor/src/main/config/resources/resources-config.xml
===================================================================
--- trunk/sandbox/ui/editor/src/main/config/resources/resources-config.xml 2008-11-18 17:23:56 UTC (rev 11226)
+++ trunk/sandbox/ui/editor/src/main/config/resources/resources-config.xml 2008-11-18 17:55:45 UTC (rev 11227)
@@ -4738,8 +4738,8 @@
<name>scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss</name>
<path>org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss</path>
</resource>
- <resource class="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons">
- <name>org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons</name>
+ <resource class="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons">
+ <name>org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons</name>
</resource>
<resource>
<name>scripts/tiny_mce/themes/advanced/source_editor.htm</name>
@@ -5038,8 +5038,8 @@
<name>scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss</name>
<path>org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss</path>
</resource>
- <resource class="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons">
- <name>org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons</name>
+ <resource class="org.richfaces.renderkit.html.images.EditorSimpleThemeIcons">
+ <name>org.richfaces.renderkit.html.images.EditorSimpleThemeIcons</name>
</resource>
<resource>
<name>scripts/tiny_mce/tiny_mce.js</name>
Copied: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorAdvancedThemeIcons.java (from rev 11224, trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java)
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorAdvancedThemeIcons.java (rev 0)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorAdvancedThemeIcons.java 2008-11-18 17:55:45 UTC (rev 11227)
@@ -0,0 +1,96 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.PngRenderer;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EditorAdvancedThemeIcons extends EditorIcons{
+
+ private Dimension dimension = new Dimension(88, 66);
+
+
+ public EditorAdvancedThemeIcons() {
+ super();
+
+ setRenderer(new PngRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance()
+ .getStartTime()));
+ }
+
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return dimension;
+ }
+
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return dimension;
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void paint(ResourceContext context, Graphics2D graphics) {
+ Object[] stored = (Object[]) restoreData(context);
+ if (stored != null) {
+ BufferedImage block1 = paintMainBlock(stored, false);
+ BufferedImage separator = paintSeparatorBlock(stored);
+ BufferedImage block2 = paintMainBlock(stored, true);
+ BufferedImage block3 = paintMainBlock(stored, true);
+
+ BufferedImage firstTriangle1 = paintFirstTriangleBlock(stored, false);
+ BufferedImage firstTriangle2 = paintFirstTriangleBlock(stored, true);
+ BufferedImage firstTriangle3 = paintFirstTriangleBlock(stored, true);
+
+ BufferedImage secondTriangle1 = paintSecondTriangleBlock(stored, false);
+ BufferedImage secondTriangle2 = paintSecondTriangleBlock(stored, true);
+
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics.drawImage(block1, 0, 0, 22, 22, null);
+ graphics.drawImage(separator, 22, 0, 5, 22, null);
+ graphics.drawImage(block2, 0, 22, 22, 22, null);
+ graphics.drawImage(block3, 0, 44, 22, 22, null);
+
+ graphics.drawImage(firstTriangle1, 44, 0, 11, 22, null);
+ graphics.drawImage(firstTriangle2, 44, 22, 11, 22, null);
+ graphics.drawImage(firstTriangle3, 44, 44, 11, 22, null);
+
+ graphics.drawImage(secondTriangle1, 66, 0, 14, 22, null);
+ graphics.drawImage(secondTriangle2, 66, 22, 14, 22, null);
+ }
+
+ }
+
+}
Copied: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java (from rev 11224, trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java)
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java (rev 0)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java 2008-11-18 17:55:45 UTC (rev 11227)
@@ -0,0 +1,312 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.renderkit.html.images;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.RenderingHints;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.PngRenderer;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.Zipper2;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public abstract class EditorIcons extends Java2Dresource {
+
+ private final String ADDITIONAL_BACKGROUND_COLOR = "additionalBackgroundColor";
+ private final String SELECT_CONTROL_COLOR = "selectControlColor";
+ private final String PANEL_BORDER_COLOR = "panelBorderColor";
+ private final String GENERAL_TEXT_COLOR = "generalTextColor";
+
+ private final int SUB_BORDER_TRANSPARENCY = 100;
+
+ public EditorIcons() {
+ super();
+
+ setRenderer(new PngRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance()
+ .getStartTime()));
+ }
+
+ protected Object getDataToStore(FacesContext context, Object data) {
+ String additionalBackgroundColor = getSkinParameter(context,
+ ADDITIONAL_BACKGROUND_COLOR);
+ String selectControlColor = getSkinParameter(context,
+ SELECT_CONTROL_COLOR);
+ String panelBorderColor = getSkinParameter(context, PANEL_BORDER_COLOR);
+ String generalTextColor = getSkinParameter(context, GENERAL_TEXT_COLOR);
+
+ byte[] ret = new byte[12];
+ Zipper2 zipper2 = new Zipper2(ret);
+ zipper2.addColor(HtmlColor.decode(additionalBackgroundColor).getRGB());
+ zipper2.addColor(HtmlColor.decode(selectControlColor).getRGB());
+ zipper2.addColor(HtmlColor.decode(panelBorderColor).getRGB());
+ zipper2.addColor(HtmlColor.decode(generalTextColor).getRGB());
+
+ return ret;
+ }
+
+ protected Object deserializeData(byte[] objectArray) {
+ if (objectArray == null) {
+ return null;
+ }
+
+ Object[] colors = new Object[5];
+ Zipper2 z = new Zipper2(objectArray);
+ colors[0] = z.nextColor();
+ colors[1] = z.nextColor();
+ colors[2] = z.nextColor();
+ colors[3] = z.nextColor();
+
+ return colors;
+ }
+
+ private String getSkinParameter(FacesContext context, String parameterName) {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
+ String value = (String) skin.getParameter(context, parameterName);
+ if (null == value || "".equals(value)) {
+ value = (String) defaultSkin.getParameter(context, parameterName);
+ }
+ return value;
+
+ }
+
+ protected BufferedImage paintMainBlock(Object[] colors, boolean selected) {
+
+ int w = 22;
+ int h = 22;
+
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D g2d = prepareImage(image);
+
+ Color additionalBackgroundColor = (Color) colors[0];
+ Color selectControlColor = (Color) colors[1];
+ Color panelBorderColor = (Color) colors[2];
+ Color subBorderColorWithAlpha = new Color(255, 255, 255,
+ SUB_BORDER_TRANSPARENCY);
+
+ // Draw body
+ Color contentColor;
+ if (selected) {
+ contentColor = selectControlColor;
+ } else {
+ contentColor = additionalBackgroundColor;
+ }
+ Paint gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
+ Color.white);
+ g2d.setPaint(gradient1);
+ Rectangle2D border = new Rectangle2D.Double(0, 1, w, h - 1);
+ g2d.fill(border);
+
+ // Draw Border
+ g2d.setColor(panelBorderColor);
+ g2d.drawLine(0, 0, w, 0);
+ g2d.drawLine(0, h - 1, w, h - 1);
+
+ // Draw subBorder
+ g2d.setColor(subBorderColorWithAlpha);
+ g2d.drawLine(0, 1, 0, h - 2);
+ g2d.drawLine(0, 1, w - 1, 1);
+ g2d.drawLine(w - 1, 1, w - 1, h - 2);
+ g2d.drawLine(0, h - 2, w - 1, h - 2);
+
+ g2d.dispose();
+
+ return image;
+ }
+
+ protected BufferedImage paintSeparatorBlock(Object[] colors) {
+
+ int w = 5;
+ int h = 22;
+
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D g2d = prepareImage(image);
+
+ Color additionalBackgroundColor = (Color) colors[0];
+ Color panelBorderColor = (Color) colors[2];
+
+ // Draw body
+ g2d.setColor(additionalBackgroundColor);
+ Rectangle2D border = new Rectangle2D.Double(0, 0, w, h);
+ g2d.fill(border);
+
+ // Draw Border
+ g2d.setColor(panelBorderColor);
+ g2d.drawLine(0, 1, 0, h - 2);
+ g2d.drawLine(w - 1, 1, w - 1, h - 2);
+
+ return image;
+ }
+
+ protected BufferedImage paintFirstTriangleBlock(Object[] colors,
+ boolean selected) {
+
+ int w = 11;
+ int h = 22;
+
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D g2d = prepareImage(image);
+
+ Color additionalBackgroundColor = (Color) colors[0];
+ Color selectControlColor = (Color) colors[1];
+ Color panelBorderColor = (Color) colors[2];
+ Color generalTextColor = (Color) colors[3];
+ Color subBorderColorWithAlpha = new Color(255, 255, 255,
+ SUB_BORDER_TRANSPARENCY);
+
+ // Draw body
+ Color contentColor;
+ if (selected) {
+ contentColor = selectControlColor;
+ } else {
+ contentColor = additionalBackgroundColor;
+ }
+ Paint gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
+ Color.white);
+ g2d.setPaint(gradient1);
+ Rectangle2D border = new Rectangle2D.Double(0, 1, w, h - 1);
+ g2d.fill(border);
+
+ // Draw Border
+ g2d.setColor(panelBorderColor);
+ g2d.drawLine(0, 0, w, 0);
+ g2d.drawLine(0, h - 1, w, h - 1);
+
+ // Draw body
+ g2d.setColor(subBorderColorWithAlpha);
+ g2d.drawLine(0, 1, 0, h - 2);
+ g2d.drawLine(0, 1, w - 1, 1);
+ g2d.drawLine(w - 1, 1, w - 1, h - 2);
+ g2d.drawLine(0, h - 2, w - 1, h - 2);
+
+ paintTriangle(g2d, 3, 10, generalTextColor, Color.WHITE, true);
+
+ return image;
+ }
+
+ private void paintTriangle(Graphics2D g2d, int x, int y, Color main,
+ Color shadow, boolean shadowNeeded) {
+ int w = 4;
+ if (shadowNeeded) {
+ g2d.setColor(shadow);
+ g2d.drawLine(x, y + 1, x + w, y + 1);
+ g2d.drawLine(x + 1, y + 2, x + w - 1, y + 2);
+ g2d.drawLine(x + 2, y + 3, x + 2, y + 3);
+ }
+ g2d.setColor(main);
+ g2d.drawLine(x, y, x + w, y);
+ g2d.drawLine(x + 1, y + 1, x + w - 1, y + 1);
+ g2d.drawLine(x + 2, y + 2, x + 2, y + 2);
+
+ }
+
+ protected BufferedImage paintSecondTriangleBlock(Object[] colors,
+ boolean selected) {
+
+ int w = 14;
+ int h = 22;
+
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D g2d = prepareImage(image);
+
+ Color additionalBackgroundColor = (Color) colors[0];
+ Color selectControlColor = (Color) colors[1];
+ Color panelBorderColor = (Color) colors[2];
+ Color generalTextColor = (Color) colors[3];
+ Color subBorderColorWithAlpha = new Color(255, 255, 255,
+ SUB_BORDER_TRANSPARENCY);
+
+ // Draw body
+ Paint gradient1;
+ Color contentColor;
+ if (selected) {
+ contentColor = selectControlColor;
+ gradient1 = new GradientPaint(w - 2, h - 2, contentColor, 2, 2,
+ Color.white);
+ } else {
+ contentColor = additionalBackgroundColor;
+ gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
+ Color.white);
+ }
+
+ g2d.setPaint(gradient1);
+ Rectangle2D border = new Rectangle2D.Double(1, 1, w - 1, h - 1);
+ g2d.fill(border);
+
+ // Draw Border
+ g2d.setColor(panelBorderColor);
+ g2d.drawLine(0, 0, w, 0);
+ g2d.drawLine(0, h - 1, w, h - 1);
+ g2d.drawLine(0, 0, 0, h);
+ g2d.drawLine(w - 1, 0, w - 1, h);
+
+ // Draw subBorder
+ g2d.setColor(subBorderColorWithAlpha);
+ g2d.drawLine(1, 1, 1, h - 2);
+ g2d.drawLine(1, 1, w - 2, 1);
+ g2d.drawLine(w - 2, 1, w - 2, h - 2);
+ g2d.drawLine(1, h - 2, w - 2, h - 2);
+
+ paintTriangle(g2d, 4, 10, generalTextColor, Color.WHITE, true);
+
+ return image;
+ }
+
+ private Graphics2D prepareImage(BufferedImage image) {
+
+ Graphics2D g2d = image.createGraphics();
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
+ RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+
+ g2d.setStroke(new BasicStroke(1));
+
+ return g2d;
+ }
+
+}
Copied: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorSimpleThemeIcons.java (from rev 11224, trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java)
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorSimpleThemeIcons.java (rev 0)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorSimpleThemeIcons.java 2008-11-18 17:55:45 UTC (rev 11227)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.PngRenderer;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EditorSimpleThemeIcons extends EditorIcons{
+
+ private Dimension dimension = new Dimension(40, 66);
+
+
+ public EditorSimpleThemeIcons() {
+ super();
+
+ setRenderer(new PngRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance()
+ .getStartTime()));
+ }
+
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return dimension;
+ }
+
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return dimension;
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void paint(ResourceContext context, Graphics2D graphics) {
+ Object[] stored = (Object[]) restoreData(context);
+ if (stored != null) {
+ BufferedImage block1 = paintMainBlock(stored, false);
+ BufferedImage separator = paintSeparatorBlock(stored);
+ BufferedImage block2 = paintMainBlock(stored, true);
+ BufferedImage block3 = paintMainBlock(stored, true);
+
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics.drawImage(block1, 0, 0, 22, 22, null);
+ graphics.drawImage(separator, 22, 0, 5, 22, null);
+ graphics.drawImage(block2, 0, 22, 22, 22, null);
+ graphics.drawImage(block3, 0, 44, 22, 22, null);
+ }
+
+ }
+
+}
Deleted: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java 2008-11-18 17:23:56 UTC (rev 11226)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java 2008-11-18 17:55:45 UTC (rev 11227)
@@ -1,96 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.renderkit.html.images;
-
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.PngRenderer;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author Alexandr Levkovsky
- *
- */
-public class EdtorAdvancedThemeIcons extends EdtorIcons{
-
- private Dimension dimension = new Dimension(88, 66);
-
-
- public EdtorAdvancedThemeIcons() {
- super();
-
- setRenderer(new PngRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance()
- .getStartTime()));
- }
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimension;
- }
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimension;
- }
-
- /**
- *
- */
- @Override
- public void paint(ResourceContext context, Graphics2D graphics) {
- Object[] stored = (Object[]) restoreData(context);
- if (stored != null) {
- BufferedImage block1 = paintMainBlock(stored, false);
- BufferedImage separator = paintSeparatorBlock(stored);
- BufferedImage block2 = paintMainBlock(stored, true);
- BufferedImage block3 = paintMainBlock(stored, true);
-
- BufferedImage firstTriangle1 = paintFirstTriangleBlock(stored, false);
- BufferedImage firstTriangle2 = paintFirstTriangleBlock(stored, true);
- BufferedImage firstTriangle3 = paintFirstTriangleBlock(stored, true);
-
- BufferedImage secondTriangle1 = paintSecondTriangleBlock(stored, false);
- BufferedImage secondTriangle2 = paintSecondTriangleBlock(stored, true);
-
- graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- graphics.drawImage(block1, 0, 0, 22, 22, null);
- graphics.drawImage(separator, 22, 0, 5, 22, null);
- graphics.drawImage(block2, 0, 22, 22, 22, null);
- graphics.drawImage(block3, 0, 44, 22, 22, null);
-
- graphics.drawImage(firstTriangle1, 44, 0, 11, 22, null);
- graphics.drawImage(firstTriangle2, 44, 22, 11, 22, null);
- graphics.drawImage(firstTriangle3, 44, 44, 11, 22, null);
-
- graphics.drawImage(secondTriangle1, 66, 0, 14, 22, null);
- graphics.drawImage(secondTriangle2, 66, 22, 14, 22, null);
- }
-
- }
-
-}
Deleted: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java 2008-11-18 17:23:56 UTC (rev 11226)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java 2008-11-18 17:55:45 UTC (rev 11227)
@@ -1,312 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.renderkit.html.images;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.Paint;
-import java.awt.RenderingHints;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.PngRenderer;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author Alexandr Levkovsky
- *
- */
-public abstract class EdtorIcons extends Java2Dresource {
-
- private final String ADDITIONAL_BACKGROUND_COLOR = "additionalBackgroundColor";
- private final String SELECT_CONTROL_COLOR = "selectControlColor";
- private final String PANEL_BORDER_COLOR = "panelBorderColor";
- private final String GENERAL_TEXT_COLOR = "generalTextColor";
-
- private final int SUB_BORDER_TRANSPARENCY = 100;
-
- public EdtorIcons() {
- super();
-
- setRenderer(new PngRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance()
- .getStartTime()));
- }
-
- protected Object getDataToStore(FacesContext context, Object data) {
- String additionalBackgroundColor = getSkinParameter(context,
- ADDITIONAL_BACKGROUND_COLOR);
- String selectControlColor = getSkinParameter(context,
- SELECT_CONTROL_COLOR);
- String panelBorderColor = getSkinParameter(context, PANEL_BORDER_COLOR);
- String generalTextColor = getSkinParameter(context, GENERAL_TEXT_COLOR);
-
- byte[] ret = new byte[12];
- Zipper2 zipper2 = new Zipper2(ret);
- zipper2.addColor(HtmlColor.decode(additionalBackgroundColor).getRGB());
- zipper2.addColor(HtmlColor.decode(selectControlColor).getRGB());
- zipper2.addColor(HtmlColor.decode(panelBorderColor).getRGB());
- zipper2.addColor(HtmlColor.decode(generalTextColor).getRGB());
-
- return ret;
- }
-
- protected Object deserializeData(byte[] objectArray) {
- if (objectArray == null) {
- return null;
- }
-
- Object[] colors = new Object[5];
- Zipper2 z = new Zipper2(objectArray);
- colors[0] = z.nextColor();
- colors[1] = z.nextColor();
- colors[2] = z.nextColor();
- colors[3] = z.nextColor();
-
- return colors;
- }
-
- private String getSkinParameter(FacesContext context, String parameterName) {
- Skin skin = SkinFactory.getInstance().getSkin(context);
- Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
- String value = (String) skin.getParameter(context, parameterName);
- if (null == value || "".equals(value)) {
- value = (String) defaultSkin.getParameter(context, parameterName);
- }
- return value;
-
- }
-
- protected BufferedImage paintMainBlock(Object[] colors, boolean selected) {
-
- int w = 22;
- int h = 22;
-
- BufferedImage image = new BufferedImage(w, h,
- BufferedImage.TYPE_INT_ARGB);
-
- Graphics2D g2d = prepareImage(image);
-
- Color additionalBackgroundColor = (Color) colors[0];
- Color selectControlColor = (Color) colors[1];
- Color panelBorderColor = (Color) colors[2];
- Color subBorderColorWithAlpha = new Color(255, 255, 255,
- SUB_BORDER_TRANSPARENCY);
-
- // Draw body
- Color contentColor;
- if (selected) {
- contentColor = selectControlColor;
- } else {
- contentColor = additionalBackgroundColor;
- }
- Paint gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
- Color.white);
- g2d.setPaint(gradient1);
- Rectangle2D border = new Rectangle2D.Double(0, 1, w, h - 1);
- g2d.fill(border);
-
- // Draw Border
- g2d.setColor(panelBorderColor);
- g2d.drawLine(0, 0, w, 0);
- g2d.drawLine(0, h - 1, w, h - 1);
-
- // Draw subBorder
- g2d.setColor(subBorderColorWithAlpha);
- g2d.drawLine(0, 1, 0, h - 2);
- g2d.drawLine(0, 1, w - 1, 1);
- g2d.drawLine(w - 1, 1, w - 1, h - 2);
- g2d.drawLine(0, h - 2, w - 1, h - 2);
-
- g2d.dispose();
-
- return image;
- }
-
- protected BufferedImage paintSeparatorBlock(Object[] colors) {
-
- int w = 5;
- int h = 22;
-
- BufferedImage image = new BufferedImage(w, h,
- BufferedImage.TYPE_INT_ARGB);
-
- Graphics2D g2d = prepareImage(image);
-
- Color additionalBackgroundColor = (Color) colors[0];
- Color panelBorderColor = (Color) colors[2];
-
- // Draw body
- g2d.setColor(additionalBackgroundColor);
- Rectangle2D border = new Rectangle2D.Double(0, 0, w, h);
- g2d.fill(border);
-
- // Draw Border
- g2d.setColor(panelBorderColor);
- g2d.drawLine(0, 1, 0, h - 2);
- g2d.drawLine(w - 1, 1, w - 1, h - 2);
-
- return image;
- }
-
- protected BufferedImage paintFirstTriangleBlock(Object[] colors,
- boolean selected) {
-
- int w = 11;
- int h = 22;
-
- BufferedImage image = new BufferedImage(w, h,
- BufferedImage.TYPE_INT_ARGB);
-
- Graphics2D g2d = prepareImage(image);
-
- Color additionalBackgroundColor = (Color) colors[0];
- Color selectControlColor = (Color) colors[1];
- Color panelBorderColor = (Color) colors[2];
- Color generalTextColor = (Color) colors[3];
- Color subBorderColorWithAlpha = new Color(255, 255, 255,
- SUB_BORDER_TRANSPARENCY);
-
- // Draw body
- Color contentColor;
- if (selected) {
- contentColor = selectControlColor;
- } else {
- contentColor = additionalBackgroundColor;
- }
- Paint gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
- Color.white);
- g2d.setPaint(gradient1);
- Rectangle2D border = new Rectangle2D.Double(0, 1, w, h - 1);
- g2d.fill(border);
-
- // Draw Border
- g2d.setColor(panelBorderColor);
- g2d.drawLine(0, 0, w, 0);
- g2d.drawLine(0, h - 1, w, h - 1);
-
- // Draw body
- g2d.setColor(subBorderColorWithAlpha);
- g2d.drawLine(0, 1, 0, h - 2);
- g2d.drawLine(0, 1, w - 1, 1);
- g2d.drawLine(w - 1, 1, w - 1, h - 2);
- g2d.drawLine(0, h - 2, w - 1, h - 2);
-
- paintTriangle(g2d, 3, 10, generalTextColor, Color.WHITE, true);
-
- return image;
- }
-
- private void paintTriangle(Graphics2D g2d, int x, int y, Color main,
- Color shadow, boolean shadowNeeded) {
- int w = 4;
- if (shadowNeeded) {
- g2d.setColor(shadow);
- g2d.drawLine(x, y + 1, x + w, y + 1);
- g2d.drawLine(x + 1, y + 2, x + w - 1, y + 2);
- g2d.drawLine(x + 2, y + 3, x + 2, y + 3);
- }
- g2d.setColor(main);
- g2d.drawLine(x, y, x + w, y);
- g2d.drawLine(x + 1, y + 1, x + w - 1, y + 1);
- g2d.drawLine(x + 2, y + 2, x + 2, y + 2);
-
- }
-
- protected BufferedImage paintSecondTriangleBlock(Object[] colors,
- boolean selected) {
-
- int w = 14;
- int h = 22;
-
- BufferedImage image = new BufferedImage(w, h,
- BufferedImage.TYPE_INT_ARGB);
-
- Graphics2D g2d = prepareImage(image);
-
- Color additionalBackgroundColor = (Color) colors[0];
- Color selectControlColor = (Color) colors[1];
- Color panelBorderColor = (Color) colors[2];
- Color generalTextColor = (Color) colors[3];
- Color subBorderColorWithAlpha = new Color(255, 255, 255,
- SUB_BORDER_TRANSPARENCY);
-
- // Draw body
- Paint gradient1;
- Color contentColor;
- if (selected) {
- contentColor = selectControlColor;
- gradient1 = new GradientPaint(w - 2, h - 2, contentColor, 2, 2,
- Color.white);
- } else {
- contentColor = additionalBackgroundColor;
- gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
- Color.white);
- }
-
- g2d.setPaint(gradient1);
- Rectangle2D border = new Rectangle2D.Double(1, 1, w - 1, h - 1);
- g2d.fill(border);
-
- // Draw Border
- g2d.setColor(panelBorderColor);
- g2d.drawLine(0, 0, w, 0);
- g2d.drawLine(0, h - 1, w, h - 1);
- g2d.drawLine(0, 0, 0, h);
- g2d.drawLine(w - 1, 0, w - 1, h);
-
- // Draw subBorder
- g2d.setColor(subBorderColorWithAlpha);
- g2d.drawLine(1, 1, 1, h - 2);
- g2d.drawLine(1, 1, w - 2, 1);
- g2d.drawLine(w - 2, 1, w - 2, h - 2);
- g2d.drawLine(1, h - 2, w - 2, h - 2);
-
- paintTriangle(g2d, 4, 10, generalTextColor, Color.WHITE, true);
-
- return image;
- }
-
- private Graphics2D prepareImage(BufferedImage image) {
-
- Graphics2D g2d = image.createGraphics();
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
- RenderingHints.VALUE_COLOR_RENDER_QUALITY);
-
- g2d.setStroke(new BasicStroke(1));
-
- return g2d;
- }
-
-}
Deleted: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java 2008-11-18 17:23:56 UTC (rev 11226)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java 2008-11-18 17:55:45 UTC (rev 11227)
@@ -1,82 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.renderkit.html.images;
-
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.PngRenderer;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author Alexandr Levkovsky
- *
- */
-public class EdtorSimpleThemeIcons extends EdtorIcons{
-
- private Dimension dimension = new Dimension(40, 66);
-
-
- public EdtorSimpleThemeIcons() {
- super();
-
- setRenderer(new PngRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance()
- .getStartTime()));
- }
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimension;
- }
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimension;
- }
-
- /**
- *
- */
- @Override
- public void paint(ResourceContext context, Graphics2D graphics) {
- Object[] stored = (Object[]) restoreData(context);
- if (stored != null) {
- BufferedImage block1 = paintMainBlock(stored, false);
- BufferedImage separator = paintSeparatorBlock(stored);
- BufferedImage block2 = paintMainBlock(stored, true);
- BufferedImage block3 = paintMainBlock(stored, true);
-
- graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- graphics.drawImage(block1, 0, 0, 22, 22, null);
- graphics.drawImage(separator, 22, 0, 5, 22, null);
- graphics.drawImage(block2, 0, 22, 22, 22, null);
- graphics.drawImage(block3, 0, 44, 22, 22, null);
- }
-
- }
-
-}
Modified: trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss
===================================================================
--- trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss 2008-11-18 17:23:56 UTC (rev 11226)
+++ trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss 2008-11-18 17:55:45 UTC (rev 11227)
@@ -205,14 +205,14 @@
<u:selector name=".richfacesSkin .mceToolbar .mceToolbarStart span">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
<u:selector name=".richfacesSkin .mceToolbar .mceToolbarEnd span">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
@@ -227,7 +227,7 @@
<u:selector name=".richfacesSkin .mceButton">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons"/>
</u:style>
</u:selector>
@@ -241,7 +241,7 @@
<u:selector name=".richfacesSkin .mceSeparator">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
@@ -257,7 +257,7 @@
<u:selector name=".richfacesSkin .mceListBox .mceOpen">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-66px 0"/>
</u:selector>
@@ -280,7 +280,7 @@
<u:selector name=".richfacesSkin .mceSplitButton">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons"/>
</u:style>
</u:selector>
@@ -293,14 +293,14 @@
<u:selector name=".richfacesSkin .mceSplitButton span.mceOpen">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-44px 0"/>
</u:selector>
<u:selector name=".richfacesSkin table.mceSplitButtonEnabled:hover a.mceAction, .richfacesSkin .mceSplitButtonHover a.mceAction, .richfacesSkin .mceSplitButtonSelected">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="0 -22px"/>
</u:selector>
Modified: trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss
===================================================================
--- trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss 2008-11-18 17:23:56 UTC (rev 11226)
+++ trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss 2008-11-18 17:55:45 UTC (rev 11227)
@@ -48,7 +48,7 @@
<u:selector name=".richfacesSimpleSkin .mceToolbar .mceToolbarStart span">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorSimpleThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
@@ -61,7 +61,7 @@
<u:selector name=".richfacesSimpleSkin .mceToolbar .mceToolbarEnd span">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorSimpleThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
@@ -90,7 +90,7 @@
<u:selector name=".richfacesSimpleSkin .mceButton">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorSimpleThemeIcons"/>
</u:style>
</u:selector>
@@ -117,7 +117,7 @@
<u:selector name=".richfacesSimpleSkin .mceSeparator">
<u:style name="background-image">
- <f:resource f:key="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EditorSimpleThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
17 years, 6 months
JBoss Rich Faces SVN: r11226 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/orderingList and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-11-18 12:23:56 -0500 (Tue, 18 Nov 2008)
New Revision: 11226
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/OrderingListTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/orderingList/orderingListTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java
Log:
RF-4941
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/OrderingListTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/OrderingListTestBean.java 2008-11-18 17:07:29 UTC (rev 11225)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/OrderingListTestBean.java 2008-11-18 17:23:56 UTC (rev 11226)
@@ -28,6 +28,7 @@
import java.util.List;
import javax.faces.context.FacesContext;
+import javax.faces.event.ValueChangeEvent;
import org.ajax4jsf.model.ListShuttleItem;
@@ -41,6 +42,7 @@
private Boolean rendered;
private String string;
private Boolean immediate;
+ private Boolean valueChanged;
public OrderingListTestBean() {
init();
@@ -57,6 +59,7 @@
setRendered(true);
setString("something");
immediate = false;
+ valueChanged = false;
}
public Object getActionResult() {
@@ -143,4 +146,16 @@
public Boolean getImmediate() {
return immediate;
}
+
+ public void valueChangeListener(ValueChangeEvent event) {
+ valueChanged = true;
+ }
+
+ public void setValueChanged(Boolean valueChanged) {
+ this.valueChanged = valueChanged;
+ }
+
+ public Boolean getValueChanged() {
+ return valueChanged;
+ }
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/orderingList/orderingListTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java 2008-11-18 17:07:29 UTC (rev 11225)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java 2008-11-18 17:23:56 UTC (rev 11226)
@@ -33,7 +33,13 @@
private String inputTextId;
private String orderingListId;
-
+
+ private String orderingListTableId;
+
+ private String valueChangedId;
+
+ private String tableId;
+
private String submitId;
private String firstButton;
@@ -76,6 +82,22 @@
private String immediateId;
+ /**
+ * value updated, listener fire
+ */
+ @Test
+ public void testValuesAndListener(Template template) {
+ renderPage(template, initMethod);
+ initFields();
+ Assert.assertEquals(selenium.getText(valueChangedId), Boolean.FALSE.toString());
+ _checkOrdering(tableId, new String[]{"0", "1", "2", "3"});
+ _selectItem(orderingListId + ":0", false, false);
+ selenium.click(downButton);
+ clickAjaxCommandAndWait(submitId);
+ Assert.assertEquals(selenium.getText(valueChangedId), Boolean.TRUE.toString());
+ _checkOrdering(tableId, new String[]{"1", "0", "2", "3"});
+ }
+
/**
* converter defined by component attribute and configured at application level works
*/
@@ -83,7 +105,7 @@
public void testConverter(Template template) {
renderPage(template, initMethod);
initFields();
- AssertValueEquals(orderingListId + ":0StateInput", "0:0:item0", "Converter doesn't work.");
+ Assert.assertTrue(selenium.getValue(orderingListId + ":0StateInput").endsWith("0:item0"), "Converter doesn't work.");
}
/**
@@ -93,15 +115,15 @@
public void testKeyboardNavigation(Template template) {
renderPage(template, initMethod);
initFields();
- _checkOrdering(new String[]{"0", "1", "2", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"0", "1", "2", "3"});
_selectItem(orderingListId + ":0", false, false);
_selectItem(orderingListId + ":2", true, false);
selenium.click(downButton);
- _checkOrdering(new String[]{"1", "0", "3", "2"});
+ _checkOrdering(orderingListTableId, new String[]{"1", "0", "3", "2"});
_selectItem(orderingListId + ":1", false, false);
_selectItem(orderingListId + ":3", false, true);
selenium.click(downButton);
- _checkOrdering(new String[]{"2", "1", "0", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"2", "1", "0", "3"});
_selectItem(orderingListId + ":0", false, false);
selenium.controlKeyDown();
selenium.keyDown(orderingListId + "focusKeeper", "A");
@@ -111,26 +133,26 @@
_selectItem(orderingListId + ":1", false, false);
selenium.keyDown(orderingListId + "focusKeeper", "\\40");
selenium.click(upButton);
- _checkOrdering(new String[]{"2", "0", "1", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"2", "0", "1", "3"});
_selectItem(orderingListId + ":3", false, false);
selenium.keyDown(orderingListId + "focusKeeper", "\\38");
selenium.click(downButton);
- _checkOrdering(new String[]{"2", "0", "3", "1"});
+ _checkOrdering(orderingListTableId, new String[]{"2", "0", "3", "1"});
_selectItem(orderingListId + ":1", false, false);
selenium.keyDown(orderingListId + "focusKeeper", "\\33");
- _checkOrdering(new String[]{"1", "2", "0", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"1", "2", "0", "3"});
selenium.keyDown(orderingListId + "focusKeeper", "\\34");
- _checkOrdering(new String[]{"2", "0", "3", "1"});
+ _checkOrdering(orderingListTableId, new String[]{"2", "0", "3", "1"});
_selectItem(orderingListId + ":1", false, false);
selenium.controlKeyDown();
selenium.keyDown(orderingListId + "focusKeeper", "\\38");
selenium.controlKeyUp();
- _checkOrdering(new String[]{"2", "0", "1", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"2", "0", "1", "3"});
_selectItem(orderingListId + ":1", false, false);
selenium.controlKeyDown();
selenium.keyDown(orderingListId + "focusKeeper", "\\40");
selenium.controlKeyUp();
- _checkOrdering(new String[]{"2", "0", "3", "1"});
+ _checkOrdering(orderingListTableId, new String[]{"2", "0", "3", "1"});
}
/**
@@ -212,17 +234,17 @@
selenium.runScript("var listShuttle = ($('" + orderingListId + "')).component;");
Assert.assertTrue("4".equals(selenium.getEval("window.listShuttle.getItems().length")));
Assert.assertTrue("0".equals(selenium.getEval("window.listShuttle.getSelection().length")));
- _checkOrdering(new String[]{"0", "1", "2", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"0", "1", "2", "3"});
selenium.click(firstRow);
Assert.assertTrue("1".equals(selenium.getEval("window.listShuttle.getSelection().length")));
selenium.runScript("listShuttle.down()");
- _checkOrdering(new String[]{"1", "0", "2", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"1", "0", "2", "3"});
selenium.runScript("listShuttle.bottom()");
- _checkOrdering(new String[]{"1", "2", "3", "0"});
+ _checkOrdering(orderingListTableId, new String[]{"1", "2", "3", "0"});
selenium.runScript("listShuttle.up()");
- _checkOrdering(new String[]{"1", "2", "0", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"1", "2", "0", "3"});
selenium.runScript("listShuttle.top()");
- _checkOrdering(new String[]{"0", "1", "2", "3"});
+ _checkOrdering(orderingListTableId, new String[]{"0", "1", "2", "3"});
}
@@ -403,10 +425,10 @@
}
}
- private void _checkOrdering(String[] ordering) {
+ private void _checkOrdering(String tableId, String[] ordering) {
for (int i = 0; i < ordering.length; i++) {
- Assert.assertEquals(selenium.
- getText("xpath=id('" + orderingListId +"tbody')/tr[" + (i + 1) + "]/td[1]"),
+ Assert.assertEquals(selenium.
+ getText("xpath=id('" + tableId + "')/tbody/tr[" + (i + 1) + "]/td[1]"),
"item" + ordering[i]);
}
@@ -439,6 +461,9 @@
String attrFormId = getParentId() + "attrFormId";
inputTextId = getParentId() + "testRequiredAndImmediate:inputTextId";
orderingListId = formId + "orderingList";
+ orderingListTableId = orderingListId + "internal_tab";
+ valueChangedId = formId + "valueChangedId";
+ tableId = formId + "tableId";
submitId = formId + "submitId";
firstButton = orderingListId + "first";
firstButtonDisabled = orderingListId + "disfirst";
17 years, 6 months
JBoss Rich Faces SVN: r11225 - trunk/docs/userguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2008-11-18 12:07:29 -0500 (Tue, 18 Nov 2008)
New Revision: 11225
Modified:
trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml
Log:
https://jira.jboss.org/jira/browse/RF-398 - Language correction
Modified: trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml 2008-11-18 16:54:35 UTC (rev 11224)
+++ trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml 2008-11-18 17:07:29 UTC (rev 11225)
@@ -1262,7 +1262,7 @@
</listitem>
</itemizedlist>
<para> Thus, it's possible to create your own handler that is called on
- timeouts, inner server errors, and etc. </para>
+ timeouts, internal server errors, and etc. </para>
</section>
<section id="SessionExpiredHandling">
<?dbhtml filename="SessionExpiredHandling.html"?>
17 years, 6 months
JBoss Rich Faces SVN: r11224 - in trunk/sandbox/ui/editor/src/main: java/org/richfaces/renderkit and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-11-18 11:54:35 -0500 (Tue, 18 Nov 2008)
New Revision: 11224
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java
Removed:
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/img/
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/img/
Modified:
trunk/sandbox/ui/editor/src/main/config/resources/resources-config.xml
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss
trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss
Log:
Editor: Implement skinnable icons drawing
Modified: trunk/sandbox/ui/editor/src/main/config/resources/resources-config.xml
===================================================================
--- trunk/sandbox/ui/editor/src/main/config/resources/resources-config.xml 2008-11-18 16:51:25 UTC (rev 11223)
+++ trunk/sandbox/ui/editor/src/main/config/resources/resources-config.xml 2008-11-18 16:54:35 UTC (rev 11224)
@@ -4738,9 +4738,8 @@
<name>scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss</name>
<path>org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss</path>
</resource>
- <resource>
- <name>scripts/tiny_mce/themes/advanced/skins/richfaces/img/button_bg.png</name>
- <path>org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/img/button_bg.png</path>
+ <resource class="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons">
+ <name>org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons</name>
</resource>
<resource>
<name>scripts/tiny_mce/themes/advanced/source_editor.htm</name>
@@ -5039,9 +5038,8 @@
<name>scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss</name>
<path>org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss</path>
</resource>
- <resource>
- <name>scripts/tiny_mce/themes/simple/skins/richfaces/img/button_bg.png</name>
- <path>org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/img/button_bg.png</path>
+ <resource class="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons">
+ <name>org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons</name>
</resource>
<resource>
<name>scripts/tiny_mce/tiny_mce.js</name>
Added: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java (rev 0)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java 2008-11-18 16:54:35 UTC (rev 11224)
@@ -0,0 +1,96 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.PngRenderer;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EdtorAdvancedThemeIcons extends EdtorIcons{
+
+ private Dimension dimension = new Dimension(88, 66);
+
+
+ public EdtorAdvancedThemeIcons() {
+ super();
+
+ setRenderer(new PngRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance()
+ .getStartTime()));
+ }
+
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return dimension;
+ }
+
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return dimension;
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void paint(ResourceContext context, Graphics2D graphics) {
+ Object[] stored = (Object[]) restoreData(context);
+ if (stored != null) {
+ BufferedImage block1 = paintMainBlock(stored, false);
+ BufferedImage separator = paintSeparatorBlock(stored);
+ BufferedImage block2 = paintMainBlock(stored, true);
+ BufferedImage block3 = paintMainBlock(stored, true);
+
+ BufferedImage firstTriangle1 = paintFirstTriangleBlock(stored, false);
+ BufferedImage firstTriangle2 = paintFirstTriangleBlock(stored, true);
+ BufferedImage firstTriangle3 = paintFirstTriangleBlock(stored, true);
+
+ BufferedImage secondTriangle1 = paintSecondTriangleBlock(stored, false);
+ BufferedImage secondTriangle2 = paintSecondTriangleBlock(stored, true);
+
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics.drawImage(block1, 0, 0, 22, 22, null);
+ graphics.drawImage(separator, 22, 0, 5, 22, null);
+ graphics.drawImage(block2, 0, 22, 22, 22, null);
+ graphics.drawImage(block3, 0, 44, 22, 22, null);
+
+ graphics.drawImage(firstTriangle1, 44, 0, 11, 22, null);
+ graphics.drawImage(firstTriangle2, 44, 22, 11, 22, null);
+ graphics.drawImage(firstTriangle3, 44, 44, 11, 22, null);
+
+ graphics.drawImage(secondTriangle1, 66, 0, 14, 22, null);
+ graphics.drawImage(secondTriangle2, 66, 22, 14, 22, null);
+ }
+
+ }
+
+}
Property changes on: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorAdvancedThemeIcons.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java (rev 0)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java 2008-11-18 16:54:35 UTC (rev 11224)
@@ -0,0 +1,312 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.renderkit.html.images;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.RenderingHints;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.PngRenderer;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.Zipper2;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public abstract class EdtorIcons extends Java2Dresource {
+
+ private final String ADDITIONAL_BACKGROUND_COLOR = "additionalBackgroundColor";
+ private final String SELECT_CONTROL_COLOR = "selectControlColor";
+ private final String PANEL_BORDER_COLOR = "panelBorderColor";
+ private final String GENERAL_TEXT_COLOR = "generalTextColor";
+
+ private final int SUB_BORDER_TRANSPARENCY = 100;
+
+ public EdtorIcons() {
+ super();
+
+ setRenderer(new PngRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance()
+ .getStartTime()));
+ }
+
+ protected Object getDataToStore(FacesContext context, Object data) {
+ String additionalBackgroundColor = getSkinParameter(context,
+ ADDITIONAL_BACKGROUND_COLOR);
+ String selectControlColor = getSkinParameter(context,
+ SELECT_CONTROL_COLOR);
+ String panelBorderColor = getSkinParameter(context, PANEL_BORDER_COLOR);
+ String generalTextColor = getSkinParameter(context, GENERAL_TEXT_COLOR);
+
+ byte[] ret = new byte[12];
+ Zipper2 zipper2 = new Zipper2(ret);
+ zipper2.addColor(HtmlColor.decode(additionalBackgroundColor).getRGB());
+ zipper2.addColor(HtmlColor.decode(selectControlColor).getRGB());
+ zipper2.addColor(HtmlColor.decode(panelBorderColor).getRGB());
+ zipper2.addColor(HtmlColor.decode(generalTextColor).getRGB());
+
+ return ret;
+ }
+
+ protected Object deserializeData(byte[] objectArray) {
+ if (objectArray == null) {
+ return null;
+ }
+
+ Object[] colors = new Object[5];
+ Zipper2 z = new Zipper2(objectArray);
+ colors[0] = z.nextColor();
+ colors[1] = z.nextColor();
+ colors[2] = z.nextColor();
+ colors[3] = z.nextColor();
+
+ return colors;
+ }
+
+ private String getSkinParameter(FacesContext context, String parameterName) {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
+ String value = (String) skin.getParameter(context, parameterName);
+ if (null == value || "".equals(value)) {
+ value = (String) defaultSkin.getParameter(context, parameterName);
+ }
+ return value;
+
+ }
+
+ protected BufferedImage paintMainBlock(Object[] colors, boolean selected) {
+
+ int w = 22;
+ int h = 22;
+
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D g2d = prepareImage(image);
+
+ Color additionalBackgroundColor = (Color) colors[0];
+ Color selectControlColor = (Color) colors[1];
+ Color panelBorderColor = (Color) colors[2];
+ Color subBorderColorWithAlpha = new Color(255, 255, 255,
+ SUB_BORDER_TRANSPARENCY);
+
+ // Draw body
+ Color contentColor;
+ if (selected) {
+ contentColor = selectControlColor;
+ } else {
+ contentColor = additionalBackgroundColor;
+ }
+ Paint gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
+ Color.white);
+ g2d.setPaint(gradient1);
+ Rectangle2D border = new Rectangle2D.Double(0, 1, w, h - 1);
+ g2d.fill(border);
+
+ // Draw Border
+ g2d.setColor(panelBorderColor);
+ g2d.drawLine(0, 0, w, 0);
+ g2d.drawLine(0, h - 1, w, h - 1);
+
+ // Draw subBorder
+ g2d.setColor(subBorderColorWithAlpha);
+ g2d.drawLine(0, 1, 0, h - 2);
+ g2d.drawLine(0, 1, w - 1, 1);
+ g2d.drawLine(w - 1, 1, w - 1, h - 2);
+ g2d.drawLine(0, h - 2, w - 1, h - 2);
+
+ g2d.dispose();
+
+ return image;
+ }
+
+ protected BufferedImage paintSeparatorBlock(Object[] colors) {
+
+ int w = 5;
+ int h = 22;
+
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D g2d = prepareImage(image);
+
+ Color additionalBackgroundColor = (Color) colors[0];
+ Color panelBorderColor = (Color) colors[2];
+
+ // Draw body
+ g2d.setColor(additionalBackgroundColor);
+ Rectangle2D border = new Rectangle2D.Double(0, 0, w, h);
+ g2d.fill(border);
+
+ // Draw Border
+ g2d.setColor(panelBorderColor);
+ g2d.drawLine(0, 1, 0, h - 2);
+ g2d.drawLine(w - 1, 1, w - 1, h - 2);
+
+ return image;
+ }
+
+ protected BufferedImage paintFirstTriangleBlock(Object[] colors,
+ boolean selected) {
+
+ int w = 11;
+ int h = 22;
+
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D g2d = prepareImage(image);
+
+ Color additionalBackgroundColor = (Color) colors[0];
+ Color selectControlColor = (Color) colors[1];
+ Color panelBorderColor = (Color) colors[2];
+ Color generalTextColor = (Color) colors[3];
+ Color subBorderColorWithAlpha = new Color(255, 255, 255,
+ SUB_BORDER_TRANSPARENCY);
+
+ // Draw body
+ Color contentColor;
+ if (selected) {
+ contentColor = selectControlColor;
+ } else {
+ contentColor = additionalBackgroundColor;
+ }
+ Paint gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
+ Color.white);
+ g2d.setPaint(gradient1);
+ Rectangle2D border = new Rectangle2D.Double(0, 1, w, h - 1);
+ g2d.fill(border);
+
+ // Draw Border
+ g2d.setColor(panelBorderColor);
+ g2d.drawLine(0, 0, w, 0);
+ g2d.drawLine(0, h - 1, w, h - 1);
+
+ // Draw body
+ g2d.setColor(subBorderColorWithAlpha);
+ g2d.drawLine(0, 1, 0, h - 2);
+ g2d.drawLine(0, 1, w - 1, 1);
+ g2d.drawLine(w - 1, 1, w - 1, h - 2);
+ g2d.drawLine(0, h - 2, w - 1, h - 2);
+
+ paintTriangle(g2d, 3, 10, generalTextColor, Color.WHITE, true);
+
+ return image;
+ }
+
+ private void paintTriangle(Graphics2D g2d, int x, int y, Color main,
+ Color shadow, boolean shadowNeeded) {
+ int w = 4;
+ if (shadowNeeded) {
+ g2d.setColor(shadow);
+ g2d.drawLine(x, y + 1, x + w, y + 1);
+ g2d.drawLine(x + 1, y + 2, x + w - 1, y + 2);
+ g2d.drawLine(x + 2, y + 3, x + 2, y + 3);
+ }
+ g2d.setColor(main);
+ g2d.drawLine(x, y, x + w, y);
+ g2d.drawLine(x + 1, y + 1, x + w - 1, y + 1);
+ g2d.drawLine(x + 2, y + 2, x + 2, y + 2);
+
+ }
+
+ protected BufferedImage paintSecondTriangleBlock(Object[] colors,
+ boolean selected) {
+
+ int w = 14;
+ int h = 22;
+
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D g2d = prepareImage(image);
+
+ Color additionalBackgroundColor = (Color) colors[0];
+ Color selectControlColor = (Color) colors[1];
+ Color panelBorderColor = (Color) colors[2];
+ Color generalTextColor = (Color) colors[3];
+ Color subBorderColorWithAlpha = new Color(255, 255, 255,
+ SUB_BORDER_TRANSPARENCY);
+
+ // Draw body
+ Paint gradient1;
+ Color contentColor;
+ if (selected) {
+ contentColor = selectControlColor;
+ gradient1 = new GradientPaint(w - 2, h - 2, contentColor, 2, 2,
+ Color.white);
+ } else {
+ contentColor = additionalBackgroundColor;
+ gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
+ Color.white);
+ }
+
+ g2d.setPaint(gradient1);
+ Rectangle2D border = new Rectangle2D.Double(1, 1, w - 1, h - 1);
+ g2d.fill(border);
+
+ // Draw Border
+ g2d.setColor(panelBorderColor);
+ g2d.drawLine(0, 0, w, 0);
+ g2d.drawLine(0, h - 1, w, h - 1);
+ g2d.drawLine(0, 0, 0, h);
+ g2d.drawLine(w - 1, 0, w - 1, h);
+
+ // Draw subBorder
+ g2d.setColor(subBorderColorWithAlpha);
+ g2d.drawLine(1, 1, 1, h - 2);
+ g2d.drawLine(1, 1, w - 2, 1);
+ g2d.drawLine(w - 2, 1, w - 2, h - 2);
+ g2d.drawLine(1, h - 2, w - 2, h - 2);
+
+ paintTriangle(g2d, 4, 10, generalTextColor, Color.WHITE, true);
+
+ return image;
+ }
+
+ private Graphics2D prepareImage(BufferedImage image) {
+
+ Graphics2D g2d = image.createGraphics();
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
+ RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+
+ g2d.setStroke(new BasicStroke(1));
+
+ return g2d;
+ }
+
+}
Property changes on: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorIcons.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java (rev 0)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java 2008-11-18 16:54:35 UTC (rev 11224)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.PngRenderer;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EdtorSimpleThemeIcons extends EdtorIcons{
+
+ private Dimension dimension = new Dimension(40, 66);
+
+
+ public EdtorSimpleThemeIcons() {
+ super();
+
+ setRenderer(new PngRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance()
+ .getStartTime()));
+ }
+
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return dimension;
+ }
+
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return dimension;
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void paint(ResourceContext context, Graphics2D graphics) {
+ Object[] stored = (Object[]) restoreData(context);
+ if (stored != null) {
+ BufferedImage block1 = paintMainBlock(stored, false);
+ BufferedImage separator = paintSeparatorBlock(stored);
+ BufferedImage block2 = paintMainBlock(stored, true);
+ BufferedImage block3 = paintMainBlock(stored, true);
+
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics.drawImage(block1, 0, 0, 22, 22, null);
+ graphics.drawImage(separator, 22, 0, 5, 22, null);
+ graphics.drawImage(block2, 0, 22, 22, 22, null);
+ graphics.drawImage(block3, 0, 44, 22, 22, null);
+ }
+
+ }
+
+}
Property changes on: trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EdtorSimpleThemeIcons.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss
===================================================================
--- trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss 2008-11-18 16:51:25 UTC (rev 11223)
+++ trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/richfaces/ui.xcss 2008-11-18 16:54:35 UTC (rev 11224)
@@ -205,14 +205,14 @@
<u:selector name=".richfacesSkin .mceToolbar .mceToolbarStart span">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
<u:selector name=".richfacesSkin .mceToolbar .mceToolbarEnd span">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
@@ -227,7 +227,7 @@
<u:selector name=".richfacesSkin .mceButton">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
</u:style>
</u:selector>
@@ -241,7 +241,7 @@
<u:selector name=".richfacesSkin .mceSeparator">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
@@ -257,7 +257,7 @@
<u:selector name=".richfacesSkin .mceListBox .mceOpen">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-66px 0"/>
</u:selector>
@@ -280,7 +280,7 @@
<u:selector name=".richfacesSkin .mceSplitButton">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
</u:style>
</u:selector>
@@ -293,14 +293,14 @@
<u:selector name=".richfacesSkin .mceSplitButton span.mceOpen">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="-44px 0"/>
</u:selector>
<u:selector name=".richfacesSkin table.mceSplitButtonEnabled:hover a.mceAction, .richfacesSkin .mceSplitButtonHover a.mceAction, .richfacesSkin .mceSplitButtonSelected">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorAdvancedThemeIcons"/>
</u:style>
<u:style name="background-position" value="0 -22px"/>
</u:selector>
Modified: trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss
===================================================================
--- trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss 2008-11-18 16:51:25 UTC (rev 11223)
+++ trunk/sandbox/ui/editor/src/main/resources/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/richfaces/ui.xcss 2008-11-18 16:54:35 UTC (rev 11224)
@@ -48,7 +48,7 @@
<u:selector name=".richfacesSimpleSkin .mceToolbar .mceToolbarStart span">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
@@ -61,7 +61,7 @@
<u:selector name=".richfacesSimpleSkin .mceToolbar .mceToolbarEnd span">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
@@ -90,7 +90,7 @@
<u:selector name=".richfacesSimpleSkin .mceButton">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons"/>
</u:style>
</u:selector>
@@ -117,7 +117,7 @@
<u:selector name=".richfacesSimpleSkin .mceSeparator">
<u:style name="background-image">
- <f:resource f:key="/org/richfaces/renderkit/html/scripts/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png"/>
+ <f:resource f:key="org.richfaces.renderkit.html.images.EdtorSimpleThemeIcons"/>
</u:style>
<u:style name="background-position" value="-22px 0"/>
</u:selector>
17 years, 6 months
JBoss Rich Faces SVN: r11223 - trunk/sandbox/ui/editor/src/test/java/org/richfaces/seamparser.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2008-11-18 11:51:25 -0500 (Tue, 18 Nov 2008)
New Revision: 11223
Modified:
trunk/sandbox/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java
Log:
additional test cases added
Modified: trunk/sandbox/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java
===================================================================
--- trunk/sandbox/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java 2008-11-18 16:50:19 UTC (rev 11222)
+++ trunk/sandbox/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java 2008-11-18 16:51:25 UTC (rev 11223)
@@ -54,27 +54,79 @@
private final static String SEAM_TEXT_EXPRESSION_4 = "The other guy said: "+ "\"Nyeah nyeah-nee\"";
- private final static String SEAM_TEXT_EXPRESSION_5 = "You can write down equations like 2\\*3\\=6 and HTML tagslike \\<body\\> using the escape character: \\\\.";
+ private final static String SEAM_TEXT_EXPRESSION_5 = "You can write down equations like 2\\*3\\+4-7\\=3 and HTML tagslike \\<body\\> using the escape character: \\\\. foo(a)tut.by, 100$ cash 100%";
private final static String SEAM_TEXT_EXPRESSION_6 = "My code doesn't work:"
+ "`for (int i=0; i<100; i--)\n"
+ "{\n"
- + "doSomething(); doSomething();\n"
+ + "doSomething(){ String str = \"& >" \"; }; doSomething();\n"
+ "doSomething() " +
"}`" + " Any ideas?";
private final static String SEAM_TEXT_EXPRESSION_7 = "+test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
- private final static String SEAM_TEXT_EXPRESSION_8 = "+test value<div>test5</div><h1>test1<div>test2</div>test4</h1>\ntest";
+ private final static String SEAM_TEXT_EXPRESSION_8 = "++test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
+
+ private final static String SEAM_TEXT_EXPRESSION_9 = "+++test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
+
+ private final static String SEAM_TEXT_EXPRESSION_10 = "++++test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
+
+ private final static String SEAM_TEXT_EXPRESSION_11 = "+test value<div>test5</div><h1>test1<div>test2</div>test4</h1>\ntest";
- private final static String SEAM_TEXT_EXPRESSION_9 = "[test link=>http://test.com]";
+ private final static String SEAM_TEXT_EXPRESSION_12 = "[test link=>http://test.com]";
- private final static String SEAM_TEXT_EXPRESSION_10 = "This is a |<tag attribute=\"value\"/>| example.";
+ private final static String SEAM_TEXT_EXPRESSION_13 = "[=>http://test.com]";
- private final static String SEAM_TEXT_EXPRESSION_11 = "= <div></div> <h1> test value </h1>";
+ private final static String SEAM_TEXT_EXPRESSION_14 = "This is a |<tag attribute=\"value\"/>| example.";
+ private final static String SEAM_TEXT_EXPRESSION_15 = "= <div class=\"testClass1 testClass2\"></div> <h1> test value </h1>";
+ private final static String SEAM_TEXT_EXPRESSION_16 = "# <div class=\"testClass1 testClass2\"></div> <h1> test value </h1>";
+
+ private final static String SEAM_TEXT_EXPRESSION_17 = "paragraph\n\n+header\ntext after header\n\nanother paragraph";
+
+ private final static String SEAM_TEXT_EXPRESSION_18 = "paragraph\n\n++header\ntext after header\n\nanother paragraph";
+ private final static String SEAM_TEXT_EXPRESSION_19 = "paragraph\n\n+++header\ntext after header\n\nanother paragraph";
+
+ private final static String SEAM_TEXT_EXPRESSION_20 = "paragraph\n\n++++header\ntext after header\n\nanother paragraph";
+
+ private final static String SEAM_TEXT_EXPRESSION_21 = "paragraph\n\n=item1\n=item2\n=item3\n\nanother paragraph";
+
+ private final static String SEAM_TEXT_EXPRESSION_22 = "paragraph\n\n#item1\n#item2\n#item3\n\nanother paragraph";
+
+ private final static String SEAM_TEXT_EXPRESSION_23 = "+header text *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
+
+ private final static String SEAM_TEXT_EXPRESSION_24 = "++header text *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
+
+ private final static String SEAM_TEXT_EXPRESSION_25 = "+++header text *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
+
+ private final static String SEAM_TEXT_EXPRESSION_26 = "++++header text *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
+
+
+ private final static String SEAM_TEXT_EXPRESSION_27 = "=item1 *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n=item2 *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
+
+ private final static String SEAM_TEXT_EXPRESSION_28 = "#item1 *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n#item2 *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
+
+ private final static String SEAM_TEXT_EXPRESSION_29 = "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";
+
+ private final static String SEAM_TEXT_EXPRESSION_30 = "<div/>";
+
+
+
+
public HtmlSeamParserTest(String name) {
super(name);
}
@@ -82,49 +134,130 @@
assertSeamConverting(SEAM_TEXT_EXPRESSION_1);
}
- public void testSeamTextConverting2() throws Exception {
+ public void testStandartSeamTextConverting2() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_2);
}
- public void testSeamTextConverting3() throws Exception {
+ public void testStandartSeamTextConverting3() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_3);
}
- public void testSeamTextConverting4() throws Exception {
+ public void testStandartSeamTextConverting4() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_4);
}
- public void testSeamTextConverting5() throws Exception {
+ public void testStandartSeamTextConverting5() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_5);
}
- public void testSeamTextConverting6() throws Exception {
+ public void testStandartSeamTextConverting6() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_6);
}
- public void testSeamTextConverting7() throws Exception {
+ public void testStandartSeamTextConverting7() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_7);
}
- public void testSeamTextConverting8() throws Exception {
+ public void testStandartSeamTextConverting8() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_8);
}
- public void testSeamTextConverting9() throws Exception {
+ public void testStandartSeamTextConverting9() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_9);
}
- public void testSeamTextConverting10() throws Exception {
+ public void testStandartSeamTextConverting10() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_10);
}
- public void testSeamTextConverting11() throws Exception {
+ public void testStandartSeamTextConverting11() throws Exception {
assertSeamConverting(SEAM_TEXT_EXPRESSION_11);
}
+ public void testStandartSeamTextConverting12() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_12);
+ }
+
+ public void testStandartSeamTextConverting13() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_13);
+ }
+ public void testStandartSeamTextConverting14() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_14);
+ }
+
+ public void testStandartSeamTextConverting15() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_15);
+ }
+
+ public void testStandartSeamTextConverting16() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_16);
+ }
+ public void testStandartSeamTextConverting17() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_17);
+ }
+
+ public void testStandartSeamTextConverting18() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_18);
+ }
+
+ public void testStandartSeamTextConverting19() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_19);
+ }
+
+ public void testStandartSeamTextConverting20() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_20);
+ }
+
+ public void testStandartSeamTextConverting21() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_21);
+ }
+
+ public void testStandartSeamTextConverting22() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_22);
+ }
+
+ public void testStandartSeamTextConverting23() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_23);
+ }
+
+ public void testStandartSeamTextConverting24() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_24);
+ }
+
+ public void testStandartSeamTextConverting25() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_25);
+ }
+
+ public void testStandartSeamTextConverting26() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_26);
+ }
+
+ public void testStandartSeamTextConverting27() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_27);
+ }
+
+ public void testStandartSeamTextConverting28() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_28);
+ }
+
+ public void testStandartSeamTextConverting29() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_29);
+ }
+
+ public void testStandartSeamTextConverting30() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_30);
+ }
+
+
+
+
+
+
+
+
/**
* Method to assert converting from Seam Text to html and back
* @param seamTextExpression
17 years, 6 months
JBoss Rich Faces SVN: r11222 - trunk/sandbox/ui/editor/src/main/antlr.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-11-18 11:50:19 -0500 (Tue, 18 Nov 2008)
New Revision: 11222
Modified:
trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g
Log:
Modified: trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g
===================================================================
--- trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g 2008-11-18 15:45:18 UTC (rev 11221)
+++ trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g 2008-11-18 16:50:19 UTC (rev 11222)
@@ -302,12 +302,16 @@
}
- public boolean isPlainHMTLRequired(Token name, java.util.Stack <Token> htmlElementStack) throws SemanticException {
+ public boolean isPlainHtmlRequired(Token name, java.util.Stack <Token> htmlElementStack) throws SemanticException {
if(!isSeamTextElement(name)) {
return true;
}
+ if(isSimpleSeamTextElement(name)) {
+ return false;
+ }
+
if(isHeader(name) && !htmlElementStack.isEmpty()) {
return true;
}
@@ -493,7 +497,7 @@
space: s:SPACE {
if(!htmlElementStack.isEmpty()) {
Token token = htmlElementStack.pop();
- if(isPlainHMTLRequired(token, htmlElementStack)) {
+ if(isPlainHtmlRequired(token, htmlElementStack)) {
append(s.getText());
}
htmlElementStack.push(token);
@@ -562,7 +566,7 @@
preformatted = true;
}
- if(!isPlainHMTLRequired(name, htmlElementStack)) {
+ if(!isPlainHtmlRequired(name, htmlElementStack)) {
if (isFormattedHtmlSeamTextElement(name)) {
@@ -621,7 +625,7 @@
beforeBody: GT {
Token name = htmlElementStack.pop();
- if((isPlainHMTLRequired(name,htmlElementStack))) {
+ if((isPlainHtmlRequired(name,htmlElementStack))) {
append(">");
}
htmlElementStack.push(name);
@@ -650,7 +654,7 @@
value = valueCollector.toString();
}
- if(!isPlainHMTLRequired(name, htmlElementStack)) {
+ if(!isPlainHtmlRequired(name, htmlElementStack)) {
if(isFormattedHtmlSeamTextElement(name)) {
if(isLink(name)){
append(createSeamTextLink(linkHolder,value.trim()));
@@ -707,9 +711,9 @@
Token token = htmlElementStack.pop();
sanitizer.validateHtmlAttribute(token, att);
// boolean isSeamTextProcessed = isSeamTextElement(token);
- boolean isPlainHMTLRequired = isPlainHMTLRequired(token, htmlElementStack);
+ boolean isPlainHtmlRequired = isPlainHtmlRequired(token, htmlElementStack);
- if (isPlainHMTLRequired) {
+ if (isPlainHtmlRequired) {
append(att.getText());
append("=\"");
}
@@ -720,7 +724,7 @@
String attValue = endCapture();
sanitizer.validateHtmlAttributeValue(token, att, attValue);
- if (isPlainHMTLRequired) {
+ if (isPlainHtmlRequired) {
append(attValue);
} else if(isLink(token) && "href".equals(att.getText())) {
@@ -729,7 +733,7 @@
}
DOUBLEQUOTE {
- if(isPlainHMTLRequired) {
+ if(isPlainHtmlRequired) {
append("\"");
}
htmlElementStack.push(token);
@@ -750,7 +754,7 @@
an:ALPHANUMERICWORD { append( an.getText() ); } |
p:PUNCTUATION { append( p.getText() ); } |
s:SLASH { append( s.getText() ); } |
- space|specialChars )*
+ space:SPACE{append(space.getText());}|specialChars )*
;
exception
catch [RecognitionException ex] {
17 years, 6 months
JBoss Rich Faces SVN: r11221 - in trunk/sandbox: ui/queue/src/main/config/component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2008-11-18 10:45:18 -0500 (Tue, 18 Nov 2008)
New Revision: 11221
Modified:
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/events.xhtml
trunk/sandbox/ui/queue/src/main/config/component/queue.xml
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
Log:
https://jira.jboss.org/jira/browse/RF-4899
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/events.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/events.xhtml 2008-11-18 15:44:24 UTC (rev 11220)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/events.xhtml 2008-11-18 15:45:18 UTC (rev 11221)
@@ -13,20 +13,98 @@
<a4j:status startText="...running..." startStyle="color: green" />
- <q:queue name="queue" oncomplete="alert('queue - oncomplete')" onbeforedomupdate="alert('queue - onbeforedomupdate')" />
+ <style type="text/css">
+ td {
+ border: 1px solid black;
+ }
+
+ #handlersTableHeaders td {
+ width: 25%;
+ }
+ </style>
+ <table id="handlersTable" width="30%">
+ <tbody>
+ <tr>
+ <td colspan="4">Queue - Q, Component - C</td>
+ </tr>
+ <tr id="handlersTableHeaders">
+ <td>onsubmit</td>
+ <td>onbeforedomupdate</td>
+ <td>oncomplete</td>
+ <td>onerror</td>
+ </tr>
+ <tr>
+ <td id="onsubmitElt"></td>
+ <td id="onbeforedomupdateElt"></td>
+ <td id="oncompleteElt"></td>
+ <td id="onerrorElt"></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <script type="text/javascript">//<![CDATA[
+ function my$(id) {
+ return document.getElementById(id);
+ }
+
+ function resetCells() {
+ var handlersTable = my$('handlersTable');
+ var rows = handlersTable.rows;
+ var cells = rows[2].cells;
+ for ( var cellIdx = 0; cellIdx < cells.length; cellIdx++) {
+ var cell = cells[cellIdx];
+ cell.innerHTML = ' ';
+ }
+ }
+
+ resetCells();
+
+ var handlersList = ["onbeforedomupdate", "onsubmit", "oncomplete", "onerror"];
+
+ var handlers = {};
+
+ for ( var i = 0; i < handlersList.length; i++) {
+ var handlerName = handlersList[i];
+ handlers["queue:" + handlerName] = new Function("my$('" + handlerName + "Elt').innerHTML += 'Q'");
+ handlers["component:" + handlerName] = new Function("my$('" + handlerName + "Elt').innerHTML += 'C'");
+ }
+ //]]></script>
+ <q:queue name="queue" onsubmit="handlers['queue:onsubmit']()" onerror="handlers['queue:onerror']()"
+ oncomplete="handlers['queue:oncomplete']()" onbeforedomupdate="handlers['queue:onbeforedomupdate']()" />
+
<h:form>
<h:panelGrid columns="1">
Components in queue
- <a4j:commandLink value="No component handlers" eventsQueue="queue"/>
- <a4j:commandLink value="Oncomplete component client handler" eventsQueue="queue" onbeforedomupdate="request.options.oncomplete = function(){alert('component - oncomplete')}" />
- <a4j:commandLink value="Both component handlers" eventsQueue="queue" oncomplete="alert('component - oncomplete')" onbeforedomupdate="alert('component - onbeforedomupdate')" />
+ <a4j:commandLink onclick="resetCells()" value="No component handlers" eventsQueue="queue"/>
+
+ <a4j:commandLink onclick="resetCells()" value="Oncomplete component client handler" eventsQueue="queue"
+ onbeforedomupdate="request.options.oncomplete = handlers['component:oncomplete']" />
+
+ <a4j:commandLink onclick="resetCells(); A4J.AJAX.onError = undefined;" value="Onerror" eventsQueue="queue" timeout="1" />
+
+ <a4j:commandLink onclick="resetCells(); A4J.AJAX.onError = handlers['component:onerror'];" value="Component onerror" eventsQueue="queue"
+ timeout="1" />
+
+ <a4j:commandLink onclick="resetCells()" value="Both component handlers" eventsQueue="queue"
+ oncomplete="handlers['component:oncomplete']()"
+ onbeforedomupdate="handlers['component:onbeforedomupdate']()" />
</h:panelGrid>
<h:panelGrid columns="1">
Components without queue
- <a4j:commandLink value="No component handlers" />
- <a4j:commandLink value="Oncomplete component client handler" onbeforedomupdate="request.options.oncomplete = function(){alert('component - oncomplete')}" />
- <a4j:commandLink value="Both component handlers" oncomplete="alert('component - oncomplete')" onbeforedomupdate="alert('component - onbeforedomupdate')" />
+ <a4j:commandLink onclick="resetCells()" value="No component handlers" />
+
+ <a4j:commandLink onclick="resetCells()" value="Oncomplete component client handler"
+ onbeforedomupdate="request.options.oncomplete = handlers['component:oncomplete']" />
+
+ <a4j:commandLink onclick="resetCells(); A4J.AJAX.onError = undefined;" value="Onerror" timeout="1" />
+
+ <a4j:commandLink onclick="resetCells(); A4J.AJAX.onError = handlers['component:onerror'];" value="Component onerror"
+ timeout="1" />
+
+ <a4j:commandLink onclick="resetCells()" value="Both component handlers"
+ oncomplete="handlers['component:oncomplete']()"
+ onbeforedomupdate="handlers['component:onbeforedomupdate']()" />
</h:panelGrid>
</h:form>
</f:view>
Modified: trunk/sandbox/ui/queue/src/main/config/component/queue.xml
===================================================================
--- trunk/sandbox/ui/queue/src/main/config/component/queue.xml 2008-11-18 15:44:24 UTC (rev 11220)
+++ trunk/sandbox/ui/queue/src/main/config/component/queue.xml 2008-11-18 15:45:18 UTC (rev 11221)
@@ -64,27 +64,23 @@
<classname>java.lang.String</classname>
</property>
<property>
- <name>oncomplete</name>
- <classname>java.lang.String</classname>
- </property>
- <property>
<name>onbeforedomupdate</name>
<classname>java.lang.String</classname>
</property>
<property>
- <name>sizeExceededBehavior</name>
+ <name>oncomplete</name>
<classname>java.lang.String</classname>
</property>
<property>
- <name>onSizeExceeded</name>
+ <name>onerror</name>
<classname>java.lang.String</classname>
</property>
<property>
- <name>onError</name>
+ <name>sizeExceededBehavior</name>
<classname>java.lang.String</classname>
</property>
<property>
- <name>onExpired</name>
+ <name>onSizeExceeded</name>
<classname>java.lang.String</classname>
</property>
</component>
Modified: trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java 2008-11-18 15:44:24 UTC (rev 11220)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java 2008-11-18 15:45:18 UTC (rev 11221)
@@ -49,8 +49,11 @@
public abstract void setOncomplete(String oncomplete);
public abstract String getOnbeforedomupdate();
- public abstract void setOnbeforedomupdate(String Onbeforedomupdate);
+ public abstract void setOnbeforedomupdate(String onbeforedomupdate);
+ public abstract String getOnerror();
+ public abstract void setOnerror(String onerror);
+
public abstract boolean isDisabled();
public abstract void setDisabled(boolean disabled);
Modified: trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-18 15:44:24 UTC (rev 11220)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-18 15:45:18 UTC (rev 11221)
@@ -47,6 +47,8 @@
private static final String QUEUE_ONCOMPLETE_ATTRIBUTE = "queueoncomplete";
+ private static final String QUEUE_ONERROR_ATTRIBUTE = "queueonerror";
+
private static final String[] QUEUE_ATTRIBUTES = new String[] {
"enabled",
"size",
@@ -143,12 +145,20 @@
String onsubmit = queue.getOnsubmit();
if (onsubmit != null) {
- JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition();
+ JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition("request");
onsubmitFunction.addToBody(onsubmit);
data.addRequestAttribute(QUEUE_ONSUBMIT_ATTRIBUTE, onsubmitFunction);
}
+ String onerror = queue.getOnerror();
+ if (onerror != null) {
+ JSFunctionDefinition onerrorFunction = new JSFunctionDefinition("request", "status", "message");
+ onerrorFunction.addToBody(onerror);
+
+ data.addRequestAttribute(QUEUE_ONERROR_ATTRIBUTE, onerrorFunction);
+ }
+
return data;
}
17 years, 6 months