@Before public void setup() throws Exception { dataSource.reloadEveryTime(); configHelper.usingCruiseConfigDao(goConfigDao); configHelper.onSetUp(); response = new MockHttpServletResponse(); configHelper.addSecurityWithPasswordFile(); configHelper.addAdmins("admin"); setCurrentUser("admin"); }
/** 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); } }