mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Added dependency injections for FileUtils and removed redundant code
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.api.system.FileUtils;
|
||||
import org.briarproject.system.FileUtilsImpl;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
@@ -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 java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.briarproject.api.system.FileUtils;
|
||||
|
||||
public class TestFileUtils implements FileUtils {
|
||||
|
||||
public long getTotalSpace(File f) throws IOException {
|
||||
return f.getTotalSpace(); // Requires Java 1.6
|
||||
}
|
||||
|
||||
public long getFreeSpace(File f) throws IOException {
|
||||
return f.getUsableSpace(); // Requires Java 1.6
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
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;
|
||||
@@ -39,6 +38,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;
|
||||
@@ -1605,7 +1605,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,5 +1,7 @@
|
||||
package org.briarproject.plugins.file;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.transport.TransportConstants.MIN_STREAM_LENGTH;
|
||||
|
||||
import java.io.File;
|
||||
@@ -11,7 +13,6 @@ import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestFileUtils;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.plugins.TransportConnectionWriter;
|
||||
@@ -29,7 +30,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;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
|
||||
Reference in New Issue
Block a user