Author: alexsmirnov
Date: 2008-11-13 19:42:12 -0500 (Thu, 13 Nov 2008)
New Revision: 11159
Added:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
Removed:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
branches/jsf2.0/tests/ajax/pom.xml
Log:
rename stub package to staging.
Test resources search.
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-13
23:58:13 UTC (rev 11158)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/StagingServer.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -37,6 +37,7 @@
import org.richfaces.test.staging.StagingHttpSession;
import org.richfaces.test.staging.StagingServletContext;
import org.richfaces.test.staging.StaticServlet;
+import org.richfaces.test.staging.UrlServerResource;
/**
@@ -193,6 +194,10 @@
serverRoot.addResource(new ServerResourcePath(path), new
ClasspathServerResource(resource));
}
+ public void addResource(String path, URL resource){
+ serverRoot.addResource(new ServerResourcePath(path), new UrlServerResource(resource));
+ }
+
public void addWebListener(EventListener listener) {
contextListeners.add(listener);
}
Added:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -0,0 +1,53 @@
+package org.richfaces.test.staging;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Collections;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.richfaces.test.ServerLogger;
+
+public abstract class AbstractServerResource implements ServerResource {
+
+ private static final Logger log = ServerLogger.RESOURCE.getLogger();
+
+ public AbstractServerResource() {
+ }
+
+ public InputStream getAsStream() throws IOException {
+ URL url = getURL();
+ if (url != null) {
+ URLConnection connection = url.openConnection();
+ try {
+ connection.setUseCaches(false);
+ } catch (IllegalArgumentException e) {
+ log.info("RESOURCE_NOT_CACHEABLE");
+ }
+ return connection.getInputStream();
+ } else {
+ return null;
+ }
+ }
+
+ public void addResource(ServerResourcePath path, ServerResource resource) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServerResource getResource(ServerResourcePath path) {
+ if(null == path){
+ throw new NullPointerException();
+ }
+ if(path.isFile()){
+ return this;
+ }
+ return null;
+ }
+
+ public Set<String> getPaths() {
+ return Collections.emptySet();
+ }
+
+}
\ No newline at end of file
Property changes on:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java 2008-11-13
23:58:13 UTC (rev 11158)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -20,7 +20,7 @@
* @author asmirnov
*
*/
-public class ClasspathServerResource implements ServerResource {
+public class ClasspathServerResource extends AbstractServerResource {
private final String classpath;
@@ -36,53 +36,6 @@
}
/* (non-Javadoc)
- * @see
org.richfaces.test.staging.ServerResource#addResource(org.richfaces.test.staging.ServerResource)
- */
- public void addResource(ServerResourcePath path, ServerResource resource) {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see
org.richfaces.test.staging.ServerResource#getResource(org.richfaces.test.staging.ServerResourcePath)
- */
- public ServerResource getResource(ServerResourcePath path) {
- if(null == path){
- throw new NullPointerException();
- }
- if(path.isFile()){
- return this;
- }
- return null;
- }
- /* (non-Javadoc)
- * @see org.richfaces.test.staging.ServerResource#getPaths()
- */
- public Set<String> getPaths() {
- return Collections.emptySet();
- }
-
-
-
- /* (non-Javadoc)
- * @see org.richfaces.test.staging.ServerResource#getAsStream()
- */
- public InputStream getAsStream() throws IOException {
- URL url = getURL();
- if (url != null) {
- URLConnection connection = url.openConnection();
- try {
- connection.setUseCaches(false);
- } catch (IllegalArgumentException e) {
- log.info("RESOURCE_NOT_CACHEABLE");
- }
- return connection.getInputStream();
- } else {
- return null;
- }
- }
-
-
- /* (non-Javadoc)
* @see org.richfaces.test.staging.ServerResource#getURL()
*/
public URL getURL() {
Added:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -0,0 +1,12 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class URLScanner {
+
+}
Property changes on:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/URLScanner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -0,0 +1,32 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import java.net.URL;
+import java.util.logging.Logger;
+
+import org.richfaces.test.ServerLogger;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class UrlServerResource extends AbstractServerResource {
+
+ private final URL resource;
+
+ static final Logger log = ServerLogger.RESOURCE.getLogger();
+
+ public UrlServerResource(URL resource) {
+ this.resource = resource;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.test.staging.ServerResource#getURL()
+ */
+ public URL getURL() {
+ return resource;
+ }
+
+}
Property changes on:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/UrlServerResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging (from
rev 11094, branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub)
Deleted:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServerResourcePathTest.java 2008-11-11
20:12:38 UTC (rev 11094)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -1,87 +0,0 @@
-/**
- *
- */
-package org.richfaces.test.stub;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-/**
- * @author asmirnov
- *
- */
-public class ServerResourcePathTest {
-
- /**
- * Test method for {@link
org.richfaces.test.stub.ServerResourcePath#ServerResourcePath(java.lang.String)}.
- */
- @Test
- public void testRootPath() {
- ServerResourcePath path = new ServerResourcePath("/");
- assertNull(path.getNextPath());
- assertNull(path.getNextElementName());
- assertTrue(path.isFile());
- assertEquals("/", path.toString());
- }
-
- /**
- * Test method for {@link
org.richfaces.test.stub.ServerResourcePath#ServerResourcePath(java.lang.String)}.
- */
- @Test
- public void testWebInfPath() {
- ServerResourcePath path = ServerResourcePath.WEB_INF;
- assertNotNull(path.getNextPath());
- assertNotNull(path.getNextElementName());
- assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
- assertEquals("/WEB-INF", path.toString());
- path = path.getNextPath();
- assertNotNull(path);
- assertTrue(path.isFile());
- path = path.getNextPath();
- assertNull(path);
- }
-
- /**
- * Test method for {@link
org.richfaces.test.stub.ServerResourcePath#ServerResourcePath(java.lang.String)}.
- */
- @Test
- public void testWebInfTrainingSlashPath() {
- ServerResourcePath path = new ServerResourcePath("/WEB-INF/");
- assertNotNull(path.getNextPath());
- assertNotNull(path.getNextElementName());
- assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
- assertEquals("/WEB-INF", path.toString());
- path = path.getNextPath();
- assertNotNull(path);
- assertTrue(path.isFile());
- path = path.getNextPath();
- assertNull(path);
- }
-
-
- /**
- * Test method for {@link
org.richfaces.test.stub.ServerResourcePath#ServerResourcePath(java.lang.String)}.
- */
- @Test
- public void testWebXmlPath() {
- ServerResourcePath path = ServerResourcePath.WEB_XML;
- assertFalse(path.isFile());
- assertEquals("WEB-INF", path.getNextElementName());
- assertEquals("/WEB-INF/web.xml", path.toString());
- path = path.getNextPath();
- assertNotNull(path.getNextElementName());
- assertFalse(path.isFile());
- assertEquals("web.xml", path.getNextElementName());
- assertEquals("/web.xml", path.toString());
- path = path.getNextPath();
- assertNotNull(path);
- assertTrue(path.isFile());
- path = path.getNextPath();
- assertNull(path);
- }
-
-
-}
Copied:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
(from rev 11158,
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServerResourcePathTest.java)
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.richfaces.test.staging.ServerResourcePath;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ServerResourcePathTest {
+
+ /**
+ * Test method for {@link
org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+ */
+ @Test
+ public void testRootPath() {
+ ServerResourcePath path = new ServerResourcePath("/");
+ assertNull(path.getNextPath());
+ assertNull(path.getNextElementName());
+ assertTrue(path.isFile());
+ assertEquals("/", path.toString());
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+ */
+ @Test
+ public void testWebInfPath() {
+ ServerResourcePath path = ServerResourcePath.WEB_INF;
+ assertNotNull(path.getNextPath());
+ assertNotNull(path.getNextElementName());
+ assertFalse(path.isFile());
+ assertEquals("WEB-INF", path.getNextElementName());
+ assertEquals("/WEB-INF", path.toString());
+ path = path.getNextPath();
+ assertNotNull(path);
+ assertTrue(path.isFile());
+ path = path.getNextPath();
+ assertNull(path);
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+ */
+ @Test
+ public void testWebInfTrainingSlashPath() {
+ ServerResourcePath path = new ServerResourcePath("/WEB-INF/");
+ assertNotNull(path.getNextPath());
+ assertNotNull(path.getNextElementName());
+ assertFalse(path.isFile());
+ assertEquals("WEB-INF", path.getNextElementName());
+ assertEquals("/WEB-INF", path.toString());
+ path = path.getNextPath();
+ assertNotNull(path);
+ assertTrue(path.isFile());
+ path = path.getNextPath();
+ assertNull(path);
+ }
+
+
+ /**
+ * Test method for {@link
org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+ */
+ @Test
+ public void testWebXmlPath() {
+ ServerResourcePath path = ServerResourcePath.WEB_XML;
+ assertFalse(path.isFile());
+ assertEquals("WEB-INF", path.getNextElementName());
+ assertEquals("/WEB-INF/web.xml", path.toString());
+ path = path.getNextPath();
+ assertNotNull(path.getNextElementName());
+ assertFalse(path.isFile());
+ assertEquals("web.xml", path.getNextElementName());
+ assertEquals("/web.xml", path.toString());
+ path = path.getNextPath();
+ assertNotNull(path);
+ assertTrue(path.isFile());
+ path = path.getNextPath();
+ assertNull(path);
+ }
+
+
+}
Deleted:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServerResourceTest.java 2008-11-11
20:12:38 UTC (rev 11094)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -1,141 +0,0 @@
-/**
- *
- */
-package org.richfaces.test.stub;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Set;
-
-import org.junit.Test;
-
-/**
- * @author asmirnov
- *
- */
-public class ServerResourceTest {
-
- private class MockResource implements ServerResource {
-
- public void addResource(ServerResourcePath path, ServerResource resource) {
- }
-
- public InputStream getAsStream() throws IOException {
- return null;
- }
-
- public Set<String> getPaths() {
- return null;
- }
-
- public ServerResource getResource(ServerResourcePath path) {
- if (null != path && path.isFile()) {
- return this;
- }
- return null;
- }
-
- public URL getURL() {
- return null;
- }
-
- }
-
- /**
- * Test method for
- * {@link
org.richfaces.test.stub.ServerResourcesDirectory#addResource(org.richfaces.test.stub.ServerResourcePath,
org.richfaces.test.stub.ServerResource)}
- * .
- */
- @Test
- public void testAddResource() {
- ServerResourcesDirectory root = new ServerResourcesDirectory();
- MockResource webXml = new MockResource();
- root.addResource(ServerResourcePath.WEB_XML, webXml);
- assertEquals(1, root.getPaths().size());
- MockResource facesConfig = new MockResource();
- root.addResource(ServerResourcePath.FACES_CONFIG, facesConfig);
- assertEquals(1, root.getPaths().size());
- ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
- assertNotNull(webInf);
- assertEquals(2, webInf.getPaths().size());
- assertSame(webXml, webInf
- .getResource(new ServerResourcePath("/web.xml")));
- assertSame(facesConfig, webInf.getResource(new ServerResourcePath(
- "/faces-config.xml")));
- }
-
- /**
- * Test method for
- * {@link
org.richfaces.test.stub.ServerResourcesDirectory#getResource(org.richfaces.test.stub.ServerResourcePath)}
- * .
- */
- @Test
- public void testGetResource() {
- ServerResourcesDirectory root = new ServerResourcesDirectory();
- MockResource webXml = new MockResource();
- root.addResource(ServerResourcePath.WEB_XML, webXml);
- ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
- assertNotNull(webInf);
- assertNull(root.getResource(new ServerResourcePath("/foo")));
- assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
- assertEquals(1, root.getPaths().size());
- assertNull(root.getResource(new ServerResourcePath(
- "/WEB-INF/web.xml/foo")));
- assertSame(webXml, webInf.getResource(new ServerResourcePath(
- "/web.xml")));
- }
-
- /**
- * Test method for
- * {@link
org.richfaces.test.stub.ServerResourcesDirectory#getResource(org.richfaces.test.stub.ServerResourcePath)}
- * .
- */
- @Test
- public void testGetResourceRoot() {
- ServerResourcesDirectory root = new ServerResourcesDirectory();
- MockResource indexXhtml = new MockResource();
- root.addResource(new ServerResourcePath("/index.xhtml"), indexXhtml);
- ServerResource index = root.getResource(new
ServerResourcePath("/index.xhtml"));
- assertNotNull(index);
- assertNull(root.getResource(new ServerResourcePath("/foo")));
- assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
- assertEquals(1, root.getPaths().size());
- }
-
- /**
- * Test method for
- * {@link org.richfaces.test.stub.ServerResourcesDirectory#getAsStream()}.
- *
- * @throws IOException
- */
- @Test
- public void testGetAsStream() throws IOException {
- ClasspathServerResource resource = new ClasspathServerResource(
- "org/richfaces/test/resource.txt");
- InputStream inputStream = resource.getAsStream();
- assertNotNull(inputStream);
- try {
- byte[] buff = new byte[20];
- assertEquals(3, inputStream.read(buff));
-
- } finally {
- inputStream.close();
- }
- }
-
-
- /**
- * Test method for
- * {@link org.richfaces.test.stub.ServerResourcesDirectory#getURL()}.
- */
- @Test
- public void testGetURL() {
- ClasspathServerResource resource = new ClasspathServerResource(
- "org/richfaces/test/resource.txt");
- assertNotNull(resource.getURL());
- }
-
-}
Copied:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
(from rev 11158,
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServerResourceTest.java)
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServerResourceTest.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -0,0 +1,145 @@
+/**
+ *
+ */
+package org.richfaces.test.staging;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Set;
+
+import org.junit.Test;
+import org.richfaces.test.staging.ClasspathServerResource;
+import org.richfaces.test.staging.ServerResource;
+import org.richfaces.test.staging.ServerResourcePath;
+import org.richfaces.test.staging.ServerResourcesDirectory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ServerResourceTest {
+
+ private class MockResource implements ServerResource {
+
+ public void addResource(ServerResourcePath path, ServerResource resource) {
+ }
+
+ public InputStream getAsStream() throws IOException {
+ return null;
+ }
+
+ public Set<String> getPaths() {
+ return null;
+ }
+
+ public ServerResource getResource(ServerResourcePath path) {
+ if (null != path && path.isFile()) {
+ return this;
+ }
+ return null;
+ }
+
+ public URL getURL() {
+ return null;
+ }
+
+ }
+
+ /**
+ * Test method for
+ * {@link
org.richfaces.test.staging.ServerResourcesDirectory#addResource(org.richfaces.test.staging.ServerResourcePath,
org.richfaces.test.staging.ServerResource)}
+ * .
+ */
+ @Test
+ public void testAddResource() {
+ ServerResourcesDirectory root = new ServerResourcesDirectory();
+ MockResource webXml = new MockResource();
+ root.addResource(ServerResourcePath.WEB_XML, webXml);
+ assertEquals(1, root.getPaths().size());
+ MockResource facesConfig = new MockResource();
+ root.addResource(ServerResourcePath.FACES_CONFIG, facesConfig);
+ assertEquals(1, root.getPaths().size());
+ ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
+ assertNotNull(webInf);
+ assertEquals(2, webInf.getPaths().size());
+ assertSame(webXml, webInf
+ .getResource(new ServerResourcePath("/web.xml")));
+ assertSame(facesConfig, webInf.getResource(new ServerResourcePath(
+ "/faces-config.xml")));
+ }
+
+ /**
+ * Test method for
+ * {@link
org.richfaces.test.staging.ServerResourcesDirectory#getResource(org.richfaces.test.staging.ServerResourcePath)}
+ * .
+ */
+ @Test
+ public void testGetResource() {
+ ServerResourcesDirectory root = new ServerResourcesDirectory();
+ MockResource webXml = new MockResource();
+ root.addResource(ServerResourcePath.WEB_XML, webXml);
+ ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
+ assertNotNull(webInf);
+ assertNull(root.getResource(new ServerResourcePath("/foo")));
+ assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
+ assertEquals(1, root.getPaths().size());
+ assertNull(root.getResource(new ServerResourcePath(
+ "/WEB-INF/web.xml/foo")));
+ assertSame(webXml, webInf.getResource(new ServerResourcePath(
+ "/web.xml")));
+ }
+
+ /**
+ * Test method for
+ * {@link
org.richfaces.test.staging.ServerResourcesDirectory#getResource(org.richfaces.test.staging.ServerResourcePath)}
+ * .
+ */
+ @Test
+ public void testGetResourceRoot() {
+ ServerResourcesDirectory root = new ServerResourcesDirectory();
+ MockResource indexXhtml = new MockResource();
+ root.addResource(new ServerResourcePath("/index.xhtml"), indexXhtml);
+ ServerResource index = root.getResource(new
ServerResourcePath("/index.xhtml"));
+ assertNotNull(index);
+ assertNull(root.getResource(new ServerResourcePath("/foo")));
+ assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
+ assertEquals(1, root.getPaths().size());
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.test.staging.ServerResourcesDirectory#getAsStream()}.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testGetAsStream() throws IOException {
+ ClasspathServerResource resource = new ClasspathServerResource(
+ "org/richfaces/test/resource.txt");
+ InputStream inputStream = resource.getAsStream();
+ assertNotNull(inputStream);
+ try {
+ byte[] buff = new byte[20];
+ assertEquals(3, inputStream.read(buff));
+
+ } finally {
+ inputStream.close();
+ }
+ }
+
+
+ /**
+ * Test method for
+ * {@link org.richfaces.test.staging.ServerResourcesDirectory#getURL()}.
+ */
+ @Test
+ public void testGetURL() {
+ ClasspathServerResource resource = new ClasspathServerResource(
+ "org/richfaces/test/resource.txt");
+ assertNotNull(resource.getURL());
+ }
+
+}
Deleted:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServletTest.java 2008-11-11
20:12:38 UTC (rev 11094)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -1,87 +0,0 @@
-package org.richfaces.test.stub;
-
-import static org.junit.Assert.*;
-
-import javax.servlet.ServletContextAttributeEvent;
-import javax.servlet.ServletException;
-
-import org.junit.Test;
-
-public class ServletTest {
-
- @Test
- public void testIsApplicable() {
- StaticServlet staticServlet = new StaticServlet();
- ServletContainer servlet = new ServletContainer("/foo/*",staticServlet);
- assertTrue(servlet.isApplicable("/foo/bar.jsf"));
- assertFalse(servlet.isApplicable("/foz/bar.jsf"));
- assertFalse(servlet.isApplicable("bar"));
- servlet = new ServletContainer("*.jsf",staticServlet);
- assertTrue(servlet.isApplicable("/foo/bar.jsf"));
- assertFalse(servlet.isApplicable("bar"));
- try {
- servlet = new ServletContainer(".jsf",staticServlet);
- } catch (IllegalArgumentException e) {
- return;
- }
- assertFalse(true);
- }
-
- @Test
- public void testGetServletPath() {
- StaticServlet staticServlet = new StaticServlet();
- ServletContainer servlet = new ServletContainer("/foo/*",staticServlet);
- assertEquals("/foo/", servlet.getServletPath("/foo/bar.jsf"));
- assertNull(servlet.getServletPath("/foz/bar.jsf"));
- servlet = new ServletContainer("*.jsf",staticServlet);
- assertEquals("/foo/bar.jsf",
servlet.getServletPath("/foo/bar.jsf"));
- }
-
- @Test
- public void testGetPathInfo() {
- StaticServlet staticServlet = new StaticServlet();
- ServletContainer servlet = new ServletContainer("/foo/*",staticServlet);
- assertEquals("bar.jsf", servlet.getPathInfo("/foo/bar.jsf"));
- assertNull(servlet.getPathInfo("/foz/bar.jsf"));
- servlet = new ServletContainer("*.jsf",staticServlet);
- assertNull(servlet.getPathInfo("/foo/bar.jsf"));
-
- }
-
- @Test
- public void testInit() throws ServletException {
- StaticServlet staticServlet = new StaticServlet();
- ServletContainer servlet = new ServletContainer("/foo/*",staticServlet);
- StubServletContext context = new StubServletContext(){
-
- @Override
- protected ServerResource getServerResource(String path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected void valueBound(ServletContextAttributeEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void valueReplaced(ServletContextAttributeEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void valueUnbound(
- ServletContextAttributeEvent servletContextAttributeEvent) {
- // TODO Auto-generated method stub
-
- }
-
- };
- servlet.init(context);
- assertSame(context,staticServlet.getServletContext());
- }
-
-}
Copied:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
(from rev 11158,
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/stub/ServletTest.java)
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/ServletTest.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -0,0 +1,92 @@
+package org.richfaces.test.staging;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletException;
+
+import org.junit.Test;
+import org.richfaces.test.staging.RequestChain;
+import org.richfaces.test.staging.ServerResource;
+import org.richfaces.test.staging.ServletContainer;
+import org.richfaces.test.staging.StaticServlet;
+import org.richfaces.test.staging.StagingServletContext;
+
+public class ServletTest {
+
+ @Test
+ public void testIsApplicable() {
+ StaticServlet staticServlet = new StaticServlet();
+ RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
+ assertTrue(servlet.isApplicable("/foo/bar.jsf"));
+ assertFalse(servlet.isApplicable("/foz/bar.jsf"));
+ assertFalse(servlet.isApplicable("bar"));
+ servlet = new ServletContainer("*.jsf",staticServlet);
+ assertTrue(servlet.isApplicable("/foo/bar.jsf"));
+ assertFalse(servlet.isApplicable("bar"));
+ try {
+ servlet = new ServletContainer(".jsf",staticServlet);
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+ assertFalse(true);
+ }
+
+ @Test
+ public void testGetServletPath() {
+ StaticServlet staticServlet = new StaticServlet();
+ RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
+ assertEquals("/foo/", servlet.getServletPath("/foo/bar.jsf"));
+ assertNull(servlet.getServletPath("/foz/bar.jsf"));
+ servlet = new ServletContainer("*.jsf",staticServlet);
+ assertEquals("/foo/bar.jsf",
servlet.getServletPath("/foo/bar.jsf"));
+ }
+
+ @Test
+ public void testGetPathInfo() {
+ StaticServlet staticServlet = new StaticServlet();
+ RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
+ assertEquals("bar.jsf", servlet.getPathInfo("/foo/bar.jsf"));
+ assertNull(servlet.getPathInfo("/foz/bar.jsf"));
+ servlet = new ServletContainer("*.jsf",staticServlet);
+ assertNull(servlet.getPathInfo("/foo/bar.jsf"));
+
+ }
+
+ @Test
+ public void testInit() throws ServletException {
+ StaticServlet staticServlet = new StaticServlet();
+ RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
+ StagingServletContext context = new StagingServletContext(){
+
+ @Override
+ protected ServerResource getServerResource(String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void valueBound(ServletContextAttributeEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void valueReplaced(ServletContextAttributeEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void valueUnbound(
+ ServletContextAttributeEvent servletContextAttributeEvent) {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+ servlet.init(context);
+ assertSame(context,staticServlet.getServletContext());
+ }
+
+}
Added:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
===================================================================
---
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
(rev 0)
+++
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java 2008-11-14
00:42:12 UTC (rev 11159)
@@ -0,0 +1,76 @@
+package org.richfaces.test.staging;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.junit.Test;
+
+public class UrlResourceLoadingTest {
+
+ @Test
+ public void testGetURL() throws Exception {
+ URL resource =
this.getClass().getClassLoader().getResource("java/util/Set.class");
+ assertNotNull(resource);
+ System.out.println(resource.toExternalForm());
+ System.out.println(resource.getProtocol());
+ String path = resource.getPath();
+ System.out.println(path);
+ String entry = path.substring(path.indexOf('!')+2);
+ path = path.substring(0,path.indexOf('!'));
+ System.out.println(path+" entry: "+entry);
+ File file = new File(new URI(path));
+ ZipFile zip = new ZipFile(file);
+ ZipEntry zipEntry = zip.getEntry(entry);
+ assertNotNull(zipEntry);
+ Enumeration<? extends ZipEntry> entries = zip.entries();
+ entry = entry.substring(0, entry.lastIndexOf('/')+1);
+ while (entries.hasMoreElements()) {
+ ZipEntry zzz = (ZipEntry) entries.nextElement();
+ if(zzz.getName().startsWith(entry) && !zzz.isDirectory()){
+ String relativePath = zzz.getName().substring(entry.length());
+ System.out.println(" entry: "+relativePath);
+ URL relativeResource = new URL(resource,relativePath);
+ System.out.println(relativeResource.toExternalForm());
+
+ }
+ }
+ resource =
this.getClass().getClassLoader().getResource("org/richfaces/test/HelloBean.class");
+ assertNotNull(resource);
+ System.out.println(resource.toExternalForm());
+ System.out.println(resource.getProtocol());
+ System.out.println(resource.getPath());
+ System.out.println(resource.toExternalForm());
+ file = new File(resource.getPath());
+ if(!file.isDirectory()){
+ file = file.getParentFile();
+ }
+ listFiles("/",file);
+ resource =
this.getClass().getClassLoader().getResource("org/richfaces/test/");
+ assertNotNull(resource);
+ System.out.println(resource.toExternalForm());
+ }
+
+ private void listFiles(String path,File file) {
+ File[] files = file.listFiles();
+ for (File subfile : files) {
+ if(subfile.isDirectory()){
+ listFiles(path+subfile.getName()+"/",subfile);
+ } else {
+ System.out.println(path+subfile.getName());
+
+ }
+ }
+ }
+
+ @Test
+ public void testGetDirectory() {
+ }
+
+}
Property changes on:
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jsf2.0/tests/ajax/pom.xml
===================================================================
--- branches/jsf2.0/tests/ajax/pom.xml 2008-11-13 23:58:13 UTC (rev 11158)
+++ branches/jsf2.0/tests/ajax/pom.xml 2008-11-14 00:42:12 UTC (rev 11159)
@@ -79,5 +79,11 @@
<version>2.0.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>jstl</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file