#392 Add datasource integration tests
This commit is contained in:
@@ -224,12 +224,6 @@ public class CacheDataSource implements DataSource {
|
||||
return source.getAccountsRegistered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateName(final String oldOne, final String newOne) { // unused method
|
||||
source.updateName(oldOne, newOne);
|
||||
cachedAuths.invalidate(oldOne);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
boolean result = source.updateRealName(user, realName);
|
||||
|
||||
@@ -169,14 +169,6 @@ public interface DataSource {
|
||||
*/
|
||||
int getAccountsRegistered();
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldOne String
|
||||
* @param newOne String
|
||||
*/
|
||||
void updateName(String oldOne, String newOne);
|
||||
|
||||
boolean updateRealName(String user, String realName);
|
||||
|
||||
boolean updateIp(String user, String ip);
|
||||
|
||||
@@ -599,14 +599,6 @@ public class FlatFile implements DataSource {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateName(String oldOne, String newOne) {
|
||||
PlayerAuth auth = this.getAuth(oldOne);
|
||||
auth.setNickname(newOne);
|
||||
this.saveAuth(auth);
|
||||
this.removeAuth(oldOne);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
@@ -81,6 +82,7 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
MySQL(NewSetting settings, HikariDataSource hikariDataSource) {
|
||||
this.host = settings.getProperty(DatabaseSettings.MYSQL_HOST);
|
||||
this.port = settings.getProperty(DatabaseSettings.MYSQL_PORT);
|
||||
@@ -817,18 +819,6 @@ public class MySQL implements DataSource {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateName(String oldOne, String newOne) {
|
||||
String sql = "UPDATE " + tableName + " SET " + col.NAME + "=? WHERE " + col.NAME + "=?;";
|
||||
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||
pst.setString(1, newOne);
|
||||
pst.setString(2, oldOne);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
logSqlException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
String sql = "UPDATE " + tableName + " SET " + col.REAL_NAME + "=? WHERE " + col.NAME + "=?;";
|
||||
|
||||
@@ -523,21 +523,6 @@ public class SQLite implements DataSource {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateName(String oldOne, String newOne) {
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + col.NAME + "=? WHERE " + col.NAME + "=?;");
|
||||
pst.setString(1, newOne);
|
||||
pst.setString(2, oldOne);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
logSqlException(ex);
|
||||
} finally {
|
||||
close(pst);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
String sql = "UPDATE " + tableName + " SET " + col.REAL_NAME + "=? WHERE " + col.NAME + "=?;";
|
||||
|
||||
Reference in New Issue
Block a user