Author: nbelaevski
Date: 2007-04-08 17:37:27 -0400 (Sun, 08 Apr 2007)
New Revision: 57
Added:
trunk/test/src/main/java/org/ajax4jsf/tests/MockViewRoot.java
Modified:
trunk/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
trunk/test/src/main/java/org/ajax4jsf/tests/MockViewHandler.java
Log:
Test environment modifications to handle requestContextPath properly
MockViewRoot class added
Modified: trunk/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
--- trunk/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-04-08
15:01:42 UTC (rev 56)
+++ trunk/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-04-08
21:37:27 UTC (rev 57)
@@ -44,7 +44,6 @@
import javax.servlet.http.HttpServletResponse;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxViewRoot;
import org.ajax4jsf.framework.renderer.AjaxViewRootRenderer;
import org.ajax4jsf.framework.renderer.ChameleonRenderKitImpl;
import org.ajax4jsf.framework.resource.InternetResource;
@@ -107,7 +106,7 @@
vcpRenderKitFactory.addRenderKit("HTML_CHAMELEON", vcpRenderKit);
renderKit.addRenderer(UIViewRoot.COMPONENT_FAMILY, UIViewRoot.COMPONENT_TYPE, new
AjaxViewRootRenderer());
// setup nessesary components.
- application.addComponent("javax.faces.ViewRoot",
AjaxViewRoot.class.getName());
+ application.addComponent("javax.faces.ViewRoot",
MockViewRoot.class.getName());
// setup AjaxContext.
ajaxContext = new AjaxContext();
request.setAttribute(AjaxContext.AJAX_CONTEXT_KEY, ajaxContext);
@@ -189,9 +188,11 @@
webConnection = new MockWebConnection(webClient) {
public WebResponse getResponse(WebRequestSettings settings)
throws IOException {
- if
(settings.getURL().getFile().startsWith(AbstractAjax4JsfTestCase.SLASHED_RESOURCE_URI_PREFIX))
{
+ String testResourceContextPath =
facesContext.getExternalContext().getRequestContextPath() +
+ AbstractAjax4JsfTestCase.SLASHED_RESOURCE_URI_PREFIX;
+ if (settings.getURL().getFile().startsWith(testResourceContextPath)) {
InternetResource resource = InternetResourceBuilder.getInstance().getResource(
- settings.getURL().getFile().substring(AbstractAjax4JsfTestCase.SLASHED_RESOURCE_URI_PREFIX.length()));
+ settings.getURL().getFile().substring(testResourceContextPath.length()));
final MockFacesResourceContext resourceContext = new
MockFacesResourceContext(facesContext);
resource.sendHeaders(resourceContext);
@@ -407,7 +408,7 @@
*/
protected Page processResponse() throws Exception {
setupWebClient();
- URL page = new URL( "http:"+facesContext.getViewRoot().getViewId());
+ URL page = new URL( "http:"+
facesContext.getExternalContext().getRequestContextPath() +
facesContext.getViewRoot().getViewId());
try {
char[] content = ((MockPrintWriter) response.getWriter()).content();
webConnection.setResponse(page,String.valueOf(content),response.getStatus(),
"OK", response.getContentType(), Collections.EMPTY_LIST);
Modified: trunk/test/src/main/java/org/ajax4jsf/tests/MockViewHandler.java
===================================================================
--- trunk/test/src/main/java/org/ajax4jsf/tests/MockViewHandler.java 2007-04-08 15:01:42
UTC (rev 56)
+++ trunk/test/src/main/java/org/ajax4jsf/tests/MockViewHandler.java 2007-04-08 21:37:27
UTC (rev 57)
@@ -38,11 +38,4 @@
//System.out.println(".writeState()");
}
- public String getResourceURL(FacesContext context, String url) {
- return url;
- }
-
- public String getActionURL(FacesContext context, String url) {
- return url;
- }
}
\ No newline at end of file
Added: trunk/test/src/main/java/org/ajax4jsf/tests/MockViewRoot.java
===================================================================
--- trunk/test/src/main/java/org/ajax4jsf/tests/MockViewRoot.java
(rev 0)
+++ trunk/test/src/main/java/org/ajax4jsf/tests/MockViewRoot.java 2007-04-08 21:37:27 UTC
(rev 57)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.framework.ajax.AjaxViewRoot;
+import org.apache.commons.collections.Buffer;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 08.04.2007
+ *
+ */
+public class MockViewRoot extends AjaxViewRoot {
+
+ public Buffer getAjaxEventsQueue(FacesContext context) {
+ return super.getAjaxEventsQueue(context);
+ }
+
+ public Buffer[] getEvents(FacesContext context) {
+ return super.getEvents(context);
+ }
+
+ public Buffer getEventsQueue(FacesContext context, PhaseId phase) {
+ return super.getEventsQueue(context, phase);
+ }
+
+}