forked from Qortal/qortal
Most SQL tables defined but only payment transactions actually implemented. Maven support added. Some code imported from 'old' Qora: RIPEMD160 renamed as BrokenMD160 and deprecated. whispersystem's Ed25519 implementation (to be replaced with bouncycastle). Basic Account/PublicKeyAccount/PrivateKeyAccount code. Some utils like Base58 and Pair. To use: Use maven to fetch dependencies. Build project. Fire up an old-gen Qora node. Run src/test/update.java as a JUnit test to build DB structure. Run src/test/migrate.java as a JUnit test to migrate old Qora blocks to DB. You should now be able to run src/test/load.java and src/test/save.java as JUnit tests demonstrating loading/saving Transactions from/to database. This commit done while halfway through adding Block support!
77 lines
1.7 KiB
Java
77 lines
1.7 KiB
Java
package test;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.DriverManager;
|
|
import java.sql.SQLException;
|
|
import java.sql.Statement;
|
|
|
|
import org.junit.Test;
|
|
|
|
public class connections {
|
|
|
|
@Test
|
|
public void testConnection() {
|
|
try {
|
|
Connection c = DriverManager.getConnection("jdbc:hsqldb:file:db/test", "SA", "");
|
|
c.close();
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
fail();
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testSimultaneousConnections() {
|
|
try {
|
|
Connection c1 = DriverManager.getConnection("jdbc:hsqldb:file:db/test", "SA", "");
|
|
Connection c2 = DriverManager.getConnection("jdbc:hsqldb:file:db/test", "SA", "");
|
|
c1.close();
|
|
c2.close();
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
fail();
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testExistOnlyConnection() {
|
|
try {
|
|
Connection c = DriverManager.getConnection("jdbc:hsqldb:file:db/test;ifexists=true", "SA", "");
|
|
c.close();
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
fail();
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testConnectionAfterShutdown() {
|
|
try {
|
|
Connection c = DriverManager.getConnection("jdbc:hsqldb:file:db/test", "SA", "");
|
|
Statement s = c.createStatement();
|
|
s.execute("SHUTDOWN COMPACT");
|
|
c.close();
|
|
|
|
c = DriverManager.getConnection("jdbc:hsqldb:file:db/test", "SA", "");
|
|
c.close();
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
fail();
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testComplexConnection() {
|
|
try {
|
|
Connection c = DriverManager.getConnection("jdbc:hsqldb:file:db/test;create=false;close_result=true;sql.strict_exec=true;sql.enforce_names=true", "SA", "");
|
|
c.close();
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
fail();
|
|
}
|
|
}
|
|
|
|
}
|