mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Added dependency injections for FileUtils and removed redundant code
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.inject.AbstractModule;
|
||||
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.api.system.FileUtils;
|
||||
import org.briarproject.system.FileUtilsImpl;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -25,6 +26,6 @@ public class TestDatabaseModule extends AbstractModule {
|
||||
|
||||
protected void configure() {
|
||||
bind(DatabaseConfig.class).toInstance(config);
|
||||
bind(FileUtils.class).to(TestFileUtils.class);
|
||||
bind(FileUtils.class).to(FileUtilsImpl.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.briarproject;
|
||||
|
||||
import org.briarproject.api.system.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFileUtils implements FileUtils {
|
||||
|
||||
public long getTotalSpace(File f) throws IOException {
|
||||
return f.getTotalSpace();
|
||||
}
|
||||
|
||||
public long getFreeSpace(File f) throws IOException {
|
||||
return f.getUsableSpace();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package org.briarproject.db;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestDatabaseConfig;
|
||||
import org.briarproject.TestFileUtils;
|
||||
import org.briarproject.TestMessage;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.Author;
|
||||
@@ -20,6 +19,7 @@ import org.briarproject.api.messaging.Message;
|
||||
import org.briarproject.api.messaging.MessageId;
|
||||
import org.briarproject.api.transport.Endpoint;
|
||||
import org.briarproject.api.transport.TemporarySecret;
|
||||
import org.briarproject.system.FileUtilsImpl;
|
||||
import org.briarproject.system.SystemClock;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -1610,7 +1610,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
|
||||
private Database<Connection> open(boolean resume) throws Exception {
|
||||
Database<Connection> db = new H2Database(new TestDatabaseConfig(testDir,
|
||||
MAX_SIZE), new TestFileUtils(), new SystemClock());
|
||||
MAX_SIZE), new FileUtilsImpl(), new SystemClock());
|
||||
if (!resume) TestUtils.deleteTestDirectory(testDir);
|
||||
db.open();
|
||||
return db;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.plugins.file;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestFileUtils;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.plugins.TransportConnectionWriter;
|
||||
@@ -34,7 +34,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
|
||||
|
||||
private final File testDir = TestUtils.getTestDirectory();
|
||||
private final ContactId contactId = new ContactId(234);
|
||||
private final FileUtils fileUtils = new TestFileUtils();
|
||||
@Inject private FileUtils fileUtils;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
Reference in New Issue
Block a user