Search in sources :

Example 11 with ConfigRepository

use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.

the class ConfigRepositoryValidatorServiceTest method shouldNotShutDownServerIfConfigRepositoryIsSane.

@Test
public void shouldNotShutDownServerIfConfigRepositoryIsSane() throws Exception {
    ConfigRepository configRepository = mock(ConfigRepository.class);
    when(configRepository.isRepositoryCorrupted()).thenReturn(false);
    ConfigRepositoryValidatorService configRepositoryValidatorServiceSpy = spy(new ConfigRepositoryValidatorService(configRepository));
    doNothing().when(configRepositoryValidatorServiceSpy).shutDownServer();
    configRepositoryValidatorServiceSpy.afterPropertiesSet();
    verify(configRepositoryValidatorServiceSpy, never()).shutDownServer();
}
Also used : ConfigRepository(com.thoughtworks.go.service.ConfigRepository) Test(org.junit.jupiter.api.Test)

Example 12 with ConfigRepository

use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.

the class GoConfigMigratorIntegrationTest method setUp.

@BeforeEach
public void setUp(@TempDir File temporaryFolder, ResetCipher resetCipher) throws Exception {
    dbHelper.onSetUp();
    configFile = new File(temporaryFolder, "cruise-config.xml");
    new SystemEnvironment().setProperty(SystemEnvironment.CONFIG_FILE_PROPERTY, configFile.getAbsolutePath());
    GoConfigFileHelper.clearConfigVersions();
    configRepository = new ConfigRepository(systemEnvironment);
    configRepository.initialize();
    serverHealthService.removeAllLogs();
    resetCipher.setupDESCipherFile();
    resetCipher.setupAESCipherFile();
    exceptions = new ArrayList<>();
    MagicalGoConfigXmlLoader xmlLoader = new MagicalGoConfigXmlLoader(configCache, registry);
    goConfigMigrator = new GoConfigMigrator(goConfigMigration, systemEnvironment, fullConfigSaveNormalFlow, xmlLoader, new GoConfigFileReader(systemEnvironment), configRepository, serverHealthService, new GoConfigMigrator.UpgradeFailedHandler() {

        @Override
        public void handle(Exception e) {
            exceptions.add(e);
        }
    });
}
Also used : ConfigRepository(com.thoughtworks.go.service.ConfigRepository) File(java.io.File) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with ConfigRepository

use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.

the class GoConfigMigrationIntegrationTest method setUp.

@BeforeEach
public void setUp(@TempDir File temporaryFolder, ResetCipher resetCipher) throws Exception {
    configFile = new File(temporaryFolder, "cruise-config.xml");
    new SystemEnvironment().setProperty(SystemEnvironment.CONFIG_FILE_PROPERTY, configFile.getAbsolutePath());
    GoConfigFileHelper.clearConfigVersions();
    configRepository = new ConfigRepository(systemEnvironment);
    configRepository.initialize();
    serverHealthService.removeAllLogs();
    loader = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins());
    resetCipher.setupDESCipherFile();
    resetCipher.setupAESCipherFile();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with ConfigRepository

use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.

the class InvalidConfigMessageRemoverIntegrationTest method setUp.

@BeforeEach
public void setUp(@TempDir File tempFolder) throws Exception {
    configFile = new File(tempFolder, "cruise-config.xml");
    configFile.createNewFile();
    GoConfigFileHelper.clearConfigVersions();
    configHelper = new GoConfigFileHelper();
    configHelper.onSetUp();
    SystemEnvironment systemEnvironment = new SystemEnvironment();
    systemEnvironment.setProperty(SystemEnvironment.CONFIG_FILE_PROPERTY, configFile.getAbsolutePath());
    new ConfigRepository(systemEnvironment).initialize();
    serverHealthService.removeAllLogs();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ConfigRepository (com.thoughtworks.go.service.ConfigRepository)14 File (java.io.File)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)4 IOException (java.io.IOException)4 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)3 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)2 ServerVersion (com.thoughtworks.go.server.util.ServerVersion)2 GoConfigFileHelper (com.thoughtworks.go.util.GoConfigFileHelper)2 TimeProvider (com.thoughtworks.go.util.TimeProvider)2 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)2 Document (org.jdom2.Document)2 Before (org.junit.Before)2 Test (org.junit.jupiter.api.Test)2 CurrentGoCDVersion (com.thoughtworks.go.CurrentGoCDVersion)1 com.thoughtworks.go.config (com.thoughtworks.go.config)1 ConfigFileHasChangedException (com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException)1 ConfigMergeException (com.thoughtworks.go.config.exceptions.ConfigMergeException)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1