package Database;

import java.sql.SQLException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

/**
 *
 * @author root
 */
public class DatabaseTest {
    public DatabaseTest() {
        DatabaseHandler.getInstance("root", "");
    }
    
    @Test
    public void connectionTest() throws SQLException {
        boolean result = DatabaseHandler.getInstance().testConnection();
        assertEquals(result, true);
    }
    
    @Test
    public void sqlInjectionTest1() {
        String username = "johnny';DROP TABLE PLAYER_DB;--";
        DatabaseHandler.getInstance().findAccount(username, "abcd");
        assertEquals(DatabaseHandler.getInstance().tableExists("PLAYER_DB"), true);
    }
    
    @Test
    public void sqlInjectionTest2() {
        String username = "johnny' OR 1=1/*";
        assertEquals(DatabaseHandler.getInstance().findName(username), false);
    }
    
    @Test
    public void sqlInjectionTest3() {
        String username = "'=''/*";
        assertEquals(DatabaseHandler.getInstance().findName(username), false);
    }
    
    @Test
    public void sqlInjectionTest4() {
        String username = "$badboypwnsyodatabase$ >:)";
        String password = "(SELECT 1 FROM DUAL)";
        DatabaseHandler.getInstance().pushPlayer(username, password);
        assertEquals(DatabaseHandler.getInstance().findAccount(username, "1"), false);
        assertEquals(DatabaseHandler.getInstance().findAccount(username, password), true);
        DatabaseHandler.getInstance().removePlayer(username, password);
        assertEquals(DatabaseHandler.getInstance().findAccount(username, password), false);
    }
}

@@ -166,16 +166,56 @@
 eTest %7B%0A
+    private final String%5B%5D tables;%0A    %0A
     publ
@@ -279,24 +279,88 @@
 root%22, %22%22);%0A
+        tables = new String%5B%5D%7B%22PLAYER_DB, MATCHES_DB, ATTEND%22%7D;%0A
     %7D%0A    %0A 
@@ -545,32 +545,216 @@
 %0A    %0A    @Test%0A
+    public void tableCreationTest() %7B%0A        for (String tableName: tables)%0A            assertEquals(DatabaseHandler.getInstance().tableExists(tableName), true);%0A    %7D%0A    %0A    @Test%0A
     public void 

Add DB table creation test