Skip to content

Commit

Permalink
Verify that connecting works
Browse files Browse the repository at this point in the history
* Test for Fix #43
* Test for Fix #42
* Test for #9
  • Loading branch information
jhannes committed Aug 17, 2016
1 parent 0d0065d commit 923191b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/test/java/org/sqldroid/SQLDroidConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
Expand Down Expand Up @@ -60,6 +59,25 @@ public void call() throws Throwable {
.hasMessageContaining("SQLiteCantOpenDatabaseException");
}

@Test
// TODO: Many issues seem to stem from users expecting subdirectories to be created. Should this be supported?
public void shouldFailOnMissingSubdirectory() throws SQLException {
DB_DIR.mkdirs();
assertThat(DB_DIR).isDirectory();
File dbSubdir = new File(DB_DIR, "non-existing-dir");
assertThat(dbSubdir).doesNotExist();
File dbFile = new File(dbSubdir, "database.db");
final String jdbcUrl = "jdbc:sqlite:" + dbFile.getAbsolutePath();
assertThatThrownBy(new ThrowableAssert.ThrowingCallable() {
@Override
public void call() throws Throwable {
new SQLDroidDriver().connect(jdbcUrl, new Properties());
}
}).isInstanceOf(SQLException.class)
.hasMessageContaining("SQLiteCantOpenDatabaseException");
assertThat(dbSubdir).doesNotExist();
}


private static final File DB_DIR = new File("./target/data/org.sqldroid/databases/");

Expand Down

0 comments on commit 923191b

Please sign in to comment.