james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r676010 - in /james/server/trunk/phoenix-deployment: pom.xml src/test/org/apache/james/mailrepository/MBoxMailRepositoryTest.java src/test/org/apache/james/test/mock/james/MockFileSystem.java
Date Fri, 11 Jul 2008 16:07:38 GMT
Author: bago
Date: Fri Jul 11 09:07:38 2008
New Revision: 676010

URL: http://svn.apache.org/viewvc?rev=676010&view=rev
Log:
Better reporting for non existent file in MockFileSystem, updated MBoxMailRepositoryTest to
be able to find its resources even under Eclipse.

Modified:
    james/server/trunk/phoenix-deployment/pom.xml
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailrepository/MBoxMailRepositoryTest.java
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java

Modified: james/server/trunk/phoenix-deployment/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/pom.xml?rev=676010&r1=676009&r2=676010&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/pom.xml (original)
+++ james/server/trunk/phoenix-deployment/pom.xml Fri Jul 11 09:07:38 2008
@@ -36,6 +36,7 @@
         <includes>
           <include>**/*.zone</include>
           <include>**/*.xml</include>
+          <include>**/Inbox</include>
         </includes>
       </testResource>
       <testResource>

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailrepository/MBoxMailRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailrepository/MBoxMailRepositoryTest.java?rev=676010&r1=676009&r2=676010&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailrepository/MBoxMailRepositoryTest.java
(original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/mailrepository/MBoxMailRepositoryTest.java
Fri Jul 11 09:07:38 2008
@@ -20,6 +20,7 @@
 
 package org.apache.james.mailrepository;
 
+import java.io.File;
 import java.util.Iterator;
 
 import junit.framework.TestCase;
@@ -29,6 +30,7 @@
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.james.services.MailRepository;
 import org.apache.james.test.mock.avalon.MockLogger;
+import org.apache.james.test.mock.james.MockFileSystem;
 
 /**
  * NOTE this test *WAS* disabled because MBoxMailRepository does not
@@ -45,7 +47,11 @@
 
         mr.enableLogging(new MockLogger());
         DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf");
-        defaultConfiguration.setAttribute("destinationURL","mbox://src/test/org/apache/james/mailrepository/testdata/Inbox");
+        
+        File fInbox = new MockFileSystem().getFile("file://conf/org/apache/james/mailrepository/testdata/Inbox");
+        String mboxPath = "mbox://"+fInbox.toURI().toString().substring(new File("").toURI().toString().length());
+        
+        defaultConfiguration.setAttribute("destinationURL",mboxPath);
         defaultConfiguration.setAttribute("type","MAIL");
         mr.configure(defaultConfiguration);
         return mr;

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java?rev=676010&r1=676009&r2=676010&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java
(original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java
Fri Jul 11 09:07:38 2008
@@ -37,14 +37,19 @@
     }
 
     public File getFile(String fileURL) throws FileNotFoundException {
-        if (fileURL.startsWith("file://")) {
-            if (fileURL.startsWith("file://conf/")) {
-                return new File("./src"+fileURL.substring(6));
+        try {
+            if (fileURL.startsWith("file://")) {
+                if (fileURL.startsWith("file://conf/")) {
+                    return new File(MockFileSystem.class.getClassLoader().getResource("./"+fileURL.substring(12)).getFile());
+                    // return new File("./src"+fileURL.substring(6));
+                } else {
+                    throw new UnsupportedOperationException("getFile: "+fileURL);
+                }
             } else {
                 throw new UnsupportedOperationException("getFile: "+fileURL);
             }
-        } else {
-            throw new UnsupportedOperationException("getFile: "+fileURL);
+        } catch (NullPointerException npe) {
+            throw new FileNotFoundException("NPE on: "+fileURL);
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message