Author: amarkhel
Date: 2009-02-12 12:53:13 -0500 (Thu, 12 Feb 2009)
New Revision: 12646
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java
Modified:
trunk/test-applications/realworld/web/pom.xml
trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/components.xml
trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/web.xml
Log:
Modified: trunk/test-applications/realworld/web/pom.xml
===================================================================
--- trunk/test-applications/realworld/web/pom.xml 2009-02-12 17:48:48 UTC (rev 12645)
+++ trunk/test-applications/realworld/web/pom.xml 2009-02-12 17:53:13 UTC (rev 12646)
@@ -16,6 +16,11 @@
<artifactId>metadata-extractor</artifactId>
<version>2.4.0-beta1</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8</version>
+ </dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java
(rev 0)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java 2009-02-12
17:53:13 UTC (rev 12646)
@@ -0,0 +1,135 @@
+package org.richfaces.realworld.fileupload;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+public class FileManagerTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ fileManager=new FileManager();
+ fileManager.setUploadRoot("C:/Upload/");
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+private byte[] image = new byte[40];
+ private FileManager fileManager;
+ public void testIsDirectoryPresent() {
+ fileManager.addDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ assertEquals(fileManager.isDirectoryPresent("amarkhel2"), false);
+ fileManager.deleteDirectory("amarkhel");
+ }
+
+ public void testDeleteDirectory() {
+ fileManager.addDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ fileManager.deleteDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
+ }
+
+ public void testRenameDirectory() throws Exception {
+ fileManager.addDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ fileManager.renameDirectory("amarkhel", "amarkhel2");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
+ assertEquals(fileManager.isDirectoryPresent("amarkhel2"), true);
+ fileManager.deleteDirectory("amarkhel2");
+ }
+
+ public void testRenameDirectory2(){
+ fileManager.addDirectory("amarkhel");
+ fileManager.addDirectory("amarkhel2");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ try {
+ fileManager.renameDirectory("amarkhel", "amarkhel2");
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ assertEquals(fileManager.isDirectoryPresent("amarkhel2"), true);
+ fileManager.deleteDirectory("amarkhel");
+ fileManager.deleteDirectory("amarkhel2");
+ }
+
+ public void testRenameDirectory3() throws Exception {
+ fileManager.addDirectory("a"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"),
true);
+ fileManager.renameDirectory("a"+System.getProperty("file.separator")+"amarkhel",
"b"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"),
false);
+ assertEquals(fileManager.isDirectoryPresent("b"+System.getProperty("file.separator")+"amarkhel"),
true);
+ fileManager.deleteDirectory("b"+System.getProperty("file.separator")+"amarkhel");
+ }
+
+ public void testRenameDirectory4() throws Exception {
+ fileManager.addDirectory("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel"),
true);
+ fileManager.renameDirectory("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel",
"b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel"),
false);
+ assertEquals(fileManager.isDirectoryPresent("b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel"),
true);
+ fileManager.deleteDirectory("b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel");
+ }
+
+ public void testAddDirectory() {
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
+ fileManager.addDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ fileManager.deleteDirectory("amarkhel");
+ }
+
+ public void testAddDirectory2() {
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"),
false);
+ fileManager.addDirectory("a"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"),
true);
+ fileManager.deleteDirectory("a"+System.getProperty("file.separator")+"amarkhel");
+ }
+
+ public void testAddImage() throws IOException {
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
+ fileManager.addImage("amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
+ fileManager.deleteImage("amarkhel.gif");
+ }
+
+ public void testDeleteImage() throws IOException {
+ fileManager.addImage("amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
+ fileManager.deleteImage("amarkhel.gif");
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
+ }
+
+ public void testRenameImage() throws IOException {
+ fileManager.addImage("amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
+ fileManager.renameImage("amarkhel.gif", "amarkhel2.gif");
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
+ assertEquals(fileManager.isImagePresent("amarkhel2.gif"), true);
+ fileManager.deleteImage("amarkhel2.gif");
+ }
+
+ public void testRenameImage2() throws IOException {
+ fileManager.addImage("a"+System.getProperty("file.separator")+"amarkhel.gif",
image);
+ assertEquals(fileManager.isImagePresent("a"+System.getProperty("file.separator")+"amarkhel.gif"),
true);
+ fileManager.renameImage("a"+System.getProperty("file.separator")+"amarkhel.gif",
"b"+System.getProperty("file.separator")+"amarkhel2.gif");
+ assertEquals(fileManager.isImagePresent("a"+System.getProperty("file.separator")+"amarkhel.gif"),
false);
+ assertEquals(fileManager.isImagePresent("b"+System.getProperty("file.separator")+"amarkhel2.gif"),
true);
+ fileManager.deleteImage("b"+System.getProperty("file.separator")+"amarkhel2.gif");
+ fileManager.deleteDirectory("b");
+ fileManager.deleteDirectory("a");
+ }
+
+ public void testIsImagePresent() throws IOException {
+ fileManager.addImage("amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
+ assertEquals(fileManager.isImagePresent("amarkhel3.gif"), false);
+ fileManager.deleteImage("amarkhel.gif");
+ fileManager.addImage("am"+System.getProperty("file.separator")+"amarkhel.gif",
image);
+ assertEquals(fileManager.isImagePresent("am"+System.getProperty("file.separator")+"amarkhel.gif"),
true);
+ fileManager.deleteImage("am"+System.getProperty("file.separator")+"amarkhel.gif");
+ fileManager.deleteDirectory("am");
+ }
+
+}
Property changes on:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/components.xml
===================================================================
---
trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/components.xml 2009-02-12
17:48:48 UTC (rev 12645)
+++
trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/components.xml 2009-02-12
17:53:13 UTC (rev 12646)
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<components
xmlns="http://jboss.com/products/seam/components"
-
xmlns:core="http://jboss.com/products/seam/core"
-
xmlns:persistence="http://jboss.com/products/seam/persistence"
-
xmlns:drools="http://jboss.com/products/seam/drools"
-
xmlns:bpm="http://jboss.com/products/seam/bpm"
-
xmlns:security="http://jboss.com/products/seam/security"
-
xmlns:mail="http://jboss.com/products/seam/mail"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:transaction="http://jboss.com/products/seam/transaction"
-
xmlns:web="http://jboss.com/products/seam/web"
- xsi:schemaLocation=
- "http://jboss.com/products/seam/core
http://jboss.com/products/seam/core-2.1.0.xsd
+
xmlns:core="http://jboss.com/products/seam/core"
+
xmlns:persistence="http://jboss.com/products/seam/persistence"
+
xmlns:drools="http://jboss.com/products/seam/drools"
+
xmlns:bpm="http://jboss.com/products/seam/bpm"
+
xmlns:security="http://jboss.com/products/seam/security"
+
xmlns:mail="http://jboss.com/products/seam/mail"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xmlns:transaction="http://jboss.com/products/seam/transaction"
+
xmlns:web="http://jboss.com/products/seam/web"
+
xsi:schemaLocation="http://jboss.com/products/seam/core
http://jboss.com/products/seam/core-2.1.0.xsd
http://jboss.com/products/seam/web
http://jboss.com/products/seam/web-2.1.0.xsd
http://jboss.com/products/seam/transaction
http://jboss.com/products/seam/transaction-2.1.0.xsd
http://jboss.com/products/seam/persistence
http://jboss.com/products/seam/persistence-2.1.0.xsd
@@ -20,23 +19,25 @@
http://jboss.com/products/seam/mail
http://jboss.com/products/seam/mail-2.1.0.xsd
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-2.1.0.xsd">
- <core:init transaction-management-enabled="false" debug="true"
jndi-pattern="@jndiPattern@"/>
- <web:context-filter url-pattern="/picture/*" />
- <web:character-encoding-filter encoding="UTF-8"
override-client="true" url-pattern="*.seam" />
- <core:manager concurrent-request-timeout="20000"
- conversation-timeout="120000"
- conversation-id-parameter="cid"
- default-flush-mode="MANUAL"/>
- <persistence:managed-persistence-context
name="entityManager"
- auto-create="true"
-
persistence-unit-jndi-name="java:/realWorldEntityManager"/>
- <transaction:ejb-transaction />
- <security:identity
authenticate-method="#{authenticator.authenticate}"/>
- <event type="org.jboss.seam.security.notLoggedIn">
- <action execute="#{redirect.captureCurrentView}"/>
- <action execute="#{identity.tryLogin()}"/>
- </event>
- <event type="org.jboss.seam.security.loginSuccessful">
- <action execute="#{redirect.returnToCapturedView}"/>
- </event>
-</components>
+ <core:init transaction-management-enabled="false" debug="true"
+ jndi-pattern="@jndiPattern@" />
+ <web:context-filter url-pattern="/picture/*" />
+ <web:character-encoding-filter encoding="UTF-8"
+ override-client="true" url-pattern="*.seam" />
+ <core:manager concurrent-request-timeout="20000"
+ conversation-timeout="120000" conversation-id-parameter="cid"
+ default-flush-mode="MANUAL" />
+ <persistence:managed-persistence-context name="entityManager"
+ auto-create="true"
+ persistence-unit-jndi-name="java:/realWorldEntityManager" />
+ <transaction:ejb-transaction />
+ <security:identity
+ authenticate-method="#{authenticator.authenticate}" />
+ <event type="org.jboss.seam.security.notLoggedIn">
+ <action execute="#{redirect.captureCurrentView}" />
+ <action execute="#{identity.tryLogin()}" />
+ </event>
+ <event type="org.jboss.seam.security.loginSuccessful">
+ <action execute="#{redirect.returnToCapturedView}" />
+ </event>
+</components>
\ No newline at end of file
Modified: trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/web.xml 2009-02-12
17:48:48 UTC (rev 12645)
+++ trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/web.xml 2009-02-12
17:53:13 UTC (rev 12646)
@@ -4,8 +4,26 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
- <!-- Ajax4jsf -->
+
+
+ <listener>
+ <listener-class>
+ org.jboss.seam.servlet.SeamListener
+ </listener-class>
+ </listener>
+
<filter>
+ <filter-name>Seam Filter</filter-name>
+ <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Seam Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+<!-- Ajax4jsf -->
+ <filter>
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
@@ -30,23 +48,6 @@
</context-param>
<!-- Seam -->
-
- <listener>
- <listener-class>
- org.jboss.seam.servlet.SeamListener
- </listener-class>
- </listener>
-
- <filter>
- <filter-name>Seam Filter</filter-name>
- <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>Seam Filter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>