Minor - Add datasource test, minor code householding

This commit is contained in:
ljacqu 2016-02-27 21:11:35 +01:00
parent b916c9b2be
commit 5fce849ce7
5 changed files with 20 additions and 5 deletions

View File

@ -351,8 +351,9 @@ public class SQLite implements DataSource {
@Override
public synchronized void close() {
try {
if (con != null && !con.isClosed())
if (con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException ex) {
logSqlException(ex);
}

View File

@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList;
/**
* This event is called when a player uses the /login command with correct credentials.
* {@link #setCanLogin(boolean) <code>event.setCanLogin(false)</code>} prevents the player from logging in.
* {@link #setCanLogin(boolean) event.setCanLogin(false)} prevents the player from logging in.
*/
public class AuthMeAsyncPreLoginEvent extends CustomEvent {

View File

@ -211,7 +211,7 @@ public final class Settings {
countriesBlacklist = configFile.getStringList("Protection.countriesBlacklist");
broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
forceRegLogin = load(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER);
spawnPriority = load(RestrictionSettings.SPAWN_PRIORITY);
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);

View File

@ -39,7 +39,7 @@ public class RegistrationSettings implements SettingsClass {
newProperty("settings.registration.doubleEmailCheck", false);
@Comment({
"Do we force kicking player after a successful registration?",
"Do we force kick a player after a successful registration?",
"Do not use with login feature below"})
public static final Property<Boolean> FORCE_KICK_AFTER_REGISTER =
newProperty("settings.registration.forceKickAfterRegister", false);

View File

@ -286,4 +286,18 @@ public abstract class AbstractDataSourceIntegrationTest {
assertThat(updatedList, hasItem(equalTo("test-1")));
}
@Test
public void shouldUpdateRealName() {
// given
DataSource dataSource = getDataSource();
// when
boolean response1 = dataSource.updateRealName("bobby", "BOBBY");
boolean response2 = dataSource.updateRealName("notExists", "NOTEXISTS");
// then
assertThat(response1 && response2, equalTo(true));
assertThat(dataSource.getAuth("bobby"), hasAuthBasicData("bobby", "BOBBY", "your@email.com", "123.45.67.89"));
}
}