Search in sources :

Example 1 with ServerVersion

use of com.thoughtworks.go.server.util.ServerVersion in project gocd by gocd.

the class GoConfigFileHelper method createTestingDao.

/**
 * Creates config dao that has custom remote configuration parts provided by partialConfig argument
 */
public static GoConfigDao createTestingDao(GoPartialConfig partialConfig) {
    SystemEnvironment systemEnvironment = new SystemEnvironment();
    try {
        ServerHealthService serverHealthService = new ServerHealthService();
        ConfigRepository configRepository = new ConfigRepository(systemEnvironment);
        configRepository.initialize();
        FullConfigSaveNormalFlow normalFlow = new FullConfigSaveNormalFlow(new ConfigCache(), com.thoughtworks.go.util.ConfigElementImplementationRegistryMother.withNoPlugins(), systemEnvironment, new ServerVersion(), new TimeProvider(), configRepository, new CachedGoPartials(serverHealthService));
        GoFileConfigDataSource dataSource = new GoFileConfigDataSource(new DoNotUpgrade(), configRepository, systemEnvironment, new TimeProvider(), new ConfigCache(), new ServerVersion(), com.thoughtworks.go.util.ConfigElementImplementationRegistryMother.withNoPlugins(), serverHealthService, new CachedGoPartials(serverHealthService), null, normalFlow);
        dataSource.upgradeIfNecessary();
        CachedGoPartials cachedGoPartials = new CachedGoPartials(serverHealthService);
        CachedGoConfig cachedConfigService = new CachedGoConfig(serverHealthService, dataSource, cachedGoPartials, null, null);
        cachedConfigService.loadConfigIfNull();
        return new GoConfigDao(cachedConfigService);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) IOException(java.io.IOException) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService)

Example 2 with ServerVersion

use of com.thoughtworks.go.server.util.ServerVersion in project gocd by gocd.

the class BackupServiceTest method setUp.

@Before
public void setUp() throws Exception {
    systemEnvironment = mock(SystemEnvironment.class);
    tempFiles = new TempFiles();
    when(systemEnvironment.getConfigDir()).thenReturn(tempFiles.createUniqueFile("config_dir").getAbsolutePath());
    serverVersion = mock(ServerVersion.class);
    configRepo = mock(ConfigRepository.class);
    databaseStrategy = mock(Database.class);
    when(configRepo.doLocked(Matchers.<ThrowingFn<Object, Exception>>any())).thenCallRealMethod();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerVersion(com.thoughtworks.go.server.util.ServerVersion) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) Database(com.thoughtworks.go.database.Database) TempFiles(com.thoughtworks.go.util.TempFiles) Before(org.junit.Before)

Example 3 with ServerVersion

use of com.thoughtworks.go.server.util.ServerVersion in project gocd by gocd.

the class GoFileConfigDataSourceTest method setup.

@Before
public void setup() throws Exception {
    systemEnvironment = new SystemEnvironment();
    systemEnvironment.setProperty(SystemEnvironment.OPTIMIZE_FULL_CONFIG_SAVE.propertyName(), "false");
    configHelper = new GoConfigFileHelper();
    configHelper.onSetUp();
    configRepository = new ConfigRepository(systemEnvironment);
    configRepository.initialize();
    timeProvider = mock(TimeProvider.class);
    fullConfigSaveMergeFlow = mock(FullConfigSaveMergeFlow.class);
    fullConfigSaveNormalFlow = mock(FullConfigSaveNormalFlow.class);
    when(timeProvider.currentTime()).thenReturn(new Date());
    ServerVersion serverVersion = new ServerVersion();
    ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    ServerHealthService serverHealthService = new ServerHealthService();
    cachedGoPartials = new CachedGoPartials(serverHealthService);
    dataSource = new GoFileConfigDataSource(new GoConfigMigration(new GoConfigMigration.UpgradeFailedHandler() {

        public void handle(Exception e) {
            throw new RuntimeException(e);
        }
    }, configRepository, new TimeProvider(), configCache, registry), configRepository, systemEnvironment, timeProvider, configCache, serverVersion, registry, mock(ServerHealthService.class), cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
    dataSource.upgradeIfNecessary();
    CachedGoConfig cachedGoConfig = new CachedGoConfig(serverHealthService, dataSource, mock(CachedGoPartials.class), null, null);
    cachedGoConfig.loadConfigIfNull();
    goConfigDao = new GoConfigDao(cachedGoConfig);
    configHelper.load();
    configHelper.usingCruiseConfigDao(goConfigDao);
    GoConfigWatchList configWatchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
    ConfigElementImplementationRegistry configElementImplementationRegistry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
    GoConfigPluginService configPluginService = new GoConfigPluginService(mock(ConfigRepoExtension.class), new ConfigCache(), configElementImplementationRegistry, cachedGoConfig);
    repoConfig = new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin");
    configHelper.addConfigRepo(repoConfig);
    SecurityContext context = SecurityContextHolder.getContext();
    context.setAuthentication(new UsernamePasswordAuthenticationToken(new User("loser_boozer", "pass", true, true, true, true, new GrantedAuthority[] {}), null));
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) User(org.springframework.security.userdetails.User) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) UsernamePasswordAuthenticationToken(org.springframework.security.providers.UsernamePasswordAuthenticationToken) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ConfigFileHasChangedException(com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) ExpectedException(org.junit.rules.ExpectedException) ConfigMergeException(com.thoughtworks.go.config.exceptions.ConfigMergeException) IOException(java.io.IOException) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) SecurityContext(org.springframework.security.context.SecurityContext) ConfigRepoExtension(com.thoughtworks.go.plugin.access.configrepo.ConfigRepoExtension) Before(org.junit.Before)

Aggregations

ServerVersion (com.thoughtworks.go.server.util.ServerVersion)3 ConfigRepository (com.thoughtworks.go.service.ConfigRepository)3 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)2 IOException (java.io.IOException)2 Before (org.junit.Before)2 ConfigFileHasChangedException (com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException)1 ConfigMergeException (com.thoughtworks.go.config.exceptions.ConfigMergeException)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)1 NoPluginsInstalled (com.thoughtworks.go.config.registry.NoPluginsInstalled)1 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)1 Database (com.thoughtworks.go.database.Database)1 ConfigRepoExtension (com.thoughtworks.go.plugin.access.configrepo.ConfigRepoExtension)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 TempFiles (com.thoughtworks.go.util.TempFiles)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 ExpectedException (org.junit.rules.ExpectedException)1 SecurityContext (org.springframework.security.context.SecurityContext)1