Search in sources :

Example 21 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class ConfigSettingKeyTest method createConfig.

private PlanConfig createConfig(File configFile) throws IOException {
    PlanConfig config = new PlanConfig(configFile, null, null, new TestPluginLogger());
    config.save();
    return config;
}
Also used : TestPluginLogger(utilities.TestPluginLogger) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig)

Example 22 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class ConfigUpdaterTest method proxyMoveChangesDoNotLeaveNewEmptyValues.

@Test
void proxyMoveChangesDoNotLeaveNewEmptyValues() throws IOException {
    Path configPath = tempDir.resolve("oldconfig.yml");
    Files.copy(oldBungeeConfig.toPath(), configPath, StandardCopyOption.REPLACE_EXISTING);
    PlanConfig config = new PlanConfig(configPath.toFile(), null, null, new TestPluginLogger());
    ConfigChange[] changes = UNDER_TEST.configEnhancementPatch();
    assertMoveChangesAreAppliedProperly(config, changes);
}
Also used : Path(java.nio.file.Path) TestPluginLogger(utilities.TestPluginLogger) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 23 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class ConfigUpdaterTest method serverConfigIsPatchedCorrectly.

@Test
void serverConfigIsPatchedCorrectly() throws IOException, IllegalAccessException {
    Path configPath = tempDir.resolve("oldconfig.yml");
    Files.copy(oldConfig.toPath(), configPath, StandardCopyOption.REPLACE_EXISTING);
    PlanConfig config = new PlanConfig(configPath.toFile(), null, null, new TestPluginLogger());
    UNDER_TEST.applyConfigUpdate(config);
    // Ensure that added settings are present
    copyMissingFrom(config, newConfig);
    TestSettings.assertValidDefaultValuesForAllSettings(config, TestSettings.getServerSettings());
}
Also used : Path(java.nio.file.Path) TestPluginLogger(utilities.TestPluginLogger) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 24 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class BungeeSystemTest method testEnableNoMySQL.

@Test
void testEnableNoMySQL() {
    PlanSystem bungeeSystem = component.getPlanSystem();
    try {
        PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
        config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
        config.set(ProxySettings.IP, "8.8.8.8");
        assertThrows(EnableException.class, bungeeSystem::enable);
    } finally {
        bungeeSystem.disable();
    }
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 25 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class BungeeSystemTest method bungeeDoesNotEnableWithDefaultIP.

@Test
void bungeeDoesNotEnableWithDefaultIP() {
    PlanSystem bungeeSystem = component.getPlanSystem();
    try {
        PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
        config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
        config.set(ProxySettings.IP, "0.0.0.0");
        DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
        SQLiteDB db = dbSystem.getSqLiteFactory().usingDefaultFile();
        db.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
        dbSystem.setActiveDatabase(db);
        EnableException thrown = assertThrows(EnableException.class, bungeeSystem::enable);
        assertEquals("IP setting still 0.0.0.0 - Configure Alternative_IP/IP that connects to the Proxy server.", thrown.getMessage());
    } finally {
        bungeeSystem.disable();
    }
}
Also used : DBSystem(com.djrapitops.plan.storage.database.DBSystem) SQLiteDB(com.djrapitops.plan.storage.database.SQLiteDB) EnableException(com.djrapitops.plan.exceptions.EnableException) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Aggregations

PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)31 Test (org.junit.jupiter.api.Test)17 BeforeAll (org.junit.jupiter.api.BeforeAll)7 Path (java.nio.file.Path)5 TestPluginLogger (utilities.TestPluginLogger)5 PluginMockComponent (utilities.mocks.PluginMockComponent)5 DBSystem (com.djrapitops.plan.storage.database.DBSystem)4 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)4 User (com.djrapitops.plan.delivery.domain.auth.User)3 SessionCache (com.djrapitops.plan.gathering.cache.SessionCache)3 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)3 SQLiteDB (com.djrapitops.plan.storage.database.SQLiteDB)3 RegisterWebUserTransaction (com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction)3 File (java.io.File)3 TimeAmountFormatter (com.djrapitops.plan.delivery.formatting.time.TimeAmountFormatter)2 Setting (com.djrapitops.plan.settings.config.paths.key.Setting)2 SQLDB (com.djrapitops.plan.storage.database.SQLDB)2 StoreConfigTransaction (com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction)2 ErrorLogger (com.djrapitops.plan.utilities.logging.ErrorLogger)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2