mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-11 04:04:20 +01:00
bind/java: Rename to Turso
This commit is contained in:
@@ -15,7 +15,7 @@ public class IntegrationTest {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
String url = "jdbc:turso:" + filePath;
|
||||
connection = new JDBC4Connection(url, filePath, new Properties());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,26 +22,26 @@ class JDBCTest {
|
||||
@Test
|
||||
void non_null_connection_is_returned_when_valid_url_is_passed() throws Exception {
|
||||
String fileUrl = TestUtils.createTempFile();
|
||||
JDBC4Connection connection = JDBC.createConnection("jdbc:sqlite:" + fileUrl, new Properties());
|
||||
JDBC4Connection connection = JDBC.createConnection("jdbc:turso:" + fileUrl, new Properties());
|
||||
assertThat(connection).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void connection_can_be_retrieved_from_DriverManager() throws SQLException {
|
||||
try (Connection connection = DriverManager.getConnection("jdbc:sqlite:sample.db")) {
|
||||
try (Connection connection = DriverManager.getConnection("jdbc:turso:sample.db")) {
|
||||
assertThat(connection).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void retrieve_version() {
|
||||
assertDoesNotThrow(() -> DriverManager.getDriver("jdbc:sqlite:").getMajorVersion());
|
||||
assertDoesNotThrow(() -> DriverManager.getDriver("jdbc:sqlite:").getMinorVersion());
|
||||
assertDoesNotThrow(() -> DriverManager.getDriver("jdbc:turso:").getMajorVersion());
|
||||
assertDoesNotThrow(() -> DriverManager.getDriver("jdbc:turso:").getMinorVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void all_driver_property_info_should_have_a_description() throws Exception {
|
||||
Driver driver = DriverManager.getDriver("jdbc:sqlite:");
|
||||
Driver driver = DriverManager.getDriver("jdbc:turso:");
|
||||
assertThat(driver.getPropertyInfo(null, null))
|
||||
.allSatisfy((info) -> assertThat(info.description).isNotNull());
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ import java.nio.file.Files;
|
||||
public class TestUtils {
|
||||
/** Create temporary file and returns the path. */
|
||||
public static String createTempFile() throws IOException {
|
||||
return Files.createTempFile("limbo_test_db", null).toAbsolutePath().toString();
|
||||
return Files.createTempFile("turso_test_db", null).toAbsolutePath().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ import java.util.Properties;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tech.turso.TestUtils;
|
||||
|
||||
class LimboDBFactoryTest {
|
||||
class TursoDBFactoryTest {
|
||||
|
||||
@Test
|
||||
void single_database_should_be_created_when_urls_are_same() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
LimboDB db1 = LimboDBFactory.open(url, filePath, new Properties());
|
||||
LimboDB db2 = LimboDBFactory.open(url, filePath, new Properties());
|
||||
String url = "jdbc:turso:" + filePath;
|
||||
TursoDB db1 = TursoDBFactory.open(url, filePath, new Properties());
|
||||
TursoDB db2 = TursoDBFactory.open(url, filePath, new Properties());
|
||||
assertEquals(db1, db2);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ class LimboDBFactoryTest {
|
||||
void multiple_databases_should_be_created_when_urls_differ() throws Exception {
|
||||
String filePath1 = TestUtils.createTempFile();
|
||||
String filePath2 = TestUtils.createTempFile();
|
||||
String url1 = "jdbc:sqlite:" + filePath1;
|
||||
String url2 = "jdbc:sqlite:" + filePath2;
|
||||
LimboDB db1 = LimboDBFactory.open(url1, filePath1, new Properties());
|
||||
LimboDB db2 = LimboDBFactory.open(url2, filePath2, new Properties());
|
||||
String url1 = "jdbc:turso:" + filePath1;
|
||||
String url2 = "jdbc:turso:" + filePath2;
|
||||
TursoDB db1 = TursoDBFactory.open(url1, filePath1, new Properties());
|
||||
TursoDB db2 = TursoDBFactory.open(url2, filePath2, new Properties());
|
||||
assertNotEquals(db1, db2);
|
||||
}
|
||||
}
|
||||
@@ -6,25 +6,25 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tech.turso.LimboErrorCode;
|
||||
import tech.turso.TestUtils;
|
||||
import tech.turso.exceptions.LimboException;
|
||||
import tech.turso.TursoErrorCode;
|
||||
import tech.turso.exceptions.TursoException;
|
||||
|
||||
public class LimboDBTest {
|
||||
public class TursoDBTest {
|
||||
|
||||
@Test
|
||||
void db_should_open_normally() throws Exception {
|
||||
LimboDB.load();
|
||||
TursoDB.load();
|
||||
String dbPath = TestUtils.createTempFile();
|
||||
LimboDB db = LimboDB.create("jdbc:sqlite" + dbPath, dbPath);
|
||||
TursoDB db = TursoDB.create("jdbc:turso" + dbPath, dbPath);
|
||||
db.open(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void db_should_close_normally() throws Exception {
|
||||
LimboDB.load();
|
||||
TursoDB.load();
|
||||
String dbPath = TestUtils.createTempFile();
|
||||
LimboDB db = LimboDB.create("jdbc:sqlite" + dbPath, dbPath);
|
||||
TursoDB db = TursoDB.create("jdbc:turso" + dbPath, dbPath);
|
||||
db.open(0);
|
||||
db.close();
|
||||
|
||||
@@ -33,9 +33,9 @@ public class LimboDBTest {
|
||||
|
||||
@Test
|
||||
void should_throw_exception_when_opened_twice() throws Exception {
|
||||
LimboDB.load();
|
||||
TursoDB.load();
|
||||
String dbPath = TestUtils.createTempFile();
|
||||
LimboDB db = LimboDB.create("jdbc:sqlite:" + dbPath, dbPath);
|
||||
TursoDB db = TursoDB.create("jdbc:turso:" + dbPath, dbPath);
|
||||
db.open(0);
|
||||
|
||||
assertThatThrownBy(() -> db.open(0)).isInstanceOf(SQLException.class);
|
||||
@@ -43,17 +43,17 @@ public class LimboDBTest {
|
||||
|
||||
@Test
|
||||
void throwJavaException_should_throw_appropriate_java_exception() throws Exception {
|
||||
LimboDB.load();
|
||||
TursoDB.load();
|
||||
String dbPath = TestUtils.createTempFile();
|
||||
LimboDB db = LimboDB.create("jdbc:sqlite:" + dbPath, dbPath);
|
||||
TursoDB db = TursoDB.create("jdbc:turso:" + dbPath, dbPath);
|
||||
|
||||
final int limboExceptionCode = LimboErrorCode.LIMBO_ETC.code;
|
||||
final int tursoExceptionCode = TursoErrorCode.TURSO_ETC.code;
|
||||
try {
|
||||
db.throwJavaException(limboExceptionCode);
|
||||
db.throwJavaException(tursoExceptionCode);
|
||||
} catch (Exception e) {
|
||||
assertThat(e).isInstanceOf(LimboException.class);
|
||||
LimboException limboException = (LimboException) e;
|
||||
assertThat(limboException.getResultCode().code).isEqualTo(limboExceptionCode);
|
||||
assertThat(e).isInstanceOf(TursoException.class);
|
||||
TursoException tursoException = (TursoException) e;
|
||||
assertThat(tursoException.getResultCode().code).isEqualTo(tursoExceptionCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,20 +12,20 @@ import org.junit.jupiter.api.Test;
|
||||
import tech.turso.TestUtils;
|
||||
import tech.turso.jdbc4.JDBC4Connection;
|
||||
|
||||
class LimboStatementTest {
|
||||
class TursoStatementTest {
|
||||
|
||||
private JDBC4Connection connection;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
String url = "jdbc:turso:" + filePath;
|
||||
connection = new JDBC4Connection(url, filePath, new Properties());
|
||||
}
|
||||
|
||||
@Test
|
||||
void closing_statement_closes_related_resources() throws Exception {
|
||||
LimboStatement stmt = connection.prepare("SELECT 1;");
|
||||
TursoStatement stmt = connection.prepare("SELECT 1;");
|
||||
stmt.execute();
|
||||
|
||||
stmt.close();
|
||||
@@ -38,9 +38,9 @@ class LimboStatementTest {
|
||||
runSql("CREATE TABLE users (name TEXT, age INT, country TEXT);");
|
||||
runSql("INSERT INTO users VALUES ('seonwoo', 30, 'KR');");
|
||||
|
||||
final LimboStatement stmt = connection.prepare("SELECT * FROM users");
|
||||
final TursoStatement stmt = connection.prepare("SELECT * FROM users");
|
||||
stmt.initializeColumnMetadata();
|
||||
final LimboResultSet rs = stmt.getResultSet();
|
||||
final TursoResultSet rs = stmt.getResultSet();
|
||||
final String[] columnNames = rs.getColumnNames();
|
||||
|
||||
assertEquals("name", columnNames[0]);
|
||||
@@ -51,12 +51,12 @@ class LimboStatementTest {
|
||||
@Test
|
||||
void test_bindNull() throws Exception {
|
||||
runSql("CREATE TABLE test (col1 TEXT);");
|
||||
LimboStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
TursoStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
stmt.bindNull(1);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
|
||||
LimboStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
TursoStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
selectStmt.execute();
|
||||
assertNull(selectStmt.getResultSet().get(1));
|
||||
selectStmt.close();
|
||||
@@ -65,12 +65,12 @@ class LimboStatementTest {
|
||||
@Test
|
||||
void test_bindLong() throws Exception {
|
||||
runSql("CREATE TABLE test (col1 BIGINT);");
|
||||
LimboStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
TursoStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
stmt.bindLong(1, 123456789L);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
|
||||
LimboStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
TursoStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
selectStmt.execute();
|
||||
assertEquals(123456789L, selectStmt.getResultSet().get(1));
|
||||
selectStmt.close();
|
||||
@@ -79,12 +79,12 @@ class LimboStatementTest {
|
||||
@Test
|
||||
void test_bindDouble() throws Exception {
|
||||
runSql("CREATE TABLE test (col1 DOUBLE);");
|
||||
LimboStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
TursoStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
stmt.bindDouble(1, 3.14);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
|
||||
LimboStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
TursoStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
selectStmt.execute();
|
||||
assertEquals(3.14, selectStmt.getResultSet().get(1));
|
||||
selectStmt.close();
|
||||
@@ -93,12 +93,12 @@ class LimboStatementTest {
|
||||
@Test
|
||||
void test_bindText() throws Exception {
|
||||
runSql("CREATE TABLE test (col1 TEXT);");
|
||||
LimboStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
TursoStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
stmt.bindText(1, "hello");
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
|
||||
LimboStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
TursoStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
selectStmt.execute();
|
||||
assertEquals("hello", selectStmt.getResultSet().get(1));
|
||||
selectStmt.close();
|
||||
@@ -107,20 +107,20 @@ class LimboStatementTest {
|
||||
@Test
|
||||
void test_bindBlob() throws Exception {
|
||||
runSql("CREATE TABLE test (col1 BLOB);");
|
||||
LimboStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
TursoStatement stmt = connection.prepare("INSERT INTO test (col1) VALUES (?);");
|
||||
byte[] blob = {1, 2, 3, 4, 5};
|
||||
stmt.bindBlob(1, blob);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
|
||||
LimboStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
TursoStatement selectStmt = connection.prepare("SELECT col1 FROM test;");
|
||||
selectStmt.execute();
|
||||
assertArrayEquals(blob, (byte[]) selectStmt.getResultSet().get(1));
|
||||
selectStmt.close();
|
||||
}
|
||||
|
||||
private void runSql(String sql) throws Exception {
|
||||
LimboStatement stmt = connection.prepare(sql);
|
||||
TursoStatement stmt = connection.prepare(sql);
|
||||
while (stmt.execute()) {
|
||||
stmt.execute();
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class JDBC4ConnectionTest {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
String url = "jdbc:turso:" + filePath;
|
||||
connection = new JDBC4Connection(url, filePath, new Properties());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class JDBC4DatabaseMetaDataTest {
|
||||
@BeforeEach
|
||||
void set_up() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
String url = "jdbc:turso:" + filePath;
|
||||
connection = new JDBC4Connection(url, filePath, new Properties());
|
||||
metaData = new JDBC4DatabaseMetaData(connection);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class JDBC4PreparedStatementTest {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
String url = "jdbc:turso:" + filePath;
|
||||
connection = new JDBC4Connection(url, filePath, new Properties());
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class JDBC4ResultSetTest {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
String url = "jdbc:turso:" + filePath;
|
||||
final JDBC4Connection connection = new JDBC4Connection(url, filePath, new Properties());
|
||||
stmt =
|
||||
connection.createStatement(
|
||||
|
||||
@@ -21,7 +21,7 @@ class JDBC4StatementTest {
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
String url = "jdbc:turso:" + filePath;
|
||||
final JDBC4Connection connection = new JDBC4Connection(url, filePath, new Properties());
|
||||
stmt =
|
||||
connection.createStatement(
|
||||
@@ -38,20 +38,20 @@ class JDBC4StatementTest {
|
||||
@Test
|
||||
void execute_insert_should_return_false() throws Exception {
|
||||
stmt.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT);");
|
||||
assertFalse(stmt.execute("INSERT INTO users VALUES (1, 'limbo');"));
|
||||
assertFalse(stmt.execute("INSERT INTO users VALUES (1, 'turso');"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void execute_update_should_return_false() throws Exception {
|
||||
stmt.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT);");
|
||||
stmt.execute("INSERT INTO users VALUES (1, 'limbo');");
|
||||
stmt.execute("INSERT INTO users VALUES (1, 'turso');");
|
||||
assertFalse(stmt.execute("UPDATE users SET username = 'seonwoo' WHERE id = 1;"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void execute_select_should_return_true() throws Exception {
|
||||
stmt.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT);");
|
||||
stmt.execute("INSERT INTO users VALUES (1, 'limbo');");
|
||||
stmt.execute("INSERT INTO users VALUES (1, 'turso');");
|
||||
assertTrue(stmt.execute("SELECT * FROM users;"));
|
||||
}
|
||||
|
||||
|
||||
1
bindings/java/src/test/resources/turso/.rustc_info.json
Normal file
1
bindings/java/src/test/resources/turso/.rustc_info.json
Normal file
@@ -0,0 +1 @@
|
||||
{"rustc_fingerprint":11551670960185020797,"outputs":{"14427667104029986310":{"success":true,"status":"","code":0,"stdout":"rustc 1.83.0 (90b35a623 2024-11-26)\nbinary: rustc\ncommit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\ncommit-date: 2024-11-26\nhost: x86_64-unknown-linux-gnu\nrelease: 1.83.0\nLLVM version: 19.1.1\n","stderr":""},"11399821309745579047":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/merlin/.rustup/toolchains/1.83.0-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}
|
||||
3
bindings/java/src/test/resources/turso/CACHEDIR.TAG
Normal file
3
bindings/java/src/test/resources/turso/CACHEDIR.TAG
Normal file
@@ -0,0 +1,3 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by cargo.
|
||||
# For information about cache directory tags see https://bford.info/cachedir/
|
||||
Reference in New Issue
Block a user