2018-01-27 16:30:44 +01:00
|
|
|
/*
|
2018-06-12 20:28:40 +02:00
|
|
|
* License is provided in the jar as LICENSE also here:
|
|
|
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
|
2018-01-27 16:30:44 +01:00
|
|
|
*/
|
2018-10-13 11:19:36 +02:00
|
|
|
package com.djrapitops.plan;
|
2018-01-27 16:30:44 +01:00
|
|
|
|
|
|
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
2018-10-13 11:19:36 +02:00
|
|
|
import com.djrapitops.plan.system.PlanSystem;
|
2018-10-13 11:43:18 +02:00
|
|
|
import com.djrapitops.plan.system.database.DBSystem;
|
|
|
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
2018-12-08 10:44:10 +01:00
|
|
|
import com.djrapitops.plan.system.settings.paths.ProxySettings;
|
|
|
|
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
2018-11-26 10:02:18 +01:00
|
|
|
import org.junit.ClassRule;
|
|
|
|
import org.junit.Ignore;
|
|
|
|
import org.junit.Rule;
|
|
|
|
import org.junit.Test;
|
2018-01-27 16:30:44 +01:00
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
|
import org.junit.rules.TemporaryFolder;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.mockito.junit.MockitoJUnitRunner;
|
2018-11-26 10:02:18 +01:00
|
|
|
import rules.BungeeComponentMocker;
|
|
|
|
import rules.ComponentMocker;
|
2018-12-18 16:16:33 +01:00
|
|
|
import utilities.RandomData;
|
2018-01-27 16:30:44 +01:00
|
|
|
|
|
|
|
/**
|
2018-08-23 12:56:24 +02:00
|
|
|
* Test for Bungee PlanSystem.
|
2018-01-27 16:30:44 +01:00
|
|
|
*
|
|
|
|
* @author Rsl1122
|
|
|
|
*/
|
|
|
|
@RunWith(MockitoJUnitRunner.Silent.class)
|
|
|
|
public class BungeeSystemTest {
|
|
|
|
|
|
|
|
@ClassRule
|
|
|
|
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
|
2018-11-26 10:02:18 +01:00
|
|
|
@ClassRule
|
|
|
|
public static ComponentMocker component = new BungeeComponentMocker(temporaryFolder);
|
|
|
|
|
2018-12-18 16:16:33 +01:00
|
|
|
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
|
|
|
|
2018-01-27 16:30:44 +01:00
|
|
|
@Rule
|
|
|
|
public ExpectedException thrown = ExpectedException.none();
|
2018-10-13 11:43:18 +02:00
|
|
|
|
2018-01-27 16:30:44 +01:00
|
|
|
@Test
|
2018-10-13 11:43:18 +02:00
|
|
|
public void bungeeEnables() throws Exception {
|
2018-11-26 10:02:18 +01:00
|
|
|
PlanSystem bungeeSystem = component.getPlanSystem();
|
|
|
|
try {
|
|
|
|
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
2018-12-18 16:16:33 +01:00
|
|
|
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
2018-12-08 10:44:10 +01:00
|
|
|
config.set(ProxySettings.IP, "8.8.8.8");
|
2018-10-13 11:43:18 +02:00
|
|
|
|
2018-11-26 10:02:18 +01:00
|
|
|
DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
|
|
|
|
dbSystem.setActiveDatabase(dbSystem.getSqLiteFactory().usingDefaultFile());
|
2018-01-27 16:30:44 +01:00
|
|
|
|
2018-11-26 10:02:18 +01:00
|
|
|
bungeeSystem.enable();
|
|
|
|
} finally {
|
|
|
|
bungeeSystem.disable();
|
|
|
|
}
|
2018-01-27 16:30:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-10-13 11:43:18 +02:00
|
|
|
@Ignore("First test causes config settings to be wrong")
|
|
|
|
public void bungeeDoesNotEnableWithDefaultIP() throws Exception {
|
2018-01-27 16:30:44 +01:00
|
|
|
thrown.expect(EnableException.class);
|
|
|
|
thrown.expectMessage("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server.");
|
|
|
|
|
2018-11-26 10:02:18 +01:00
|
|
|
PlanSystem bungeeSystem = component.getPlanSystem();
|
|
|
|
try {
|
|
|
|
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
2018-12-18 16:16:33 +01:00
|
|
|
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
2018-12-08 10:44:10 +01:00
|
|
|
config.set(ProxySettings.IP, "0.0.0.0");
|
2018-01-27 16:30:44 +01:00
|
|
|
|
2018-11-26 10:02:18 +01:00
|
|
|
DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
|
|
|
|
dbSystem.setActiveDatabase(dbSystem.getSqLiteFactory().usingDefaultFile());
|
2018-01-27 16:30:44 +01:00
|
|
|
|
2018-11-26 10:02:18 +01:00
|
|
|
bungeeSystem.enable();
|
|
|
|
} finally {
|
|
|
|
bungeeSystem.disable();
|
|
|
|
}
|
2018-01-27 16:30:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-03-12 11:02:55 +01:00
|
|
|
@Ignore("MySQL Driver unavailable for some reason.")
|
2018-01-27 16:30:44 +01:00
|
|
|
public void testEnableNoMySQL() throws EnableException {
|
|
|
|
thrown.expect(EnableException.class);
|
|
|
|
thrown.expectMessage("Database failed to initialize");
|
|
|
|
|
2018-11-26 10:02:18 +01:00
|
|
|
PlanSystem bungeeSystem = component.getPlanSystem();
|
|
|
|
try {
|
|
|
|
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
2018-12-18 16:16:33 +01:00
|
|
|
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
2018-12-08 10:44:10 +01:00
|
|
|
config.set(ProxySettings.IP, "8.8.8.8");
|
2018-10-13 11:43:18 +02:00
|
|
|
|
2018-11-26 10:02:18 +01:00
|
|
|
bungeeSystem.enable();
|
|
|
|
} finally {
|
|
|
|
bungeeSystem.disable();
|
|
|
|
}
|
2018-01-27 16:30:44 +01:00
|
|
|
}
|
2018-06-12 20:28:40 +02:00
|
|
|
}
|