Search in sources :

Example 21 with SvnCommand

use of com.thoughtworks.go.domain.materials.svn.SvnCommand in project gocd by gocd.

the class SvnPostCommitHookImplementerTest method shouldCreateRemoteUrlToRemoteUUIDMap.

@Test
public void shouldCreateRemoteUrlToRemoteUUIDMap() {
    final SvnPostCommitHookImplementer spy = spy(implementer);
    final SvnCommand svnCommand = mock(SvnCommand.class);
    final Material svnMaterial1 = mock(SvnMaterial.class);
    final Material hgMaterial1 = mock(HgMaterial.class);
    final HashSet<Material> allMaterials = new HashSet<>(Arrays.asList(svnMaterial1, hgMaterial1));
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return svnCommand;
        }
    }).when(spy).getEmptySvnCommand();
    spy.createUrlToRemoteUUIDMap(allMaterials);
    verify(svnCommand).createUrlToRemoteUUIDMap(new HashSet<>(Arrays.asList((SvnMaterial) svnMaterial1)));
}
Also used : Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 22 with SvnCommand

use of com.thoughtworks.go.domain.materials.svn.SvnCommand in project gocd by gocd.

the class MaterialExpansionService method svn.

private Subversion svn(SvnMaterialConfig svnMaterialConfig) {
    String cacheKey = cacheKeyForSubversionMaterialCommand(svnMaterialConfig.getFingerprint());
    Subversion svnLazyLoaded = (SvnCommand) goCache.get(cacheKey);
    if (svnLazyLoaded == null || !svnLazyLoaded.getUrl().forCommandline().equals(svnMaterialConfig.getUrl())) {
        synchronized (cacheKey) {
            svnLazyLoaded = (SvnCommand) goCache.get(cacheKey);
            if (svnLazyLoaded == null || !svnLazyLoaded.getUrl().forCommandline().equals(svnMaterialConfig.getUrl())) {
                svnLazyLoaded = new SvnCommand(svnMaterialConfig.getFingerprint(), svnMaterialConfig.getUrl(), svnMaterialConfig.getUserName(), svnMaterialConfig.getPassword(), svnMaterialConfig.isCheckExternals());
                goCache.put(cacheKeyForSubversionMaterialCommand(svnMaterialConfig.getFingerprint()), svnLazyLoaded);
            }
        }
    }
    return svnLazyLoaded;
}
Also used : Subversion(com.thoughtworks.go.domain.materials.svn.Subversion) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand)

Example 23 with SvnCommand

use of com.thoughtworks.go.domain.materials.svn.SvnCommand in project gocd by gocd.

the class BuildAssignmentServiceIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    configCache = new ConfigCache();
    registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    configHelper = new GoConfigFileHelper().usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    dbHelper.onSetUp();
    fixture = new PipelineWithTwoStages(materialRepository, transactionTemplate);
    fixture.usingConfigHelper(configHelper).usingDbHelper(dbHelper).onSetUp();
    repository = new SvnCommand(null, testRepo.projectRepositoryUrl());
    evolveConfig = configHelper.addPipeline("evolve", STAGE_NAME, repository, "unit");
    configHelper.addPipeline("anotherPipeline", STAGE_NAME, repository, "anotherTest");
    configHelper.addPipeline("thirdPipeline", STAGE_NAME, repository, "yetAnotherTest");
    goConfigService.forceNotifyListeners();
    goCache.clear();
    u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    agent = new AgentStub();
    notifier.disableUpdates();
}
Also used : PipelineWithTwoStages(com.thoughtworks.go.fixture.PipelineWithTwoStages) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) AgentStub(com.thoughtworks.go.server.websocket.AgentStub)

Example 24 with SvnCommand

use of com.thoughtworks.go.domain.materials.svn.SvnCommand in project gocd by gocd.

the class BuildRepositoryServiceIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    dbHelper.onSetUp();
    config.onSetUp();
    config.usingCruiseConfigDao(goConfigDao);
    goConfigService.forceNotifyListeners();
    svnTestRepo = new SvnTestRepo("testsvnrepo");
    svnRepo = new SvnCommand(null, svnTestRepo.projectRepositoryUrl());
    config.addPipeline(PIPELINE_NAME, DEV_STAGE, svnRepo, "foo");
    mingle = config.addStageToPipeline(PIPELINE_NAME, FT_STAGE, "bar");
    config.addAgent(HOSTNAME, AGENT_UUID);
    pipeline = dbHelper.newPipelineWithAllStagesPassed(mingle);
    goCache.clear();
}
Also used : SvnTestRepo(com.thoughtworks.go.helper.SvnTestRepo) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand)

Example 25 with SvnCommand

use of com.thoughtworks.go.domain.materials.svn.SvnCommand in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationTest method should_NOT_markAsChangedWhenMaterialIsReIntroducedWithSameRevisionsToPipeline.

@Test
public void should_NOT_markAsChangedWhenMaterialIsReIntroducedWithSameRevisionsToPipeline() throws Exception {
    SvnMaterial svn1 = SvnMaterial.createSvnMaterialWithMock(repository);
    svn1.setFolder("another_repo");
    mingleConfig = configHelper.replaceMaterialForPipeline(MINGLE_PIPELINE_NAME, svn1.config());
    runAndPassWith(svn1, "foo.c", svnRepository);
    SvnTestRepo svn2Repository = new SvnTestRepo("testSvnRepo2");
    Subversion repository2 = new SvnCommand(null, svn2Repository.projectRepositoryUrl());
    SvnMaterial svn2 = SvnMaterial.createSvnMaterialWithMock(repository2);
    svn2.setFolder("boulder");
    checkinFile(svn2, "bar.c", svn2Repository);
    mingleConfig = configHelper.addMaterialToPipeline(MINGLE_PIPELINE_NAME, svn2.config());
    scheduleHelper.autoSchedulePipelinesWithRealMaterials(MINGLE_PIPELINE_NAME);
    assertThat(pipelineScheduleQueue.toBeScheduled().keySet(), hasItem(MINGLE_PIPELINE_NAME));
    BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(MINGLE_PIPELINE_NAME);
    verifyChanged(svn2, mingleBuildCause, true);
    //this should not have changed, as foo.c was already built in the previous instance
    verifyChanged(svn1, mingleBuildCause, false);
    runAndPass(mingleBuildCause.getMaterialRevisions());
    mingleConfig = configHelper.replaceMaterialForPipeline(MINGLE_PIPELINE_NAME, svn1.config());
    scheduleHelper.autoSchedulePipelinesWithRealMaterials(MINGLE_PIPELINE_NAME);
    assertThat(pipelineScheduleQueue.toBeScheduled().keySet(), hasItem(MINGLE_PIPELINE_NAME));
    mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(MINGLE_PIPELINE_NAME);
    //this should not have changed, as foo.c was already built in the previous instance
    verifyChanged(svn1, mingleBuildCause, false);
    runAndPassWith(svn1, "baz.c", svnRepository);
    mingleConfig = configHelper.addMaterialToPipeline(MINGLE_PIPELINE_NAME, svn2.config());
    checkinFile(svn1, "quux.c", svnRepository);
    scheduleHelper.autoSchedulePipelinesWithRealMaterials(MINGLE_PIPELINE_NAME);
    assertThat(pipelineScheduleQueue.toBeScheduled().keySet(), hasItem(MINGLE_PIPELINE_NAME));
    mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(MINGLE_PIPELINE_NAME);
    verifyChanged(svn2, mingleBuildCause, false);
    verifyChanged(svn1, mingleBuildCause, true);
}
Also used : Subversion(com.thoughtworks.go.domain.materials.svn.Subversion) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) SvnTestRepo(com.thoughtworks.go.helper.SvnTestRepo) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Aggregations

SvnCommand (com.thoughtworks.go.domain.materials.svn.SvnCommand)25 SvnTestRepo (com.thoughtworks.go.helper.SvnTestRepo)9 Before (org.junit.Before)8 GoConfigFileHelper (com.thoughtworks.go.util.GoConfigFileHelper)5 Test (org.junit.Test)5 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)4 Subversion (com.thoughtworks.go.domain.materials.svn.Subversion)4 PipelineWithTwoStages (com.thoughtworks.go.fixture.PipelineWithTwoStages)3 TestRepo (com.thoughtworks.go.helper.TestRepo)3 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)3 File (java.io.File)3 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)2 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)2 HgTestRepo (com.thoughtworks.go.helper.HgTestRepo)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 SvnRepoFixture (com.thoughtworks.go.utils.SvnRepoFixture)2 Date (java.util.Date)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1