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
|
|
|
*/
|
|
|
|
package com.djrapitops.plan.system;
|
|
|
|
|
|
|
|
import com.djrapitops.plan.PlanBungee;
|
|
|
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
|
|
|
import org.junit.*;
|
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
|
import org.junit.rules.TemporaryFolder;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.mockito.junit.MockitoJUnitRunner;
|
2018-10-13 09:45:59 +02:00
|
|
|
import utilities.mocks.PlanBungeeMocker;
|
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();
|
|
|
|
private static PlanBungee planMock;
|
|
|
|
@Rule
|
|
|
|
public ExpectedException thrown = ExpectedException.none();
|
2018-08-23 12:56:24 +02:00
|
|
|
private PlanSystem bungeeSystem;
|
2018-01-27 16:30:44 +01:00
|
|
|
|
2018-02-02 12:12:12 +01:00
|
|
|
@BeforeClass
|
|
|
|
public static void setUpClass() throws Exception {
|
2018-10-13 09:45:59 +02:00
|
|
|
PlanBungeeMocker mockUtil = PlanBungeeMocker.setUp()
|
2018-01-27 16:30:44 +01:00
|
|
|
.withDataFolder(temporaryFolder.getRoot())
|
|
|
|
.withLogging()
|
|
|
|
.withPluginDescription()
|
|
|
|
.withResourceFetchingFromJar()
|
|
|
|
.withProxy();
|
|
|
|
planMock = mockUtil.getPlanMock();
|
|
|
|
}
|
2018-02-04 11:54:31 +01:00
|
|
|
|
2018-01-27 16:30:44 +01:00
|
|
|
@After
|
|
|
|
public void tearDown() {
|
|
|
|
if (bungeeSystem != null) {
|
|
|
|
bungeeSystem.disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-08-20 17:26:37 +02:00
|
|
|
@Ignore
|
2018-01-27 16:30:44 +01:00
|
|
|
public void testEnable() throws EnableException {
|
2018-08-20 17:26:37 +02:00
|
|
|
bungeeSystem = null; //TODO
|
2018-01-27 16:30:44 +01:00
|
|
|
|
2018-09-18 16:30:57 +02:00
|
|
|
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
|
|
|
// Settings.BUNGEE_IP.setTemporaryValue("8.8.8.8");
|
|
|
|
// Settings.DB_TYPE.setTemporaryValue("sqlite");
|
2018-08-21 15:26:37 +02:00
|
|
|
// bungeeSystem.setDatabaseSystem(new BukkitDBSystem(Locale::new));
|
2018-01-27 16:30:44 +01:00
|
|
|
|
|
|
|
bungeeSystem.enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-08-20 17:26:37 +02:00
|
|
|
@Ignore
|
2018-01-27 16:30:44 +01:00
|
|
|
public void testEnableDefaultIP() throws EnableException {
|
|
|
|
thrown.expect(EnableException.class);
|
|
|
|
thrown.expectMessage("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server.");
|
|
|
|
|
2018-08-20 17:26:37 +02:00
|
|
|
bungeeSystem = null; //TODO
|
2018-01-27 16:30:44 +01:00
|
|
|
|
2018-09-18 16:30:57 +02:00
|
|
|
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
|
|
|
// Settings.DB_TYPE.setTemporaryValue("sqlite");
|
2018-08-21 15:26:37 +02:00
|
|
|
// bungeeSystem.setDatabaseSystem(new BukkitDBSystem(Locale::new));
|
2018-01-27 16:30:44 +01:00
|
|
|
|
|
|
|
bungeeSystem.enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
@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-08-20 17:26:37 +02:00
|
|
|
bungeeSystem = null; //TODO
|
2018-01-27 16:30:44 +01:00
|
|
|
bungeeSystem.enable();
|
|
|
|
}
|
2018-06-12 20:28:40 +02:00
|
|
|
}
|