JBoss Portal SVN: r10527 - modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-10 19:32:30 -0400 (Thu, 10 Apr 2008)
New Revision: 10527
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java
Log:
more robust implementation of the mapping style obtention
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java 2008-04-10 22:53:05 UTC (rev 10526)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java 2008-04-10 23:32:30 UTC (rev 10527)
@@ -22,9 +22,10 @@
******************************************************************************/
package org.jboss.portal.web.endpoint;
-import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
+import org.w3c.dom.Document;
import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.common.text.FastURLDecoder;
@@ -41,8 +42,11 @@
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ByteArrayInputStream;
/**
* A web end point.
@@ -79,19 +83,50 @@
ServletContext servletContext = getServletContext();
// XPath expression for selecting the url pattern for this servlet instance
- String xpathExpression = "//servlet-mapping[servlet-name='" + servletName + "']/url-pattern";
+ String exprValue = "//servlet-mapping[servlet-name='" + servletName + "']/url-pattern";
XPath xpath = XPathFactory.newInstance().newXPath();
+ XPathExpression expr;
+ try
+ {
+ expr = xpath.compile(exprValue);
+ }
+ catch (XPathExpressionException e)
+ {
+ throw new ServletException(e);
+ }
//
log.debug("Going to look for the configuration of the end point servlet " + servletName);
// Obtain url pattern values in order to find out how this servlet instance is mapped
InputStream in = servletContext.getResourceAsStream("/WEB-INF/web.xml");
+ byte[] bytes;
try
{
- NodeList nodes = (NodeList)xpath.evaluate(xpathExpression, new InputSource(in), XPathConstants.NODESET);
+ bytes = IOTools.getBytes(in);
+ // That's the descriptor but we won't parse it as the encoding may not be correct, it's just here for debugging purpose
+ String descriptor = new String(bytes);
+ log.debug("The a priori descriptor is " + descriptor);
+ }
+ catch (IOException e)
+ {
+ throw new ServletException("The end point servlet " + servletName + " is not able to load the web descriptor");
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+
+ //
+ try
+ {
+ Document doc = XMLTools.getDocumentBuilderFactory().newDocumentBuilder().parse(new ByteArrayInputStream(bytes));
+
//
+ NodeList nodes = (NodeList)expr.evaluate(doc, XPathConstants.NODESET);
+
+ //
for (int i = 0;i < nodes.getLength();i++)
{
Element urlPatternElt = (Element)nodes.item(i);
@@ -127,6 +162,18 @@
}
}
}
+ catch (IOException e)
+ {
+ throw new ServletException(e);
+ }
+ catch (SAXException e)
+ {
+ throw new ServletException(e);
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new ServletException(e);
+ }
catch (XPathExpressionException e)
{
throw new ServletException(e);
@@ -135,6 +182,12 @@
{
IOTools.safeClose(in);
}
+
+ //
+ if (mappingType == null)
+ {
+ throw new ServletException("The same end point servlet " + servletName + " was not able to detect its mapping");
+ }
}
protected final void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
18 years
JBoss Portal SVN: r10526 - in modules/web/trunk/web/src: main/java/org/jboss/portal/web/endpoint and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-10 18:53:05 -0400 (Thu, 10 Apr 2008)
New Revision: 10526
Added:
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/RenderURLTestCase.java
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/Body.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRequest.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebResponse.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointRequest.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointResponse.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebRequest.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java
modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml
Log:
added more testing to the endpoint stuff in web module
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/Body.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/Body.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/Body.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -28,6 +28,7 @@
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.IOException;
+import java.util.Map;
/**
* The body of a request.
@@ -71,7 +72,7 @@
this.parameters = parameters;
}
- public ParameterMap getParameters()
+ public Map<String, String[]> getParameters()
{
return parameters;
}
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRequest.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRequest.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRequest.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -22,14 +22,14 @@
******************************************************************************/
package org.jboss.portal.web;
-import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.net.media.MediaType;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.Charset;
+import java.util.Map;
/**
- * Add useful information about an <code>HttpServletRequest</code>.
+ * Extends the HttpServletRequest interface to add web module concepts.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -52,15 +52,50 @@
/** . */
Charset UTF_8_CHARSET = Charset.forName("UTF-8");
+ /**
+ * Returns the an enum instead of a string as returned by
+ * {@link javax.servlet.http.HttpServletRequest#getMethod()} which is more convenient to use sometimes.
+ *
+ * @return the verb
+ */
Verb getVerb();
- ParameterMap getQueryParameterMap();
+ /**
+ * Returns the query parameter map. If no query string was provided it returns an empty map in order
+ * to avoid to return a null object.
+ *
+ * @return the query parameter map
+ */
+ Map<String, String[]> getQueryParameterMap();
+ /**
+ * Returns the body of the request when the request is of type POST otherwise return null.
+ *
+ * @return the body
+ */
Body getBody();
+ /**
+ * Returns the media type or null if none was provided.
+ *
+ * @return the media type
+ */
MediaType getMediaType();
+ /**
+ * Returns the web request path which is a consistent value and does not depend on the kind of mapping of the underlying
+ * servlet. It is never null and always start with a '/' char.
+ *
+ * @return the web request path
+ */
String getWebRequestPath();
+ /**
+ * Returns the web context path. The web context path value is computed such as the value returned by the method
+ * {@link javax.servlet.http.HttpServletRequest#getRequestURI()} is a prefix of the concatenation of the web context
+ * path and the web request path.
+ *
+ * @return the web context path
+ */
String getWebContextPath();
}
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebResponse.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebResponse.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebResponse.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -30,7 +30,7 @@
import java.io.IOException;
/**
- * todo
+ * Extends the HttpServletResponse interface to add web module concepts.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -39,30 +39,31 @@
{
/**
- * Renders an URL and returns the rendered string.
+ * <p>Renders an URL and returns the rendered string.</p>
*
- * The path argument is mandatory and must begin with '/' char. The parameters argument is optional and the
- * wantedURLFormat is also optional.
+ * <p>The path argument is mandatory and must begin with '/' char. The parameters argument is optional and the
+ * wantedURLFormat is also optional.</p>
*
+ * <p>If the parameter map is not null, it must provide a key set with no null elements and the values must be
+ * string arrays with no null entries. Any entry with an empty length value will be skipped.</p>
+ *
* @param path the path relative to the web context
* @param parameters the optional parameter map
* @param wantedURLFormat the url format needed
* @return the rendered URL
- * @throws IllegalArgumentException if the path value is not correct
+ * @throws IllegalArgumentException if the path value is not correct or the parameter map is corrupted
*/
String renderURL(String path, Map<String, String[]> parameters, URLFormat wantedURLFormat) throws IllegalArgumentException;
/**
* Renders an URL in the provided writer.
*
- * The path argument is mandatory and must begin with '/' char. The parameters argument is optional and the
- * wantedURLFormat is also optional.
- *
+ * @see org.jboss.portal.web.WebResponse#renderURL(String, java.util.Map, org.jboss.portal.common.servlet.URLFormat)
* @param writer the writer
* @param path the path relative to the web context
* @param parameters the optional parameter map
* @param wantedURLFormat the url format needed
- * @throws IllegalArgumentException if the path value is not correct or the write is null
+ * @throws IllegalArgumentException if the path value is not correct or the write is null or the parameter map is corrupted
* @throws IOException any IOException thrown by the writer
*/
void renderURL(Writer writer, String path, Map<String, String[]> parameters, URLFormat wantedURLFormat) throws IllegalArgumentException, IOException;
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointRequest.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointRequest.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointRequest.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -41,7 +41,14 @@
/** . */
private final String webContextPath;
- public EndPointRequest(HttpServletRequest req, String webRequestPath, String webContextPath)
+ /** . */
+ private final int mappingType;
+
+ public EndPointRequest(
+ HttpServletRequest req,
+ String webRequestPath,
+ String webContextPath,
+ int mappingType)
throws UnsupportedEncodingException, IllegalRequestException
{
super(req);
@@ -49,6 +56,7 @@
//
this.webRequestPath = webRequestPath;
this.webContextPath = webContextPath;
+ this.mappingType = mappingType;
}
public String getWebRequestPath()
@@ -60,4 +68,9 @@
{
return webContextPath;
}
+
+ public int getMappingType()
+ {
+ return mappingType;
+ }
}
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointResponse.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointResponse.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointResponse.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -28,12 +28,9 @@
import org.jboss.portal.common.text.FastURLEncoder;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
- * Todo: find a way to manage the different servlet that take care of security/authenticated as today it is hardcoded.
- *
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
* @version $Revision: 630 $
*/
@@ -44,38 +41,98 @@
private static final FastURLEncoder urlEncoder = FastURLEncoder.getUTF8Instance();
/** . */
- private final String requestRelativePrefix;
+ private static final URLFormat nullFormat = URLFormat.create(
+ null,
+ null,
+ null,
+ null,
+ null);
/** . */
- private final String requestPrefix;
+ private String requestRelativePrefix;
- public EndPointResponse(HttpServletRequest req, HttpServletResponse resp)
+ /** . */
+ private String requestPrefix;
+
+ /** . */
+ private final EndPointRequest req;
+
+ public EndPointResponse(EndPointRequest req, HttpServletResponse resp)
{
super(resp);
+
//
- StringBuffer requestRelativePrefix = new StringBuffer();
- requestRelativePrefix.append(req.getScheme()).append("://").append(req.getServerName());
- if (req.isSecure())
+ this.req = req;
+ }
+
+ private String getRequestRelativePrefix()
+ {
+ if (requestRelativePrefix == null)
{
- if (req.getServerPort() != 443)
+ //
+ StringBuilder requestRelativePrefix = new StringBuilder();
+
+ //
+ requestRelativePrefix.append(req.getScheme()).append("://").append(req.getServerName());
+ if (req.isSecure())
{
+ if (req.getServerPort() != 443)
+ {
+ requestRelativePrefix.append(":").append(Integer.toString(req.getServerPort()));
+ }
+ }
+ else if (req.getServerPort() != 80)
+ {
requestRelativePrefix.append(":").append(Integer.toString(req.getServerPort()));
}
+
+ //
+ requestRelativePrefix.append(req.getContextPath());
+
+ //
+ if (req.getMappingType() != EndPointServlet.DEFAULT_SERVLET_MAPPING)
+ {
+ requestRelativePrefix.append(req.getServletPath());
+ }
+
+ //
+ this.requestRelativePrefix = requestRelativePrefix.toString();
}
- else if (req.getServerPort() != 80)
+
+ //
+ return requestRelativePrefix;
+ }
+
+ private String getRequestPrefix()
+ {
+ if (requestPrefix == null)
{
- requestRelativePrefix.append(":").append(Integer.toString(req.getServerPort()));
+ this.requestPrefix = req.getMappingType() != EndPointServlet.DEFAULT_SERVLET_MAPPING ? req.getContextPath() : req.getContextPath() + req.getServletPath();
}
- requestRelativePrefix.append(req.getContextPath());
//
- this.requestRelativePrefix = requestRelativePrefix.toString();
- this.requestPrefix = req.getContextPath();
+ return requestPrefix;
}
public String renderURL(String path, Map<String, String[]> parameters, URLFormat wantedURLFormat) throws IllegalArgumentException
{
+ if (path == null)
+ {
+ throw new IllegalArgumentException("No null path accepted");
+ }
+ if (!path.startsWith("/"))
+ {
+ throw new IllegalArgumentException("Path value " + path + " should start with a trailing '/'");
+ }
+
+ //
+ if (wantedURLFormat == null)
+ {
+ wantedURLFormat = nullFormat;
+ }
+
+ //
Buffer buffer = new Buffer(wantedURLFormat);
//
@@ -96,43 +153,19 @@
public Buffer(URLFormat format)
{
- if (!format.getRelative())
+ if (Boolean.FALSE.equals(format.getRelative()))
{
- append(requestRelativePrefix);
+ append(getRequestPrefix());
}
else
{
- append(requestPrefix);
+ append(getRequestRelativePrefix());
}
- // Append the servlet path
- if (format.getSecure())
- {
- if (format.getAuthenticated())
- {
- append("/authsec");
- }
- else
- {
- append("/sec");
- }
- }
- else
- {
- if (format.getAuthenticated())
- {
- append("/auth");
- }
- else
- {
- //
- }
- }
-
// Save the prefix length
this.prefixLength = length;
this.format = format;
- this.parameterSeparator = format.getEscapeXML() ? "&" : "&";
+ this.parameterSeparator = Boolean.TRUE.equals(format.getEscapeXML()) ? "&" : "&";
}
public String toString(String path, Map<String, String[]> parameters)
@@ -151,9 +184,23 @@
for (Map.Entry parameter: parameters.entrySet())
{
String name = (String)parameter.getKey();
+
+ //
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Null key in the parameter map are not allowed");
+ }
+
+ //
String[] values = (String[])parameter.getValue();
for (String value : values)
{
+ if (value == null)
+ {
+ throw new IllegalArgumentException("Null value for the key " + name + " in the parameter map are not allowed");
+ }
+
+ //
append(first ? "?" : parameterSeparator);
append(name, urlEncoder);
append('=');
@@ -167,7 +214,7 @@
String s = asString();
// Let the servlet rewrite the URL if necessary
- if (format.getServletEncoded())
+ if (!Boolean.FALSE.equals(format.getServletEncoded()))
{
s = encodeURL(s);
}
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -69,7 +69,7 @@
public static final int PATH_MAPPING = 2;
/** . */
- private Integer mappingStyle;
+ private Integer mappingType;
public void init() throws ServletException
{
@@ -103,7 +103,7 @@
log.debug("Found url pattern " + urlPattern + " for end point servlet " + servletName);
//
- if (mappingStyle != null)
+ if (mappingType != null)
{
throw new ServletException("The same end point servlet " + servletName + " is mapped several times and this is not allowed");
}
@@ -111,15 +111,15 @@
//
if (urlPattern.equals("/"))
{
- mappingStyle = DEFAULT_SERVLET_MAPPING;
+ mappingType = DEFAULT_SERVLET_MAPPING;
}
else if (urlPattern.equals("/*"))
{
- mappingStyle = ROOT_PATH_MAPPING;
+ mappingType = ROOT_PATH_MAPPING;
}
else if (urlPattern.startsWith("/") && urlPattern.endsWith("/*"))
{
- mappingStyle = PATH_MAPPING;
+ mappingType = PATH_MAPPING;
}
else
{
@@ -146,7 +146,7 @@
// Determine the request path
String webRequestPath = null;
String webContextPath = null;
- switch (mappingStyle)
+ switch (mappingType)
{
case DEFAULT_SERVLET_MAPPING:
webRequestPath = requestURI.substring(contextPath.length());
@@ -171,7 +171,11 @@
webContextPath = decoder.encode(webContextPath);
//
- service(new EndPointRequest(req, webRequestPath, webContextPath), new EndPointResponse(req, resp));
+ EndPointRequest wreq = new EndPointRequest(req, webRequestPath, webContextPath, mappingType);
+ EndPointResponse wresp = new EndPointResponse(wreq, resp);
+
+ //
+ service(wreq, wresp);
}
protected abstract void service(WebRequest req, WebResponse resp) throws ServletException, IOException;
@@ -181,8 +185,8 @@
*
* @return the mapping style
*/
- public Integer getMappingStyle()
+ public Integer getMappingType()
{
- return mappingStyle;
+ return mappingType;
}
}
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebRequest.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebRequest.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebRequest.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -26,7 +26,6 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.net.media.ContentType;
import org.jboss.portal.common.net.media.MediaType;
-import org.jboss.portal.common.net.media.Parameter;
import org.jboss.portal.web.Body;
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.web.WebRequest;
@@ -34,6 +33,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.util.Map;
+import java.util.Collections;
import java.nio.charset.Charset;
import java.io.UnsupportedEncodingException;
@@ -56,7 +56,7 @@
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
/** . */
- private final ParameterMap queryParameterMap;
+ private final Map<String, String[]> queryParameterMap;
/** . */
private final Body body;
@@ -96,7 +96,7 @@
// Parse the query string to have the get parameters
// The resulting map has its parameters decoded from the x-www-form-url encoding
- ParameterMap queryParameterMap;
+ Map<String, String[]> queryParameterMap;
String queryString = req.getQueryString();
if (queryString != null)
{
@@ -104,7 +104,7 @@
}
else
{
- queryParameterMap = new ParameterMap();
+ queryParameterMap = Collections.emptyMap();
}
// Only affect the charset encoding if the servlet container will decode the request
@@ -141,6 +141,8 @@
// Values decoded from the query string
String[] queryValues = queryParameterMap.get(paramName);
+
+ //
if (queryValues != null)
{
int bodyValuesLength = paramValues.length - queryValues.length;
@@ -168,7 +170,7 @@
//
this.verb = verb;
- this.queryParameterMap = new ParameterMap(queryParameterMap);
+ this.queryParameterMap = queryParameterMap;
this.body = body;
this.mediaType = mediaType;
}
@@ -178,7 +180,7 @@
return verb;
}
- public ParameterMap getQueryParameterMap()
+ public Map<String, String[]> getQueryParameterMap()
{
return queryParameterMap;
}
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -34,7 +34,7 @@
public String rewriteURL(EndPointServlet endPointServlet, String url)
{
- switch (endPointServlet.getMappingStyle())
+ switch (endPointServlet.getMappingType())
{
case EndPointServlet.DEFAULT_SERVLET_MAPPING:
if (url.startsWith("/"))
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -23,7 +23,6 @@
package org.jboss.portal.test.web.endpoint;
import org.jboss.portal.test.web.TestServlet;
-import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.IllegalRequestException;
@@ -39,6 +38,7 @@
import javax.servlet.ServletException;
import java.io.IOException;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -58,7 +58,7 @@
{
if (getRequestCount() == 0)
{
- ParameterMap queryParameters = assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = assertNotNull(req.getQueryParameterMap());
assertNull(req.getBody());
assertTrue(queryParameters.isEmpty());
@@ -74,7 +74,7 @@
{
try
{
- ParameterMap queryParameters = assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = assertNotNull(req.getQueryParameterMap());
assertNull(req.getBody());
assertEquals(3, queryParameters.size());
assertEquals(new String[]{"a_value"}, queryParameters.get("a"));
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -24,7 +24,6 @@
import org.jboss.portal.test.web.TestServlet;
import org.jboss.portal.common.text.FastURLEncoder;
-import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.Body;
import org.jboss.portal.web.WebResponse;
@@ -41,6 +40,7 @@
import javax.servlet.ServletException;
import java.io.IOException;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -60,10 +60,10 @@
{
if (getRequestCount() == 0)
{
- ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertTrue(queryParameters.isEmpty());
Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
- ParameterMap formParameters = form.getParameters();
+ Map<String, String[]> formParameters = form.getParameters();
assertTrue(formParameters.isEmpty());
//
@@ -74,11 +74,11 @@
}
else if (getRequestCount() == 1)
{
- ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertEquals(1, queryParameters.size());
assertEquals(new String[]{"a_value_query"}, queryParameters.get("a"));
Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
- ParameterMap formParameters = form.getParameters();
+ Map<String, String[]> formParameters = form.getParameters();
assertTrue(formParameters.isEmpty());
//
@@ -91,10 +91,10 @@
}
else if (getRequestCount() == 2)
{
- ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertTrue(queryParameters.isEmpty());
Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
- ParameterMap formParameters = form.getParameters();
+ Map<String, String[]> formParameters = form.getParameters();
assertEquals(1, formParameters.size());
assertEquals(new String[]{"a_value_body"}, formParameters.get("a"));
@@ -109,11 +109,11 @@
}
else if (getRequestCount() == 3)
{
- ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertEquals(1, queryParameters.size());
assertEquals(new String[]{"a_value_query"}, queryParameters.get("a"));
Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
- ParameterMap formParameters = form.getParameters();
+ Map<String, String[]> formParameters = form.getParameters();
assertEquals(1, formParameters.size());
assertEquals(new String[]{"a_value_form"}, formParameters.get("a"));
@@ -128,11 +128,11 @@
}
else if (getRequestCount() == 4)
{
- ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertEquals(1, queryParameters.size());
assertNull(compareString(RANGE_0_255, queryParameters.get("a")[0]));
Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
- ParameterMap formParameters = form.getParameters();
+ Map<String, String[]> formParameters = form.getParameters();
assertEquals(1, formParameters.size());
assertNull(compareString(RANGE_256_512, formParameters.get("a")[0]));
@@ -147,11 +147,11 @@
}
else if (getRequestCount() == 5)
{
- ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertEquals(1, queryParameters.size());
assertNull(compareString(RANGE_256_512, queryParameters.get("a")[0]));
Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
- ParameterMap formParameters = form.getParameters();
+ Map<String, String[]> formParameters = form.getParameters();
assertEquals(1, formParameters.size());
assertNull(compareString(RANGE_0_255, formParameters.get("a")[0]));
}
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -24,7 +24,6 @@
import org.jboss.portal.test.web.TestServlet;
import org.jboss.portal.common.text.FastURLEncoder;
-import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.Body;
@@ -44,6 +43,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -63,7 +63,7 @@
{
if (getRequestCount() == 0)
{
- ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
+ Map<String, String[]> queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
Assert.assertTrue(queryParameters.isEmpty());
Body.Raw raw = Assert.assertInstanceOf(req.getBody(), Body.Raw.class);
InputStream in = raw.getInputStream();
Added: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/RenderURLTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/RenderURLTestCase.java (rev 0)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/RenderURLTestCase.java 2008-04-10 22:53:05 UTC (rev 10526)
@@ -0,0 +1,183 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.endpoint;
+
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import org.jboss.unit.Failure;
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.portal.test.web.TestServlet;
+import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.web.WebResponse;
+import org.jboss.portal.common.servlet.URLFormat;
+import org.jboss.portal.common.util.Tools;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class RenderURLTestCase extends EndPointTestCase
+{
+
+ /** . */
+ private static final URLFormat format = URLFormat.create(null, null, null, null, null);
+
+ public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse resp) throws ServletException, IOException
+ {
+ if (getRequestCount() == 0)
+ {
+ try
+ {
+ resp.renderURL(null, new HashMap<String, String[]>(), format);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ try
+ {
+ resp.renderURL("", new HashMap<String, String[]>(), format);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ try
+ {
+ HashMap<String, String[]> corruptedMap = new HashMap<String, String[]>();
+ corruptedMap.put(null, new String[0]);
+ resp.renderURL("/", corruptedMap, format);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ try
+ {
+ HashMap<String, String[]> corruptedMap = new HashMap<String, String[]>();
+ corruptedMap.put("foo", new String[]{null});
+ resp.renderURL("/", corruptedMap, format);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+
+ //
+ String url = resp.renderURL("/", null, null);
+ return new InvokeGetResponse(url);
+ }
+ else if (getRequestCount() == 1)
+ {
+ assertEquals("/", req.getWebRequestPath());
+ assertEquals(new HashMap<String, String[]>(), req.getQueryParameterMap());
+
+ //
+ String url = resp.renderURL("/", new HashMap<String, String[]>(), null);
+ return new InvokeGetResponse(url);
+ }
+ else if (getRequestCount() == 2)
+ {
+ assertEquals("/", req.getWebRequestPath());
+ assertEquals(new HashMap<String, String[]>(), req.getQueryParameterMap());
+
+ //
+ Map<String, String[]> parameters = new HashMap<String, String[]>();
+ parameters.put("foo", new String[]{"foo_value"});
+ parameters.put("bar", new String[]{"bar_value_1", "bar_value_2"});
+ parameters.put("juu", new String[0]);
+ String url = resp.renderURL("/", parameters, null);
+ return new InvokeGetResponse(url);
+ }
+ else if (getRequestCount() == 3)
+ {
+ assertEquals("/", req.getWebRequestPath());
+ Map<String, String[]> parameters = assertNotNull(req.getQueryParameterMap());
+ assertEquals(2, parameters.size());
+ assertEquals(Tools.toSet("foo", "bar"), parameters.keySet());
+ assertEquals(new String[]{"foo_value"}, parameters.get("foo"));
+ assertEquals(new String[]{"bar_value_1","bar_value_2"}, parameters.get("bar"));
+
+ //
+ String url = resp.renderURL("/blah", null, null);
+ return new InvokeGetResponse(url);
+ }
+ else if (getRequestCount() == 4)
+ {
+ assertEquals("/blah", req.getWebRequestPath());
+ assertEquals(new HashMap<String, String[]>(), req.getQueryParameterMap());
+
+ //
+ String url = resp.renderURL("/blah", new HashMap<String, String[]>(), null);
+ return new InvokeGetResponse(url);
+ }
+ else if (getRequestCount() == 5)
+ {
+ assertEquals("/blah", req.getWebRequestPath());
+ assertEquals(new HashMap<String, String[]>(), req.getQueryParameterMap());
+
+ //
+ Map<String, String[]> parameters = new HashMap<String, String[]>();
+ parameters.put("foo", new String[]{"foo_value"});
+ parameters.put("bar", new String[]{"bar_value_1", "bar_value_2"});
+ parameters.put("juu", new String[0]);
+ String url = resp.renderURL("/blah", parameters, null);
+ return new InvokeGetResponse(url);
+ }
+ else if (getRequestCount() == 6)
+ {
+ assertEquals("/blah", req.getWebRequestPath());
+ Map<String, String[]> parameters = assertNotNull(req.getQueryParameterMap());
+ assertEquals(2, parameters.size());
+ assertEquals(Tools.toSet("foo", "bar"), parameters.keySet());
+ assertEquals(new String[]{"foo_value"}, parameters.get("foo"));
+ assertEquals(new String[]{"bar_value_1","bar_value_2"}, parameters.get("bar"));
+
+ //
+ return new EndTestResponse();
+ }
+
+ //
+ return new FailureResponse(Failure.createAssertionFailure(""));
+ }
+
+ public DriverResponse invoke(TestServlet testServlet, DriverCommand driverCommand)
+ {
+ if (getRequestCount() == -1)
+ {
+ return new InvokeGetResponse(rewriteURL(testServlet, ""));
+ }
+ else
+ {
+ return new FailureResponse(Failure.createAssertionFailure(""));
+ }
+ }
+}
\ No newline at end of file
Modified: modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml 2008-04-10 20:35:44 UTC (rev 10525)
+++ modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml 2008-04-10 22:53:05 UTC (rev 10526)
@@ -93,4 +93,13 @@
</uninstall>
</bean>
+ <bean name="RenderURLTestCase" class="org.jboss.portal.test.web.endpoint.RenderURLTestCase">
+ <install bean="TestSuite" method="mount">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="TestSuite" method="unmount">
+ <parameter><this/></parameter>
+ </uninstall>
+ </bean>
+
</deployment>
18 years
JBoss Portal SVN: r10525 - in modules/web/trunk/web/src: test and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-10 16:35:44 -0400 (Thu, 10 Apr 2008)
New Revision: 10525
Added:
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/WebPathTestCase.java
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java
modules/web/trunk/web/src/test/build.xml
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java
modules/web/trunk/web/src/test/resources/config/log4j.properties
modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml
Log:
added test case for webContextPath and webRequestPath
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java 2008-04-10 16:40:49 UTC (rev 10524)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java 2008-04-10 20:35:44 UTC (rev 10525)
@@ -159,6 +159,10 @@
case PATH_MAPPING:
webRequestPath = requestURI.substring(contextPath.length() + servletPath.length());
webContextPath = requestURI.substring(0, contextPath.length() + servletPath.length());
+ if (webRequestPath.length() == 0)
+ {
+ webRequestPath = "/";
+ }
break;
}
Modified: modules/web/trunk/web/src/test/build.xml
===================================================================
--- modules/web/trunk/web/src/test/build.xml 2008-04-10 16:40:49 UTC (rev 10524)
+++ modules/web/trunk/web/src/test/build.xml 2008-04-10 20:35:44 UTC (rev 10525)
@@ -513,7 +513,6 @@
<!-- spi tests -->
-<!--
<antcall target="tests.jboss-4.2.spi">
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_0"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_0_HOME}"/>
@@ -526,7 +525,6 @@
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_2"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_2_HOME}"/>
</antcall>
--->
<!-- endpoint tests -->
@@ -573,7 +571,7 @@
<configuration>
<property name="cargo.servlet.port" value="8080"/>
<property name="cargo.logging" value="high"/>
- <!--<property name="cargo.jvmargs" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"/>-->
+ <!--<property name="cargo.jvmargs" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/>-->
<deployable type="war" file="${test.temp.lib}/manager.war"/>
<deployable type="war" file="${cargo.war}"/>
</configuration>
@@ -591,37 +589,6 @@
</cargo>
</target>
-<!--
- <target name="tests.tomcat-6.container-servlet" if="${test.tomcat-6.home.variable-name}">
- <echo message="Starting Tomcat 6 container-servlet tests with ${test.tomcat-6.home}"/>
- <antcall target="cargo.tomcat-6.start">
- <param name="cargo.wait" value="false"/>
- <param name="test.spi.server.path" value="${test.archive.path}"/>
- </antcall>
- <antcall target="tests.remote">
- <param name="test.server.name" value="RemoteTomcat_6_0"/>
- <param name="test.deploy.name" value="tomcat-6.0-container-servlet"/>
- </antcall>
- <antcall target="cargo.tomcat-6.stop">
- </antcall>
- </target>
-
- <target name="tests.tomcat-6.generic" if="${test.tomcat-6.home.variable-name}">
- <fail unless="test.tomcat-6.home" message="Please set the environment variable TOMCAT_6_0_HOME"/>
- <echo message="Starting Tomcat 6 generic tests with ${test.tomcat-6.home}"/>
- <antcall target="cargo.tomcat-6.start">
- <param name="cargo.wait" value="false"/>
- <param name="test.spi.server.path" value="${test.archive.path}"/>
- </antcall>
- <antcall target="tests.remote">
- <param name="test.server.name" value="RemoteTomcat_6_0"/>
- <param name="test.deploy.name" value="tomcat-6.0-generic"/>
- </antcall>
- <antcall target="cargo.tomcat-6.stop">
- </antcall>
- </target>
--->
-
<target name="tests.tomcat-6.0.execute" unless="tests.tomcat-6.0.execute.skip">
<echo message="Starting Tomcat 6.0 ${test.tomcat-6.0.name} with ${test.tomcat-6.0.home} to execute ${test.id} tests"/>
<antcall target="cargo.tomcat-6.0.start">
@@ -666,13 +633,13 @@
<param name="test.archive.path" value=""/>
</antcall>
<antcall target="tests.tomcat-6.0.execute">
- <param name="test.id" value="${test.tomcat-6.0.name}-endpoint-path-mapping"/>
- <param name="test.war" value="${test.temp.lib}/tomcat-6.0/path-mapping.war"/>
+ <param name="test.id" value="${test.tomcat-6.0.name}-endpoint-root-path-mapping"/>
+ <param name="test.war" value="${test.temp.lib}/tomcat-6.0/root-path-mapping.war"/>
<param name="test.archive.path" value=""/>
</antcall>
<antcall target="tests.tomcat-6.0.execute">
- <param name="test.id" value="${test.tomcat-6.0.name}-endpoint-root-path-mapping"/>
- <param name="test.war" value="${test.temp.lib}/tomcat-6.0/root-path-mapping.war"/>
+ <param name="test.id" value="${test.tomcat-6.0.name}-endpoint-path-mapping"/>
+ <param name="test.war" value="${test.temp.lib}/tomcat-6.0/path-mapping.war"/>
<param name="test.archive.path" value=""/>
</antcall>
</target>
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
@@ -32,16 +32,30 @@
public abstract class EndPointTestCase extends ServletTestCase
{
- public String getURIPrefix(EndPointServlet endPointServlet)
+ public String rewriteURL(EndPointServlet endPointServlet, String url)
{
switch (endPointServlet.getMappingStyle())
{
case EndPointServlet.DEFAULT_SERVLET_MAPPING:
- return "/default-servlet-mapping/";
+ if (url.startsWith("/"))
+ {
+ return "/default-servlet-mapping" + url;
+ }
+ else
+ {
+ return "/default-servlet-mapping/" + url;
+ }
case EndPointServlet.ROOT_PATH_MAPPING:
- return "/root-path-mapping/";
+ if (url.startsWith("/"))
+ {
+ return "/root-path-mapping" + url;
+ }
+ else
+ {
+ return "/root-path-mapping/" + url;
+ }
case EndPointServlet.PATH_MAPPING:
- return "/path-mapping/foo";
+ return "/path-mapping/foo" + url;
default:
throw new AssertionError();
}
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
@@ -63,7 +63,7 @@
assertTrue(queryParameters.isEmpty());
//
- StringBuffer tmp = new StringBuffer(getURIPrefix(testServlet));
+ StringBuffer tmp = new StringBuffer(rewriteURL(testServlet, "/"));
tmp.append('?').append(encoder.encode("a")).append("=").append(encoder.encode("a_value"));
tmp.append('&').append(encoder.encode("b")).append("=").append(encoder.encode("b_value_1"));
tmp.append('&').append(encoder.encode("b")).append("=").append(encoder.encode("b_value_2"));
@@ -99,7 +99,7 @@
{
if (getRequestCount() == -1)
{
- return new InvokeGetResponse(getURIPrefix(testServlet));
+ return new InvokeGetResponse(rewriteURL(testServlet, "/"));
}
else
{
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
@@ -67,7 +67,7 @@
assertTrue(formParameters.isEmpty());
//
- InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet) + "?a=a_value_query");
+ InvokePostResponse post = new InvokePostResponse(rewriteURL(testServlet, "?a=a_value_query"));
post.setBody(new HttpRequest.Form());
post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
return post;
@@ -82,7 +82,7 @@
assertTrue(formParameters.isEmpty());
//
- InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet));
+ InvokePostResponse post = new InvokePostResponse(rewriteURL(testServlet, "/"));
HttpRequest.Form requestForm = new HttpRequest.Form();
requestForm.addParameter("a", new String[]{"a_value_body"});
post.setBody(requestForm);
@@ -99,7 +99,7 @@
assertEquals(new String[]{"a_value_body"}, formParameters.get("a"));
//
- InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet) + "?a=a_value_query");
+ InvokePostResponse post = new InvokePostResponse(rewriteURL(testServlet, "?a=a_value_query"));
post.setBody(new HttpRequest.Form());
HttpRequest.Form requestForm = new HttpRequest.Form();
requestForm.addParameter("a", new String[]{"a_value_form"});
@@ -118,7 +118,7 @@
assertEquals(new String[]{"a_value_form"}, formParameters.get("a"));
//
- InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet) + "?a=" + encoder.encode(RANGE_0_255));
+ InvokePostResponse post = new InvokePostResponse(rewriteURL(testServlet, "?a=" + encoder.encode(RANGE_0_255)));
post.setBody(new HttpRequest.Form());
HttpRequest.Form requestForm = new HttpRequest.Form();
requestForm.addParameter("a", new String[]{RANGE_256_512});
@@ -137,7 +137,7 @@
assertNull(compareString(RANGE_256_512, formParameters.get("a")[0]));
//
- InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet) + "?a=" + encoder.encode(RANGE_256_512));
+ InvokePostResponse post = new InvokePostResponse(rewriteURL(testServlet, "?a=" + encoder.encode(RANGE_256_512)));
post.setBody(new HttpRequest.Form());
HttpRequest.Form requestForm = new HttpRequest.Form();
requestForm.addParameter("a", new String[]{RANGE_0_255});
@@ -168,7 +168,7 @@
{
if (getRequestCount() == -1)
{
- InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet));
+ InvokePostResponse post = new InvokePostResponse(rewriteURL(testServlet, "/"));
post.setBody(new HttpRequest.Form());
post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
return post;
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
@@ -83,7 +83,7 @@
{
if (getRequestCount() == -1)
{
- InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet));
+ InvokePostResponse post = new InvokePostResponse(rewriteURL(testServlet, "/"));
HttpRequest.Raw raw = new HttpRequest.Raw();
post.setBody(raw);
raw.setBytes(new byte[]{0,1,1,2,3,5,8,13,21,34});
Added: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/WebPathTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/WebPathTestCase.java (rev 0)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/WebPathTestCase.java 2008-04-10 20:35:44 UTC (rev 10525)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.endpoint;
+
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import org.jboss.unit.Failure;
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.portal.test.web.TestServlet;
+import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.web.WebResponse;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class WebPathTestCase extends EndPointTestCase
+{
+
+ public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse resp) throws ServletException, IOException
+ {
+ String requestURI = req.getContextPath() + req.getServletPath() + (req.getPathInfo() != null ? req.getPathInfo() : "");
+ String webURI = req.getWebContextPath() + req.getWebRequestPath();
+ assertTrue("At interaction " + getRequestCount() + " expected " + requestURI + " to be a prefix of " + webURI, webURI.startsWith(requestURI));
+
+ //
+ if (getRequestCount() == 0)
+ {
+ assertEquals("/", req.getWebRequestPath());
+ return new InvokeGetResponse(rewriteURL(testServlet, "/"));
+ }
+ else if (getRequestCount() == 1)
+ {
+ assertEquals("/", req.getWebRequestPath());
+ return new InvokeGetResponse(rewriteURL(testServlet, "/bar"));
+ }
+ else if (getRequestCount() == 2)
+ {
+ assertEquals("/bar", req.getWebRequestPath());
+ return new EndTestResponse();
+ }
+
+ //
+ return new FailureResponse(Failure.createAssertionFailure(""));
+ }
+
+ public DriverResponse invoke(TestServlet testServlet, DriverCommand driverCommand)
+ {
+ if (getRequestCount() == -1)
+ {
+ return new InvokeGetResponse(rewriteURL(testServlet, ""));
+ }
+ else
+ {
+ return new FailureResponse(Failure.createAssertionFailure(""));
+ }
+ }
+}
Modified: modules/web/trunk/web/src/test/resources/config/log4j.properties
===================================================================
--- modules/web/trunk/web/src/test/resources/config/log4j.properties 2008-04-10 16:40:49 UTC (rev 10524)
+++ modules/web/trunk/web/src/test/resources/config/log4j.properties 2008-04-10 20:35:44 UTC (rev 10525)
@@ -7,7 +7,7 @@
log4j.rootCategory=ALL, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=DEBUG
+log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
Modified: modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml 2008-04-10 16:40:49 UTC (rev 10524)
+++ modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml 2008-04-10 20:35:44 UTC (rev 10525)
@@ -84,4 +84,13 @@
</uninstall>
</bean>
+ <bean name="WebPathTestCase" class="org.jboss.portal.test.web.endpoint.WebPathTestCase">
+ <install bean="TestSuite" method="mount">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="TestSuite" method="unmount">
+ <parameter><this/></parameter>
+ </uninstall>
+ </bean>
+
</deployment>
18 years
JBoss Portal SVN: r10524 - in modules/web/trunk/web/src: main/java/org/jboss/portal/web/endpoint and 22 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-10 12:40:49 -0400 (Thu, 10 Apr 2008)
New Revision: 10524
Added:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointRequest.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointResponse.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebRequest.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebResponse.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java
modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/jboss-web.xml
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/web.xml
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/jboss-web.xml
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/web.xml
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/jboss-web.xml
modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/web.xml
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/default-servlet-mapping-war/
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/default-servlet-mapping-war/WEB-INF/
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/default-servlet-mapping-war/WEB-INF/web.xml
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/path-mapping-war/
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/path-mapping-war/WEB-INF/
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/path-mapping-war/WEB-INF/web.xml
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/root-path-mapping-war/
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/root-path-mapping-war/WEB-INF/
modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/root-path-mapping-war/WEB-INF/web.xml
Removed:
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/
modules/web/trunk/web/src/test/resources/portal-test-request-jar/
Modified:
modules/web/trunk/web/src/main/java/org/jboss/portal/web/Body.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRequest.java
modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebResponse.java
modules/web/trunk/web/src/test/build.xml
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/ServletTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/TestServlet.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/spi/SPITestCase.java
modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml
Log:
start to add notion of endpoint in web module and improved much the build.xml file
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/Body.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/Body.java 2008-04-10 14:24:38 UTC (rev 10523)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/Body.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -57,7 +57,7 @@
/** . */
private final ParameterMap parameters;
- Form(String characterEncoding, ParameterMap parameters)
+ public Form(String characterEncoding, ParameterMap parameters)
{
super(characterEncoding);
@@ -86,7 +86,7 @@
/** . */
private boolean consumed;
- Raw(String characterEncoding, HttpServletRequest request)
+ public Raw(String characterEncoding, HttpServletRequest request)
{
super(characterEncoding);
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRequest.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRequest.java 2008-04-10 14:24:38 UTC (rev 10523)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebRequest.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -22,14 +22,11 @@
******************************************************************************/
package org.jboss.portal.web;
-import org.jboss.portal.common.http.QueryStringParser;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.net.media.MediaType;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import java.util.Map;
import java.nio.charset.Charset;
-import java.io.UnsupportedEncodingException;
/**
* Add useful information about an <code>HttpServletRequest</code>.
@@ -37,7 +34,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class WebRequest extends HttpServletRequestWrapper
+public interface WebRequest extends HttpServletRequest
{
public enum Verb
@@ -47,172 +44,23 @@
}
/** . */
- public static final String APPLICATION_X_WWW_FORM_URLENCODED_MEDIA_TYPE = "application/x-www-form-urlencoded";
+ MediaType APPLICATION_X_WWW_FORM_URLENCODED_MEDIA_TYPE = MediaType.APPLICATION_X_WWW_FORM_URLENCODED;
/** . */
- public static final String MULTIPART_FORM_DATA_MEDIA_TYPE = "multipart/form-data";
+ MediaType MULTIPART_FORM_DATA_MEDIA_TYPE = MediaType.MULTIPART_FORM_DATA_MEDIA_TYPE;
/** . */
- public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
+ Charset UTF_8_CHARSET = Charset.forName("UTF-8");
- /** . */
- private final ParameterMap queryParameterMap;
+ Verb getVerb();
- /** . */
- private final Body body;
+ ParameterMap getQueryParameterMap();
- /** . */
- private final Verb verb;
+ Body getBody();
- /** . */
- private final String mediaType;
+ MediaType getMediaType();
- public WebRequest(HttpServletRequest req) throws UnsupportedEncodingException, IllegalRequestException
- {
- super(req);
+ String getWebRequestPath();
- //
- Verb verb;
- if ("GET".equals(req.getMethod()))
- {
- verb = Verb.GET;
- }
- else if ("POST".equals(req.getMethod()))
- {
- verb = Verb.POST;
- }
- else
- {
- throw new IllegalRequestException("HTTP Method " + req.getMethod() + " not accepted");
- }
-
- // Compute the media type in the content type
- String mediaType = retrieveMediaType(req.getContentType());
-
- // Parse the query string to have the get parameters
- // The resulting map has its parameters decoded from the x-www-form-url encoding
- ParameterMap queryParameterMap;
- String queryString = req.getQueryString();
- if (queryString != null)
- {
- queryParameterMap = QueryStringParser.getInstance().parseQueryString(queryString);
- }
- else
- {
- queryParameterMap = new ParameterMap();
- }
-
- // Only affect the charset encoding if the servlet container will decode the request
- Body body = null;
- if (verb == Verb.POST)
- {
- if (APPLICATION_X_WWW_FORM_URLENCODED_MEDIA_TYPE.equals(mediaType))
- {
- // Now we must ensure that we have either an equals or a trailing space after the media-type
- String characterEncoding = req.getCharacterEncoding();
- if (characterEncoding == null)
- {
- // Set out charset for the request
- req.setCharacterEncoding(UTF_8_CHARSET.name());
- }
- else
- {
- Charset charset = Charset.forName(characterEncoding);
- if (!UTF_8_CHARSET.equals(charset))
- {
- throw new IllegalRequestException("Charset " + characterEncoding + " not accepted, it should be UTF8");
- }
- }
-
- //
- ParameterMap bodyParameterMap = new ParameterMap();
- for (Map.Entry<String, String[]> entry : ((Map<String, String[]>)req.getParameterMap()).entrySet())
- {
- // Get param name
- String paramName = entry.getKey();
-
- // Values that are aggregated from the query string and the body
- String[] paramValues = entry.getValue();
-
- // Values decoded from the query string
- String[] queryValues = queryParameterMap.get(paramName);
- if (queryValues != null)
- {
- int bodyValuesLength = paramValues.length - queryValues.length;
- if (bodyValuesLength > 0)
- {
- String[] bodyValues = new String[bodyValuesLength];
- System.arraycopy(paramValues, queryValues.length, bodyValues, 0, bodyValuesLength);
- bodyParameterMap.put(paramName, bodyValues);
- }
- }
- else
- {
- bodyParameterMap.put(paramName, paramValues);
- }
- }
-
- //
- body = new Body.Form(req.getCharacterEncoding(), bodyParameterMap);
- }
- else
- {
- body = new Body.Raw(req.getCharacterEncoding(), req);
- }
- }
-
- //
- this.verb = verb;
- this.queryParameterMap = new ParameterMap(queryParameterMap);
- this.body = body;
- this.mediaType = mediaType;
- }
-
- public Verb getVerb()
- {
- return verb;
- }
-
- public Charset getCharset()
- {
- return UTF_8_CHARSET;
- }
-
- public ParameterMap getQueryParameterMap()
- {
- return queryParameterMap;
- }
-
- public Body getBody()
- {
- return body;
- }
-
- public String getMediaType()
- {
- return mediaType;
- }
-
- private String retrieveMediaType(String contentType)
- {
- String mediaType = contentType;
-
- //
- if (mediaType != null)
- {
- // Remove any parameters
- int index = mediaType.indexOf(';');
- if (index != -1)
- {
- mediaType = contentType.substring(0, index);
- }
-
- // Trim
- mediaType = mediaType.trim();
-
- // Media type matching is case insensitive, so we convert to lower case
- mediaType = mediaType.toLowerCase();
- }
- return mediaType;
- }
+ String getWebContextPath();
}
Modified: modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebResponse.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebResponse.java 2008-04-10 14:24:38 UTC (rev 10523)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/WebResponse.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -22,8 +22,12 @@
******************************************************************************/
package org.jboss.portal.web;
-import javax.servlet.http.HttpServletResponseWrapper;
+import org.jboss.portal.common.servlet.URLFormat;
+
import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+import java.io.Writer;
+import java.io.IOException;
/**
* todo
@@ -31,10 +35,36 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class WebResponse extends HttpServletResponseWrapper
+public interface WebResponse extends HttpServletResponse
{
- public WebResponse(HttpServletResponse resp)
- {
- super(resp);
- }
+
+ /**
+ * Renders an URL and returns the rendered string.
+ *
+ * The path argument is mandatory and must begin with '/' char. The parameters argument is optional and the
+ * wantedURLFormat is also optional.
+ *
+ * @param path the path relative to the web context
+ * @param parameters the optional parameter map
+ * @param wantedURLFormat the url format needed
+ * @return the rendered URL
+ * @throws IllegalArgumentException if the path value is not correct
+ */
+ String renderURL(String path, Map<String, String[]> parameters, URLFormat wantedURLFormat) throws IllegalArgumentException;
+
+ /**
+ * Renders an URL in the provided writer.
+ *
+ * The path argument is mandatory and must begin with '/' char. The parameters argument is optional and the
+ * wantedURLFormat is also optional.
+ *
+ * @param writer the writer
+ * @param path the path relative to the web context
+ * @param parameters the optional parameter map
+ * @param wantedURLFormat the url format needed
+ * @throws IllegalArgumentException if the path value is not correct or the write is null
+ * @throws IOException any IOException thrown by the writer
+ */
+ void renderURL(Writer writer, String path, Map<String, String[]> parameters, URLFormat wantedURLFormat) throws IllegalArgumentException, IOException;
+
}
Added: modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointRequest.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointRequest.java (rev 0)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointRequest.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.endpoint;
+
+import org.jboss.portal.web.impl.AbstractWebRequest;
+import org.jboss.portal.web.IllegalRequestException;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EndPointRequest extends AbstractWebRequest
+{
+
+ /** . */
+ private final String webRequestPath;
+
+ /** . */
+ private final String webContextPath;
+
+ public EndPointRequest(HttpServletRequest req, String webRequestPath, String webContextPath)
+ throws UnsupportedEncodingException, IllegalRequestException
+ {
+ super(req);
+
+ //
+ this.webRequestPath = webRequestPath;
+ this.webContextPath = webContextPath;
+ }
+
+ public String getWebRequestPath()
+ {
+ return webRequestPath;
+ }
+
+ public String getWebContextPath()
+ {
+ return webContextPath;
+ }
+}
Added: modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointResponse.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointResponse.java (rev 0)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointResponse.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,179 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.endpoint;
+
+import org.jboss.portal.web.impl.AbstractWebResponse;
+import org.jboss.portal.common.servlet.URLFormat;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * Todo: find a way to manage the different servlet that take care of security/authenticated as today it is hardcoded.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EndPointResponse extends AbstractWebResponse
+{
+
+ /** The fast url encoder. */
+ private static final FastURLEncoder urlEncoder = FastURLEncoder.getUTF8Instance();
+
+ /** . */
+ private final String requestRelativePrefix;
+
+ /** . */
+ private final String requestPrefix;
+
+ public EndPointResponse(HttpServletRequest req, HttpServletResponse resp)
+ {
+ super(resp);
+
+ //
+ StringBuffer requestRelativePrefix = new StringBuffer();
+ requestRelativePrefix.append(req.getScheme()).append("://").append(req.getServerName());
+ if (req.isSecure())
+ {
+ if (req.getServerPort() != 443)
+ {
+ requestRelativePrefix.append(":").append(Integer.toString(req.getServerPort()));
+ }
+ }
+ else if (req.getServerPort() != 80)
+ {
+ requestRelativePrefix.append(":").append(Integer.toString(req.getServerPort()));
+ }
+ requestRelativePrefix.append(req.getContextPath());
+
+ //
+ this.requestRelativePrefix = requestRelativePrefix.toString();
+ this.requestPrefix = req.getContextPath();
+ }
+
+ public String renderURL(String path, Map<String, String[]> parameters, URLFormat wantedURLFormat) throws IllegalArgumentException
+ {
+ Buffer buffer = new Buffer(wantedURLFormat);
+
+ //
+ return buffer.toString(path, parameters);
+ }
+
+ public class Buffer extends CharBuffer
+ {
+
+ /** . */
+ private final URLFormat format;
+
+ /** . */
+ private final int prefixLength;
+
+ /** . */
+ private final String parameterSeparator;
+
+ public Buffer(URLFormat format)
+ {
+ if (!format.getRelative())
+ {
+ append(requestRelativePrefix);
+ }
+ else
+ {
+ append(requestPrefix);
+ }
+
+ // Append the servlet path
+ if (format.getSecure())
+ {
+ if (format.getAuthenticated())
+ {
+ append("/authsec");
+ }
+ else
+ {
+ append("/sec");
+ }
+ }
+ else
+ {
+ if (format.getAuthenticated())
+ {
+ append("/auth");
+ }
+ else
+ {
+ //
+ }
+ }
+
+ // Save the prefix length
+ this.prefixLength = length;
+ this.format = format;
+ this.parameterSeparator = format.getEscapeXML() ? "&" : "&";
+ }
+
+ public String toString(String path, Map<String, String[]> parameters)
+ {
+ // Reset the prefix length
+ this.length = prefixLength;
+
+ // julien : check UTF-8 is ok and should not be dependant on the response charset ????
+ // same for xml escape
+ append(path);
+
+ //
+ boolean first = true;
+ if (parameters != null)
+ {
+ for (Map.Entry parameter: parameters.entrySet())
+ {
+ String name = (String)parameter.getKey();
+ String[] values = (String[])parameter.getValue();
+ for (String value : values)
+ {
+ append(first ? "?" : parameterSeparator);
+ append(name, urlEncoder);
+ append('=');
+ append(value, urlEncoder);
+ first = false;
+ }
+ }
+ }
+
+ // Stringify
+ String s = asString();
+
+ // Let the servlet rewrite the URL if necessary
+ if (format.getServletEncoded())
+ {
+ s = encodeURL(s);
+ }
+
+ //
+ return s;
+ }
+ }
+}
Added: modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java (rev 0)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/endpoint/EndPointServlet.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,184 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.endpoint;
+
+import org.xml.sax.InputSource;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Element;
+import org.jboss.portal.common.xml.XMLTools;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.text.FastURLDecoder;
+import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.web.WebResponse;
+import org.apache.log4j.Logger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import javax.servlet.ServletContext;
+import javax.xml.xpath.XPathFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathConstants;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A web end point.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class EndPointServlet extends HttpServlet
+{
+
+ /** . */
+ private final static Logger log = Logger.getLogger(EndPointServlet.class);
+
+ /** . */
+ private FastURLDecoder decoder = FastURLDecoder.getUTF8Instance();
+
+ /** Describes a default servlet mapping. */
+ public static final int DEFAULT_SERVLET_MAPPING = 0;
+
+ /** Describes a root path mapping. */
+ public static final int ROOT_PATH_MAPPING = 1;
+
+ /** Describes a path mapping. */
+ public static final int PATH_MAPPING = 2;
+
+ /** . */
+ private Integer mappingStyle;
+
+ public void init() throws ServletException
+ {
+ String servletName = getServletConfig().getServletName();
+
+ //
+ ServletContext servletContext = getServletContext();
+
+ // XPath expression for selecting the url pattern for this servlet instance
+ String xpathExpression = "//servlet-mapping[servlet-name='" + servletName + "']/url-pattern";
+ XPath xpath = XPathFactory.newInstance().newXPath();
+
+ //
+ log.debug("Going to look for the configuration of the end point servlet " + servletName);
+
+ // Obtain url pattern values in order to find out how this servlet instance is mapped
+ InputStream in = servletContext.getResourceAsStream("/WEB-INF/web.xml");
+ try
+ {
+ NodeList nodes = (NodeList)xpath.evaluate(xpathExpression, new InputSource(in), XPathConstants.NODESET);
+
+ //
+ for (int i = 0;i < nodes.getLength();i++)
+ {
+ Element urlPatternElt = (Element)nodes.item(i);
+
+ //
+ String urlPattern = XMLTools.asString(urlPatternElt, true);
+
+ //
+ log.debug("Found url pattern " + urlPattern + " for end point servlet " + servletName);
+
+ //
+ if (mappingStyle != null)
+ {
+ throw new ServletException("The same end point servlet " + servletName + " is mapped several times and this is not allowed");
+ }
+
+ //
+ if (urlPattern.equals("/"))
+ {
+ mappingStyle = DEFAULT_SERVLET_MAPPING;
+ }
+ else if (urlPattern.equals("/*"))
+ {
+ mappingStyle = ROOT_PATH_MAPPING;
+ }
+ else if (urlPattern.startsWith("/") && urlPattern.endsWith("/*"))
+ {
+ mappingStyle = PATH_MAPPING;
+ }
+ else
+ {
+ throw new ServletException("The end point servlet " + servletName + " is mapped with a pattern value " + urlPattern);
+ }
+ }
+ }
+ catch (XPathExpressionException e)
+ {
+ throw new ServletException(e);
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ protected final void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ String requestURI = req.getRequestURI();
+ String servletPath = req.getServletPath();
+ String contextPath = req.getContextPath();
+
+ // Determine the request path
+ String webRequestPath = null;
+ String webContextPath = null;
+ switch (mappingStyle)
+ {
+ case DEFAULT_SERVLET_MAPPING:
+ webRequestPath = requestURI.substring(contextPath.length());
+ webContextPath = requestURI.substring(0, contextPath.length());
+ break;
+ case ROOT_PATH_MAPPING:
+ webRequestPath = requestURI.substring(contextPath.length());
+ webContextPath = requestURI.substring(0, contextPath.length());
+ break;
+ case PATH_MAPPING:
+ webRequestPath = requestURI.substring(contextPath.length() + servletPath.length());
+ webContextPath = requestURI.substring(0, contextPath.length() + servletPath.length());
+ break;
+ }
+
+ // Apply the url decoding
+ webRequestPath = decoder.encode(webRequestPath);
+ webContextPath = decoder.encode(webContextPath);
+
+ //
+ service(new EndPointRequest(req, webRequestPath, webContextPath), new EndPointResponse(req, resp));
+ }
+
+ protected abstract void service(WebRequest req, WebResponse resp) throws ServletException, IOException;
+
+ /**
+ * Returns the style of mapping of the endpoint.
+ *
+ * @return the mapping style
+ */
+ public Integer getMappingStyle()
+ {
+ return mappingStyle;
+ }
+}
Added: modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebRequest.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebRequest.java (rev 0)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebRequest.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,195 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl;
+
+import org.jboss.portal.common.http.QueryStringParser;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.net.media.ContentType;
+import org.jboss.portal.common.net.media.MediaType;
+import org.jboss.portal.common.net.media.Parameter;
+import org.jboss.portal.web.Body;
+import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.web.WebRequest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.util.Map;
+import java.nio.charset.Charset;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Add useful information about an <code>HttpServletRequest</code>.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractWebRequest extends HttpServletRequestWrapper implements WebRequest
+{
+
+ /** . */
+ public static final MediaType APPLICATION_X_WWW_FORM_URLENCODED_MEDIA_TYPE = MediaType.APPLICATION_X_WWW_FORM_URLENCODED;
+
+ /** . */
+ public static final MediaType MULTIPART_FORM_DATA_MEDIA_TYPE = MediaType.create("multipart/form-data");
+
+ /** . */
+ public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
+
+ /** . */
+ private final ParameterMap queryParameterMap;
+
+ /** . */
+ private final Body body;
+
+ /** . */
+ private final Verb verb;
+
+ /** . */
+ private final MediaType mediaType;
+
+ public AbstractWebRequest(HttpServletRequest req) throws UnsupportedEncodingException, IllegalRequestException
+ {
+ super(req);
+
+ //
+ Verb verb;
+ if ("GET".equals(req.getMethod()))
+ {
+ verb = Verb.GET;
+ }
+ else if ("POST".equals(req.getMethod()))
+ {
+ verb = Verb.POST;
+ }
+ else
+ {
+ throw new IllegalRequestException("HTTP Method " + req.getMethod() + " not accepted");
+ }
+
+ // Compute the media type in the content type
+ MediaType mediaType = null;
+ if (req.getContentType() != null)
+ {
+ ContentType contentType = ContentType.create(req.getContentType());
+ mediaType = contentType.getMediaType();
+ }
+
+ // Parse the query string to have the get parameters
+ // The resulting map has its parameters decoded from the x-www-form-url encoding
+ ParameterMap queryParameterMap;
+ String queryString = req.getQueryString();
+ if (queryString != null)
+ {
+ queryParameterMap = QueryStringParser.getInstance().parseQueryString(queryString);
+ }
+ else
+ {
+ queryParameterMap = new ParameterMap();
+ }
+
+ // Only affect the charset encoding if the servlet container will decode the request
+ Body body = null;
+ if (verb == Verb.POST)
+ {
+ if (APPLICATION_X_WWW_FORM_URLENCODED_MEDIA_TYPE.equals(mediaType))
+ {
+ // Now we must ensure that we have either an equals or a trailing space after the media-type
+ String characterEncoding = req.getCharacterEncoding();
+ if (characterEncoding == null)
+ {
+ // Set out charset for the request
+ req.setCharacterEncoding(UTF_8_CHARSET.name());
+ }
+ else
+ {
+ Charset charset = Charset.forName(characterEncoding);
+ if (!UTF_8_CHARSET.equals(charset))
+ {
+ throw new IllegalRequestException("Charset " + characterEncoding + " not accepted, it should be UTF8");
+ }
+ }
+
+ //
+ ParameterMap bodyParameterMap = new ParameterMap();
+ for (Map.Entry<String, String[]> entry : ((Map<String, String[]>)req.getParameterMap()).entrySet())
+ {
+ // Get param name
+ String paramName = entry.getKey();
+
+ // Values that are aggregated from the query string and the body
+ String[] paramValues = entry.getValue();
+
+ // Values decoded from the query string
+ String[] queryValues = queryParameterMap.get(paramName);
+ if (queryValues != null)
+ {
+ int bodyValuesLength = paramValues.length - queryValues.length;
+ if (bodyValuesLength > 0)
+ {
+ String[] bodyValues = new String[bodyValuesLength];
+ System.arraycopy(paramValues, queryValues.length, bodyValues, 0, bodyValuesLength);
+ bodyParameterMap.put(paramName, bodyValues);
+ }
+ }
+ else
+ {
+ bodyParameterMap.put(paramName, paramValues);
+ }
+ }
+
+ //
+ body = new Body.Form(req.getCharacterEncoding(), bodyParameterMap);
+ }
+ else
+ {
+ body = new Body.Raw(req.getCharacterEncoding(), req);
+ }
+ }
+
+ //
+ this.verb = verb;
+ this.queryParameterMap = new ParameterMap(queryParameterMap);
+ this.body = body;
+ this.mediaType = mediaType;
+ }
+
+ public Verb getVerb()
+ {
+ return verb;
+ }
+
+ public ParameterMap getQueryParameterMap()
+ {
+ return queryParameterMap;
+ }
+
+ public Body getBody()
+ {
+ return body;
+ }
+
+ public MediaType getMediaType()
+ {
+ return mediaType;
+ }
+}
\ No newline at end of file
Added: modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebResponse.java
===================================================================
--- modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebResponse.java (rev 0)
+++ modules/web/trunk/web/src/main/java/org/jboss/portal/web/impl/AbstractWebResponse.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.web.impl;
+
+import org.jboss.portal.web.WebResponse;
+import org.jboss.portal.common.servlet.URLFormat;
+
+import javax.servlet.http.HttpServletResponseWrapper;
+import javax.servlet.http.HttpServletResponse;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * todo
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractWebResponse extends HttpServletResponseWrapper implements WebResponse
+{
+ public AbstractWebResponse(HttpServletResponse resp)
+ {
+ super(resp);
+ }
+
+ /**
+ * The implementation renders the URL by delegating to the {@link AbstractWebResponse#renderURL(String, java.util.Map, org.jboss.portal.common.servlet.URLFormat)}
+ * methods and then prints it in the specified writer. The method can be overriden in order to provide a customized implementation.
+ */
+ public void renderURL(Writer writer, String path, Map<String, String[]> parameters, URLFormat wantedURLFormat) throws IllegalArgumentException, IOException
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("No null writer accepted");
+ }
+
+ //
+ String value = renderURL(path, parameters, wantedURLFormat);
+
+ //
+ writer.write(value);
+ }
+}
\ No newline at end of file
Modified: modules/web/trunk/web/src/test/build.xml
===================================================================
--- modules/web/trunk/web/src/test/build.xml 2008-04-10 14:24:38 UTC (rev 10523)
+++ modules/web/trunk/web/src/test/build.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -8,16 +8,15 @@
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
+ <!-- -->
+ <delete dir="${test.temp.dir}"/>
<antcall target="package-tests"/>
-
+ <!-- -->
<antcall target="tests.local"/>
<antcall target="tests.call.single"/>
<antcall target="tests.call.all"/>
- <!--Cleanup-->
- <delete dir="${test.temp.dir}"/>
-
</target>
<target name="tests.call.all" unless="tests">
@@ -34,7 +33,7 @@
<antcall target="tests.jboss-4.2"/>
</target>
<target name="tests.tomcat">
- <antcall target="tests.tomcat-6"/>
+ <antcall target="tests.tomcat-6.0"/>
</target>
<target name="prepare_env">
@@ -157,13 +156,6 @@
</path>
<path id="mc.jboss_aop">
<pathelement path="${dependency.jboss-aop.jar}"/>
- <!--<pathelement path="${dependency.jboss-aop-as4-deployer.jar}"/>-->
- <!--<pathelement path="${dependency.jboss-aop-deployer-jdk50.jar}"/>-->
- <!--<pathelement path="${dependency.jboss-aop-jdk50.jar}"/>-->
- <!--<pathelement path="${dependency.jboss-aop-jdk50-client.jar}"/>-->
- <!--<pathelement path="${dependency.jboss-standalone-aspect-library-jdk50.jar}"/>-->
- <!--<pathelement path="${dependency.jrockit-pluggable-instrumentor.jar}"/>-->
- <!--<pathelement path="${dependency.pluggable-instrumentor.jar}"/>-->
</path>
<path id="mc.jboss_microcontainer">
<pathelement path="${dependency.jboss-aop-mc-int.jar}"/>
@@ -205,33 +197,19 @@
<pathelement path="${dependency.log4j.jar}"/>
</path>
- <!-- **************************** -->
- <!-- Tomcat 6.0 container servlet -->
- <!-- **************************** -->
-
- <copy todir="${test.support}/tomcat-6.0-container-servlet/server-war/WEB-INF/lib" flatten="true">
+ <path id="jboss-4.2">
<path refid="mc.portal-common"/>
- <path refid="mc.jboss-unit"/>
- <path refid="mc.jboss-remoting"/>
- <path refid="mc.log4j"/>
- <path refid="mc.concurrent"/>
+ <path refid="mc.portal-test-generic"/>
<path refid="mc.trove"/>
- <path refid="mc.xerces"/>
<path refid="mc.javassist"/>
<path refid="mc.jboss_common_core"/>
<path refid="mc.jboss_vfs"/>
<path refid="mc.jboss_xb"/>
<path refid="mc.jboss_aop"/>
<path refid="mc.jboss_microcontainer"/>
- </copy>
- <mkdir dir="${test.temp.lib}/tomcat-6.0-container-servlet"/>
+ </path>
- <!-- **************************** -->
- <!-- Tomcat 6.0 lifecyle listener -->
- <!-- **************************** -->
-
-
- <copy todir="${test.support}/tomcat-6.0-lifecycle-listener/server-war/WEB-INF/lib" flatten="true">
+ <path id="tomcat-6.0">
<path refid="mc.portal-common"/>
<path refid="mc.jboss-unit"/>
<path refid="mc.jboss-remoting"/>
@@ -245,70 +223,11 @@
<path refid="mc.jboss_xb"/>
<path refid="mc.jboss_aop"/>
<path refid="mc.jboss_microcontainer"/>
- </copy>
- <mkdir dir="${test.temp.lib}/tomcat-6.0-lifecycle-listener"/>
+ </path>
- <!-- ****************** -->
- <!-- Tomcat 6.0 generic -->
- <!-- ****************** -->
-
- <!-- -->
- <mkdir dir="${test.support}/tomcat-6.0-generic/server-war/WEB-INF/lib"/>
- <copy todir="${test.support}/tomcat-6.0-generic/server-war/WEB-INF/lib" flatten="true">
- <path refid="mc.portal-common"/>
- <path refid="mc.jboss-unit"/>
- <path refid="mc.jboss-remoting"/>
- <path refid="mc.log4j"/>
- <path refid="mc.concurrent"/>
- <path refid="mc.trove"/>
- <path refid="mc.xerces"/>
- <path refid="mc.javassist"/>
- <path refid="mc.jboss_common_core"/>
- <path refid="mc.jboss_vfs"/>
- <path refid="mc.jboss_xb"/>
- <path refid="mc.jboss_aop"/>
- <path refid="mc.jboss_microcontainer"/>
- </copy>
- <mkdir dir="${test.temp.lib}/tomcat-6.0-generic"/>
-
- <!-- *************************** -->
- <!-- JBoss 4.2 container servlet -->
- <!-- *************************** -->
-
- <!-- -->
- <copy todir="${test.support}/jboss-4.2-container-servlet/server-war/WEB-INF/lib" flatten="true">
- <path refid="mc.portal-common"/>
- <path refid="mc.portal-test-generic"/>
- <path refid="mc.trove"/>
- <path refid="mc.javassist"/>
- <path refid="mc.jboss_common_core"/>
- <path refid="mc.jboss_vfs"/>
- <path refid="mc.jboss_xb"/>
- <path refid="mc.jboss_aop"/>
- <path refid="mc.jboss_microcontainer"/>
- </copy>
- <mkdir dir="${test.temp.lib}/jboss-4.2-container-servlet"/>
-
- <!-- ***************** -->
- <!-- JBoss 4.2 generic -->
- <!-- ***************** -->
-
- <!-- -->
- <copy todir="${test.support}/jboss-4.2-generic/server-war/WEB-INF/lib" flatten="true">
- <path refid="mc.portal-common"/>
- <path refid="mc.portal-test-generic"/>
- <path refid="mc.trove"/>
- <path refid="mc.javassist"/>
- <path refid="mc.jboss_common_core"/>
- <path refid="mc.jboss_vfs"/>
- <path refid="mc.jboss_xb"/>
- <path refid="mc.jboss_aop"/>
- <path refid="mc.jboss_microcontainer"/>
- </copy>
- <mkdir dir="${test.temp.lib}/jboss-4.2-generic"/>
-
<!-- SPI Test case-->
+ <mkdir dir="${test.temp.lib}"/>
<jar jarfile="${test.temp.lib}/portal-test-spi-lib.jar">
<fileset dir="${target}/test-classes/">
<include name="org/jboss/portal/test/web/spi/**"/>
@@ -319,6 +238,14 @@
<fileset dir="${target}/test-classes//portal-test-spi-jar"/>
</jar>
+ <!-- **************************** -->
+ <!-- Tomcat 6.0 container servlet -->
+ <!-- **************************** -->
+
+ <copy todir="${test.support}/tomcat-6.0-container-servlet/server-war/WEB-INF/lib" flatten="true">
+ <path refid="tomcat-6.0"/>
+ </copy>
+ <mkdir dir="${test.temp.lib}/tomcat-6.0-container-servlet"/>
<war jarfile="${test.temp.lib}/tomcat-6.0-container-servlet/test-spi-server.war">
<fileset dir="${test.support}/tomcat-6.0-container-servlet/server-war"/>
<lib dir="${test.temp.lib}" includes="portal-test-spi-lib.jar"/>
@@ -326,13 +253,33 @@
<jar jarfile="${test.temp.lib}/tomcat-6.0-container-servlet/test-spi-app.war">
<fileset dir="${target}/test-classes/spi/app-war"/>
</jar>
+
+ <!-- **************************** -->
+ <!-- Tomcat 6.0 lifecyle listener -->
+ <!-- **************************** -->
+
+ <copy todir="${test.support}/tomcat-6.0-lifecycle-listener/server-war/WEB-INF/lib" flatten="true">
+ <path refid="tomcat-6.0"/>
+ </copy>
+ <mkdir dir="${test.temp.lib}/tomcat-6.0-lifecycle-listener"/>
<war jarfile="${test.temp.lib}/tomcat-6.0-lifecycle-listener/test-spi-server.war">
<fileset dir="${test.support}/tomcat-6.0-lifecycle-listener/server-war"/>
<lib dir="${test.temp.lib}" includes="portal-test-spi-lib.jar"/>
</war>
- <jar jarfile="${test.temp.lib}/tomcat-6.0-container-servlet/test-spi-app.war">
+ <jar jarfile="${test.temp.lib}/tomcat-6.0-lifecycle-listener/test-spi-app.war">
<fileset dir="${target}/test-classes/spi/app-war"/>
</jar>
+
+ <!-- ****************** -->
+ <!-- Tomcat 6.0 generic -->
+ <!-- ****************** -->
+
+ <!-- -->
+ <mkdir dir="${test.support}/tomcat-6.0-generic/server-war/WEB-INF/lib"/>
+ <copy todir="${test.support}/tomcat-6.0-generic/server-war/WEB-INF/lib" flatten="true">
+ <path refid="tomcat-6.0"/>
+ </copy>
+ <mkdir dir="${test.temp.lib}/tomcat-6.0-generic"/>
<war jarfile="${test.temp.lib}/tomcat-6.0-generic/test-spi-server.war">
<fileset dir="${test.support}/tomcat-6.0-generic/server-war"/>
<lib dir="${test.temp.lib}" includes="portal-test-spi-lib.jar"/>
@@ -340,6 +287,16 @@
<jar jarfile="${test.temp.lib}/tomcat-6.0-generic/test-spi-app.war">
<fileset dir="${target}/test-classes/spi/generic/app-war"/>
</jar>
+
+ <!-- *************************** -->
+ <!-- JBoss 4.2 container servlet -->
+ <!-- *************************** -->
+
+ <!-- -->
+ <copy todir="${test.support}/jboss-4.2-container-servlet/server-war/WEB-INF/lib" flatten="true">
+ <path refid="jboss-4.2"/>
+ </copy>
+ <mkdir dir="${test.temp.lib}/jboss-4.2-container-servlet"/>
<war jarfile="${test.temp.lib}/jboss-4.2-container-servlet/test-spi-server.war">
<fileset dir="${test.support}/jboss-4.2-container-servlet/server-war"/>
<lib dir="${test.temp.lib}" includes="portal-test-spi-lib.jar"/>
@@ -347,6 +304,16 @@
<jar jarfile="${test.temp.lib}/jboss-4.2-container-servlet/test-spi-app.war">
<fileset dir="${target}/test-classes/spi/app-war"/>
</jar>
+
+ <!-- ***************** -->
+ <!-- JBoss 4.2 generic -->
+ <!-- ***************** -->
+
+ <!-- -->
+ <copy todir="${test.support}/jboss-4.2-generic/server-war/WEB-INF/lib" flatten="true">
+ <path refid="jboss-4.2"/>
+ </copy>
+ <mkdir dir="${test.temp.lib}/jboss-4.2-generic"/>
<war jarfile="${test.temp.lib}/jboss-4.2-generic/test-spi-server.war">
<fileset dir="${test.support}/jboss-4.2-generic/server-war"/>
<lib dir="${test.temp.lib}" includes="portal-test-spi-lib.jar"/>
@@ -355,29 +322,78 @@
<fileset dir="${target}/test-classes/spi/generic/app-war"/>
</jar>
- <!--Request Test case-->
+ <!--endpoint test case-->
- <jar jarfile="${test.temp.lib}/portal-test-request-lib.jar">
+ <jar jarfile="${test.temp.lib}/portal-test-endpoint-lib.jar">
<fileset dir="${target}/test-classes/">
- <include name="org/jboss/portal/test/web/request/**"/>
+ <include name="org/jboss/portal/test/web/endpoint/**"/>
<include name="org/jboss/portal/test/web/ServletTestCase.class"/>
<include name="org/jboss/portal/test/web/TestServlet.class"/>
<include name="org/jboss/portal/test/web/WebAppRegistry.class"/>
</fileset>
- <fileset dir="${target}/test-classes/portal-test-request-jar"/>
+ <fileset dir="${target}/test-classes/portal-test-endpoint-jar"/>
</jar>
- <war jarfile="${test.temp.lib}/tomcat-6.0-container-servlet/test-request-server.war">
- <fileset dir="${test.support}/tomcat-6.0-container-servlet/server-war"/>
- <lib dir="${test.temp.lib}" includes="portal-test-request-lib.jar"/>
+ <!-- ********** -->
+ <!-- Tomcat 6.0 -->
+ <!-- ********** -->
+
+ <mkdir dir="${test.temp.lib}/tomcat-6.0"/>
+
+ <copy todir="${test.support}/tomcat-6.0-endpoint/default-servlet-mapping-war/WEB-INF/lib" flatten="true">
+ <path refid="tomcat-6.0"/>
+ </copy>
+ <war jarfile="${test.temp.lib}/tomcat-6.0/default-servlet-mapping.war">
+ <fileset dir="${test.support}/tomcat-6.0-endpoint/default-servlet-mapping-war"/>
+ <lib dir="${test.temp.lib}" includes="portal-test-endpoint-lib.jar"/>
</war>
- <war jarfile="${test.temp.lib}/jboss-4.2-container-servlet/test-request-server.war">
- <fileset dir="${test.support}/jboss-4.2-container-servlet/server-war"/>
- <lib dir="${test.temp.lib}" includes="portal-test-request-lib.jar"/>
+ <copy todir="${test.support}/tomcat-6.0-endpoint/path-mapping-war/WEB-INF/lib" flatten="true">
+ <path refid="tomcat-6.0"/>
+ </copy>
+ <war jarfile="${test.temp.lib}/tomcat-6.0/path-mapping.war">
+ <fileset dir="${test.support}/tomcat-6.0-endpoint/path-mapping-war"/>
+ <lib dir="${test.temp.lib}" includes="portal-test-endpoint-lib.jar"/>
</war>
+ <copy todir="${test.support}/tomcat-6.0-endpoint/root-path-mapping-war/WEB-INF/lib" flatten="true">
+ <path refid="tomcat-6.0"/>
+ </copy>
+ <war jarfile="${test.temp.lib}/tomcat-6.0/root-path-mapping.war">
+ <fileset dir="${test.support}/tomcat-6.0-endpoint/root-path-mapping-war"/>
+ <lib dir="${test.temp.lib}" includes="portal-test-endpoint-lib.jar"/>
+ </war>
+ <!-- ********* -->
+ <!-- JBoss 4.2 -->
+ <!-- ********* -->
+
+ <mkdir dir="${test.temp.lib}/jboss-4.2"/>
+
+ <copy todir="${test.support}/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/lib" flatten="true">
+ <path refid="jboss-4.2"/>
+ </copy>
+ <war jarfile="${test.temp.lib}/jboss-4.2/default-servlet-mapping.war">
+ <fileset dir="${test.support}/jboss-4.2-endpoint/default-servlet-mapping-war"/>
+ <lib dir="${test.temp.lib}" includes="portal-test-endpoint-lib.jar"/>
+ </war>
+
+ <copy todir="${test.support}/jboss-4.2-endpoint/path-mapping-war/WEB-INF/lib" flatten="true">
+ <path refid="jboss-4.2"/>
+ </copy>
+ <war jarfile="${test.temp.lib}/jboss-4.2/path-mapping.war">
+ <fileset dir="${test.support}/jboss-4.2-endpoint/path-mapping-war"/>
+ <lib dir="${test.temp.lib}" includes="portal-test-endpoint-lib.jar"/>
+ </war>
+
+ <copy todir="${test.support}/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/lib" flatten="true">
+ <path refid="jboss-4.2"/>
+ </copy>
+ <war jarfile="${test.temp.lib}/jboss-4.2/root-path-mapping.war">
+ <fileset dir="${test.support}/jboss-4.2-endpoint/root-path-mapping-war"/>
+ <lib dir="${test.temp.lib}" includes="portal-test-endpoint-lib.jar"/>
+ </war>
+
<!--Strip cargo manager war filename-->
<copy file="${dependency.cargo-manager.war}" tofile="${test.temp.lib}/manager.war"/>
@@ -421,7 +437,7 @@
<configuration>
<property name="cargo.servlet.port" value="8080"/>
<property name="cargo.logging" value="high"/>
- <deployable type="war" file="${test.spi.server.path}"/>
+ <deployable type="war" file="${cargo.war}"/>
</configuration>
</cargo>
</target>
@@ -438,108 +454,103 @@
</cargo>
</target>
- <target name="tests.jboss-4.2.container-servlet" if="${test.jboss-4.2.home.variable-name}">
- <echo message="Starting JBoss 4.2 container-servlet tests with ${test.jboss-4.2.home}"/>
+ <target name="tests.jboss-4.2.execute" unless="tests.jboss-4.2.execute.skip">
+ <echo message="Starting JBoss 4.2 ${test.jboss-4.2.name} with ${test.jboss-4.2.home} to execute ${test.id} tests"/>
<antcall target="cargo.jboss-4.2.start">
<param name="cargo.wait" value="false"/>
- <param name="test.spi.server.path" value="${test.archive.path}"/>
+ <param name="cargo.war" value="${test.war}"/>
</antcall>
<antcall target="tests.remote">
- <param name="test.server.name" value="${test.jboss-4.2.name}"/>
- <param name="test.deploy.name" value="jboss-4.2-container-servlet"/>
+ <param name="test.remote.server.name" value="${test.jboss-4.2.name}"/>
+ <param name="test.remote.archive.path" value="${test.archive.path}"/>
</antcall>
<antcall target="cargo.jboss-4.2.stop">
</antcall>
</target>
- <target name="tests.jboss-4.2.generic" if="${test.jboss-4.2.home.variable-name}">
- <echo message="Starting JBoss 4.2 generic tests with ${test.jboss-4.2.home}"/>
- <antcall target="cargo.jboss-4.2.start">
- <param name="cargo.wait" value="false"/>
- <param name="test.spi.server.path" value="${test.archive.path}"/>
+ <target name="tests.jboss-4.2.spi">
+ <condition property="tests.jboss-4.2.execute.skip">
+ <not>
+ <available file="${test.jboss-4.2.home}" type="dir"/>
+ </not>
+ </condition>
+ <antcall target="tests.jboss-4.2.execute">
+ <param name="test.id" value="${test.jboss-4.2.name}-spi-container-servlet"/>
+ <param name="test.war" value="${test.temp.lib}/jboss-4.2-container-servlet/test-spi-server.war"/>
+ <param name="test.archive.path" value="jboss-4.2-container-servlet"/>
</antcall>
- <antcall target="tests.remote">
- <param name="test.server.name" value="${test.jboss-4.2.name}"/>
- <param name="test.deploy.name" value="jboss-4.2-generic"/>
+ <antcall target="tests.jboss-4.2.execute">
+ <param name="test.id" value="${test.jboss-4.2.name}-spi-generic"/>
+ <param name="test.war" value="${test.temp.lib}/jboss-4.2-generic/test-spi-server.war"/>
+ <param name="test.archive.path" value="jboss-4.2-generic"/>
</antcall>
- <antcall target="cargo.jboss-4.2.stop">
- </antcall>
</target>
- <target name="tests.jboss-4.2">
- <antcall target="tests.jboss-4.2.container-servlet">
- <param name="test.id" value="JBoss-4_2_0-spi-container-servlet"/>
- <param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_0"/>
- <param name="test.jboss-4.2.home" value="${JBOSS_4_2_0_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_0_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-container-servlet/test-spi-server.war"/>
+ <target name="tests.jboss-4.2.endpoint">
+ <condition property="tests.jboss-4.2.execute.skip">
+ <not>
+ <available file="${test.jboss-4.2.home}" type="dir"/>
+ </not>
+ </condition>
+ <antcall target="tests.jboss-4.2.execute">
+ <param name="test.id" value="${test.jboss-4.2.name}-endpoint-default-servlet-mapping"/>
+ <param name="test.war" value="${test.temp.lib}/jboss-4.2/default-servlet-mapping.war"/>
+ <param name="test.archive.path" value=""/>
</antcall>
- <antcall target="tests.jboss-4.2.container-servlet">
- <param name="test.id" value="JBoss-4_2_1-spi-container-servlet"/>
- <param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_1"/>
- <param name="test.jboss-4.2.home" value="${JBOSS_4_2_1_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_1_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-container-servlet/test-spi-server.war"/>
+ <antcall target="tests.jboss-4.2.execute">
+ <param name="test.id" value="${test.jboss-4.2.name}-endpoint-path-mapping"/>
+ <param name="test.war" value="${test.temp.lib}/jboss-4.2/path-mapping.war"/>
+ <param name="test.archive.path" value=""/>
</antcall>
- <antcall target="tests.jboss-4.2.container-servlet">
- <param name="test.id" value="JBoss-4_2_2-spi-container-servlet"/>
- <param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_2"/>
- <param name="test.jboss-4.2.home" value="${JBOSS_4_2_2_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_2_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-container-servlet/test-spi-server.war"/>
+ <antcall target="tests.jboss-4.2.execute">
+ <param name="test.id" value="${test.jboss-4.2.name}-endpoint-root-path-mapping"/>
+ <param name="test.war" value="${test.temp.lib}/jboss-4.2/root-path-mapping.war"/>
+ <param name="test.archive.path" value=""/>
</antcall>
- <antcall target="tests.jboss-4.2.generic">
- <param name="test.id" value="JBoss-4_2_0-spi-generic"/>
+ </target>
+
+ <target name="tests.jboss-4.2" if="biltobilto">
+
+ <!-- spi tests -->
+
+<!--
+ <antcall target="tests.jboss-4.2.spi">
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_0"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_0_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_0_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-generic/test-spi-server.war"/>
</antcall>
- <antcall target="tests.jboss-4.2.generic">
- <param name="test.id" value="JBoss-4_2_1-spi-generic"/>
+ <antcall target="tests.jboss-4.2.spi">
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_1"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_1_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_1_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-generic/test-spi-server.war"/>
</antcall>
- <antcall target="tests.jboss-4.2.generic">
- <param name="test.id" value="JBoss-4_2_2-spi-generic"/>
+ <antcall target="tests.jboss-4.2.spi">
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_2"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_2_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_2_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-generic/test-spi-server.war"/>
</antcall>
+-->
- <antcall target="tests.jboss-4.2.container-servlet">
- <param name="test.id" value="JBoss-4_2_0-request-container-servlet"/>
+ <!-- endpoint tests -->
+
+ <antcall target="tests.jboss-4.2.endpoint">
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_0"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_0_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_0_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-container-servlet/test-request-server.war"/>
</antcall>
- <antcall target="tests.jboss-4.2.container-servlet">
- <param name="test.id" value="JBoss-4_2_1-request-container-servlet"/>
+ <antcall target="tests.jboss-4.2.endpoint">
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_1"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_1_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_1_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-container-servlet/test-request-server.war"/>
</antcall>
- <antcall target="tests.jboss-4.2.container-servlet">
- <param name="test.id" value="JBoss-4_2_2-request-container-servlet"/>
+ <antcall target="tests.jboss-4.2.endpoint">
<param name="test.jboss-4.2.name" value="RemoteJBoss_4_2_2"/>
<param name="test.jboss-4.2.home" value="${JBOSS_4_2_2_HOME}"/>
- <param name="test.jboss-4.2.home.variable-name" value="JBOSS_4_2_2_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/jboss-4.2-container-servlet/test-request-server.war"/>
</antcall>
</target>
- <target name="cargo.tomcat-6.start" depends="cargo.setup">
+ <target name="cargo.tomcat-6.0.start" depends="cargo.setup">
<cargo
containerId="tomcat5x"
- home="${test.tomcat-6.home}"
+ home="${test.tomcat-6.0.home}"
output="${cargo.log.dir}/cargo.${test.id}.server.log"
log="${cargo.log.dir}/cargo.${test.id}.start.log"
action="start"
@@ -564,15 +575,15 @@
<property name="cargo.logging" value="high"/>
<!--<property name="cargo.jvmargs" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"/>-->
<deployable type="war" file="${test.temp.lib}/manager.war"/>
- <deployable type="war" file="${test.spi.server.path}"/>
+ <deployable type="war" file="${cargo.war}"/>
</configuration>
</cargo>
</target>
- <target name="cargo.tomcat-6.stop" depends="cargo.setup">
+ <target name="cargo.tomcat-6.0.stop" depends="cargo.setup">
<cargo
containerId="tomcat5x"
- home="${test.tomcat-6.home}"
+ home="${test.tomcat-6.0.home}"
log="${cargo.log.dir}/cargo.${test.id}.shutdown.log"
action="stop">
<configuration>
@@ -580,6 +591,7 @@
</cargo>
</target>
+<!--
<target name="tests.tomcat-6.container-servlet" if="${test.tomcat-6.home.variable-name}">
<echo message="Starting Tomcat 6 container-servlet tests with ${test.tomcat-6.home}"/>
<antcall target="cargo.tomcat-6.start">
@@ -608,33 +620,81 @@
<antcall target="cargo.tomcat-6.stop">
</antcall>
</target>
+-->
- <target name="tests.tomcat-6">
- <antcall target="tests.tomcat-6.container-servlet">
- <param name="test.id" value="Tomcat-6_0-spi-container-servlet"/>
- <param name="test.tomcat-6.name" value="RemoteTomcat_6_0"/>
- <param name="test.tomcat-6.home" value="${TOMCAT_6_0_HOME}"/>
- <param name="test.tomcat-6.home.variable-name" value="TOMCAT_6_0_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/tomcat-6.0-container-servlet/test-spi-server.war"/>
+ <target name="tests.tomcat-6.0.execute" unless="tests.tomcat-6.0.execute.skip">
+ <echo message="Starting Tomcat 6.0 ${test.tomcat-6.0.name} with ${test.tomcat-6.0.home} to execute ${test.id} tests"/>
+ <antcall target="cargo.tomcat-6.0.start">
+ <param name="cargo.wait" value="false"/>
+ <param name="cargo.war" value="${test.war}"/>
</antcall>
- <antcall target="tests.tomcat-6.generic">
- <param name="test.id" value="Tomcat-6_0-spi-generic"/>
- <param name="test.tomcat-6.name" value="RemoteTomcat_6_0"/>
- <param name="test.tomcat-6.home" value="${TOMCAT_6_0_HOME}"/>
- <param name="test.tomcat-6.home.variable-name" value="TOMCAT_6_0_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/tomcat-6.0-generic/test-spi-server.war"/>
+ <antcall target="tests.remote">
+ <param name="test.remote.server.name" value="${test.tomcat-6.0.name}"/>
+ <param name="test.remote.archive.path" value="${test.archive.path}"/>
</antcall>
- <antcall target="tests.tomcat-6.container-servlet">
- <param name="test.id" value="Tomcat-6_0-request-container-servlet"/>
- <param name="test.tomcat-6.name" value="RemoteTomcat_6_0"/>
- <param name="test.tomcat-6.home" value="${TOMCAT_6_0_HOME}"/>
- <param name="test.tomcat-6.home.variable-name" value="TOMCAT_6_0_HOME"/>
- <param name="test.archive.path" value="${test.temp.lib}/tomcat-6.0-container-servlet/test-request-server.war"/>
+ <antcall target="cargo.tomcat-6.0.stop">
</antcall>
</target>
+ <target name="tests.tomcat-6.0.spi">
+ <condition property="tests.tomcat-6.0.execute.skip">
+ <not>
+ <available file="${test.tomcat-6.0.home}" type="dir"/>
+ </not>
+ </condition>
+ <antcall target="tests.tomcat-6.0.execute">
+ <param name="test.id" value="${test.tomcat-6.0.name}-spi-container-servlet"/>
+ <param name="test.war" value="${test.temp.lib}/tomcat-6.0-container-servlet/test-spi-server.war"/>
+ <param name="test.archive.path" value="tomcat-6.0-container-servlet"/>
+ </antcall>
+ <antcall target="tests.tomcat-6.0.execute">
+ <param name="test.id" value="${test.tomcat-6.0.name}-spi-generic"/>
+ <param name="test.war" value="${test.temp.lib}/tomcat-6.0-generic/test-spi-server.war"/>
+ <param name="test.archive.path" value="tomcat-6.0-generic"/>
+ </antcall>
+ </target>
+ <target name="tests.tomcat-6.0.endpoint">
+ <condition property="tests.tomcat-6.0.execute.skip">
+ <not>
+ <available file="${test.tomcat-6.0.home}" type="dir"/>
+ </not>
+ </condition>
+ <antcall target="tests.tomcat-6.0.execute">
+ <param name="test.id" value="${test.tomcat-6.0.name}-endpoint-default-servlet-mapping"/>
+ <param name="test.war" value="${test.temp.lib}/tomcat-6.0/default-servlet-mapping.war"/>
+ <param name="test.archive.path" value=""/>
+ </antcall>
+ <antcall target="tests.tomcat-6.0.execute">
+ <param name="test.id" value="${test.tomcat-6.0.name}-endpoint-path-mapping"/>
+ <param name="test.war" value="${test.temp.lib}/tomcat-6.0/path-mapping.war"/>
+ <param name="test.archive.path" value=""/>
+ </antcall>
+ <antcall target="tests.tomcat-6.0.execute">
+ <param name="test.id" value="${test.tomcat-6.0.name}-endpoint-root-path-mapping"/>
+ <param name="test.war" value="${test.temp.lib}/tomcat-6.0/root-path-mapping.war"/>
+ <param name="test.archive.path" value=""/>
+ </antcall>
+ </target>
+ <target name="tests.tomcat-6.0">
+
+ <!-- spi tests -->
+
+ <antcall target="tests.tomcat-6.0.spi">
+ <param name="test.tomcat-6.0.name" value="RemoteTomcat_6_0"/>
+ <param name="test.tomcat-6.0.home" value="${TOMCAT_6_0_HOME}"/>
+ </antcall>
+
+ <!-- endpoint tests -->
+
+ <antcall target="tests.tomcat-6.0.endpoint">
+ <param name="test.tomcat-6.0.name" value="RemoteTomcat_6_0"/>
+ <param name="test.tomcat-6.0.home" value="${TOMCAT_6_0_HOME}"/>
+ </antcall>
+
+ </target>
+
<target name="tests.local">
<taskdef name="jboss-unit" classname="org.jboss.unit.tooling.ant.JBossUnitTask" classpath="${plugin_classpath}"/>
@@ -666,12 +726,11 @@
<taskdef name="jboss-unit" classname="org.jboss.unit.tooling.ant.JBossUnitTask" classpath="${plugin_classpath}"/>
-
<jboss-unit>
<tests config="${target}/test-classes/remote-jboss-unit.xml">
- <property name="archivePath" value="${test.temp.lib}/${test.deploy.name}"/>
- <property name="serverName" value="${test.server.name}"/>
+ <property name="archivePath" value="${test.temp.lib}/${test.remote.archive.path}"/>
+ <property name="serverName" value="${test.remote.server.name}"/>
</tests>
<reports>
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/ServletTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/ServletTestCase.java 2008-04-10 14:24:38 UTC (rev 10523)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/ServletTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -32,9 +32,9 @@
import org.jboss.unit.remote.ResponseContext;
import org.jboss.unit.remote.RequestContext;
import org.jboss.unit.remote.driver.RemoteTestDriver;
+import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.web.WebResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Map;
@@ -114,11 +114,10 @@
this.responseContext = responseContext;
}
- public abstract DriverResponse service(TestServlet testServlet, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+ public abstract DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse resp) throws ServletException, IOException;
public abstract DriverResponse invoke(TestServlet testServlet, DriverCommand driverCommand);
-
public static String RANGE_0_255 = computeFrom0To255();
public static String RANGE_256_512 = computeFrom256To512();
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/TestServlet.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/TestServlet.java 2008-04-10 14:24:38 UTC (rev 10523)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/TestServlet.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -28,6 +28,9 @@
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.Failure;
import org.jboss.unit.info.TestInfo;
+import org.jboss.portal.web.endpoint.EndPointServlet;
+import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.web.WebResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -41,7 +44,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public final class TestServlet extends HttpServlet
+public final class TestServlet extends EndPointServlet
{
/** . */
@@ -52,6 +55,9 @@
public void init() throws ServletException
{
+ super.init();
+
+ //
testSuite = (CompositeTestDriver)getServletContext().getAttribute("TestSuite");
// Init the test cases
@@ -61,7 +67,7 @@
}
}
- protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ protected void service(WebRequest req, WebResponse resp) throws ServletException, IOException
{
DriverResponse response;
try
@@ -79,6 +85,9 @@
public void destroy()
{
testSuite = null;
+
+ //
+ super.destroy();
}
public TestInfo getInfo()
Copied: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint (from rev 10502, modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request)
Added: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java (rev 0)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/EndPointTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.web.endpoint;
+
+import org.jboss.portal.test.web.ServletTestCase;
+import org.jboss.portal.web.endpoint.EndPointServlet;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class EndPointTestCase extends ServletTestCase
+{
+
+ public String getURIPrefix(EndPointServlet endPointServlet)
+ {
+ switch (endPointServlet.getMappingStyle())
+ {
+ case EndPointServlet.DEFAULT_SERVLET_MAPPING:
+ return "/default-servlet-mapping/";
+ case EndPointServlet.ROOT_PATH_MAPPING:
+ return "/root-path-mapping/";
+ case EndPointServlet.PATH_MAPPING:
+ return "/path-mapping/foo";
+ default:
+ throw new AssertionError();
+ }
+ }
+
+}
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/GetTestCase.java 2008-04-04 12:10:09 UTC (rev 10502)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/GetTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -20,16 +20,14 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.test.web.request;
+package org.jboss.portal.test.web.endpoint;
-import org.jboss.portal.test.web.ServletTestCase;
import org.jboss.portal.test.web.TestServlet;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.text.FastURLEncoder;
-import org.jboss.portal.common.http.HttpRequest;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.IllegalRequestException;
-import org.jboss.portal.web.Body;
+import org.jboss.portal.web.WebResponse;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.response.EndTestResponse;
@@ -37,20 +35,16 @@
import static org.jboss.unit.api.Assert.*;
import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
-import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
import org.jboss.unit.Failure;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
-import java.nio.charset.Charset;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class GetTestCase extends ServletTestCase
+public class GetTestCase extends EndPointTestCase
{
/** . */
@@ -60,19 +54,16 @@
{
}
- public DriverResponse service(TestServlet testServlet, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse resp) throws ServletException, IOException
{
- WebRequest webRequest = new WebRequest(req);
-
- //
if (getRequestCount() == 0)
{
- ParameterMap queryParameters = assertNotNull(webRequest.getQueryParameterMap());
- assertNull(webRequest.getBody());
+ ParameterMap queryParameters = assertNotNull(req.getQueryParameterMap());
+ assertNull(req.getBody());
assertTrue(queryParameters.isEmpty());
//
- StringBuffer tmp = new StringBuffer("/test-request-server/");
+ StringBuffer tmp = new StringBuffer(getURIPrefix(testServlet));
tmp.append('?').append(encoder.encode("a")).append("=").append(encoder.encode("a_value"));
tmp.append('&').append(encoder.encode("b")).append("=").append(encoder.encode("b_value_1"));
tmp.append('&').append(encoder.encode("b")).append("=").append(encoder.encode("b_value_2"));
@@ -83,8 +74,8 @@
{
try
{
- ParameterMap queryParameters = assertNotNull(webRequest.getQueryParameterMap());
- assertNull(webRequest.getBody());
+ ParameterMap queryParameters = assertNotNull(req.getQueryParameterMap());
+ assertNull(req.getBody());
assertEquals(3, queryParameters.size());
assertEquals(new String[]{"a_value"}, queryParameters.get("a"));
assertEquals(new String[]{"b_value_1","b_value_2"}, queryParameters.get("b"));
@@ -108,7 +99,7 @@
{
if (getRequestCount() == -1)
{
- return new InvokeGetResponse("/test-request-server/");
+ return new InvokeGetResponse(getURIPrefix(testServlet));
}
else
{
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostApplicationXWWWFormURLEncodedTestCase.java 2008-04-04 12:10:09 UTC (rev 10502)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostApplicationXWWWFormURLEncodedTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -20,14 +20,14 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.test.web.request;
+package org.jboss.portal.test.web.endpoint;
-import org.jboss.portal.test.web.ServletTestCase;
import org.jboss.portal.test.web.TestServlet;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.Body;
+import org.jboss.portal.web.WebResponse;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.response.EndTestResponse;
@@ -39,8 +39,6 @@
import static org.jboss.unit.api.Assert.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
@@ -48,7 +46,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PostApplicationXWWWFormURLEncodedTestCase extends ServletTestCase
+public class PostApplicationXWWWFormURLEncodedTestCase extends EndPointTestCase
{
/** . */
@@ -58,36 +56,33 @@
{
}
- public DriverResponse service(TestServlet testServlet, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse resp) throws ServletException, IOException
{
- WebRequest webRequest = new WebRequest(req);
-
- //
if (getRequestCount() == 0)
{
- ParameterMap queryParameters = Assert.assertNotNull(webRequest.getQueryParameterMap());
+ ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertTrue(queryParameters.isEmpty());
- Body.Form form = Assert.assertInstanceOf(webRequest.getBody(), Body.Form.class);
+ Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
ParameterMap formParameters = form.getParameters();
assertTrue(formParameters.isEmpty());
//
- InvokePostResponse post = new InvokePostResponse("/test-request-server/?a=a_value_query");
+ InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet) + "?a=a_value_query");
post.setBody(new HttpRequest.Form());
post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
return post;
}
else if (getRequestCount() == 1)
{
- ParameterMap queryParameters = Assert.assertNotNull(webRequest.getQueryParameterMap());
+ ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertEquals(1, queryParameters.size());
assertEquals(new String[]{"a_value_query"}, queryParameters.get("a"));
- Body.Form form = Assert.assertInstanceOf(webRequest.getBody(), Body.Form.class);
+ Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
ParameterMap formParameters = form.getParameters();
assertTrue(formParameters.isEmpty());
//
- InvokePostResponse post = new InvokePostResponse("/test-request-server/");
+ InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet));
HttpRequest.Form requestForm = new HttpRequest.Form();
requestForm.addParameter("a", new String[]{"a_value_body"});
post.setBody(requestForm);
@@ -96,15 +91,15 @@
}
else if (getRequestCount() == 2)
{
- ParameterMap queryParameters = Assert.assertNotNull(webRequest.getQueryParameterMap());
+ ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertTrue(queryParameters.isEmpty());
- Body.Form form = Assert.assertInstanceOf(webRequest.getBody(), Body.Form.class);
+ Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
ParameterMap formParameters = form.getParameters();
assertEquals(1, formParameters.size());
assertEquals(new String[]{"a_value_body"}, formParameters.get("a"));
//
- InvokePostResponse post = new InvokePostResponse("/test-request-server/?a=a_value_query");
+ InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet) + "?a=a_value_query");
post.setBody(new HttpRequest.Form());
HttpRequest.Form requestForm = new HttpRequest.Form();
requestForm.addParameter("a", new String[]{"a_value_form"});
@@ -114,16 +109,16 @@
}
else if (getRequestCount() == 3)
{
- ParameterMap queryParameters = Assert.assertNotNull(webRequest.getQueryParameterMap());
+ ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertEquals(1, queryParameters.size());
assertEquals(new String[]{"a_value_query"}, queryParameters.get("a"));
- Body.Form form = Assert.assertInstanceOf(webRequest.getBody(), Body.Form.class);
+ Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
ParameterMap formParameters = form.getParameters();
assertEquals(1, formParameters.size());
assertEquals(new String[]{"a_value_form"}, formParameters.get("a"));
//
- InvokePostResponse post = new InvokePostResponse("/test-request-server/?a=" + encoder.encode(RANGE_0_255));
+ InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet) + "?a=" + encoder.encode(RANGE_0_255));
post.setBody(new HttpRequest.Form());
HttpRequest.Form requestForm = new HttpRequest.Form();
requestForm.addParameter("a", new String[]{RANGE_256_512});
@@ -133,16 +128,16 @@
}
else if (getRequestCount() == 4)
{
- ParameterMap queryParameters = Assert.assertNotNull(webRequest.getQueryParameterMap());
+ ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertEquals(1, queryParameters.size());
assertNull(compareString(RANGE_0_255, queryParameters.get("a")[0]));
- Body.Form form = Assert.assertInstanceOf(webRequest.getBody(), Body.Form.class);
+ Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
ParameterMap formParameters = form.getParameters();
assertEquals(1, formParameters.size());
assertNull(compareString(RANGE_256_512, formParameters.get("a")[0]));
//
- InvokePostResponse post = new InvokePostResponse("/test-request-server/?a=" + encoder.encode(RANGE_256_512));
+ InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet) + "?a=" + encoder.encode(RANGE_256_512));
post.setBody(new HttpRequest.Form());
HttpRequest.Form requestForm = new HttpRequest.Form();
requestForm.addParameter("a", new String[]{RANGE_0_255});
@@ -152,10 +147,10 @@
}
else if (getRequestCount() == 5)
{
- ParameterMap queryParameters = Assert.assertNotNull(webRequest.getQueryParameterMap());
+ ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
assertEquals(1, queryParameters.size());
assertNull(compareString(RANGE_256_512, queryParameters.get("a")[0]));
- Body.Form form = Assert.assertInstanceOf(webRequest.getBody(), Body.Form.class);
+ Body.Form form = Assert.assertInstanceOf(req.getBody(), Body.Form.class);
ParameterMap formParameters = form.getParameters();
assertEquals(1, formParameters.size());
assertNull(compareString(RANGE_0_255, formParameters.get("a")[0]));
@@ -173,7 +168,7 @@
{
if (getRequestCount() == -1)
{
- InvokePostResponse post = new InvokePostResponse("/test-request-server/");
+ InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet));
post.setBody(new HttpRequest.Form());
post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
return post;
@@ -183,5 +178,4 @@
return new FailureResponse(Failure.createAssertionFailure(""));
}
}
-
}
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostMultipartFormDataTestCase.java 2008-04-04 12:10:09 UTC (rev 10502)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/endpoint/PostMultipartFormDataTestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -20,15 +20,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.test.web.request;
+package org.jboss.portal.test.web.endpoint;
-import org.jboss.portal.test.web.ServletTestCase;
import org.jboss.portal.test.web.TestServlet;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.Body;
+import org.jboss.portal.web.WebResponse;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.response.EndTestResponse;
@@ -40,8 +40,6 @@
import static org.jboss.unit.api.Assert.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.InputStream;
@@ -51,7 +49,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PostMultipartFormDataTestCase extends ServletTestCase
+public class PostMultipartFormDataTestCase extends EndPointTestCase
{
/** . */
@@ -61,16 +59,13 @@
{
}
- public DriverResponse service(TestServlet testServlet, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse resp) throws ServletException, IOException
{
- WebRequest webRequest = new WebRequest(req);
-
- //
if (getRequestCount() == 0)
{
- ParameterMap queryParameters = Assert.assertNotNull(webRequest.getQueryParameterMap());
+ ParameterMap queryParameters = Assert.assertNotNull(req.getQueryParameterMap());
Assert.assertTrue(queryParameters.isEmpty());
- Body.Raw raw = Assert.assertInstanceOf(webRequest.getBody(), Body.Raw.class);
+ Body.Raw raw = Assert.assertInstanceOf(req.getBody(), Body.Raw.class);
InputStream in = raw.getInputStream();
byte[] bytes = IOTools.getBytes(in);
assertTrue(Arrays.equals(new byte[]{0,1,1,2,3,5,8,13,21,34},bytes));
@@ -88,7 +83,7 @@
{
if (getRequestCount() == -1)
{
- InvokePostResponse post = new InvokePostResponse("/test-request-server/");
+ InvokePostResponse post = new InvokePostResponse(getURIPrefix(testServlet));
HttpRequest.Raw raw = new HttpRequest.Raw();
post.setBody(raw);
raw.setBytes(new byte[]{0,1,1,2,3,5,8,13,21,34});
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/spi/SPITestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/spi/SPITestCase.java 2008-04-10 14:24:38 UTC (rev 10523)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/spi/SPITestCase.java 2008-04-10 16:40:49 UTC (rev 10524)
@@ -30,6 +30,8 @@
import org.jboss.portal.web.ServletContainer;
import org.jboss.portal.web.WebApp;
import org.jboss.portal.web.ServletContextDispatcher;
+import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.web.WebResponse;
import org.jboss.portal.web.impl.DefaultServletContainerFactory;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
@@ -41,8 +43,6 @@
import org.jboss.unit.Failure;
import static org.jboss.unit.api.Assert.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.ServletContext;
import java.io.IOException;
@@ -65,7 +65,7 @@
/** . */
private ServletContainer container;
- public DriverResponse service(TestServlet testServlet, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse resp) throws ServletException, IOException
{
if (getRequestCount() == 1)
{
Copied: modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar (from rev 10502, modules/web/trunk/web/src/test/resources/portal-test-request-jar)
Modified: modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/portal-test-request-jar/org/jboss/portal/test/web/server-beans.xml 2008-04-04 12:10:09 UTC (rev 10502)
+++ modules/web/trunk/web/src/test/resources/portal-test-endpoint-jar/org/jboss/portal/test/web/server-beans.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -57,7 +57,7 @@
<bean name="TestSuite" class="org.jboss.unit.driver.impl.composite.CompositeTestDriver"/>
- <bean name="GetTestCase" class="org.jboss.portal.test.web.request.GetTestCase">
+ <bean name="GetTestCase" class="org.jboss.portal.test.web.endpoint.GetTestCase">
<install bean="TestSuite" method="mount">
<parameter><this/></parameter>
</install>
@@ -66,7 +66,7 @@
</uninstall>
</bean>
- <bean name="PostApplicationXWWWFormURLEncodedTestCase" class="org.jboss.portal.test.web.request.PostApplicationXWWWFormURLEncodedTestCase">
+ <bean name="PostApplicationXWWWFormURLEncodedTestCase" class="org.jboss.portal.test.web.endpoint.PostApplicationXWWWFormURLEncodedTestCase">
<install bean="TestSuite" method="mount">
<parameter><this/></parameter>
</install>
@@ -75,7 +75,7 @@
</uninstall>
</bean>
- <bean name="PostMultipartFormDataTestCase" class="org.jboss.portal.test.web.request.PostMultipartFormDataTestCase">
+ <bean name="PostMultipartFormDataTestCase" class="org.jboss.portal.test.web.endpoint.PostMultipartFormDataTestCase">
<install bean="TestSuite" method="mount">
<parameter><this/></parameter>
</install>
Added: modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/jboss-web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/jboss-web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/jboss-web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<!DOCTYPE jboss-web PUBLIC
+ "-//JBoss//DTD Web Application 4.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
+<jboss-web>
+ <class-loading java2ClassLoadingCompliance="false">
+ <loader-repository>test:loader=portlet</loader-repository>
+ </class-loading>
+</jboss-web>
\ No newline at end of file
Added: modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/default-servlet-mapping-war/WEB-INF/web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+ <param-value>org/jboss/portal/test/web/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.web.TestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/jboss-web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/jboss-web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/jboss-web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<!DOCTYPE jboss-web PUBLIC
+ "-//JBoss//DTD Web Application 4.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
+<jboss-web>
+ <class-loading java2ClassLoadingCompliance="false">
+ <loader-repository>test:loader=portlet</loader-repository>
+ </class-loading>
+</jboss-web>
\ No newline at end of file
Added: modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/path-mapping-war/WEB-INF/web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+ <param-value>org/jboss/portal/test/web/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.web.TestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/foo/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/jboss-web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/jboss-web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/jboss-web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<!DOCTYPE jboss-web PUBLIC
+ "-//JBoss//DTD Web Application 4.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
+<jboss-web>
+ <class-loading java2ClassLoadingCompliance="false">
+ <loader-repository>test:loader=portlet</loader-repository>
+ </class-loading>
+</jboss-web>
\ No newline at end of file
Added: modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/jboss-4.2-endpoint/root-path-mapping-war/WEB-INF/web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+ <param-value>org/jboss/portal/test/web/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.web.TestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/default-servlet-mapping-war/WEB-INF/web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/default-servlet-mapping-war/WEB-INF/web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/default-servlet-mapping-war/WEB-INF/web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+ <param-value>org/jboss/portal/test/web/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.web.TestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/path-mapping-war/WEB-INF/web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/path-mapping-war/WEB-INF/web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/path-mapping-war/WEB-INF/web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+ <param-value>org/jboss/portal/test/web/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.web.TestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/foo/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/root-path-mapping-war/WEB-INF/web.xml
===================================================================
--- modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/root-path-mapping-war/WEB-INF/web.xml (rev 0)
+++ modules/web/trunk/web/src/test/resources/support/tomcat-6.0-endpoint/root-path-mapping-war/WEB-INF/web.xml 2008-04-10 16:40:49 UTC (rev 10524)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+ <param-value>org/jboss/portal/test/web/server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.jboss.portal.test.web.TestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
18 years, 1 month
JBoss Portal SVN: r10523 - branches/JBoss_Portal_Branch_2_7/core-admin.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-10 10:24:38 -0400 (Thu, 10 Apr 2008)
New Revision: 10523
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/build.xml
Log:
Reference correct libs
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/build.xml 2008-04-09 22:21:21 UTC (rev 10522)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/build.xml 2008-04-10 14:24:38 UTC (rev 10523)
@@ -100,13 +100,10 @@
<path refid="sun.servlet.classpath"/>
<path refid="facelets.facelets.classpath"/>
<path refid="el.el.classpath"/>
- <pathelement location="${source.etc}/sun-jsf/jsf-facelets-1.1.14.jar"/>
+ <path refid="richfaces.richfaces.classpath"/>
+ <path refid="facelets.facelets.classpath"/>
<pathelement location="${source.etc}/sun-jsf/portletbridge-api-1.0.0-SNAPSHOT.jar"/>
<pathelement location="${source.etc}/sun-jsf/portletbridge-impl-1.0.0-SNAPSHOT.jar"/>
- <pathelement location="${source.etc}/sun-jsf/richfaces-api-3.1.4.SR1.jar"/>
- <pathelement location="${source.etc}/sun-jsf/richfaces-impl-3.1.4.SR1.jar"/>
- <pathelement location="${source.etc}/sun-jsf/richfaces-ui-3.1.4.SR1.jar"/>
-
</path>
<!-- Configure modules -->
@@ -194,14 +191,14 @@
<!-- portal-admin.war -->
<copy todir="${build.resources}/portal-admin-war/WEB-INF/lib">
<fileset dir="${apache.myfaces.lib}" includes="jstl.jar"/>
- <fileset dir="../core-admin/src/etc/sun-jsf" includes="jsf-facelets-1.1.14.jar"/>
+ <fileset dir="${facelets.facelets.lib}" includes="jsf-facelets.jar"/>
<fileset dir="../core-admin/src/etc/sun-jsf" includes="portletbridge-api-1.0.0-SNAPSHOT.jar"/>
<fileset dir="../core-admin/src/etc/sun-jsf" includes="portletbridge-impl-1.0.0-SNAPSHOT.jar"/>
- <fileset dir="../core-admin/src/etc/sun-jsf" includes="richfaces-api-3.1.4.SR1.jar"/>
- <fileset dir="../core-admin/src/etc/sun-jsf" includes="richfaces-impl-3.1.4.SR1.jar"/>
- <fileset dir="../core-admin/src/etc/sun-jsf" includes="richfaces-ui-3.1.4.SR1.jar"/>
+ <fileset dir="${richfaces.richfaces.lib}" includes="richfaces-api.jar"/>
+ <fileset dir="${richfaces.richfaces.lib}" includes="richfaces-impl.jar"/>
+ <fileset dir="${richfaces.richfaces.lib}" includes="richfaces-ui.jar"/>
<fileset dir="${build.lib}" includes="portal-core-admin-lib.jar"/>
- <fileset dir="${jboss.portal-faces.root}/lib" includes="portal-faces-lib.jar"/>
+ <fileset dir="${jboss.portal-faces.root}/lib" includes="portal-faces-lib.jar"/>
<fileset dir="${apache.beanutils.lib}" includes="commons-beanutils.jar"/>
<fileset dir="${apache.digester.lib}" includes="commons-digester.jar"/>
<fileset dir="${apache.lang.lib}" includes="commons-lang.jar"/>
18 years, 1 month
JBoss Portal SVN: r10522 - in modules/portlet/trunk: controller/src/main/java/org/jboss/portal/portlet/controller and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-09 18:21:21 -0400 (Wed, 09 Apr 2008)
New Revision: 10522
Modified:
modules/portlet/trunk/build/pom.xml
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java
Log:
JBPORTAL-1981 : Remove the window id from PageNavigationalState.void setPublicNavigationalState(String windowId, Map<String, String[]>)
Modified: modules/portlet/trunk/build/pom.xml
===================================================================
--- modules/portlet/trunk/build/pom.xml 2008-04-09 15:16:45 UTC (rev 10521)
+++ modules/portlet/trunk/build/pom.xml 2008-04-09 22:21:21 UTC (rev 10522)
@@ -33,8 +33,8 @@
<version.jboss-logging>2.0.3.GA</version.jboss-logging>
<version.jbossxb>2.0.0.CR5</version.jbossxb>
<version.jboss-remoting>2.2.1.GA</version.jboss-remoting>
- <version.jboss.portal.common>1.2.0-SNAPSHOT</version.jboss.portal.common>
- <version.jboss.portal.web>1.2.0-SNAPSHOT</version.jboss.portal.web>
+ <version.jboss.portal.common>1.2.0.Beta3</version.jboss.portal.common>
+ <version.jboss.portal.web>1.2.0.Beta3</version.jboss.portal.web>
<version.jboss.unit>1.2.0.Beta2</version.jboss.unit>
<version.log4j>1.2.14</version.log4j>
<version.apache.commons-logging>1.1.1</version.apache.commons-logging>
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java 2008-04-09 15:16:45 UTC (rev 10521)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java 2008-04-09 22:21:21 UTC (rev 10522)
@@ -60,8 +60,8 @@
* Create a portlet invocation context for the specified window id.
*
* @param windowId the window id
- * @param pageNavigationalState
- * @return
+ * @param pageNavigationalState the page navigational state
+ * @return a portlet invocation context
*/
PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageNavigationalState);
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-04-09 15:16:45 UTC (rev 10521)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-04-09 22:21:21 UTC (rev 10522)
@@ -29,6 +29,8 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.controller.event.Event;
import org.jboss.portal.portlet.controller.event.EventControllerContext;
import org.jboss.portal.portlet.controller.request.PortletActionRequest;
@@ -48,6 +50,7 @@
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import javax.servlet.http.Cookie;
+import javax.xml.namespace.QName;
import java.util.List;
import java.util.Map;
@@ -400,10 +403,32 @@
pageNavigationalState.setWindowNavigationalState(windowId, windowNS);
// Now update shared state scoped at page
- Map<String, String[]> publicNS = update.getPublicNavigationalStateUpdates();
- if (publicNS != null)
+ PortletInfo info = context.getPortletInfo(windowId);
+ if (info != null)
{
- pageNavigationalState.setPublicNavigationalState(windowId, publicNS);
+ NavigationInfo navigationInfo = info.getNavigation();
+ for (Map.Entry<String, String[]> entry : update.getPublicNavigationalStateUpdates().entrySet())
+ {
+ String id = entry.getKey();
+
+ //
+ ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
+
+ //
+ if (parameterInfo != null)
+ {
+ QName name = parameterInfo.getName();
+ String[] value = entry.getValue();
+ if (value.length > 0)
+ {
+ pageNavigationalState.setPublicNavigationalState(name, value);
+ }
+ else
+ {
+ pageNavigationalState.removePublicNavigationalState(name);
+ }
+ }
+ }
}
}
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-04-09 15:16:45 UTC (rev 10521)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-04-09 22:21:21 UTC (rev 10522)
@@ -27,7 +27,6 @@
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.NavigationInfo;
import javax.xml.namespace.QName;
import java.io.Serializable;
@@ -132,45 +131,6 @@
windows.put(windowId, windowState);
}
- public void setPublicNavigationalState(String windowId, Map<String, String[]> update)
- {
- if (!modifiable)
- {
- throw new IllegalStateException("The page navigational state is not modifiable");
- }
-
- //
- PortletInfo info = context.portletControllerContext.getPortletInfo(windowId);
-
- //
- if (info != null)
- {
- NavigationInfo navigationInfo = info.getNavigation();
- for (Map.Entry<String, String[]> entry : update.entrySet())
- {
- String id = entry.getKey();
-
- //
- ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
-
- //
- if (parameterInfo != null)
- {
- QName name = parameterInfo.getName();
- String[] value = entry.getValue();
- if (value.length > 0)
- {
- setPublicNavigationalState(name, value);
- }
- else
- {
- removePublicNavigationalState(name);
- }
- }
- }
- }
- }
-
public void setPublicNavigationalState(QName name, String[] value)
{
if (!modifiable)
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-04-09 15:16:45 UTC (rev 10521)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-04-09 22:21:21 UTC (rev 10522)
@@ -25,7 +25,6 @@
import org.jboss.portal.common.util.ParameterMap;
import javax.xml.namespace.QName;
-import java.util.Map;
import java.util.Set;
/**
@@ -84,20 +83,6 @@
Set<QName> getPublicNames();
/**
- * Update the public navigational state of a window. The interpretation of what should be updated is left up to the
- * implementor. An example of implementation would use the mapping between qname and name provided by the referenced
- * portlet info.
- * <p/>
- * The update argument values with a length of zero should be treated as removals.
- *
- * @param windowId the window id
- * @param update the updates
- * @throws IllegalArgumentException if an argument is not valid
- * @throws IllegalStateException if the page state is read only
- */
- void setPublicNavigationalState(String windowId, Map<String, String[]> update) throws IllegalArgumentException, IllegalStateException;
-
- /**
* Returns a public navigational state entry or null if it is not found.
*
* @param name the name
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java 2008-04-09 15:16:45 UTC (rev 10521)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java 2008-04-09 22:21:21 UTC (rev 10522)
@@ -32,10 +32,11 @@
{
/**
- * Clone an existing page state object.
+ * Clone an existing page navigational state object.
*
- * @param pageNavigationalState
- *@param modifiable set the modifiable status @return the page state clone
+ * @param pageNavigationalState the page navigational state to clone
+ * @param modifiable set the modifiable status @return the page state clone
+ * @return a clone of the provided page navigational state
*/
PageNavigationalState clonePageNavigationalState(PageNavigationalState pageNavigationalState, boolean modifiable);
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java 2008-04-09 15:16:45 UTC (rev 10521)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java 2008-04-09 22:21:21 UTC (rev 10522)
@@ -27,9 +27,7 @@
import org.jboss.portal.common.util.ParameterMap;
import javax.xml.namespace.QName;
-import java.util.Map;
import java.util.Set;
-import java.util.HashMap;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
@@ -80,11 +78,6 @@
return defaultState.getPublicNames();
}
- public void setPublicNavigationalState(String windowId, Map<String, String[]> update) throws IllegalArgumentException, IllegalStateException
- {
- defaultState.setPublicNavigationalState(windowId, update);
- }
-
public String[] getPublicNavigationalState(QName name) throws IllegalArgumentException
{
return defaultState.getPublicNavigationalState(name);
18 years, 1 month
JBoss Portal SVN: r10521 - in modules/common/trunk/common/src/main/java/org/jboss/portal/common/net: media and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-09 11:16:45 -0400 (Wed, 09 Apr 2008)
New Revision: 10521
Removed:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/URLFormat.java
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/media/MediaType.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/media/SubtypeDef.java
Log:
added multipart/form-data as media type constant
Deleted: modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/URLFormat.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/URLFormat.java 2008-04-09 09:52:31 UTC (rev 10520)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/URLFormat.java 2008-04-09 15:16:45 UTC (rev 10521)
@@ -1,87 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.common.net;
-
-/**
- * Defines how a URL should be formatted when rendered.
- *
- * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class URLFormat
-{
-
- /**
- * Factory creation of URLFormat objects.
- *
- * @param secure if the url should be secure
- * @param authenticated if the url should force the user to authenticate
- * @param relative if the url is relative or absolute
- * @param escapeXML if the url should have XML escaped
- * @return the rendered URL
- */
- public static URLFormat create(Boolean secure, Boolean authenticated, Boolean relative, Boolean escapeXML)
- {
- return new URLFormat(secure, authenticated, relative, escapeXML);
- }
-
- /** . */
- private final Boolean secure;
-
- /** . */
- private final Boolean authenticated;
-
- /** . */
- private final Boolean relative;
-
- /** . */
- private final Boolean escapeXML;
-
- private URLFormat(Boolean secure, Boolean authenticated, Boolean relative, Boolean escapeXML)
- {
- this.secure = secure;
- this.authenticated = authenticated;
- this.relative = relative;
- this.escapeXML = escapeXML;
- }
-
- public Boolean getSecure()
- {
- return secure;
- }
-
- public Boolean getAuthenticated()
- {
- return authenticated;
- }
-
- public Boolean getRelative()
- {
- return relative;
- }
-
- public Boolean getEscapeXML()
- {
- return escapeXML;
- }
-}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/media/MediaType.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/media/MediaType.java 2008-04-09 09:52:31 UTC (rev 10520)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/media/MediaType.java 2008-04-09 15:16:45 UTC (rev 10521)
@@ -43,6 +43,9 @@
/** . */
public static final MediaType APPLICATION_X_WWW_FORM_URLENCODED = new MediaType(TypeDef.APPLICATION, SubtypeDef.X_WWW_FORM_URLENCODED);
+ /** . */
+ public static final MediaType MULTIPART_FORM_DATA_MEDIA_TYPE = new MediaType(TypeDef.MULTIPART, SubtypeDef.FORM_DATA);
+
/**
* Create a media type object by parsing a media type name. The media type name format is defined by the
* section 5.1 of the <a href="http://tools.ietf.org/html/rfc2045#section-5.1">RFC2045</a> but is limited
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/media/SubtypeDef.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/media/SubtypeDef.java 2008-04-09 09:52:31 UTC (rev 10520)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/net/media/SubtypeDef.java 2008-04-09 15:16:45 UTC (rev 10521)
@@ -49,6 +49,9 @@
/** . */
public static final SubtypeDef X_WWW_FORM_URLENCODED = new SubtypeDef("x-www-form-urlencoded");
+ /** . */
+ public static final SubtypeDef FORM_DATA = new SubtypeDef("form-data");
+
/**
* Returns a corresponding subtype definition for the specified subtype name.
*
18 years, 1 month
JBoss Portal SVN: r10520 - in branches/JBoss_Portal_Branch_2_7/core-identity/src: main/org/jboss/portal/core/identity/services/metadata and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-09 05:52:31 -0400 (Wed, 09 Apr 2008)
New Revision: 10520
Removed:
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/WorkflowSoftDependency.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-1976: WorkflowSoftDependency is not working correctly anymore
Removed it since it wasn't reliable.
Deleted: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/WorkflowSoftDependency.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/WorkflowSoftDependency.java 2008-04-09 09:50:20 UTC (rev 10519)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/WorkflowSoftDependency.java 2008-04-09 09:52:31 UTC (rev 10520)
@@ -1,173 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.identity.services;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MBeanServerNotification;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-import org.jboss.mx.util.MBeanProxy;
-import org.jboss.mx.util.MBeanProxyCreationException;
-import org.jboss.portal.core.identity.services.metadata.IdentityUIConfigurationService;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.workflow.service.WorkflowService;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class WorkflowSoftDependency extends AbstractJBossService
-{
- private MBeanServer server;
-
- private IdentityUIConfigurationService identityUIConfigurationService;
-
- private NotificationListener notificationListener;
-
- private ObjectName mbeanServerDelegate;
-
- private ObjectName workflowServiceObjectName;
-
- /** The logger. */
- private Logger log = Logger.getLogger(WorkflowSoftDependency.class);
-
- public WorkflowSoftDependency()
- {
- server = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
- try
- {
- mbeanServerDelegate = new ObjectName("JMImplementation:type=MBeanServerDelegate");
- workflowServiceObjectName = new ObjectName("portal:service=Workflow,type=WorkflowService");
- notificationListener = new WorkflowServiceNotificationListener(workflowServiceObjectName);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public void startService()
- {
- // Check if the workflow service is already registered
- if (server.isRegistered(workflowServiceObjectName))
- {
- try
- {
- WorkflowService workflowService = (WorkflowService)MBeanProxy.get(WorkflowService.class, workflowServiceObjectName, server);
- identityUIConfigurationService.setWorkflowService(workflowService);
- log.debug("Starting identityUIConfigurationService workflow part");
- identityUIConfigurationService.startWorkflow();
- }
- catch (Exception e)
- {
- log.error("Error starting workflow", e);
- }
- }
-
- // Add the listener for registration/unregistration if the workflow service
- try
- {
- server.addNotificationListener(mbeanServerDelegate, notificationListener, null, identityUIConfigurationService);
- }
- catch (Exception e)
- {
- log.error(e);
- }
- }
-
- public void stopService()
- {
- try
- {
- server.removeNotificationListener(mbeanServerDelegate, notificationListener);
- }
- catch (Exception e)
- {
- log.error(e);
- }
- }
-
- public void setIdentityUIConfigurationService(IdentityUIConfigurationService identityUIConfigurationService)
- {
- this.identityUIConfigurationService = identityUIConfigurationService;
- }
-
- private class WorkflowServiceNotificationListener implements NotificationListener
- {
-
- ObjectName objectName = null;
-
- public WorkflowServiceNotificationListener(ObjectName objectName)
- {
- this.objectName = objectName;
- }
-
- public void handleNotification(Notification notification, Object object)
- {
- if (notification instanceof MBeanServerNotification)
- {
- MBeanServerNotification notif = (MBeanServerNotification)notification;
- try
- {
- if (notif.getMBeanName().equals(objectName))
- {
- IdentityUIConfigurationService identityUIConfigurationService = (IdentityUIConfigurationService)object;
- if (notif.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION))
- {
- try
- {
- WorkflowService workflowService = (WorkflowService)MBeanProxy.get(WorkflowService.class, new ObjectName("portal:service=Workflow,type=WorkflowService"), server);
- identityUIConfigurationService.setWorkflowService(workflowService);
- log.debug("Starting identityUIConfigurationService workflow part");
- identityUIConfigurationService.startWorkflow();
-
- }
- catch (MBeanProxyCreationException e)
- {
- log.error("Error starting workflow", e);
- }
- }
- else
- {
- // Unregistration
- log.debug("Stopping identityUIConfigurationService workflow part");
- identityUIConfigurationService.stopWorkflow();
- identityUIConfigurationService.setWorkflowService(null);
- }
- }
- }
- catch (Exception e)
- {
- log.error(e);
- }
- }
- }
-
- }
-
-}
-
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java 2008-04-09 09:50:20 UTC (rev 10519)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java 2008-04-09 09:52:31 UTC (rev 10520)
@@ -139,6 +139,7 @@
jndiBinding = new JNDI.Binding(jndiName, this);
jndiBinding.bind();
}
+ startWorkflow();
}
public void stopService() throws Exception
@@ -150,6 +151,7 @@
jndiBinding.unbind();
jndiBinding = null;
}
+ stopWorkflow();
}
public String getJNDIName()
@@ -243,7 +245,7 @@
}
catch(Exception e)
{
- throw new CoreIdentityConfigurationException("I don't like your subscription mode! Please make sure that the file and the process name match - also check the syntax.", e);
+ throw new CoreIdentityConfigurationException("I don't like your subscription mode [" + processName + "] ! Please make sure that the file and the process name match - also check the syntax.", e);
}
finally
{
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml 2008-04-09 09:50:20 UTC (rev 10519)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml 2008-04-09 09:52:31 UTC (rev 10520)
@@ -58,6 +58,9 @@
<depends optional-attribute-name="IdentityServiceController" proxy-type="attribute">
portal:service=Module,type=IdentityServiceController
</depends>
+ <depends optional-attribute-name="WorkflowService" proxy-type="attribute">
+ portal:service=Workflow,type=WorkflowService
+ </depends>
<attribute name="JNDIName">java:portal/IdentityUIConfigurationService</attribute>
</mbean>
@@ -129,14 +132,4 @@
proxy-type="attribute">portal:commandFactory=IdentityUI</depends>
</mbean>
- <mbean
- code="org.jboss.portal.core.identity.services.WorkflowSoftDependency"
- name="portal:service=WorkflowSoftDependency"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <depends
- optional-attribute-name="IdentityUIConfigurationService"
- proxy-type="attribute">portal:service=IdentityUIConfigurationService,type=IdentityUI</depends>
- <xmbean/>
- </mbean>
</server>
\ No newline at end of file
18 years, 1 month
JBoss Portal SVN: r10519 - in branches/JBoss_Portal_Branch_2_6/core-identity/src: main/org/jboss/portal/core/identity/services/metadata and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-09 05:50:20 -0400 (Wed, 09 Apr 2008)
New Revision: 10519
Removed:
branches/JBoss_Portal_Branch_2_6/core-identity/src/main/org/jboss/portal/core/identity/services/WorkflowSoftDependency.java
Modified:
branches/JBoss_Portal_Branch_2_6/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java
branches/JBoss_Portal_Branch_2_6/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-1976: WorkflowSoftDependency is not working correctly anymore
Removed it since it wasn't reliable.
Deleted: branches/JBoss_Portal_Branch_2_6/core-identity/src/main/org/jboss/portal/core/identity/services/WorkflowSoftDependency.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-identity/src/main/org/jboss/portal/core/identity/services/WorkflowSoftDependency.java 2008-04-08 11:45:42 UTC (rev 10518)
+++ branches/JBoss_Portal_Branch_2_6/core-identity/src/main/org/jboss/portal/core/identity/services/WorkflowSoftDependency.java 2008-04-09 09:50:20 UTC (rev 10519)
@@ -1,173 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.identity.services;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MBeanServerNotification;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-import org.jboss.mx.util.MBeanProxy;
-import org.jboss.mx.util.MBeanProxyCreationException;
-import org.jboss.portal.core.identity.services.metadata.IdentityUIConfigurationService;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.workflow.service.WorkflowService;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class WorkflowSoftDependency extends AbstractJBossService
-{
- private MBeanServer server;
-
- private IdentityUIConfigurationService identityUIConfigurationService;
-
- private NotificationListener notificationListener;
-
- private ObjectName mbeanServerDelegate;
-
- private ObjectName workflowServiceObjectName;
-
- /** The logger. */
- private Logger log = Logger.getLogger(WorkflowSoftDependency.class);
-
- public WorkflowSoftDependency()
- {
- server = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
- try
- {
- mbeanServerDelegate = new ObjectName("JMImplementation:type=MBeanServerDelegate");
- workflowServiceObjectName = new ObjectName("portal:service=Workflow,type=WorkflowService");
- notificationListener = new WorkflowServiceNotificationListener(workflowServiceObjectName);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public void startService()
- {
- // Check if the workflow service is already registered
- if (server.isRegistered(workflowServiceObjectName))
- {
- try
- {
- WorkflowService workflowService = (WorkflowService)MBeanProxy.get(WorkflowService.class, workflowServiceObjectName, server);
- identityUIConfigurationService.setWorkflowService(workflowService);
- log.debug("Starting identityUIConfigurationService workflow part");
- identityUIConfigurationService.startWorkflow();
- }
- catch (Exception e)
- {
- log.error("Error starting workflow", e);
- }
- }
-
- // Add the listener for registration/unregistration if the workflow service
- try
- {
- server.addNotificationListener(mbeanServerDelegate, notificationListener, null, identityUIConfigurationService);
- }
- catch (Exception e)
- {
- log.error(e);
- }
- }
-
- public void stopService()
- {
- try
- {
- server.removeNotificationListener(mbeanServerDelegate, notificationListener);
- }
- catch (Exception e)
- {
- log.error(e);
- }
- }
-
- public void setIdentityUIConfigurationService(IdentityUIConfigurationService identityUIConfigurationService)
- {
- this.identityUIConfigurationService = identityUIConfigurationService;
- }
-
- private class WorkflowServiceNotificationListener implements NotificationListener
- {
-
- ObjectName objectName = null;
-
- public WorkflowServiceNotificationListener(ObjectName objectName)
- {
- this.objectName = objectName;
- }
-
- public void handleNotification(Notification notification, Object object)
- {
- if (notification instanceof MBeanServerNotification)
- {
- MBeanServerNotification notif = (MBeanServerNotification)notification;
- try
- {
- if (notif.getMBeanName().equals(objectName))
- {
- IdentityUIConfigurationService identityUIConfigurationService = (IdentityUIConfigurationService)object;
- if (notif.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION))
- {
- try
- {
- WorkflowService workflowService = (WorkflowService)MBeanProxy.get(WorkflowService.class, new ObjectName("portal:service=Workflow,type=WorkflowService"), server);
- identityUIConfigurationService.setWorkflowService(workflowService);
- log.debug("Starting identityUIConfigurationService workflow part");
- identityUIConfigurationService.startWorkflow();
-
- }
- catch (MBeanProxyCreationException e)
- {
- log.error("Error starting workflow", e);
- }
- }
- else
- {
- // Unregistration
- log.debug("Stopping identityUIConfigurationService workflow part");
- identityUIConfigurationService.stopWorkflow();
- identityUIConfigurationService.setWorkflowService(null);
- }
- }
- }
- catch (Exception e)
- {
- log.error(e);
- }
- }
- }
-
- }
-
-}
-
Modified: branches/JBoss_Portal_Branch_2_6/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java 2008-04-08 11:45:42 UTC (rev 10518)
+++ branches/JBoss_Portal_Branch_2_6/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java 2008-04-09 09:50:20 UTC (rev 10519)
@@ -139,6 +139,7 @@
jndiBinding = new JNDI.Binding(jndiName, this);
jndiBinding.bind();
}
+ startWorkflow();
}
public void stopService() throws Exception
@@ -150,6 +151,7 @@
jndiBinding.unbind();
jndiBinding = null;
}
+ stopWorkflow();
}
public String getJNDIName()
@@ -243,7 +245,7 @@
}
catch(Exception e)
{
- throw new CoreIdentityConfigurationException("I don't like your subscription mode! Please make sure that the file and the process name match - also check the syntax.", e);
+ throw new CoreIdentityConfigurationException("I don't like your subscription mode [" + processName + "] ! Please make sure that the file and the process name match - also check the syntax.", e);
}
finally
{
Modified: branches/JBoss_Portal_Branch_2_6/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml 2008-04-08 11:45:42 UTC (rev 10518)
+++ branches/JBoss_Portal_Branch_2_6/core-identity/src/resources/portal-identity-sar/META-INF/jboss-service.xml 2008-04-09 09:50:20 UTC (rev 10519)
@@ -58,6 +58,9 @@
<depends optional-attribute-name="IdentityServiceController" proxy-type="attribute">
portal:service=Module,type=IdentityServiceController
</depends>
+ <depends optional-attribute-name="WorkflowService" proxy-type="attribute">
+ portal:service=Workflow,type=WorkflowService
+ </depends>
<attribute name="JNDIName">java:portal/IdentityUIConfigurationService</attribute>
</mbean>
@@ -129,14 +132,4 @@
proxy-type="attribute">portal:commandFactory=IdentityUI</depends>
</mbean>
- <mbean
- code="org.jboss.portal.core.identity.services.WorkflowSoftDependency"
- name="portal:service=WorkflowSoftDependency"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <depends
- optional-attribute-name="IdentityUIConfigurationService"
- proxy-type="attribute">portal:service=IdentityUIConfigurationService,type=IdentityUI</depends>
- <xmbean/>
- </mbean>
</server>
\ No newline at end of file
18 years, 1 month
JBoss Portal SVN: r10518 - branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-08 07:45:42 -0400 (Tue, 08 Apr 2008)
New Revision: 10518
Modified:
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityMailServiceImpl.java
Log:
JBPORTAL-1975: Cannot load email templates in core-identity
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityMailServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityMailServiceImpl.java 2008-04-08 11:42:53 UTC (rev 10517)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityMailServiceImpl.java 2008-04-08 11:45:42 UTC (rev 10518)
@@ -66,7 +66,7 @@
private static final String TEMPLATE_PATH = "conf/templates/";
/** The template prefix. */
- private static final String TEMPLATE_PREFIX = "/emailTemplate_";
+ private static final String TEMPLATE_PREFIX = "/emailTemplate";
/** The core-identity configuration service. */
private IdentityUIConfigurationService identityUIConfigurationService;
@@ -215,10 +215,10 @@
private String generateEmailText(String templateLocation, Map<String, String> mailData, Locale locale) throws IOException, TemplateException
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- URL config = tcl.getResource(TEMPLATE_PATH + templateLocation + TEMPLATE_PREFIX + locale.getLanguage() + "_" + locale.getCountry() + ".tpl");
+ URL config = tcl.getResource(TEMPLATE_PATH + templateLocation + TEMPLATE_PREFIX + "_" + locale.getLanguage() + "_" + locale.getCountry() + ".tpl");
if (config == null)
{
- config = tcl.getResource(TEMPLATE_PATH + templateLocation + TEMPLATE_PREFIX + locale.getLanguage() + ".tpl");
+ config = tcl.getResource(TEMPLATE_PATH + templateLocation + TEMPLATE_PREFIX + "_" + locale.getLanguage() + ".tpl");
}
if (config == null)
{
@@ -226,7 +226,7 @@
}
if (config == null)
{
- throw new FileNotFoundException("Cannot load a suitable email templte in: " + TEMPLATE_PATH);
+ throw new FileNotFoundException("Cannot load a suitable email template in: " + TEMPLATE_PATH);
}
InputStream in = config.openStream();
18 years, 1 month