Author: alexsmirnov
Date: 2009-03-27 20:31:19 -0400 (Fri, 27 Mar 2009)
New Revision: 13274
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java
Log:
minor improvements.
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2009-03-27
19:41:21 UTC (rev 13273)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2009-03-28
00:31:19 UTC (rev 13274)
@@ -6,12 +6,14 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.EventListener;
import java.util.Locale;
import java.util.Properties;
import java.util.logging.LogManager;
+import javax.faces.FacesException;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
@@ -255,8 +257,24 @@
* @throws Exception
*/
protected void setupFacesRequest() throws Exception {
+ String url = "http://localhost/test.jsf";
+ setupFacesRequest(url);
+ UIViewRoot viewRoot = setupView();
+ if (null != viewRoot) {
+ facesContext.setViewRoot(viewRoot);
+ }
+ }
+
+ /**
+ * <p class="changed_added_2_0"></p>
+ * @param url
+ * @throws MalformedURLException
+ * @throws FacesException
+ */
+ protected void setupFacesRequest(String url) throws MalformedURLException,
+ FacesException {
connection = facesServer.getConnection(new URL(
- "http://localhost/test.jsf"));
+ url));
setupConnection();
connection.start();
FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
@@ -264,10 +282,6 @@
facesContext = facesContextFactory.getFacesContext(facesServer
.getContext(), connection.getRequest(), connection
.getResponse(), lifecycle);
- UIViewRoot viewRoot = setupView();
- if (null != viewRoot) {
- facesContext.setViewRoot(viewRoot);
- }
}
/**
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2009-03-27
19:41:21 UTC (rev 13273)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2009-03-28
00:31:19 UTC (rev 13274)
@@ -178,6 +178,10 @@
public Set getResourcePaths(String path) {
HashSet result=null;
ServerResource resource = getServerResource(path);
+ if(null == resource && !path.endsWith("/")){
+ path+="/";
+ resource = getServerResource(path);
+ }
if(null != resource){
Set<String> paths = resource.getPaths();
if(null != paths && paths.size()>0){
Modified:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java 2009-03-27
19:41:21 UTC (rev 13273)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java 2009-03-28
00:31:19 UTC (rev 13274)
@@ -5,6 +5,7 @@
import static org.junit.Assert.*;
+import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -24,6 +25,7 @@
import org.junit.Test;
import org.w3c.dom.Element;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
@@ -69,8 +71,7 @@
*/
@Test
public void testHelloFacelets() throws Exception {
- WebClient webClient = new LocalWebClient(facesServer);
- HtmlPage page = webClient.getPage("http://localhost/hello.jsf");
+ HtmlPage page = getPage("/hello.jsf");
System.out.println(page.asXml());
Element submitElement = page.getElementById("helloForm:submit");
HtmlForm htmlForm = page.getFormByName("helloForm");
@@ -92,4 +93,17 @@
assertEquals("foo", span.getTextContent().trim());
}
+ /**
+ * <p class="changed_added_2_0"></p>
+ * @param url TODO
+ * @return
+ * @throws IOException
+ * @throws MalformedURLException
+ */
+ protected HtmlPage getPage(String url) throws Exception {
+ WebClient webClient = new LocalWebClient(facesServer);
+ HtmlPage page = webClient.getPage("http://localhost"+url);
+ return page;
+ }
+
}
Show replies by date