public void onTearDown() { sysEnv.setProperty(SystemEnvironment.CONFIG_DIR_PROPERTY, originalConfigDir); FileUtils.deleteQuietly(configFile); try { cachedGoConfig.save(originalXml, true); } catch (Exception e) { throw new RuntimeException(e); } }
public void writeConfigFile(CruiseConfig cruiseConfig) { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); getXml(cruiseConfig, buffer); cachedGoConfig.save(new String(buffer.toByteArray()), false); } catch (Exception e) { throw bomb(e); } }
/** Creates config dao that accesses single file */ public static GoConfigDao createTestingDao() { SystemEnvironment systemEnvironment = new SystemEnvironment(); try { ServerHealthService serverHealthService = new ServerHealthService(); ConfigRepository configRepository = new ConfigRepository(systemEnvironment); configRepository.initialize(); ConfigCache configCache = new ConfigCache(); ConfigElementImplementationRegistry configElementImplementationRegistry = ConfigElementImplementationRegistryMother.withNoPlugins(); CachedGoPartials cachedGoPartials = new CachedGoPartials(serverHealthService); FullConfigSaveNormalFlow normalFlow = new FullConfigSaveNormalFlow( configCache, configElementImplementationRegistry, systemEnvironment, new ServerVersion(), new TimeProvider(), configRepository, cachedGoPartials); GoFileConfigDataSource dataSource = new GoFileConfigDataSource( new DoNotUpgrade(), configRepository, systemEnvironment, new TimeProvider(), configCache, new ServerVersion(), configElementImplementationRegistry, serverHealthService, cachedGoPartials, null, normalFlow); dataSource.upgradeIfNecessary(); CachedGoConfig cachedConfigService = new CachedGoConfig(serverHealthService, dataSource, cachedGoPartials, null, null); cachedConfigService.loadConfigIfNull(); return new GoConfigDao(cachedConfigService); } catch (IOException e) { throw new RuntimeException(e); } }