Skip to content

Commit

Permalink
Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
dennysem committed Dec 8, 2014
1 parent 15d5711 commit 3ad6508
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 1,079 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public class DatabaseTest {

@BeforeClass
public static void setUpClass() throws IOException {
dbPath = folder.newFolder("fizteh.db.dir");
database = new DatabaseFactory().create(dbPath.getPath());
database = new DatabaseFactory().create(folder.newFolder().getAbsolutePath().toString());
}

@Test
Expand Down Expand Up @@ -80,26 +79,6 @@ public void testReturnNullWhenTableExist() {
database.removeTable("qwerty");
}

@Test
public void testGetTableFromManyTablesAndLoadDatabase() {
for (int i = 0; i < 10; i++) {
database.createTable("t" + i);
}
for (int i = 0; i < 10; i++) {
assertCanGetTableTNum(i);
}
database = new DatabaseFactory().create(dbPath.getPath());
for (int i = 0; i < 10; i++) {
database.removeTable("t" + i);
for (int j = 0; j <= i; j++) {
Assert.assertEquals(null, database.getTable("t" + j));
}
for (int j = i + 1; j < 10; j++) {
assertCanGetTableTNum(j);
}
}
}

private void assertCanGetTableTNum(int i) {
Assert.assertEquals("t" + i, database.getTable("t" + i).getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public class TableHashTest {
public void initTable() throws IOException {
TableProviderFactory factory = new DatabaseFactory();
dbDirPath = tmpFolder.newFolder().getAbsolutePath();
TableProvider provider = factory.create("fizteh.db.dir");
provider.removeTable("table");
TableProvider provider = factory.create(dbDirPath.toString());
table = provider.createTable("table");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import ru.fizteh.fivt.storage.strings.TableProvider;
import ru.fizteh.fivt.storage.strings.TableProviderFactory;

import java.nio.file.Path;

public class DatabaseFactory implements TableProviderFactory{
Database database;

@Override
public TableProvider create(String dir) {
String directoryPath = System.getProperty("fizteh.db.dir");
public TableProvider create(String directoryPath) {
if (directoryPath == null) {
throw new IllegalArgumentException("Database directory doesn't set.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class MultiFileHashMapMain {
public static void main(String[] args) {
TableProviderFactory databaseFactory = new DatabaseFactory();
Database db = (Database) databaseFactory.create("fizteh.db.dir");
Database db = (Database) databaseFactory.create(System.getProperty("fizteh.db.dir"));
DatabaseInterpreterState databaseInterpreterState = new DatabaseInterpreterState(db);
new Interpreter(databaseInterpreterState, new Command[]{
new Command("put", 2, new BiConsumer<InterpreterState, String[]>() {
Expand Down
Loading

0 comments on commit 3ad6508

Please sign in to comment.