More test prints

This commit is contained in:
Rsl1122 2018-02-07 19:49:57 +02:00
parent 1b5d3637f9
commit e408f6aa62
3 changed files with 24 additions and 9 deletions

View File

@ -56,7 +56,7 @@ public class SQLiteDB extends SQLDB {
String dbFilePath = new File(PlanPlugin.getInstance().getDataFolder(), dbName + ".db").getAbsolutePath();
Connection newConnection = getConnectionFor(dbFilePath);
Log.debug("SQLite: Opened a new Connection");
Log.debug("SQLite " + dbName + ": Opened a new Connection");
newConnection.setAutoCommit(false);
return newConnection;
}
@ -130,8 +130,10 @@ public class SQLiteDB extends SQLDB {
@Override
public void close() {
stopConnectionPingTask();
Log.debug("SQLite: Closed Connection");
MiscUtils.close(connection);
if (connection != null) {
Log.debug("SQLite " + dbName + ": Closed Connection");
MiscUtils.close(connection);
}
super.close();
}
}

View File

@ -116,8 +116,11 @@ public class MiscUtils {
if (c != null) {
try {
c.close();
} catch (IOException ignored) {
/* Ignored */
} catch (IOException e) {
if (Settings.DEV_MODE.isTrue()) {
Log.warn("THIS ERROR IS ONLY LOGGED IN DEV MODE:");
Log.toLog(MiscUtils.class, e);
}
}
}
}
@ -128,8 +131,11 @@ public class MiscUtils {
if (c != null) {
try {
c.close();
} catch (Exception ignored) {
/* Ignored */
} catch (Exception e) {
if (Settings.DEV_MODE.isTrue()) {
Log.warn("THIS ERROR IS ONLY LOGGED IN DEV MODE:");
Log.toLog(MiscUtils.class, e);
}
}
}
}

View File

@ -61,10 +61,12 @@ public class SQLiteTest {
@BeforeClass
public static void setUpClass() throws Exception {
System.out.println("--- Test Class Setup ---");
db = new SQLiteDB();
SystemMockUtil.setUp(temporaryFolder.getRoot())
.enableConfigSystem()
.enableDatabaseSystem(db)
.enableServerInfoSystem()
.enableServerInfoSystem();
StaticHolder.saveInstance(SQLDB.class, Plan.class);
StaticHolder.saveInstance(SQLiteTest.class, Plan.class);
@ -74,6 +76,7 @@ public class SQLiteTest {
Settings.DEV_MODE.setTemporaryValue(true);
db.init();
System.out.println("--- Class Setup Complete ---\n");
}
@AfterClass
@ -86,12 +89,12 @@ public class SQLiteTest {
@Before
public void setUp() throws DBException, SQLException {
System.out.println("-- Clearing Test Database --");
System.out.println("\n-- Clearing Test Database --");
db.remove().everything();
ServerTable serverTable = db.getServerTable();
serverTable.saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20));
assertEquals(ServerInfo.getServerUUID(), TestConstants.SERVER_UUID);
System.out.println("-- Clear Complete --");
System.out.println("-- Clear Complete --\n");
}
@Test
@ -755,8 +758,10 @@ public class SQLiteTest {
@Test
public void testBackupAndRestore() throws SQLException, DBInitException {
System.out.println("- Creating Backup Database -");
SQLiteDB backup = new SQLiteDB("debug-backup" + MiscUtils.getTime());
backup.init();
System.out.println("- Backup Database Created -");
saveAllData(db);
@ -852,9 +857,11 @@ public class SQLiteTest {
public void testRegisterProcessorRegisterException() throws SQLException {
assertFalse(db.getUsersTable().isRegistered(playerUUID));
assertFalse(db.getUserInfoTable().isRegistered(playerUUID));
System.out.println("\n- Running RegisterProcessors -");
for (int i = 0; i < 200; i++) {
new RegisterProcessor(playerUUID, 500L, 1000L, "name", 4).process();
}
System.out.println("- RegisterProcessors Run -\n");
assertTrue(db.getUsersTable().isRegistered(playerUUID));
assertTrue(db.getUserInfoTable().isRegistered(playerUUID));
}