use of com.thoughtworks.go.server.cache.GoCache in project gocd by gocd.
the class BaseUrlChangeListenerTest method shouldFlushCacheWhenBaseUrlConfigChangesAndUpdateTheSiteURLAndSecureSiteURLToTheNewValues.
@Test
public void shouldFlushCacheWhenBaseUrlConfigChangesAndUpdateTheSiteURLAndSecureSiteURLToTheNewValues() throws IOException {
GoCache cache = mock(GoCache.class);
BaseUrlChangeListener listener = new BaseUrlChangeListener(new ServerSiteUrlConfig(""), new ServerSiteUrlConfig(""), cache);
CruiseConfig newCruiseConfig = new BasicCruiseConfig();
newCruiseConfig.setServerConfig(serverConfigWith("http://blah.com", "https://blah.com"));
listener.onConfigChange(newCruiseConfig);
listener.onConfigChange(newCruiseConfig);
verify(cache, times(1)).remove("urls_cache");
}
use of com.thoughtworks.go.server.cache.GoCache in project gocd by gocd.
the class MaterialRepositoryTest method setUp.
@Before
public void setUp() {
databaseStrategy = mock(DatabaseStrategy.class);
sessionFactory = mock(SessionFactory.class);
goCache = mock(GoCache.class);
ourCustomCache = new HashMap<>();
transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
mockHibernateTemplate = mock(HibernateTemplate.class);
materialConfigConverter = mock(MaterialConfigConverter.class);
materialExpansionService = mock(MaterialExpansionService.class);
materialRepository = new MaterialRepository(sessionFactory, goCache, 4242, transactionSynchronizationManager, materialConfigConverter, materialExpansionService, databaseStrategy);
materialRepository.setHibernateTemplate(mockHibernateTemplate);
when(goCache.get(anyString())).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
return ourCustomCache.get(arguments[0]);
}
});
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
return ourCustomCache.put((String) arguments[0], arguments[1]);
}
}).when(goCache).put(anyString(), anyObject());
when(goCache.remove(anyString())).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
return ourCustomCache.remove(arguments[0]);
}
});
}
use of com.thoughtworks.go.server.cache.GoCache in project gocd by gocd.
the class StageSqlMapDaoTest method setUp.
@Before
public void setUp() {
goCache = new StubGoCache(new TestTransactionSynchronizationManager());
sqlMapClientTemplate = mock(SqlMapClientTemplate.class);
stageSqlMapDao = new StageSqlMapDao(mock(JobInstanceSqlMapDao.class), new Cache(true, false, false), mock(TransactionTemplate.class), mock(SqlMapClient.class), goCache, mock(TransactionSynchronizationManager.class), mock(SystemEnvironment.class), null);
stageSqlMapDao.setSqlMapClientTemplate(sqlMapClientTemplate);
cloner = mock(Cloner.class);
ReflectionUtil.setField(stageSqlMapDao, "cloner", cloner);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
return invocationOnMock.getArguments()[0];
}
}).when(cloner).deepClone(anyObject());
}
use of com.thoughtworks.go.server.cache.GoCache in project gocd by gocd.
the class GoConfigServiceTest method setup.
@Before
public void setup() throws Exception {
new SystemEnvironment().setProperty(SystemEnvironment.ENFORCE_SERVERID_MUTABILITY, "N");
configRepo = mock(ConfigRepository.class);
goConfigDao = mock(GoConfigDao.class);
pipelineRepository = mock(PipelineRepository.class);
pipelinePauseService = mock(PipelinePauseService.class);
systemEnvironment = mock(SystemEnvironment.class);
cruiseConfig = unchangedConfig();
expectLoad(cruiseConfig);
this.clock = mock(Clock.class);
goCache = mock(GoCache.class);
instanceFactory = mock(InstanceFactory.class);
userDao = mock(UserDao.class);
stub(systemEnvironment.optimizeFullConfigSave()).toReturn(false);
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
goConfigService = new GoConfigService(goConfigDao, pipelineRepository, this.clock, new GoConfigMigration(configRepo, new TimeProvider(), new ConfigCache(), registry), goCache, configRepo, registry, instanceFactory, mock(CachedGoPartials.class), systemEnvironment);
}
use of com.thoughtworks.go.server.cache.GoCache in project gocd by gocd.
the class StageServiceTest method setUp.
@Before
public void setUp() throws Exception {
stageDao = mock(StageDao.class);
pipelineDao = mock(PipelineDao.class);
jobInstanceService = mock(JobInstanceService.class);
securityService = mock(SecurityService.class);
pipelineNames = asList(new CaseInsensitiveString("blah-pipeline"));
user = new Username(new CaseInsensitiveString("poovan"));
operationResult = new HttpLocalizedOperationResult();
cruiseConfig = mock(BasicCruiseConfig.class);
goConfigService = mock(GoConfigService.class);
changesetService = mock(ChangesetService.class);
goCache = mock(GoCache.class);
transactionSynchronizationManager = new TestTransactionSynchronizationManager();
transactionTemplate = new TestTransactionTemplate(transactionSynchronizationManager);
}
Aggregations