You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2018/01/17 13:28:10 UTC
[4/9] james-project git commit: JAMES-2286 Allow to clean
MockFileSystem
JAMES-2286 Allow to clean MockFileSystem
Note: conf special behaviour was kept
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/409dd0d0
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/409dd0d0
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/409dd0d0
Branch: refs/heads/master
Commit: 409dd0d0f5e87f7c9efdf46764027c780244c3dd
Parents: 2618edc
Author: benwa <bt...@linagora.com>
Authored: Mon Jan 15 11:03:43 2018 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Tue Jan 16 16:34:46 2018 +0100
----------------------------------------------------------------------
.../james/filesystem/api/mock/MockFileSystem.java | 16 ++++++++++++++--
.../org/apache/james/smtpserver/SMTPServerTest.java | 2 +-
2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/409dd0d0/server/container/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java
----------------------------------------------------------------------
diff --git a/server/container/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java b/server/container/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java
index f11d88f..857d938 100644
--- a/server/container/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java
+++ b/server/container/filesystem-api/src/test/java/org/apache/james/filesystem/api/mock/MockFileSystem.java
@@ -28,12 +28,20 @@ import java.net.URISyntaxException;
import java.net.URL;
import org.apache.james.filesystem.api.FileSystem;
+import org.junit.rules.TemporaryFolder;
public class MockFileSystem implements FileSystem {
+ private final TemporaryFolder temporaryFolder;
+
+ public MockFileSystem() throws IOException {
+ this.temporaryFolder = new TemporaryFolder();
+ temporaryFolder.create();
+ }
+
@Override
public File getBasedir() throws FileNotFoundException {
- return new File(".");
+ return temporaryFolder.getRoot();
}
@Override
@@ -54,7 +62,7 @@ public class MockFileSystem implements FileSystem {
}
// return new File("./src"+fileURL.substring(6));
} else {
- return new File(fileURL.substring(FileSystem.FILE_PROTOCOL.length()));
+ return new File(temporaryFolder.getRoot() + File.separator + fileURL.substring(FileSystem.FILE_PROTOCOL.length()));
}
} else {
throw new UnsupportedOperationException("getFile: " + fileURL);
@@ -63,4 +71,8 @@ public class MockFileSystem implements FileSystem {
throw new FileNotFoundException("NPE on: " + fileURL);
}
}
+
+ public void clear() {
+ temporaryFolder.delete();
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/409dd0d0/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index 7098438..3b2d869 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -217,7 +217,7 @@ public class SMTPServerTest {
smtpServer.init();
}
- protected void setUpFakeLoader() {
+ protected void setUpFakeLoader() throws IOException {
chain = new MockProtocolHandlerLoader();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org